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
JetBrains/teamcity-dottrace
dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/PatternsGenerator.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // }
import com.intellij.openapi.util.text.StringUtil; import java.util.Collections; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import org.jetbrains.annotations.NotNull; import org.w3c.dom.Document; import org.w3c.dom.Element;
/* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.agent; public class PatternsGenerator implements ResourceGenerator<Context> { private static final String PATTERNS_ELEMENT = "Patterns"; private static final String PATTERN_ELEMENT = "Pattern"; private final TextParser<Metrics> myThresholdsParser; private final RunnerParametersService myParametersService; private final XmlDocumentManager myDocumentManager; public PatternsGenerator( @NotNull final TextParser<Metrics> thresholdsParser, @NotNull final RunnerParametersService parametersService, @NotNull final XmlDocumentManager documentManager) { myThresholdsParser = thresholdsParser; myParametersService = parametersService; myDocumentManager = documentManager; } @NotNull @Override public String create(@NotNull final Context context) { final Document doc = myDocumentManager.createDocument(); final Element patternsElement = doc.createElement(PATTERNS_ELEMENT);
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // Path: dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/PatternsGenerator.java import com.intellij.openapi.util.text.StringUtil; import java.util.Collections; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import org.jetbrains.annotations.NotNull; import org.w3c.dom.Document; import org.w3c.dom.Element; /* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.agent; public class PatternsGenerator implements ResourceGenerator<Context> { private static final String PATTERNS_ELEMENT = "Patterns"; private static final String PATTERN_ELEMENT = "Pattern"; private final TextParser<Metrics> myThresholdsParser; private final RunnerParametersService myParametersService; private final XmlDocumentManager myDocumentManager; public PatternsGenerator( @NotNull final TextParser<Metrics> thresholdsParser, @NotNull final RunnerParametersService parametersService, @NotNull final XmlDocumentManager documentManager) { myThresholdsParser = thresholdsParser; myParametersService = parametersService; myDocumentManager = documentManager; } @NotNull @Override public String create(@NotNull final Context context) { final Document doc = myDocumentManager.createDocument(); final Element patternsElement = doc.createElement(PATTERNS_ELEMENT);
String thresholdsStr = myParametersService.tryGetRunnerParameter(Constants.THRESHOLDS_VAR);
JetBrains/teamcity-dottrace
dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceBean.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // // Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/MeasureType.java // public enum MeasureType { // SAMPLING("sampling", "Sampling", "Sampling"), // TRACING("tracing", "Tracing", ""), // LINE_BY_LINE("line-by-line", "Line-by-line", "TracingInject"); // // private final String myValue; // private final String myDescription; // private final String myId; // // MeasureType(@NotNull final String value, @NotNull final String description, @NotNull final String id) { // myValue = value; // myDescription = description; // myId = id; // } // // @NotNull // public String getValue() { // return myValue; // } // // @NotNull // public String getDescription() { // return myDescription; // } // // @NotNull // @Override // public String toString() { // return myDescription; // } // // @NotNull // public String getId() { // return myId; // } // }
import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotTrace.MeasureType; import org.jetbrains.annotations.NotNull;
/* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.server; public class DotTraceBean { public static final DotTraceBean Shared = new DotTraceBean(); @NotNull public String getUseDotTraceKey() {
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // // Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/MeasureType.java // public enum MeasureType { // SAMPLING("sampling", "Sampling", "Sampling"), // TRACING("tracing", "Tracing", ""), // LINE_BY_LINE("line-by-line", "Line-by-line", "TracingInject"); // // private final String myValue; // private final String myDescription; // private final String myId; // // MeasureType(@NotNull final String value, @NotNull final String description, @NotNull final String id) { // myValue = value; // myDescription = description; // myId = id; // } // // @NotNull // public String getValue() { // return myValue; // } // // @NotNull // public String getDescription() { // return myDescription; // } // // @NotNull // @Override // public String toString() { // return myDescription; // } // // @NotNull // public String getId() { // return myId; // } // } // Path: dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceBean.java import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotTrace.MeasureType; import org.jetbrains.annotations.NotNull; /* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.server; public class DotTraceBean { public static final DotTraceBean Shared = new DotTraceBean(); @NotNull public String getUseDotTraceKey() {
return Constants.USE_VAR;
JetBrains/teamcity-dottrace
dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceBean.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // // Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/MeasureType.java // public enum MeasureType { // SAMPLING("sampling", "Sampling", "Sampling"), // TRACING("tracing", "Tracing", ""), // LINE_BY_LINE("line-by-line", "Line-by-line", "TracingInject"); // // private final String myValue; // private final String myDescription; // private final String myId; // // MeasureType(@NotNull final String value, @NotNull final String description, @NotNull final String id) { // myValue = value; // myDescription = description; // myId = id; // } // // @NotNull // public String getValue() { // return myValue; // } // // @NotNull // public String getDescription() { // return myDescription; // } // // @NotNull // @Override // public String toString() { // return myDescription; // } // // @NotNull // public String getId() { // return myId; // } // }
import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotTrace.MeasureType; import org.jetbrains.annotations.NotNull;
public String getPathKey() { return Constants.PATH_VAR; } @NotNull public String getThresholdsKey() { return Constants.THRESHOLDS_VAR; } @NotNull public String getMeasureTypeKey() { return Constants.MEASURE_TYPE_VAR; } @NotNull public String getProfileChildProcessesKey() { return Constants.PROFILE_CHILD_PROCESSES_VAR; } @NotNull public String getProcessFiltersKey() { return Constants.PROCESS_FILTERS_VAR; } @NotNull public String getSnapshotsPathKey() { return Constants.SNAPSHOTS_PATH_VAR; } @NotNull
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // // Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/MeasureType.java // public enum MeasureType { // SAMPLING("sampling", "Sampling", "Sampling"), // TRACING("tracing", "Tracing", ""), // LINE_BY_LINE("line-by-line", "Line-by-line", "TracingInject"); // // private final String myValue; // private final String myDescription; // private final String myId; // // MeasureType(@NotNull final String value, @NotNull final String description, @NotNull final String id) { // myValue = value; // myDescription = description; // myId = id; // } // // @NotNull // public String getValue() { // return myValue; // } // // @NotNull // public String getDescription() { // return myDescription; // } // // @NotNull // @Override // public String toString() { // return myDescription; // } // // @NotNull // public String getId() { // return myId; // } // } // Path: dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceBean.java import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotTrace.MeasureType; import org.jetbrains.annotations.NotNull; public String getPathKey() { return Constants.PATH_VAR; } @NotNull public String getThresholdsKey() { return Constants.THRESHOLDS_VAR; } @NotNull public String getMeasureTypeKey() { return Constants.MEASURE_TYPE_VAR; } @NotNull public String getProfileChildProcessesKey() { return Constants.PROFILE_CHILD_PROCESSES_VAR; } @NotNull public String getProcessFiltersKey() { return Constants.PROCESS_FILTERS_VAR; } @NotNull public String getSnapshotsPathKey() { return Constants.SNAPSHOTS_PATH_VAR; } @NotNull
public MeasureType[] getMeasureTypes() {
JetBrains/teamcity-dottrace
dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceStatisticTranslator.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/StatisticMessage.java // public class StatisticMessage extends MessageWithAttributes { // public static final String MESSAGE_NAME = "dotTraceStatistic"; // private static final String METHOD_STATISTIC_MESSAGE_ATTR = "methodName"; // private static final String THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "totalTimeThreshold"; // private static final String THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR = "ownTimeThreshold"; // private static final String MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "measuredTotalTime"; // private static final String MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR = "measuredOwnTime"; // // public StatisticMessage( // @NotNull final String methodName, // @NotNull final String totalTimeThreshold, // @NotNull final String ownTimeThreshold, // @NotNull final String measuredTotalTime, // @NotNull final String measuredOwnTime) { // super( // MESSAGE_NAME, // CollectionsUtil.asMap( // METHOD_STATISTIC_MESSAGE_ATTR, methodName, // THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, totalTimeThreshold, // THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR, ownTimeThreshold, // MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, measuredTotalTime, // MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR, measuredOwnTime)); // } // // private StatisticMessage(@NotNull final Map<String, String> attributes) { // super(MESSAGE_NAME, attributes); // } // // @Nullable // public static StatisticMessage tryParse(@NotNull final ServiceMessage message) { // if(!MESSAGE_NAME.equalsIgnoreCase(message.getMessageName())) { // return null; // } // // return new StatisticMessage(message.getAttributes()); // } // // @NotNull // public String getMethodName() { // return getAttributes().get(METHOD_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getOwnTimeThreshold() { // return getAttributes().get(THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getTotalTimeThreshold() { // return getAttributes().get(THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredOwnTime() { // return getAttributes().get(MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredTotalTime() { // return getAttributes().get(MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @Override // public boolean equals(final Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final StatisticMessage statisticMessage = (StatisticMessage)o; // // if (!getMethodName().equals(statisticMessage.getMethodName())) return false; // if (!getTotalTimeThreshold().equals(statisticMessage.getTotalTimeThreshold())) return false; // if (!getOwnTimeThreshold().equals(statisticMessage.getOwnTimeThreshold())) return false; // if (!getMeasuredTotalTime().equals(statisticMessage.getMeasuredTotalTime())) return false; // return getMeasuredOwnTime().equals(statisticMessage.getMeasuredOwnTime()); // // } // // @Override // public int hashCode() { // int result = getMethodName().hashCode(); // result = 31 * result + getTotalTimeThreshold().hashCode(); // result = 31 * result + getOwnTimeThreshold().hashCode(); // result = 31 * result + getMeasuredTotalTime().hashCode(); // result = 31 * result + getMeasuredOwnTime().hashCode(); // return result; // } // }
import java.math.BigDecimal; import java.util.Collections; import java.util.List; import java.util.Vector; import jetbrains.buildServer.dotTrace.StatisticMessage; import jetbrains.buildServer.messages.BuildMessage1; import jetbrains.buildServer.messages.Status; import jetbrains.buildServer.messages.serviceMessages.ServiceMessage; import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTranslator; import jetbrains.buildServer.serverSide.SBuildType; import jetbrains.buildServer.serverSide.SRunningBuild; import jetbrains.buildServer.serverSide.ServerExtensionHolder; import jetbrains.buildServer.serverSide.statistics.build.BuildDataStorage; import org.jetbrains.annotations.NotNull;
/* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.server; public class DotTraceStatisticTranslator implements ServiceMessageTranslator { public static final String TOTAL_TIME_THRESHOLD_NAME = "Total Time"; public static final String OWN_TIME_THRESHOLD_NAME = "Own Time"; private final BuildDataStorage myStorage; private final MetricComparer myMetricComparer; private final StatisticKeyFactory myStatisticKeyFactory; private final StatisticProvider myStatisticProvider; private final History myHistory; public DotTraceStatisticTranslator( @NotNull final ServerExtensionHolder server, @NotNull final BuildDataStorage storage, @NotNull final MetricComparer metricComparer, @NotNull final StatisticKeyFactory statisticKeyFactory, @NotNull final StatisticProvider statisticProvider, @NotNull final History history) { myMetricComparer = metricComparer; myStorage = storage; myStatisticKeyFactory = statisticKeyFactory; myStatisticProvider = statisticProvider; myHistory = history; server.registerExtension(ServiceMessageTranslator.class, getClass().getName(), this); } @NotNull @Override public String getServiceMessageName() {
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/StatisticMessage.java // public class StatisticMessage extends MessageWithAttributes { // public static final String MESSAGE_NAME = "dotTraceStatistic"; // private static final String METHOD_STATISTIC_MESSAGE_ATTR = "methodName"; // private static final String THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "totalTimeThreshold"; // private static final String THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR = "ownTimeThreshold"; // private static final String MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "measuredTotalTime"; // private static final String MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR = "measuredOwnTime"; // // public StatisticMessage( // @NotNull final String methodName, // @NotNull final String totalTimeThreshold, // @NotNull final String ownTimeThreshold, // @NotNull final String measuredTotalTime, // @NotNull final String measuredOwnTime) { // super( // MESSAGE_NAME, // CollectionsUtil.asMap( // METHOD_STATISTIC_MESSAGE_ATTR, methodName, // THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, totalTimeThreshold, // THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR, ownTimeThreshold, // MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, measuredTotalTime, // MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR, measuredOwnTime)); // } // // private StatisticMessage(@NotNull final Map<String, String> attributes) { // super(MESSAGE_NAME, attributes); // } // // @Nullable // public static StatisticMessage tryParse(@NotNull final ServiceMessage message) { // if(!MESSAGE_NAME.equalsIgnoreCase(message.getMessageName())) { // return null; // } // // return new StatisticMessage(message.getAttributes()); // } // // @NotNull // public String getMethodName() { // return getAttributes().get(METHOD_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getOwnTimeThreshold() { // return getAttributes().get(THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getTotalTimeThreshold() { // return getAttributes().get(THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredOwnTime() { // return getAttributes().get(MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredTotalTime() { // return getAttributes().get(MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @Override // public boolean equals(final Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final StatisticMessage statisticMessage = (StatisticMessage)o; // // if (!getMethodName().equals(statisticMessage.getMethodName())) return false; // if (!getTotalTimeThreshold().equals(statisticMessage.getTotalTimeThreshold())) return false; // if (!getOwnTimeThreshold().equals(statisticMessage.getOwnTimeThreshold())) return false; // if (!getMeasuredTotalTime().equals(statisticMessage.getMeasuredTotalTime())) return false; // return getMeasuredOwnTime().equals(statisticMessage.getMeasuredOwnTime()); // // } // // @Override // public int hashCode() { // int result = getMethodName().hashCode(); // result = 31 * result + getTotalTimeThreshold().hashCode(); // result = 31 * result + getOwnTimeThreshold().hashCode(); // result = 31 * result + getMeasuredTotalTime().hashCode(); // result = 31 * result + getMeasuredOwnTime().hashCode(); // return result; // } // } // Path: dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceStatisticTranslator.java import java.math.BigDecimal; import java.util.Collections; import java.util.List; import java.util.Vector; import jetbrains.buildServer.dotTrace.StatisticMessage; import jetbrains.buildServer.messages.BuildMessage1; import jetbrains.buildServer.messages.Status; import jetbrains.buildServer.messages.serviceMessages.ServiceMessage; import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTranslator; import jetbrains.buildServer.serverSide.SBuildType; import jetbrains.buildServer.serverSide.SRunningBuild; import jetbrains.buildServer.serverSide.ServerExtensionHolder; import jetbrains.buildServer.serverSide.statistics.build.BuildDataStorage; import org.jetbrains.annotations.NotNull; /* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.server; public class DotTraceStatisticTranslator implements ServiceMessageTranslator { public static final String TOTAL_TIME_THRESHOLD_NAME = "Total Time"; public static final String OWN_TIME_THRESHOLD_NAME = "Own Time"; private final BuildDataStorage myStorage; private final MetricComparer myMetricComparer; private final StatisticKeyFactory myStatisticKeyFactory; private final StatisticProvider myStatisticProvider; private final History myHistory; public DotTraceStatisticTranslator( @NotNull final ServerExtensionHolder server, @NotNull final BuildDataStorage storage, @NotNull final MetricComparer metricComparer, @NotNull final StatisticKeyFactory statisticKeyFactory, @NotNull final StatisticProvider statisticProvider, @NotNull final History history) { myMetricComparer = metricComparer; myStorage = storage; myStatisticKeyFactory = statisticKeyFactory; myStatisticProvider = statisticProvider; myHistory = history; server.registerExtension(ServiceMessageTranslator.class, getClass().getName(), this); } @NotNull @Override public String getServiceMessageName() {
return StatisticMessage.MESSAGE_NAME;
JetBrains/teamcity-dottrace
dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/CmdGenerator.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // }
import java.io.File; import java.util.Arrays; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import org.jetbrains.annotations.NotNull;
/* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.agent; public class CmdGenerator implements ResourceGenerator<Context> { static final String DOT_TRACE_EXE_NAME = "ConsoleProfiler.exe"; static final String DOT_TRACE_REPORTER_EXE_NAME = "Reporter.exe"; private static final String ourLineSeparator = System.getProperty("line.separator"); private final CommandLineArgumentsService myCommandLineArgumentsService; private final RunnerParametersService myParametersService; private final FileService myFileService; public CmdGenerator( @NotNull final CommandLineArgumentsService commandLineArgumentsService, @NotNull final RunnerParametersService parametersService, @NotNull final FileService fileService) { myCommandLineArgumentsService = commandLineArgumentsService; myParametersService = parametersService; myFileService = fileService; } @NotNull @Override public String create(@NotNull final Context ctx) {
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // Path: dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/CmdGenerator.java import java.io.File; import java.util.Arrays; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import org.jetbrains.annotations.NotNull; /* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.agent; public class CmdGenerator implements ResourceGenerator<Context> { static final String DOT_TRACE_EXE_NAME = "ConsoleProfiler.exe"; static final String DOT_TRACE_REPORTER_EXE_NAME = "Reporter.exe"; private static final String ourLineSeparator = System.getProperty("line.separator"); private final CommandLineArgumentsService myCommandLineArgumentsService; private final RunnerParametersService myParametersService; private final FileService myFileService; public CmdGenerator( @NotNull final CommandLineArgumentsService commandLineArgumentsService, @NotNull final RunnerParametersService parametersService, @NotNull final FileService fileService) { myCommandLineArgumentsService = commandLineArgumentsService; myParametersService = parametersService; myFileService = fileService; } @NotNull @Override public String create(@NotNull final Context ctx) {
File dotTracePath = new File(myParametersService.getRunnerParameter(Constants.PATH_VAR));
JetBrains/teamcity-dottrace
dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/DotTraceSnapshotsPublisher.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // }
import com.intellij.openapi.util.text.StringUtil; import java.io.File; import java.util.*; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.messages.serviceMessages.PublishArtifacts; import org.jetbrains.annotations.NotNull;
/* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.agent; public class DotTraceSnapshotsPublisher implements ResourcePublisher { private final LoggerService myLoggerService; private final RunnerParametersService myParametersService; private final FileService myFileService; public DotTraceSnapshotsPublisher( @NotNull final LoggerService loggerService, @NotNull final RunnerParametersService parametersService, @NotNull final FileService fileService) { myLoggerService = loggerService; myParametersService = parametersService; myFileService = fileService; } @Override public void publishBeforeBuildFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file, @NotNull final String content) { } @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) {
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // Path: dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/DotTraceSnapshotsPublisher.java import com.intellij.openapi.util.text.StringUtil; import java.io.File; import java.util.*; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.messages.serviceMessages.PublishArtifacts; import org.jetbrains.annotations.NotNull; /* * Copyright 2000-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.dotTrace.agent; public class DotTraceSnapshotsPublisher implements ResourcePublisher { private final LoggerService myLoggerService; private final RunnerParametersService myParametersService; private final FileService myFileService; public DotTraceSnapshotsPublisher( @NotNull final LoggerService loggerService, @NotNull final RunnerParametersService parametersService, @NotNull final FileService fileService) { myLoggerService = loggerService; myParametersService = parametersService; myFileService = fileService; } @Override public void publishBeforeBuildFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file, @NotNull final String content) { } @Override public void publishAfterBuildArtifactFile(@NotNull final CommandLineExecutionContext executionContext, @NotNull final File file) {
final String snapshotsTargetDirectoryStr = myParametersService.tryGetRunnerParameter(Constants.SNAPSHOTS_PATH_VAR);
JetBrains/teamcity-dottrace
dotTrace-agent/src/test/java/jetbrains/buildServer/dotTrace/agent/BuildPublisherTest.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // // Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/StatisticMessage.java // public class StatisticMessage extends MessageWithAttributes { // public static final String MESSAGE_NAME = "dotTraceStatistic"; // private static final String METHOD_STATISTIC_MESSAGE_ATTR = "methodName"; // private static final String THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "totalTimeThreshold"; // private static final String THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR = "ownTimeThreshold"; // private static final String MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "measuredTotalTime"; // private static final String MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR = "measuredOwnTime"; // // public StatisticMessage( // @NotNull final String methodName, // @NotNull final String totalTimeThreshold, // @NotNull final String ownTimeThreshold, // @NotNull final String measuredTotalTime, // @NotNull final String measuredOwnTime) { // super( // MESSAGE_NAME, // CollectionsUtil.asMap( // METHOD_STATISTIC_MESSAGE_ATTR, methodName, // THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, totalTimeThreshold, // THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR, ownTimeThreshold, // MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, measuredTotalTime, // MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR, measuredOwnTime)); // } // // private StatisticMessage(@NotNull final Map<String, String> attributes) { // super(MESSAGE_NAME, attributes); // } // // @Nullable // public static StatisticMessage tryParse(@NotNull final ServiceMessage message) { // if(!MESSAGE_NAME.equalsIgnoreCase(message.getMessageName())) { // return null; // } // // return new StatisticMessage(message.getAttributes()); // } // // @NotNull // public String getMethodName() { // return getAttributes().get(METHOD_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getOwnTimeThreshold() { // return getAttributes().get(THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getTotalTimeThreshold() { // return getAttributes().get(THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredOwnTime() { // return getAttributes().get(MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredTotalTime() { // return getAttributes().get(MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @Override // public boolean equals(final Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final StatisticMessage statisticMessage = (StatisticMessage)o; // // if (!getMethodName().equals(statisticMessage.getMethodName())) return false; // if (!getTotalTimeThreshold().equals(statisticMessage.getTotalTimeThreshold())) return false; // if (!getOwnTimeThreshold().equals(statisticMessage.getOwnTimeThreshold())) return false; // if (!getMeasuredTotalTime().equals(statisticMessage.getMeasuredTotalTime())) return false; // return getMeasuredOwnTime().equals(statisticMessage.getMeasuredOwnTime()); // // } // // @Override // public int hashCode() { // int result = getMethodName().hashCode(); // result = 31 * result + getTotalTimeThreshold().hashCode(); // result = 31 * result + getOwnTimeThreshold().hashCode(); // result = 31 * result + getMeasuredTotalTime().hashCode(); // result = 31 * result + getMeasuredOwnTime().hashCode(); // return result; // } // }
import java.io.File; import java.io.IOException; import java.util.Arrays; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotTrace.StatisticMessage; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test;
final Metrics thresholdsMetrics = new Metrics( Arrays.asList( new Metric("Method88", "88", "345"), new Metric("Method1", "100", "1000"), new Metric("MethodA", "F22", "F35"))); final CommandLineExecutionContext ctx = new CommandLineExecutionContext(0); myCtx.checking(new Expectations() {{ oneOf(myAfterBuildPublisher).publishAfterBuildArtifactFile(ctx, reportFile); oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.THRESHOLDS_VAR); will(returnValue("thresholds")); oneOf(myThresholdsParser).parse("thresholds"); will(returnValue(thresholdsMetrics)); //noinspection EmptyCatchBlock try { oneOf(myFileService).readAllTextFile(reportFile); } catch (IOException e) { } will(returnValue("report's content")); oneOf(myReportParser).parse("report's content"); will(returnValue(reportMetrics));
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // // Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/StatisticMessage.java // public class StatisticMessage extends MessageWithAttributes { // public static final String MESSAGE_NAME = "dotTraceStatistic"; // private static final String METHOD_STATISTIC_MESSAGE_ATTR = "methodName"; // private static final String THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "totalTimeThreshold"; // private static final String THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR = "ownTimeThreshold"; // private static final String MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR = "measuredTotalTime"; // private static final String MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR = "measuredOwnTime"; // // public StatisticMessage( // @NotNull final String methodName, // @NotNull final String totalTimeThreshold, // @NotNull final String ownTimeThreshold, // @NotNull final String measuredTotalTime, // @NotNull final String measuredOwnTime) { // super( // MESSAGE_NAME, // CollectionsUtil.asMap( // METHOD_STATISTIC_MESSAGE_ATTR, methodName, // THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, totalTimeThreshold, // THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR, ownTimeThreshold, // MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR, measuredTotalTime, // MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR, measuredOwnTime)); // } // // private StatisticMessage(@NotNull final Map<String, String> attributes) { // super(MESSAGE_NAME, attributes); // } // // @Nullable // public static StatisticMessage tryParse(@NotNull final ServiceMessage message) { // if(!MESSAGE_NAME.equalsIgnoreCase(message.getMessageName())) { // return null; // } // // return new StatisticMessage(message.getAttributes()); // } // // @NotNull // public String getMethodName() { // return getAttributes().get(METHOD_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getOwnTimeThreshold() { // return getAttributes().get(THRESHOLD_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getTotalTimeThreshold() { // return getAttributes().get(THRESHOLD_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredOwnTime() { // return getAttributes().get(MEASURED_OWN_TIME_STATISTIC_MESSAGE_ATTR); // } // // @NotNull // public String getMeasuredTotalTime() { // return getAttributes().get(MEASURED_TOTAL_TIME_STATISTIC_MESSAGE_ATTR); // } // // @Override // public boolean equals(final Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // final StatisticMessage statisticMessage = (StatisticMessage)o; // // if (!getMethodName().equals(statisticMessage.getMethodName())) return false; // if (!getTotalTimeThreshold().equals(statisticMessage.getTotalTimeThreshold())) return false; // if (!getOwnTimeThreshold().equals(statisticMessage.getOwnTimeThreshold())) return false; // if (!getMeasuredTotalTime().equals(statisticMessage.getMeasuredTotalTime())) return false; // return getMeasuredOwnTime().equals(statisticMessage.getMeasuredOwnTime()); // // } // // @Override // public int hashCode() { // int result = getMethodName().hashCode(); // result = 31 * result + getTotalTimeThreshold().hashCode(); // result = 31 * result + getOwnTimeThreshold().hashCode(); // result = 31 * result + getMeasuredTotalTime().hashCode(); // result = 31 * result + getMeasuredOwnTime().hashCode(); // return result; // } // } // Path: dotTrace-agent/src/test/java/jetbrains/buildServer/dotTrace/agent/BuildPublisherTest.java import java.io.File; import java.io.IOException; import java.util.Arrays; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotTrace.StatisticMessage; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; final Metrics thresholdsMetrics = new Metrics( Arrays.asList( new Metric("Method88", "88", "345"), new Metric("Method1", "100", "1000"), new Metric("MethodA", "F22", "F35"))); final CommandLineExecutionContext ctx = new CommandLineExecutionContext(0); myCtx.checking(new Expectations() {{ oneOf(myAfterBuildPublisher).publishAfterBuildArtifactFile(ctx, reportFile); oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.THRESHOLDS_VAR); will(returnValue("thresholds")); oneOf(myThresholdsParser).parse("thresholds"); will(returnValue(thresholdsMetrics)); //noinspection EmptyCatchBlock try { oneOf(myFileService).readAllTextFile(reportFile); } catch (IOException e) { } will(returnValue("report's content")); oneOf(myReportParser).parse("report's content"); will(returnValue(reportMetrics));
oneOf(myLoggerService).onMessage(new StatisticMessage("Method1", "100", "1000", "100", "33"));
JetBrains/teamcity-dottrace
dotTrace-agent/src/test/java/jetbrains/buildServer/dotTrace/agent/DotTraceSetupBuilderTest.java
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // }
import java.io.File; import java.util.Arrays; import java.util.Collections; import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.assertj.core.api.BDDAssertions.then;
myPatternsGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "PatternsGenerator"); //noinspection unchecked myCmdGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "CmdGenerator"); //noinspection unchecked myRunnerParametersService = myCtx.mock(RunnerParametersService.class); myBeforeBuildPublisher = myCtx.mock(ResourcePublisher.class, "beforeBuildPublisher"); myDotTraceBuildPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceBuildPublisher"); myDotTraceSnapshotsPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceSnapshotsPublisher"); myCommandLineResource = myCtx.mock(CommandLineResource.class); myFileService = myCtx.mock(FileService.class); myAssertions = myCtx.mock(RunnerAssertions.class); } @Test public void shouldCreateSetupWhenGetSetup() { // Given final CommandLineSetup baseSetup = new CommandLineSetup("someTool", Arrays.asList(new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)), Collections.singletonList(myCommandLineResource)); final File cmdFile = new File("cmd"); final File projectFile = new File("project"); final File snapshotDir = new File("snapshotRoot"); final File snapshotFile = new File(snapshotDir, DotTraceSetupBuilder.DOT_TRACE_SNAPSHOT_FILE); final File patternsFile = new File("patterns"); final File reportFile = new File("report"); final Context ctx = new Context(baseSetup, projectFile, snapshotFile, patternsFile, reportFile); myCtx.checking(new Expectations() {{ oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED); will(returnValue(false));
// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java // public class Constants { // public static final String USE_VAR = "dot_trace"; // public static final String PATH_VAR = "dot_trace_path"; // public static final String THRESHOLDS_VAR = "dot_trace_thresholds"; // public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type"; // public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes"; // public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters"; // public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path"; // } // Path: dotTrace-agent/src/test/java/jetbrains/buildServer/dotTrace/agent/DotTraceSetupBuilderTest.java import java.io.File; import java.util.Arrays; import java.util.Collections; import jetbrains.buildServer.dotTrace.Constants; import jetbrains.buildServer.dotNet.buildRunner.agent.*; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.assertj.core.api.BDDAssertions.then; myPatternsGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "PatternsGenerator"); //noinspection unchecked myCmdGenerator = (ResourceGenerator<Context>)myCtx.mock(ResourceGenerator.class, "CmdGenerator"); //noinspection unchecked myRunnerParametersService = myCtx.mock(RunnerParametersService.class); myBeforeBuildPublisher = myCtx.mock(ResourcePublisher.class, "beforeBuildPublisher"); myDotTraceBuildPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceBuildPublisher"); myDotTraceSnapshotsPublisher = myCtx.mock(ResourcePublisher.class, "dotTraceSnapshotsPublisher"); myCommandLineResource = myCtx.mock(CommandLineResource.class); myFileService = myCtx.mock(FileService.class); myAssertions = myCtx.mock(RunnerAssertions.class); } @Test public void shouldCreateSetupWhenGetSetup() { // Given final CommandLineSetup baseSetup = new CommandLineSetup("someTool", Arrays.asList(new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)), Collections.singletonList(myCommandLineResource)); final File cmdFile = new File("cmd"); final File projectFile = new File("project"); final File snapshotDir = new File("snapshotRoot"); final File snapshotFile = new File(snapshotDir, DotTraceSetupBuilder.DOT_TRACE_SNAPSHOT_FILE); final File patternsFile = new File("patterns"); final File reportFile = new File("report"); final Context ctx = new Context(baseSetup, projectFile, snapshotFile, patternsFile, reportFile); myCtx.checking(new Expectations() {{ oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED); will(returnValue(false));
oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.USE_VAR);
kontalk/desktopclient-java
src/main/java/org/kontalk/crypto/PGPUtils.java
// Path: src/main/java/org/kontalk/misc/KonException.java // public final class KonException extends Exception { // // public enum Error { // DB, // IMPORT_ARCHIVE, // IMPORT_READ_FILE, // IMPORT_KEY, // CHANGE_PASS, // CHANGE_PASS_COPY, // WRITE_FILE, // READ_FILE, // LOAD_KEY, // LOAD_KEY_DECRYPT, // CLIENT_CONNECT, // CLIENT_LOGIN, // CLIENT_ERROR, // DOWNLOAD_CREATE, // DOWNLOAD_RESPONSE, // DOWNLOAD_EXECUTE, // DOWNLOAD_WRITE, // UPLOAD_CREATE, // UPLOAD_RESPONSE, // UPLOAD_EXECUTE, // } // // private final Error mError; // // public KonException(Error error, Exception ex) { // super(ex); // mError = error; // } // // public KonException(Error error) { // super(); // mError = error; // } // // public Class<?> getCauseClass() { // Throwable cause = this.getCause(); // return cause == null ? this.getClass() : cause.getClass(); // } // // public Error getError() { // return mError; // } // }
import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.Security; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Iterator; import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.bouncycastle.bcpg.HashAlgorithmTags; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openpgp.PGPCompressedData; import org.bouncycastle.openpgp.PGPEncryptedData; import org.bouncycastle.openpgp.PGPEncryptedDataList; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPKeyFlags; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPMarker; import org.bouncycastle.openpgp.PGPObjectFactory; import org.bouncycastle.openpgp.PGPOnePassSignatureList; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureList; import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; import org.bouncycastle.openpgp.PGPUtil; import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory; import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor; import org.bouncycastle.openpgp.operator.PGPDigestCalculator; import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider; import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter; import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; import org.bouncycastle.util.encoders.Hex; import org.kontalk.misc.KonException;
sKeyConverter = new JcaPGPKeyConverter().setProvider(PGPUtils.PROVIDER); } static PrivateKey convertPrivateKey(PGPPrivateKey key) throws PGPException { ensureKeyConverter(); return sKeyConverter.getPrivateKey(key); } static PublicKey convertPublicKey(PGPPublicKey key) throws PGPException { ensureKeyConverter(); return sKeyConverter.getPublicKey(key); } private static int getKeyFlags(PGPPublicKey key) { @SuppressWarnings("unchecked") Iterator<PGPSignature> sigs = key.getSignatures(); while (sigs.hasNext()) { PGPSignature sig = sigs.next(); PGPSignatureSubpacketVector subpackets = sig.getHashedSubPackets(); if (subpackets != null) return subpackets.getKeyFlags(); } return 0; } static boolean isSigningKey(PGPPublicKey key) { int keyFlags = getKeyFlags(key); return (keyFlags & PGPKeyFlags.CAN_SIGN) == PGPKeyFlags.CAN_SIGN; }
// Path: src/main/java/org/kontalk/misc/KonException.java // public final class KonException extends Exception { // // public enum Error { // DB, // IMPORT_ARCHIVE, // IMPORT_READ_FILE, // IMPORT_KEY, // CHANGE_PASS, // CHANGE_PASS_COPY, // WRITE_FILE, // READ_FILE, // LOAD_KEY, // LOAD_KEY_DECRYPT, // CLIENT_CONNECT, // CLIENT_LOGIN, // CLIENT_ERROR, // DOWNLOAD_CREATE, // DOWNLOAD_RESPONSE, // DOWNLOAD_EXECUTE, // DOWNLOAD_WRITE, // UPLOAD_CREATE, // UPLOAD_RESPONSE, // UPLOAD_EXECUTE, // } // // private final Error mError; // // public KonException(Error error, Exception ex) { // super(ex); // mError = error; // } // // public KonException(Error error) { // super(); // mError = error; // } // // public Class<?> getCauseClass() { // Throwable cause = this.getCause(); // return cause == null ? this.getClass() : cause.getClass(); // } // // public Error getError() { // return mError; // } // } // Path: src/main/java/org/kontalk/crypto/PGPUtils.java import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.Security; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Iterator; import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.bouncycastle.bcpg.HashAlgorithmTags; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openpgp.PGPCompressedData; import org.bouncycastle.openpgp.PGPEncryptedData; import org.bouncycastle.openpgp.PGPEncryptedDataList; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPKeyFlags; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPMarker; import org.bouncycastle.openpgp.PGPObjectFactory; import org.bouncycastle.openpgp.PGPOnePassSignatureList; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureList; import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; import org.bouncycastle.openpgp.PGPUtil; import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory; import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor; import org.bouncycastle.openpgp.operator.PGPDigestCalculator; import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider; import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter; import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; import org.bouncycastle.util.encoders.Hex; import org.kontalk.misc.KonException; sKeyConverter = new JcaPGPKeyConverter().setProvider(PGPUtils.PROVIDER); } static PrivateKey convertPrivateKey(PGPPrivateKey key) throws PGPException { ensureKeyConverter(); return sKeyConverter.getPrivateKey(key); } static PublicKey convertPublicKey(PGPPublicKey key) throws PGPException { ensureKeyConverter(); return sKeyConverter.getPublicKey(key); } private static int getKeyFlags(PGPPublicKey key) { @SuppressWarnings("unchecked") Iterator<PGPSignature> sigs = key.getSignatures(); while (sigs.hasNext()) { PGPSignature sig = sigs.next(); PGPSignatureSubpacketVector subpackets = sig.getHashedSubPackets(); if (subpackets != null) return subpackets.getKeyFlags(); } return 0; } static boolean isSigningKey(PGPPublicKey key) { int keyFlags = getKeyFlags(key); return (keyFlags & PGPKeyFlags.CAN_SIGN) == PGPKeyFlags.CAN_SIGN; }
static PGPKeyPair decrypt(PGPSecretKey secretKey, PBESecretKeyDecryptor dec) throws KonException {
kontalk/desktopclient-java
src/main/java/org/kontalk/util/MediaUtils.java
// Path: src/main/java/org/kontalk/misc/Callback.java // public final class Callback<V> { // private static final Logger LOGGER = Logger.getLogger(Callback.class.getName()); // // public final V value; // public final Optional<Exception> exception; // // public Callback() { // this.value = null; // this.exception = Optional.empty(); // } // // public Callback(V response) { // this.value = response; // this.exception = Optional.empty(); // } // // public Callback(Exception ex) { // this.value = null; // this.exception = Optional.of(ex); // } // // public interface Handler<V> { // void handle(Callback<V> callback); // } // // public static class Synchronizer { // private final CountDownLatch mLatch = new CountDownLatch(1); // // public void sync() { // mLatch.countDown(); // } // // public void waitForSync() { // boolean succ = false; // try { // succ = mLatch.await(5, TimeUnit.SECONDS); // } catch (InterruptedException ex) { // LOGGER.log(Level.WARNING, "interrupted", ex); // } // if (!succ) { // LOGGER.warning("await failed, timeout reached"); // } // } // } // }
import javax.imageio.ImageIO; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.apache.tika.mime.MimeType; import org.apache.tika.mime.MimeTypeException; import org.apache.tika.mime.MimeTypes; import org.kontalk.misc.Callback;
return new byte[0]; } if (!succ) { LOGGER.warning("no image writer found, format: "+format); } return out.toByteArray(); } /** * Scale image down to max pixels preserving ratio. * Blocking */ public static BufferedImage scale(BufferedImage image, int maxPixels) { int iw = image.getWidth(); int ih = image.getHeight(); double scale = Math.sqrt(maxPixels / (iw * ih * 1.0)); return toBufferedImage(scaleImage(image, (int) (iw * scale), (int) (ih * scale))); } /** * Scale image down to minimum width/height, preserving ratio. * Blocking. */ public static BufferedImage scale(Image image, int width, int height) { return toBufferedImage(scaleAsync(image, width, height)); } private static BufferedImage toBufferedImage(Image image) {
// Path: src/main/java/org/kontalk/misc/Callback.java // public final class Callback<V> { // private static final Logger LOGGER = Logger.getLogger(Callback.class.getName()); // // public final V value; // public final Optional<Exception> exception; // // public Callback() { // this.value = null; // this.exception = Optional.empty(); // } // // public Callback(V response) { // this.value = response; // this.exception = Optional.empty(); // } // // public Callback(Exception ex) { // this.value = null; // this.exception = Optional.of(ex); // } // // public interface Handler<V> { // void handle(Callback<V> callback); // } // // public static class Synchronizer { // private final CountDownLatch mLatch = new CountDownLatch(1); // // public void sync() { // mLatch.countDown(); // } // // public void waitForSync() { // boolean succ = false; // try { // succ = mLatch.await(5, TimeUnit.SECONDS); // } catch (InterruptedException ex) { // LOGGER.log(Level.WARNING, "interrupted", ex); // } // if (!succ) { // LOGGER.warning("await failed, timeout reached"); // } // } // } // } // Path: src/main/java/org/kontalk/util/MediaUtils.java import javax.imageio.ImageIO; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.apache.tika.mime.MimeType; import org.apache.tika.mime.MimeTypeException; import org.apache.tika.mime.MimeTypes; import org.kontalk.misc.Callback; return new byte[0]; } if (!succ) { LOGGER.warning("no image writer found, format: "+format); } return out.toByteArray(); } /** * Scale image down to max pixels preserving ratio. * Blocking */ public static BufferedImage scale(BufferedImage image, int maxPixels) { int iw = image.getWidth(); int ih = image.getHeight(); double scale = Math.sqrt(maxPixels / (iw * ih * 1.0)); return toBufferedImage(scaleImage(image, (int) (iw * scale), (int) (ih * scale))); } /** * Scale image down to minimum width/height, preserving ratio. * Blocking. */ public static BufferedImage scale(Image image, int width, int height) { return toBufferedImage(scaleAsync(image, width, height)); } private static BufferedImage toBufferedImage(Image image) {
final Callback.Synchronizer syncer = new Callback.Synchronizer();
kontalk/desktopclient-java
src/main/java/org/kontalk/crypto/PersonalKey.java
// Path: src/main/java/org/kontalk/misc/KonException.java // public final class KonException extends Exception { // // public enum Error { // DB, // IMPORT_ARCHIVE, // IMPORT_READ_FILE, // IMPORT_KEY, // CHANGE_PASS, // CHANGE_PASS_COPY, // WRITE_FILE, // READ_FILE, // LOAD_KEY, // LOAD_KEY_DECRYPT, // CLIENT_CONNECT, // CLIENT_LOGIN, // CLIENT_ERROR, // DOWNLOAD_CREATE, // DOWNLOAD_RESPONSE, // DOWNLOAD_EXECUTE, // DOWNLOAD_WRITE, // UPLOAD_CREATE, // UPLOAD_RESPONSE, // UPLOAD_EXECUTE, // } // // private final Error mError; // // public KonException(Error error, Exception ex) { // super(ex); // mError = error; // } // // public KonException(Error error) { // super(); // mError = error; // } // // public Class<?> getCauseClass() { // Throwable cause = this.getCause(); // return cause == null ? this.getClass() : cause.getClass(); // } // // public Error getError() { // return mError; // } // }
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.SignatureException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.bc.BcPGPPublicKeyRing; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.util.encoders.Hex; import org.kontalk.misc.KonException;
/* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.crypto; /** * Personal PGP key(s). */ public final class PersonalKey { private static final Logger LOGGER = Logger.getLogger(PersonalKey.class.getName()); /** (Server) Authentication key. */ private final PGPPublicKey mAuthKey; /** (Server) Login key. */ private final PrivateKey mLoginKey; /** Signing key. */ private final PGPKeyPair mSignKey; /** En-/decryption key. */ private final PGPKeyPair mEncryptKey; /** X.509 bridge certificate. */ private final X509Certificate mBridgeCert; /** Primary user ID. */ private final String mUID; private PersonalKey(PGPKeyPair authKP, PGPKeyPair signKP, PGPKeyPair encryptKP, X509Certificate bridgeCert, String uid) throws PGPException { mAuthKey = authKP.getPublicKey(); mLoginKey = PGPUtils.convertPrivateKey(authKP.getPrivateKey()); mSignKey = signKP; mEncryptKey = encryptKP; mBridgeCert = bridgeCert; mUID = uid; } PGPPrivateKey getPrivateEncryptionKey() { return mEncryptKey.getPrivateKey(); } PGPPrivateKey getPrivateSigningKey() { return mSignKey.getPrivateKey(); } int getSigningAlgorithm() { return mSignKey.getPublicKey().getAlgorithm(); } public X509Certificate getBridgeCertificate() { return mBridgeCert; } public PrivateKey getServerLoginKey() { return mLoginKey; } /** Returns the first user ID in the key. */ public String getUserId() { return mUID; } public String getFingerprint() { return Hex.toHexString(mAuthKey.getFingerprint()); } /** Creates a {@link PersonalKey} from private keyring data. * X.509 bridge certificate is created from key data. */ public static PersonalKey load(byte[] privateKeyData, char[] passphrase)
// Path: src/main/java/org/kontalk/misc/KonException.java // public final class KonException extends Exception { // // public enum Error { // DB, // IMPORT_ARCHIVE, // IMPORT_READ_FILE, // IMPORT_KEY, // CHANGE_PASS, // CHANGE_PASS_COPY, // WRITE_FILE, // READ_FILE, // LOAD_KEY, // LOAD_KEY_DECRYPT, // CLIENT_CONNECT, // CLIENT_LOGIN, // CLIENT_ERROR, // DOWNLOAD_CREATE, // DOWNLOAD_RESPONSE, // DOWNLOAD_EXECUTE, // DOWNLOAD_WRITE, // UPLOAD_CREATE, // UPLOAD_RESPONSE, // UPLOAD_EXECUTE, // } // // private final Error mError; // // public KonException(Error error, Exception ex) { // super(ex); // mError = error; // } // // public KonException(Error error) { // super(); // mError = error; // } // // public Class<?> getCauseClass() { // Throwable cause = this.getCause(); // return cause == null ? this.getClass() : cause.getClass(); // } // // public Error getError() { // return mError; // } // } // Path: src/main/java/org/kontalk/crypto/PersonalKey.java import java.io.ByteArrayOutputStream; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.SignatureException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.bc.BcPGPPublicKeyRing; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.util.encoders.Hex; import org.kontalk.misc.KonException; /* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.crypto; /** * Personal PGP key(s). */ public final class PersonalKey { private static final Logger LOGGER = Logger.getLogger(PersonalKey.class.getName()); /** (Server) Authentication key. */ private final PGPPublicKey mAuthKey; /** (Server) Login key. */ private final PrivateKey mLoginKey; /** Signing key. */ private final PGPKeyPair mSignKey; /** En-/decryption key. */ private final PGPKeyPair mEncryptKey; /** X.509 bridge certificate. */ private final X509Certificate mBridgeCert; /** Primary user ID. */ private final String mUID; private PersonalKey(PGPKeyPair authKP, PGPKeyPair signKP, PGPKeyPair encryptKP, X509Certificate bridgeCert, String uid) throws PGPException { mAuthKey = authKP.getPublicKey(); mLoginKey = PGPUtils.convertPrivateKey(authKP.getPrivateKey()); mSignKey = signKP; mEncryptKey = encryptKP; mBridgeCert = bridgeCert; mUID = uid; } PGPPrivateKey getPrivateEncryptionKey() { return mEncryptKey.getPrivateKey(); } PGPPrivateKey getPrivateSigningKey() { return mSignKey.getPrivateKey(); } int getSigningAlgorithm() { return mSignKey.getPublicKey().getAlgorithm(); } public X509Certificate getBridgeCertificate() { return mBridgeCert; } public PrivateKey getServerLoginKey() { return mLoginKey; } /** Returns the first user ID in the key. */ public String getUserId() { return mUID; } public String getFingerprint() { return Hex.toHexString(mAuthKey.getFingerprint()); } /** Creates a {@link PersonalKey} from private keyring data. * X.509 bridge certificate is created from key data. */ public static PersonalKey load(byte[] privateKeyData, char[] passphrase)
throws KonException, IOException, PGPException, CertificateException, NoSuchProviderException {
kontalk/desktopclient-java
src/main/java/org/kontalk/util/MessageUtils.java
// Path: src/main/java/org/kontalk/model/message/OutMessage.java // public final class OutMessage extends KonMessage { // private static final Logger LOGGER = Logger.getLogger(OutMessage.class.getName()); // // private final Set<Transmission> mTransmissions; // // public OutMessage(Chat chat, List<Contact> contacts, // MessageContent content, boolean encrypted) { // super( // chat, // "Kon_" + EncodingUtils.randomString(8), // content, // Optional.empty(), // Status.PENDING, // encrypted ? // CoderStatus.createToEncrypt() : // CoderStatus.createInsecure()); // // Set<Transmission> ts = new HashSet<>(); // contacts.forEach(contact -> { // boolean succ = ts.add(new Transmission(contact, contact.getJID(), mID)); // if (!succ) // LOGGER.warning("duplicate contact: " + contact); // }); // mTransmissions = Collections.unmodifiableSet(ts); // } // // // used when loading from database // OutMessage(KonMessage.Builder builder) { // super(builder); // // mTransmissions = Collections.unmodifiableSet(builder.mTransmissions); // } // // public void setReceived(JID jid, Date date) { // Transmission transmission = mTransmissions.stream() // .filter(t -> t.getContact().getJID().equals(jid)) // .findFirst().orElse(null); // if (transmission == null) { // LOGGER.warning("can't find transmission for received status, IDs: "+jid); // return; // } // // if (transmission.isReceived()) // // probably already received by another client // return; // // transmission.setReceived(date); // this.changed(ViewChange.STATUS); // } // // public void setStatus(Status status) { // if (status == Status.IN || status == Status.RECEIVED) { // LOGGER.warning("wrong status argument: "+status); // return; // } // // if (status == Status.SENT && mStatus != Status.PENDING) // LOGGER.warning("unexpected new status of sent message: "+status); // // mStatus = status; // if (status != Status.PENDING) // mServerDate = new Date(); // this.save(); // this.changed(ViewChange.STATUS); // } // // // Note: only one error per message (not transmission) possible // public void setServerError(String condition, String text) { // if (mStatus != Status.SENT) // LOGGER.warning("unexpected status of message with error: "+mStatus); // mServerError = new KonMessage.ServerError(condition, text); // this.setStatus(Status.ERROR); // } // // public boolean isSendEncrypted() { // return mCoderStatus.getEncryption() != Coder.Encryption.NOT || // mCoderStatus.getSigning() != Coder.Signing.NOT; // } // // @Override // public Set<Transmission> getTransmissions() { // return mTransmissions; // } // // @Override // public final boolean equals(Object o) { // if (o == this) // return true; // // if (!(o instanceof OutMessage)) // return false; // // return this.abstractEquals((KonMessage) o); // } // // @Override // public int hashCode() { // int hash = this.abstractHashCode(); // hash = 67 * hash + Objects.hash(mTransmissions); // return hash; // } // }
import org.kontalk.model.message.OutMessage;
/* * Kontalk Java client * Copyright (C) 2017 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.util; /** * Static utilities used as interface between control, crypto and client. * @author Alexander Bikadorov {@literal <[email protected]>} */ public class MessageUtils { private MessageUtils() {} public static class SendTask { public enum Encryption {NONE, RFC3923, XEP0373}
// Path: src/main/java/org/kontalk/model/message/OutMessage.java // public final class OutMessage extends KonMessage { // private static final Logger LOGGER = Logger.getLogger(OutMessage.class.getName()); // // private final Set<Transmission> mTransmissions; // // public OutMessage(Chat chat, List<Contact> contacts, // MessageContent content, boolean encrypted) { // super( // chat, // "Kon_" + EncodingUtils.randomString(8), // content, // Optional.empty(), // Status.PENDING, // encrypted ? // CoderStatus.createToEncrypt() : // CoderStatus.createInsecure()); // // Set<Transmission> ts = new HashSet<>(); // contacts.forEach(contact -> { // boolean succ = ts.add(new Transmission(contact, contact.getJID(), mID)); // if (!succ) // LOGGER.warning("duplicate contact: " + contact); // }); // mTransmissions = Collections.unmodifiableSet(ts); // } // // // used when loading from database // OutMessage(KonMessage.Builder builder) { // super(builder); // // mTransmissions = Collections.unmodifiableSet(builder.mTransmissions); // } // // public void setReceived(JID jid, Date date) { // Transmission transmission = mTransmissions.stream() // .filter(t -> t.getContact().getJID().equals(jid)) // .findFirst().orElse(null); // if (transmission == null) { // LOGGER.warning("can't find transmission for received status, IDs: "+jid); // return; // } // // if (transmission.isReceived()) // // probably already received by another client // return; // // transmission.setReceived(date); // this.changed(ViewChange.STATUS); // } // // public void setStatus(Status status) { // if (status == Status.IN || status == Status.RECEIVED) { // LOGGER.warning("wrong status argument: "+status); // return; // } // // if (status == Status.SENT && mStatus != Status.PENDING) // LOGGER.warning("unexpected new status of sent message: "+status); // // mStatus = status; // if (status != Status.PENDING) // mServerDate = new Date(); // this.save(); // this.changed(ViewChange.STATUS); // } // // // Note: only one error per message (not transmission) possible // public void setServerError(String condition, String text) { // if (mStatus != Status.SENT) // LOGGER.warning("unexpected status of message with error: "+mStatus); // mServerError = new KonMessage.ServerError(condition, text); // this.setStatus(Status.ERROR); // } // // public boolean isSendEncrypted() { // return mCoderStatus.getEncryption() != Coder.Encryption.NOT || // mCoderStatus.getSigning() != Coder.Signing.NOT; // } // // @Override // public Set<Transmission> getTransmissions() { // return mTransmissions; // } // // @Override // public final boolean equals(Object o) { // if (o == this) // return true; // // if (!(o instanceof OutMessage)) // return false; // // return this.abstractEquals((KonMessage) o); // } // // @Override // public int hashCode() { // int hash = this.abstractHashCode(); // hash = 67 * hash + Objects.hash(mTransmissions); // return hash; // } // } // Path: src/main/java/org/kontalk/util/MessageUtils.java import org.kontalk.model.message.OutMessage; /* * Kontalk Java client * Copyright (C) 2017 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.util; /** * Static utilities used as interface between control, crypto and client. * @author Alexander Bikadorov {@literal <[email protected]>} */ public class MessageUtils { private MessageUtils() {} public static class SendTask { public enum Encryption {NONE, RFC3923, XEP0373}
public final OutMessage message;
kontalk/desktopclient-java
src/main/java/org/kontalk/model/chat/GroupMetaData.java
// Path: src/main/java/org/kontalk/misc/JID.java // public final class JID { // private static final Logger LOGGER = Logger.getLogger(JID.class.getName()); // // static { // // good to know. For working JID validation // SimpleXmppStringprep.setup(); // } // // private final String mLocal; // escaped! // private final String mDomain; // private final String mResource; // private final boolean mValid; // // private JID(String local, String domain, String resource) { // mLocal = local; // mDomain = domain; // mResource = resource; // // mValid = !mLocal.isEmpty() && !mDomain.isEmpty() // // NOTE: domain check could be stronger - compliant with RFC 6122, but // // server does not accept most special characters // // NOTE: resource not checked // && JidUtil.isTypicalValidEntityBareJid( // XmppStringUtils.completeJidFrom(mLocal, mDomain)); // } // // /** Return unescaped local part. */ // public String local() { // return XmppStringUtils.unescapeLocalpart(mLocal); // } // // public String domain() { // return mDomain; // } // // /** Return JID as escaped string. */ // public String string() { // return XmppStringUtils.completeJidFrom(mLocal, mDomain, mResource); // } // // public String asUnescapedString() { // return XmppStringUtils.completeJidFrom(this.local(), mDomain, mResource); // } // // public boolean isValid() { // return mValid; // } // // public boolean isHash() { // return mLocal.matches("[0-9a-f]{40}"); // } // // public boolean isFull() { // return !mResource.isEmpty(); // } // // public JID toBare() { // return new JID(mLocal, mDomain, ""); // } // // /** To invalid(!) domain JID. */ // public JID toDomain() { // return new JID("", mDomain, ""); // } // // public BareJid toBareSmack() { // try { // return JidCreate.bareFrom(this.string()); // } catch (XmppStringprepException ex) { // LOGGER.log(Level.WARNING, "could not convert to smack", ex); // throw new RuntimeException("You didn't check isValid(), idiot!"); // } // } // // public Jid toSmack() { // try { // return JidCreate.from(this.string()); // } catch (XmppStringprepException ex) { // LOGGER.log(Level.WARNING, "could not convert to smack", ex); // throw new RuntimeException("Not even a simple Jid?"); // } // } // // /** // * Comparing only bare JIDs. // * Case-insensitive. // */ // @Override // public final boolean equals(Object o) { // if (o == this) // return true; // // if (!(o instanceof JID)) // return false; // // JID oJID = (JID) o; // return mLocal.equalsIgnoreCase(oJID.mLocal) && // mDomain.equalsIgnoreCase(oJID.mDomain); // } // // @Override // public int hashCode() { // return Objects.hash(mLocal, mDomain); // } // // /** Use this only for debugging and otherwise string() instead! */ // @Override // public String toString() { // return "'"+this.string()+"'"; // } // // public static JID full(String jid) { // jid = StringUtils.defaultString(jid); // return escape(XmppStringUtils.parseLocalpart(jid), // XmppStringUtils.parseDomain(jid), // XmppStringUtils.parseResource(jid)); // } // // public static JID bare(String jid) { // jid = StringUtils.defaultString(jid); // return escape(XmppStringUtils.parseLocalpart(jid), XmppStringUtils.parseDomain(jid), ""); // } // // public static JID fromSmack(Jid jid) { // Localpart localpart = jid.getLocalpartOrNull(); // return new JID(localpart != null ? localpart.toString() : "", // jid.getDomain().toString(), // jid.getResourceOrEmpty().toString()); // } // // public static JID bare(String local, String domain) { // return escape(local, domain, ""); // } // // private static JID escape(String local, String domain, String resource) { // return new JID(XmppStringUtils.escapeLocalpart(local), domain, resource); // } // // public static JID deleted(int id) { // return new JID("", Integer.toString(id), ""); // } // }
import java.util.Map; import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.kontalk.misc.JID;
/* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.model.chat; /** * Immutable meta data fields for a specific group chat protocol implementation. * * @author Alexander Bikadorov {@literal <[email protected]>} */ public abstract class GroupMetaData { private static final Logger LOGGER = Logger.getLogger(GroupMetaData.class.getName()); abstract String toJSON(); /** Data fields specific to a Kontalk group chat (custom protocol). */ public static class KonGroupData extends GroupMetaData { private static final String JSON_OWNER_JID = "jid"; private static final String JSON_ID = "id";
// Path: src/main/java/org/kontalk/misc/JID.java // public final class JID { // private static final Logger LOGGER = Logger.getLogger(JID.class.getName()); // // static { // // good to know. For working JID validation // SimpleXmppStringprep.setup(); // } // // private final String mLocal; // escaped! // private final String mDomain; // private final String mResource; // private final boolean mValid; // // private JID(String local, String domain, String resource) { // mLocal = local; // mDomain = domain; // mResource = resource; // // mValid = !mLocal.isEmpty() && !mDomain.isEmpty() // // NOTE: domain check could be stronger - compliant with RFC 6122, but // // server does not accept most special characters // // NOTE: resource not checked // && JidUtil.isTypicalValidEntityBareJid( // XmppStringUtils.completeJidFrom(mLocal, mDomain)); // } // // /** Return unescaped local part. */ // public String local() { // return XmppStringUtils.unescapeLocalpart(mLocal); // } // // public String domain() { // return mDomain; // } // // /** Return JID as escaped string. */ // public String string() { // return XmppStringUtils.completeJidFrom(mLocal, mDomain, mResource); // } // // public String asUnescapedString() { // return XmppStringUtils.completeJidFrom(this.local(), mDomain, mResource); // } // // public boolean isValid() { // return mValid; // } // // public boolean isHash() { // return mLocal.matches("[0-9a-f]{40}"); // } // // public boolean isFull() { // return !mResource.isEmpty(); // } // // public JID toBare() { // return new JID(mLocal, mDomain, ""); // } // // /** To invalid(!) domain JID. */ // public JID toDomain() { // return new JID("", mDomain, ""); // } // // public BareJid toBareSmack() { // try { // return JidCreate.bareFrom(this.string()); // } catch (XmppStringprepException ex) { // LOGGER.log(Level.WARNING, "could not convert to smack", ex); // throw new RuntimeException("You didn't check isValid(), idiot!"); // } // } // // public Jid toSmack() { // try { // return JidCreate.from(this.string()); // } catch (XmppStringprepException ex) { // LOGGER.log(Level.WARNING, "could not convert to smack", ex); // throw new RuntimeException("Not even a simple Jid?"); // } // } // // /** // * Comparing only bare JIDs. // * Case-insensitive. // */ // @Override // public final boolean equals(Object o) { // if (o == this) // return true; // // if (!(o instanceof JID)) // return false; // // JID oJID = (JID) o; // return mLocal.equalsIgnoreCase(oJID.mLocal) && // mDomain.equalsIgnoreCase(oJID.mDomain); // } // // @Override // public int hashCode() { // return Objects.hash(mLocal, mDomain); // } // // /** Use this only for debugging and otherwise string() instead! */ // @Override // public String toString() { // return "'"+this.string()+"'"; // } // // public static JID full(String jid) { // jid = StringUtils.defaultString(jid); // return escape(XmppStringUtils.parseLocalpart(jid), // XmppStringUtils.parseDomain(jid), // XmppStringUtils.parseResource(jid)); // } // // public static JID bare(String jid) { // jid = StringUtils.defaultString(jid); // return escape(XmppStringUtils.parseLocalpart(jid), XmppStringUtils.parseDomain(jid), ""); // } // // public static JID fromSmack(Jid jid) { // Localpart localpart = jid.getLocalpartOrNull(); // return new JID(localpart != null ? localpart.toString() : "", // jid.getDomain().toString(), // jid.getResourceOrEmpty().toString()); // } // // public static JID bare(String local, String domain) { // return escape(local, domain, ""); // } // // private static JID escape(String local, String domain, String resource) { // return new JID(XmppStringUtils.escapeLocalpart(local), domain, resource); // } // // public static JID deleted(int id) { // return new JID("", Integer.toString(id), ""); // } // } // Path: src/main/java/org/kontalk/model/chat/GroupMetaData.java import java.util.Map; import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; import org.json.simple.JSONValue; import org.kontalk.misc.JID; /* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.model.chat; /** * Immutable meta data fields for a specific group chat protocol implementation. * * @author Alexander Bikadorov {@literal <[email protected]>} */ public abstract class GroupMetaData { private static final Logger LOGGER = Logger.getLogger(GroupMetaData.class.getName()); abstract String toJSON(); /** Data fields specific to a Kontalk group chat (custom protocol). */ public static class KonGroupData extends GroupMetaData { private static final String JSON_OWNER_JID = "jid"; private static final String JSON_ID = "id";
public final JID owner;
kontalk/desktopclient-java
src/main/java/org/kontalk/client/PrivateKeyReceiver.java
// Path: src/main/java/org/kontalk/misc/Callback.java // public final class Callback<V> { // private static final Logger LOGGER = Logger.getLogger(Callback.class.getName()); // // public final V value; // public final Optional<Exception> exception; // // public Callback() { // this.value = null; // this.exception = Optional.empty(); // } // // public Callback(V response) { // this.value = response; // this.exception = Optional.empty(); // } // // public Callback(Exception ex) { // this.value = null; // this.exception = Optional.of(ex); // } // // public interface Handler<V> { // void handle(Callback<V> callback); // } // // public static class Synchronizer { // private final CountDownLatch mLatch = new CountDownLatch(1); // // public void sync() { // mLatch.countDown(); // } // // public void waitForSync() { // boolean succ = false; // try { // succ = mLatch.await(5, TimeUnit.SECONDS); // } catch (InterruptedException ex) { // LOGGER.log(Level.WARNING, "interrupted", ex); // } // if (!succ) { // LOGGER.warning("await failed, timeout reached"); // } // } // } // }
import org.jivesoftware.smackx.xdata.packet.DataForm; import org.kontalk.misc.Callback; import java.io.IOException; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.util.SuccessCallback; import org.jivesoftware.smackx.iqregister.packet.Registration; import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.FormField;
/* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.client; /** * Send request and listen to response for private data over * 'jabber:iq:register' namespace. * * Temporary server connection is established when requesting key. * * TODO not used * * @author Alexander Bikadorov {@literal <[email protected]>} */ public final class PrivateKeyReceiver implements SuccessCallback<IQ> { private static final Logger LOGGER = Logger.getLogger(PrivateKeyReceiver.class.getName()); private static final String FORM_TYPE_VALUE = "http://kontalk.org/protocol/register#privatekey"; private static final String FORM_TOKEN_VAR = "token";
// Path: src/main/java/org/kontalk/misc/Callback.java // public final class Callback<V> { // private static final Logger LOGGER = Logger.getLogger(Callback.class.getName()); // // public final V value; // public final Optional<Exception> exception; // // public Callback() { // this.value = null; // this.exception = Optional.empty(); // } // // public Callback(V response) { // this.value = response; // this.exception = Optional.empty(); // } // // public Callback(Exception ex) { // this.value = null; // this.exception = Optional.of(ex); // } // // public interface Handler<V> { // void handle(Callback<V> callback); // } // // public static class Synchronizer { // private final CountDownLatch mLatch = new CountDownLatch(1); // // public void sync() { // mLatch.countDown(); // } // // public void waitForSync() { // boolean succ = false; // try { // succ = mLatch.await(5, TimeUnit.SECONDS); // } catch (InterruptedException ex) { // LOGGER.log(Level.WARNING, "interrupted", ex); // } // if (!succ) { // LOGGER.warning("await failed, timeout reached"); // } // } // } // } // Path: src/main/java/org/kontalk/client/PrivateKeyReceiver.java import org.jivesoftware.smackx.xdata.packet.DataForm; import org.kontalk.misc.Callback; import java.io.IOException; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.util.SuccessCallback; import org.jivesoftware.smackx.iqregister.packet.Registration; import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.FormField; /* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.client; /** * Send request and listen to response for private data over * 'jabber:iq:register' namespace. * * Temporary server connection is established when requesting key. * * TODO not used * * @author Alexander Bikadorov {@literal <[email protected]>} */ public final class PrivateKeyReceiver implements SuccessCallback<IQ> { private static final Logger LOGGER = Logger.getLogger(PrivateKeyReceiver.class.getName()); private static final String FORM_TYPE_VALUE = "http://kontalk.org/protocol/register#privatekey"; private static final String FORM_TOKEN_VAR = "token";
private final Callback.Handler<String> mHandler;
kontalk/desktopclient-java
src/main/java/org/kontalk/view/SearchPanel.java
// Path: src/main/java/org/kontalk/util/Tr.java // public class Tr { // private static final Logger LOGGER = Logger.getLogger(Tr.class.getName()); // // private static final String DEFAULT_LANG = "en"; // private static final String I18N_DIR = "i18n/"; // private static final String STRING_FILE = "strings"; // private static final String PROP_EXT = ".properties"; // // private static final String WIKI_BASE = "https://github.com/kontalk/desktopclient-java/wiki"; // private static final String WIKI_HOME = "Home"; // private static final List<String> WIKI_LANGS = Arrays.asList("de"); // // /** Map default (English) strings to translated strings. **/ // private static Map<String, String> TR_MAP = null; // // /** // * Translate string used in user interface. // * Spaces at beginning or end of string not supported! // * @param s string that wants to be translated (in English) // * @return translation of input string (depending on platform language) // */ // public static String tr(String s) { // if (TR_MAP == null || !TR_MAP.containsKey(s)) // return s; // return TR_MAP.get(s); // } // // public static void init() { // // get language // String lang = Locale.getDefault().getLanguage(); // // for testing // //String lang = new Locale("zh").getLanguage(); // if (lang.equals(DEFAULT_LANG)) { // return; // } // // LOGGER.info("Setting language: "+lang); // // // load string keys file // String path = I18N_DIR + STRING_FILE + PROP_EXT; // PropertiesConfiguration stringKeys; // try { // stringKeys = new PropertiesConfiguration(ClassLoader.getSystemResource(path)); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load string key file", ex); // return; // } // // // load translation file // path = I18N_DIR + STRING_FILE + "_" + lang + PROP_EXT; // URL url = ClassLoader.getSystemResource(path); // if (url == null) { // LOGGER.info("can't find translation file: "+path); // return; // } // PropertiesConfiguration tr = new PropertiesConfiguration(); // tr.setEncoding("UTF-8"); // try { // tr.load(url); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load translation file", ex); // return; // } // // TR_MAP = new HashMap<>(); // Iterator<String> it = tr.getKeys(); // while (it.hasNext()) { // String k = it.next(); // if (!stringKeys.containsKey(k)) { // LOGGER.warning("key in translation but not in key file: "+k); // continue; // } // TR_MAP.put(stringKeys.getString(k), tr.getString(k)); // } // } // // public static String getLocalizedWikiLink() { // String lang = Locale.getDefault().getLanguage(); // if (WIKI_LANGS.contains(lang)) { // // damn URI decoding // return WIKI_BASE + "/%5B" + lang + "%5D-" + WIKI_HOME; // } // return WIKI_BASE; // } // }
import javax.swing.Icon; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import com.alee.extended.image.WebImage; import com.alee.laf.button.WebButton; import com.alee.laf.panel.WebPanel; import com.alee.laf.text.WebTextField; import org.kontalk.util.Tr;
/* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.view; /** * A search bar to search for text in contact, chat and message lists. * @author Alexander Bikadorov {@literal <[email protected]>} */ final class SearchPanel extends WebPanel { private final WebTextField mSearchField; SearchPanel(final ListView[] lists, final ChatView chatView) { mSearchField = new WebTextField();
// Path: src/main/java/org/kontalk/util/Tr.java // public class Tr { // private static final Logger LOGGER = Logger.getLogger(Tr.class.getName()); // // private static final String DEFAULT_LANG = "en"; // private static final String I18N_DIR = "i18n/"; // private static final String STRING_FILE = "strings"; // private static final String PROP_EXT = ".properties"; // // private static final String WIKI_BASE = "https://github.com/kontalk/desktopclient-java/wiki"; // private static final String WIKI_HOME = "Home"; // private static final List<String> WIKI_LANGS = Arrays.asList("de"); // // /** Map default (English) strings to translated strings. **/ // private static Map<String, String> TR_MAP = null; // // /** // * Translate string used in user interface. // * Spaces at beginning or end of string not supported! // * @param s string that wants to be translated (in English) // * @return translation of input string (depending on platform language) // */ // public static String tr(String s) { // if (TR_MAP == null || !TR_MAP.containsKey(s)) // return s; // return TR_MAP.get(s); // } // // public static void init() { // // get language // String lang = Locale.getDefault().getLanguage(); // // for testing // //String lang = new Locale("zh").getLanguage(); // if (lang.equals(DEFAULT_LANG)) { // return; // } // // LOGGER.info("Setting language: "+lang); // // // load string keys file // String path = I18N_DIR + STRING_FILE + PROP_EXT; // PropertiesConfiguration stringKeys; // try { // stringKeys = new PropertiesConfiguration(ClassLoader.getSystemResource(path)); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load string key file", ex); // return; // } // // // load translation file // path = I18N_DIR + STRING_FILE + "_" + lang + PROP_EXT; // URL url = ClassLoader.getSystemResource(path); // if (url == null) { // LOGGER.info("can't find translation file: "+path); // return; // } // PropertiesConfiguration tr = new PropertiesConfiguration(); // tr.setEncoding("UTF-8"); // try { // tr.load(url); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load translation file", ex); // return; // } // // TR_MAP = new HashMap<>(); // Iterator<String> it = tr.getKeys(); // while (it.hasNext()) { // String k = it.next(); // if (!stringKeys.containsKey(k)) { // LOGGER.warning("key in translation but not in key file: "+k); // continue; // } // TR_MAP.put(stringKeys.getString(k), tr.getString(k)); // } // } // // public static String getLocalizedWikiLink() { // String lang = Locale.getDefault().getLanguage(); // if (WIKI_LANGS.contains(lang)) { // // damn URI decoding // return WIKI_BASE + "/%5B" + lang + "%5D-" + WIKI_HOME; // } // return WIKI_BASE; // } // } // Path: src/main/java/org/kontalk/view/SearchPanel.java import javax.swing.Icon; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import com.alee.extended.image.WebImage; import com.alee.laf.button.WebButton; import com.alee.laf.panel.WebPanel; import com.alee.laf.text.WebTextField; import org.kontalk.util.Tr; /* * Kontalk Java client * Copyright (C) 2016 Kontalk Devteam <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kontalk.view; /** * A search bar to search for text in contact, chat and message lists. * @author Alexander Bikadorov {@literal <[email protected]>} */ final class SearchPanel extends WebPanel { private final WebTextField mSearchField; SearchPanel(final ListView[] lists, final ChatView chatView) { mSearchField = new WebTextField();
mSearchField.setInputPrompt(Tr.tr("Search…"));
kontalk/desktopclient-java
src/main/java/org/kontalk/persistence/Config.java
// Path: src/main/java/org/kontalk/util/Tr.java // public class Tr { // private static final Logger LOGGER = Logger.getLogger(Tr.class.getName()); // // private static final String DEFAULT_LANG = "en"; // private static final String I18N_DIR = "i18n/"; // private static final String STRING_FILE = "strings"; // private static final String PROP_EXT = ".properties"; // // private static final String WIKI_BASE = "https://github.com/kontalk/desktopclient-java/wiki"; // private static final String WIKI_HOME = "Home"; // private static final List<String> WIKI_LANGS = Arrays.asList("de"); // // /** Map default (English) strings to translated strings. **/ // private static Map<String, String> TR_MAP = null; // // /** // * Translate string used in user interface. // * Spaces at beginning or end of string not supported! // * @param s string that wants to be translated (in English) // * @return translation of input string (depending on platform language) // */ // public static String tr(String s) { // if (TR_MAP == null || !TR_MAP.containsKey(s)) // return s; // return TR_MAP.get(s); // } // // public static void init() { // // get language // String lang = Locale.getDefault().getLanguage(); // // for testing // //String lang = new Locale("zh").getLanguage(); // if (lang.equals(DEFAULT_LANG)) { // return; // } // // LOGGER.info("Setting language: "+lang); // // // load string keys file // String path = I18N_DIR + STRING_FILE + PROP_EXT; // PropertiesConfiguration stringKeys; // try { // stringKeys = new PropertiesConfiguration(ClassLoader.getSystemResource(path)); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load string key file", ex); // return; // } // // // load translation file // path = I18N_DIR + STRING_FILE + "_" + lang + PROP_EXT; // URL url = ClassLoader.getSystemResource(path); // if (url == null) { // LOGGER.info("can't find translation file: "+path); // return; // } // PropertiesConfiguration tr = new PropertiesConfiguration(); // tr.setEncoding("UTF-8"); // try { // tr.load(url); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load translation file", ex); // return; // } // // TR_MAP = new HashMap<>(); // Iterator<String> it = tr.getKeys(); // while (it.hasNext()) { // String k = it.next(); // if (!stringKeys.containsKey(k)) { // LOGGER.warning("key in translation but not in key file: "+k); // continue; // } // TR_MAP.put(stringKeys.getString(k), tr.getString(k)); // } // } // // public static String getLocalizedWikiLink() { // String lang = Locale.getDefault().getLanguage(); // if (WIKI_LANGS.contains(lang)) { // // damn URI decoding // return WIKI_BASE + "/%5B" + lang + "%5D-" + WIKI_HOME; // } // return WIKI_BASE; // } // }
import java.nio.file.Path; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.kontalk.util.Tr;
public static final String SERV_HOST = "server.host"; public static final String SERV_PORT = "server.port"; public static final String SERV_CERT_VALIDATION = "server.cert_validation"; public static final String ACC_PASS = "account.passphrase"; public static final String ACC_JID = "account.jid"; public static final String VIEW_FRAME_WIDTH = "view.frame.width"; public static final String VIEW_FRAME_HEIGHT = "view.frame.height"; public static final String VIEW_SELECTED_CHAT = "view.thread"; public static final String VIEW_CHAT_BG = "view.thread_bg"; public static final String VIEW_USER_CONTACT = "view.user_in_contactlist"; public static final String VIEW_HIDE_BLOCKED = "view.hide_blocked_contacts"; public static final String VIEW_MESSAGE_FONT_SIZE = "view.msg_font_size"; public static final String NET_SEND_CHAT_STATE = "net.chatstate"; public static final String NET_SEND_ROSTER_NAME = "net.roster_name"; public static final String NET_STATUS_LIST = "net.status_list"; public static final String NET_AUTO_SUBSCRIPTION = "net.auto_subscription"; public static final String NET_REQUEST_AVATARS = "net.request_avatars"; public static final String NET_MAX_IMG_SIZE = "net.max_img_size"; public static final String MAIN_CONNECT_STARTUP = "main.connect_startup"; public static final String NET_RETRY_CONNECT = "main.retry_connect"; public static final String MAIN_TRAY = "main.tray"; public static final String MAIN_TRAY_CLOSE = "main.tray_close"; public static final String MAIN_ENTER_SENDS = "main.enter_sends"; // default server address //public static final String DEFAULT_SERV_NET = "kontalk.net"; public static final String DEFAULT_SERV_HOST = "beta.kontalk.net"; public static final int DEFAULT_SERV_PORT = 5999; private final String mDefaultXMPPStatus =
// Path: src/main/java/org/kontalk/util/Tr.java // public class Tr { // private static final Logger LOGGER = Logger.getLogger(Tr.class.getName()); // // private static final String DEFAULT_LANG = "en"; // private static final String I18N_DIR = "i18n/"; // private static final String STRING_FILE = "strings"; // private static final String PROP_EXT = ".properties"; // // private static final String WIKI_BASE = "https://github.com/kontalk/desktopclient-java/wiki"; // private static final String WIKI_HOME = "Home"; // private static final List<String> WIKI_LANGS = Arrays.asList("de"); // // /** Map default (English) strings to translated strings. **/ // private static Map<String, String> TR_MAP = null; // // /** // * Translate string used in user interface. // * Spaces at beginning or end of string not supported! // * @param s string that wants to be translated (in English) // * @return translation of input string (depending on platform language) // */ // public static String tr(String s) { // if (TR_MAP == null || !TR_MAP.containsKey(s)) // return s; // return TR_MAP.get(s); // } // // public static void init() { // // get language // String lang = Locale.getDefault().getLanguage(); // // for testing // //String lang = new Locale("zh").getLanguage(); // if (lang.equals(DEFAULT_LANG)) { // return; // } // // LOGGER.info("Setting language: "+lang); // // // load string keys file // String path = I18N_DIR + STRING_FILE + PROP_EXT; // PropertiesConfiguration stringKeys; // try { // stringKeys = new PropertiesConfiguration(ClassLoader.getSystemResource(path)); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load string key file", ex); // return; // } // // // load translation file // path = I18N_DIR + STRING_FILE + "_" + lang + PROP_EXT; // URL url = ClassLoader.getSystemResource(path); // if (url == null) { // LOGGER.info("can't find translation file: "+path); // return; // } // PropertiesConfiguration tr = new PropertiesConfiguration(); // tr.setEncoding("UTF-8"); // try { // tr.load(url); // } catch (ConfigurationException ex) { // LOGGER.log(Level.WARNING, "can't load translation file", ex); // return; // } // // TR_MAP = new HashMap<>(); // Iterator<String> it = tr.getKeys(); // while (it.hasNext()) { // String k = it.next(); // if (!stringKeys.containsKey(k)) { // LOGGER.warning("key in translation but not in key file: "+k); // continue; // } // TR_MAP.put(stringKeys.getString(k), tr.getString(k)); // } // } // // public static String getLocalizedWikiLink() { // String lang = Locale.getDefault().getLanguage(); // if (WIKI_LANGS.contains(lang)) { // // damn URI decoding // return WIKI_BASE + "/%5B" + lang + "%5D-" + WIKI_HOME; // } // return WIKI_BASE; // } // } // Path: src/main/java/org/kontalk/persistence/Config.java import java.nio.file.Path; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.kontalk.util.Tr; public static final String SERV_HOST = "server.host"; public static final String SERV_PORT = "server.port"; public static final String SERV_CERT_VALIDATION = "server.cert_validation"; public static final String ACC_PASS = "account.passphrase"; public static final String ACC_JID = "account.jid"; public static final String VIEW_FRAME_WIDTH = "view.frame.width"; public static final String VIEW_FRAME_HEIGHT = "view.frame.height"; public static final String VIEW_SELECTED_CHAT = "view.thread"; public static final String VIEW_CHAT_BG = "view.thread_bg"; public static final String VIEW_USER_CONTACT = "view.user_in_contactlist"; public static final String VIEW_HIDE_BLOCKED = "view.hide_blocked_contacts"; public static final String VIEW_MESSAGE_FONT_SIZE = "view.msg_font_size"; public static final String NET_SEND_CHAT_STATE = "net.chatstate"; public static final String NET_SEND_ROSTER_NAME = "net.roster_name"; public static final String NET_STATUS_LIST = "net.status_list"; public static final String NET_AUTO_SUBSCRIPTION = "net.auto_subscription"; public static final String NET_REQUEST_AVATARS = "net.request_avatars"; public static final String NET_MAX_IMG_SIZE = "net.max_img_size"; public static final String MAIN_CONNECT_STARTUP = "main.connect_startup"; public static final String NET_RETRY_CONNECT = "main.retry_connect"; public static final String MAIN_TRAY = "main.tray"; public static final String MAIN_TRAY_CLOSE = "main.tray_close"; public static final String MAIN_ENTER_SENDS = "main.enter_sends"; // default server address //public static final String DEFAULT_SERV_NET = "kontalk.net"; public static final String DEFAULT_SERV_HOST = "beta.kontalk.net"; public static final int DEFAULT_SERV_PORT = 5999; private final String mDefaultXMPPStatus =
Tr.tr("Hey, I'm using Kontalk on my PC!");
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/CalabashHttpClient.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // }
import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static java.lang.Integer.parseInt; import static java.lang.String.format;
package com.thoughtworks.calabash.android; public class CalabashHttpClient { private static final String TEST_SERVER_DUMP_URL = "http://localhost:%s/dump"; private URL url; public CalabashHttpClient(CalabashWrapper calabashWrapper) { try { final int serverPort = parseInt(calabashWrapper.getTestServerPort()); url = new URL(format(TEST_SERVER_DUMP_URL, serverPort)); } catch (MalformedURLException e) { throw new RuntimeException(e); } catch (CalabashException e) { throw new RuntimeException(e); } } public String getViewDump() { String dump = "{}"; try { final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); final InputStream stream = connection.getInputStream(); dump = Utils.toString(stream); } catch (IOException e) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // Path: src/com/thoughtworks/calabash/android/CalabashHttpClient.java import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static java.lang.Integer.parseInt; import static java.lang.String.format; package com.thoughtworks.calabash.android; public class CalabashHttpClient { private static final String TEST_SERVER_DUMP_URL = "http://localhost:%s/dump"; private URL url; public CalabashHttpClient(CalabashWrapper calabashWrapper) { try { final int serverPort = parseInt(calabashWrapper.getTestServerPort()); url = new URL(format(TEST_SERVER_DUMP_URL, serverPort)); } catch (MalformedURLException e) { throw new RuntimeException(e); } catch (CalabashException e) { throw new RuntimeException(e); } } public String getViewDump() { String dump = "{}"; try { final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); final InputStream stream = connection.getInputStream(); dump = Utils.toString(stream); } catch (IOException e) {
CalabashLogger.error("Could not fetch view dump", e);
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/unit/DeviceListTest.java
// Path: src/com/thoughtworks/calabash/android/DeviceList.java // public class DeviceList { // List<Device> devices = new ArrayList<Device>(); // public static final String[] STATES = new String[]{"no device", "device", "offline"}; // public static final String HEADER = "List of devices attached "; // // public DeviceList(String outputFromAdbDeviceList) { // parseForDevices(outputFromAdbDeviceList); // } // // private void parseForDevices(String outputFromAdbDeviceList) { // int startIndex = outputFromAdbDeviceList.indexOf(HEADER) + HEADER.length(); // String devices = outputFromAdbDeviceList.substring(startIndex); // // String[] devicesNameSerialList = devices.split("\t"); // // String nextSerial = devicesNameSerialList[0]; // for (int i = 1; i < devicesNameSerialList.length; i++) { // String serial = nextSerial; // String state = getState(devicesNameSerialList[i]); // Device device = new Device(serial, state); // this.add(device); // nextSerial = getNextSerial(devicesNameSerialList[i], state); // } // } // // private String getNextSerial(String split, String state) { // return split.substring(state.length(), split.length()); // // } // // private String getState(String split) { // for (String state : STATES) { // if (split.contains(state)) // return state; // } // return null; // } // // private void add(Device device) { // devices.add(device); // } // // public int size() { // return devices.size(); // } // // public Device get(int index) { // return devices.get(index); // } // // public boolean contains(Device device) { // return devices.contains(device); // } // }
import com.thoughtworks.calabash.android.DeviceList; import org.junit.Test; import static org.junit.Assert.assertEquals;
package com.thoughtworks.calabash.android.unit; public class DeviceListTest { @Test public void shouldGetDeviceListFromAbdOutput() { String deviceListOutput = "List of devices attached " + "emulator-5554\tdevice123456789\tofflineemulator-5556\tno device";
// Path: src/com/thoughtworks/calabash/android/DeviceList.java // public class DeviceList { // List<Device> devices = new ArrayList<Device>(); // public static final String[] STATES = new String[]{"no device", "device", "offline"}; // public static final String HEADER = "List of devices attached "; // // public DeviceList(String outputFromAdbDeviceList) { // parseForDevices(outputFromAdbDeviceList); // } // // private void parseForDevices(String outputFromAdbDeviceList) { // int startIndex = outputFromAdbDeviceList.indexOf(HEADER) + HEADER.length(); // String devices = outputFromAdbDeviceList.substring(startIndex); // // String[] devicesNameSerialList = devices.split("\t"); // // String nextSerial = devicesNameSerialList[0]; // for (int i = 1; i < devicesNameSerialList.length; i++) { // String serial = nextSerial; // String state = getState(devicesNameSerialList[i]); // Device device = new Device(serial, state); // this.add(device); // nextSerial = getNextSerial(devicesNameSerialList[i], state); // } // } // // private String getNextSerial(String split, String state) { // return split.substring(state.length(), split.length()); // // } // // private String getState(String split) { // for (String state : STATES) { // if (split.contains(state)) // return state; // } // return null; // } // // private void add(Device device) { // devices.add(device); // } // // public int size() { // return devices.size(); // } // // public Device get(int index) { // return devices.get(index); // } // // public boolean contains(Device device) { // return devices.contains(device); // } // } // Path: tests/com/thoughtworks/calabash/android/unit/DeviceListTest.java import com.thoughtworks.calabash.android.DeviceList; import org.junit.Test; import static org.junit.Assert.assertEquals; package com.thoughtworks.calabash.android.unit; public class DeviceListTest { @Test public void shouldGetDeviceListFromAbdOutput() { String deviceListOutput = "List of devices attached " + "emulator-5554\tdevice123456789\tofflineemulator-5556\tno device";
DeviceList deviceList = new DeviceList(deviceListOutput);
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/unit/TreeBuilderTest.java
// Path: tests/com/thoughtworks/calabash/android/TestUtils.java // public static String readFileFromResources(final String fileName) throws IOException { // final File file = new File("tests/resources/" + fileName); // return FileUtils.readFileToString(file, "UTF-8"); // }
import com.thoughtworks.calabash.android.*; import org.codehaus.jackson.JsonNode; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import java.util.List; import static com.thoughtworks.calabash.android.TestUtils.readFileFromResources; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks;
package com.thoughtworks.calabash.android.unit; public class TreeBuilderTest { @Mock private CalabashWrapper wrapper; @Mock private CalabashHttpClient httpClient; @Mock private TreeNodeBuilder treeNodeBuilder; @Before public void setUp() { initMocks(this); } @Test public void shouldGetDumpInfo() throws Exception {
// Path: tests/com/thoughtworks/calabash/android/TestUtils.java // public static String readFileFromResources(final String fileName) throws IOException { // final File file = new File("tests/resources/" + fileName); // return FileUtils.readFileToString(file, "UTF-8"); // } // Path: tests/com/thoughtworks/calabash/android/unit/TreeBuilderTest.java import com.thoughtworks.calabash.android.*; import org.codehaus.jackson.JsonNode; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import java.util.List; import static com.thoughtworks.calabash.android.TestUtils.readFileFromResources; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; package com.thoughtworks.calabash.android.unit; public class TreeBuilderTest { @Mock private CalabashWrapper wrapper; @Mock private CalabashHttpClient httpClient; @Mock private TreeNodeBuilder treeNodeBuilder; @Before public void setUp() { initMocks(this); } @Test public void shouldGetDumpInfo() throws Exception {
String dump = readFileFromResources("simple-dump.json");
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/TreeBuilder.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // }
import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jruby.RubyArray; import org.jruby.RubyHash; import java.io.IOException; import java.net.MalformedURLException; import java.util.*; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info;
} return true; } private TreeNode createBranch(List<UIElement> elements) { TreeNode startNode = new TreeNode(); TreeNode current = startNode; for (int i = 0; i < elements.size(); i++) { current.setData(elements.get(i)); if (i + 1 < elements.size()) { TreeNode childNode = new TreeNode(elements.get(i + 1)); current.addChild(childNode); current = childNode; } } return startNode; } private int matchWith(List<TreeNode> elements, UIElement elementToMatch) { for (int i = 0; i < elements.size(); i++) { if (elements.get(i).getData().equals(elementToMatch)) return i; } return -1; } public List<TreeNode> createTree() { List<TreeNode> treeNodes = null; try {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // } // Path: src/com/thoughtworks/calabash/android/TreeBuilder.java import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jruby.RubyArray; import org.jruby.RubyHash; import java.io.IOException; import java.net.MalformedURLException; import java.util.*; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info; } return true; } private TreeNode createBranch(List<UIElement> elements) { TreeNode startNode = new TreeNode(); TreeNode current = startNode; for (int i = 0; i < elements.size(); i++) { current.setData(elements.get(i)); if (i + 1 < elements.size()) { TreeNode childNode = new TreeNode(elements.get(i + 1)); current.addChild(childNode); current = childNode; } } return startNode; } private int matchWith(List<TreeNode> elements, UIElement elementToMatch) { for (int i = 0; i < elements.size(); i++) { if (elements.get(i).getData().equals(elementToMatch)) return i; } return -1; } public List<TreeNode> createTree() { List<TreeNode> treeNodes = null; try {
info("Fetching view hierarchy");
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/TreeBuilder.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // }
import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jruby.RubyArray; import org.jruby.RubyHash; import java.io.IOException; import java.net.MalformedURLException; import java.util.*; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info;
} } return startNode; } private int matchWith(List<TreeNode> elements, UIElement elementToMatch) { for (int i = 0; i < elements.size(); i++) { if (elements.get(i).getData().equals(elementToMatch)) return i; } return -1; } public List<TreeNode> createTree() { List<TreeNode> treeNodes = null; try { info("Fetching view hierarchy"); treeNodes = new ArrayList<TreeNode>(); final JsonNode jsonNode = mapper.readTree(calabashHttpClient.getViewDump()); final JsonNode childNodes = jsonNode.get("children"); if (childNodes == null) { return treeNodes; } JsonNode rootJsonNode = childNodes.get(0); final TreeNode rootTreeNode = treeNodeBuilder.buildFrom(rootJsonNode, "* index:0"); addChildren(rootTreeNode, rootJsonNode); treeNodes.add(rootTreeNode); } catch (MalformedURLException e) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // } // Path: src/com/thoughtworks/calabash/android/TreeBuilder.java import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jruby.RubyArray; import org.jruby.RubyHash; import java.io.IOException; import java.net.MalformedURLException; import java.util.*; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info; } } return startNode; } private int matchWith(List<TreeNode> elements, UIElement elementToMatch) { for (int i = 0; i < elements.size(); i++) { if (elements.get(i).getData().equals(elementToMatch)) return i; } return -1; } public List<TreeNode> createTree() { List<TreeNode> treeNodes = null; try { info("Fetching view hierarchy"); treeNodes = new ArrayList<TreeNode>(); final JsonNode jsonNode = mapper.readTree(calabashHttpClient.getViewDump()); final JsonNode childNodes = jsonNode.get("children"); if (childNodes == null) { return treeNodes; } JsonNode rootJsonNode = childNodes.get(0); final TreeNode rootTreeNode = treeNodeBuilder.buildFrom(rootJsonNode, "* index:0"); addChildren(rootTreeNode, rootJsonNode); treeNodes.add(rootTreeNode); } catch (MalformedURLException e) {
error("malformed url", e);
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/unit/ConditionalWaiterTest.java
// Path: src/com/thoughtworks/calabash/android/CalabashException.java // public class CalabashException extends Exception { // // public CalabashException(String message, Exception e) { // super(message, e); // } // // public CalabashException(String message) { // super(message); // } // } // // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java // public class ConditionalWaiter { // private final ICondition condition; // // public ConditionalWaiter(ICondition condition) { // this.condition = condition; // } // // public void run(int times, int sleepTimeInSec) throws CalabashException { // int timesTested = 0; // int sleepTimeInMilli = sleepTimeInSec * 1000; // while (!condition.test() && timesTested <= times) { // try { // info("Retrying wait condition: " + condition.getDescription()); // Thread.sleep(sleepTimeInMilli); // timesTested++; // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // if (timesTested > times) // throw new CalabashException("Wait condition failed : " + condition.getDescription()); // // } // // public void run(int timeoutInMillis) throws CalabashException { // long startTime = System.currentTimeMillis(); // do { // if (condition.test()) { // return; // } // } while ((System.currentTimeMillis() - startTime) < timeoutInMillis); // throw new CalabashException(format("Wait condition (%s) timed out after %s ms", condition.getDescription(), timeoutInMillis)); // } // } // // Path: src/com/thoughtworks/calabash/android/ICondition.java // public abstract class ICondition { // private final String description; // // public ICondition(String description){ // this.description = description; // } // // protected ICondition() { // description = null; // } // // public abstract boolean test() throws CalabashException; // // public String getDescription() { // return description; // } // // }
import com.thoughtworks.calabash.android.CalabashException; import com.thoughtworks.calabash.android.ConditionalWaiter; import com.thoughtworks.calabash.android.ICondition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.thoughtworks.calabash.android.unit; public class ConditionalWaiterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test
// Path: src/com/thoughtworks/calabash/android/CalabashException.java // public class CalabashException extends Exception { // // public CalabashException(String message, Exception e) { // super(message, e); // } // // public CalabashException(String message) { // super(message); // } // } // // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java // public class ConditionalWaiter { // private final ICondition condition; // // public ConditionalWaiter(ICondition condition) { // this.condition = condition; // } // // public void run(int times, int sleepTimeInSec) throws CalabashException { // int timesTested = 0; // int sleepTimeInMilli = sleepTimeInSec * 1000; // while (!condition.test() && timesTested <= times) { // try { // info("Retrying wait condition: " + condition.getDescription()); // Thread.sleep(sleepTimeInMilli); // timesTested++; // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // if (timesTested > times) // throw new CalabashException("Wait condition failed : " + condition.getDescription()); // // } // // public void run(int timeoutInMillis) throws CalabashException { // long startTime = System.currentTimeMillis(); // do { // if (condition.test()) { // return; // } // } while ((System.currentTimeMillis() - startTime) < timeoutInMillis); // throw new CalabashException(format("Wait condition (%s) timed out after %s ms", condition.getDescription(), timeoutInMillis)); // } // } // // Path: src/com/thoughtworks/calabash/android/ICondition.java // public abstract class ICondition { // private final String description; // // public ICondition(String description){ // this.description = description; // } // // protected ICondition() { // description = null; // } // // public abstract boolean test() throws CalabashException; // // public String getDescription() { // return description; // } // // } // Path: tests/com/thoughtworks/calabash/android/unit/ConditionalWaiterTest.java import com.thoughtworks.calabash.android.CalabashException; import com.thoughtworks.calabash.android.ConditionalWaiter; import com.thoughtworks.calabash.android.ICondition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.thoughtworks.calabash.android.unit; public class ConditionalWaiterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test
public void shouldThrowExceptionWhenWaitFails() throws CalabashException {
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/unit/ConditionalWaiterTest.java
// Path: src/com/thoughtworks/calabash/android/CalabashException.java // public class CalabashException extends Exception { // // public CalabashException(String message, Exception e) { // super(message, e); // } // // public CalabashException(String message) { // super(message); // } // } // // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java // public class ConditionalWaiter { // private final ICondition condition; // // public ConditionalWaiter(ICondition condition) { // this.condition = condition; // } // // public void run(int times, int sleepTimeInSec) throws CalabashException { // int timesTested = 0; // int sleepTimeInMilli = sleepTimeInSec * 1000; // while (!condition.test() && timesTested <= times) { // try { // info("Retrying wait condition: " + condition.getDescription()); // Thread.sleep(sleepTimeInMilli); // timesTested++; // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // if (timesTested > times) // throw new CalabashException("Wait condition failed : " + condition.getDescription()); // // } // // public void run(int timeoutInMillis) throws CalabashException { // long startTime = System.currentTimeMillis(); // do { // if (condition.test()) { // return; // } // } while ((System.currentTimeMillis() - startTime) < timeoutInMillis); // throw new CalabashException(format("Wait condition (%s) timed out after %s ms", condition.getDescription(), timeoutInMillis)); // } // } // // Path: src/com/thoughtworks/calabash/android/ICondition.java // public abstract class ICondition { // private final String description; // // public ICondition(String description){ // this.description = description; // } // // protected ICondition() { // description = null; // } // // public abstract boolean test() throws CalabashException; // // public String getDescription() { // return description; // } // // }
import com.thoughtworks.calabash.android.CalabashException; import com.thoughtworks.calabash.android.ConditionalWaiter; import com.thoughtworks.calabash.android.ICondition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.thoughtworks.calabash.android.unit; public class ConditionalWaiterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void shouldThrowExceptionWhenWaitFails() throws CalabashException { expectedException.expect(CalabashException.class); expectedException.expectMessage("Wait condition (wait description) timed out after 1000 ms");
// Path: src/com/thoughtworks/calabash/android/CalabashException.java // public class CalabashException extends Exception { // // public CalabashException(String message, Exception e) { // super(message, e); // } // // public CalabashException(String message) { // super(message); // } // } // // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java // public class ConditionalWaiter { // private final ICondition condition; // // public ConditionalWaiter(ICondition condition) { // this.condition = condition; // } // // public void run(int times, int sleepTimeInSec) throws CalabashException { // int timesTested = 0; // int sleepTimeInMilli = sleepTimeInSec * 1000; // while (!condition.test() && timesTested <= times) { // try { // info("Retrying wait condition: " + condition.getDescription()); // Thread.sleep(sleepTimeInMilli); // timesTested++; // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // if (timesTested > times) // throw new CalabashException("Wait condition failed : " + condition.getDescription()); // // } // // public void run(int timeoutInMillis) throws CalabashException { // long startTime = System.currentTimeMillis(); // do { // if (condition.test()) { // return; // } // } while ((System.currentTimeMillis() - startTime) < timeoutInMillis); // throw new CalabashException(format("Wait condition (%s) timed out after %s ms", condition.getDescription(), timeoutInMillis)); // } // } // // Path: src/com/thoughtworks/calabash/android/ICondition.java // public abstract class ICondition { // private final String description; // // public ICondition(String description){ // this.description = description; // } // // protected ICondition() { // description = null; // } // // public abstract boolean test() throws CalabashException; // // public String getDescription() { // return description; // } // // } // Path: tests/com/thoughtworks/calabash/android/unit/ConditionalWaiterTest.java import com.thoughtworks.calabash.android.CalabashException; import com.thoughtworks.calabash.android.ConditionalWaiter; import com.thoughtworks.calabash.android.ICondition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.thoughtworks.calabash.android.unit; public class ConditionalWaiterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void shouldThrowExceptionWhenWaitFails() throws CalabashException { expectedException.expect(CalabashException.class); expectedException.expectMessage("Wait condition (wait description) timed out after 1000 ms");
ConditionalWaiter conditionalWaiter = new ConditionalWaiter(new ICondition("wait description") {
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/unit/ConditionalWaiterTest.java
// Path: src/com/thoughtworks/calabash/android/CalabashException.java // public class CalabashException extends Exception { // // public CalabashException(String message, Exception e) { // super(message, e); // } // // public CalabashException(String message) { // super(message); // } // } // // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java // public class ConditionalWaiter { // private final ICondition condition; // // public ConditionalWaiter(ICondition condition) { // this.condition = condition; // } // // public void run(int times, int sleepTimeInSec) throws CalabashException { // int timesTested = 0; // int sleepTimeInMilli = sleepTimeInSec * 1000; // while (!condition.test() && timesTested <= times) { // try { // info("Retrying wait condition: " + condition.getDescription()); // Thread.sleep(sleepTimeInMilli); // timesTested++; // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // if (timesTested > times) // throw new CalabashException("Wait condition failed : " + condition.getDescription()); // // } // // public void run(int timeoutInMillis) throws CalabashException { // long startTime = System.currentTimeMillis(); // do { // if (condition.test()) { // return; // } // } while ((System.currentTimeMillis() - startTime) < timeoutInMillis); // throw new CalabashException(format("Wait condition (%s) timed out after %s ms", condition.getDescription(), timeoutInMillis)); // } // } // // Path: src/com/thoughtworks/calabash/android/ICondition.java // public abstract class ICondition { // private final String description; // // public ICondition(String description){ // this.description = description; // } // // protected ICondition() { // description = null; // } // // public abstract boolean test() throws CalabashException; // // public String getDescription() { // return description; // } // // }
import com.thoughtworks.calabash.android.CalabashException; import com.thoughtworks.calabash.android.ConditionalWaiter; import com.thoughtworks.calabash.android.ICondition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException;
package com.thoughtworks.calabash.android.unit; public class ConditionalWaiterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void shouldThrowExceptionWhenWaitFails() throws CalabashException { expectedException.expect(CalabashException.class); expectedException.expectMessage("Wait condition (wait description) timed out after 1000 ms");
// Path: src/com/thoughtworks/calabash/android/CalabashException.java // public class CalabashException extends Exception { // // public CalabashException(String message, Exception e) { // super(message, e); // } // // public CalabashException(String message) { // super(message); // } // } // // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java // public class ConditionalWaiter { // private final ICondition condition; // // public ConditionalWaiter(ICondition condition) { // this.condition = condition; // } // // public void run(int times, int sleepTimeInSec) throws CalabashException { // int timesTested = 0; // int sleepTimeInMilli = sleepTimeInSec * 1000; // while (!condition.test() && timesTested <= times) { // try { // info("Retrying wait condition: " + condition.getDescription()); // Thread.sleep(sleepTimeInMilli); // timesTested++; // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // if (timesTested > times) // throw new CalabashException("Wait condition failed : " + condition.getDescription()); // // } // // public void run(int timeoutInMillis) throws CalabashException { // long startTime = System.currentTimeMillis(); // do { // if (condition.test()) { // return; // } // } while ((System.currentTimeMillis() - startTime) < timeoutInMillis); // throw new CalabashException(format("Wait condition (%s) timed out after %s ms", condition.getDescription(), timeoutInMillis)); // } // } // // Path: src/com/thoughtworks/calabash/android/ICondition.java // public abstract class ICondition { // private final String description; // // public ICondition(String description){ // this.description = description; // } // // protected ICondition() { // description = null; // } // // public abstract boolean test() throws CalabashException; // // public String getDescription() { // return description; // } // // } // Path: tests/com/thoughtworks/calabash/android/unit/ConditionalWaiterTest.java import com.thoughtworks.calabash.android.CalabashException; import com.thoughtworks.calabash.android.ConditionalWaiter; import com.thoughtworks.calabash.android.ICondition; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; package com.thoughtworks.calabash.android.unit; public class ConditionalWaiterTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void shouldThrowExceptionWhenWaitFails() throws CalabashException { expectedException.expect(CalabashException.class); expectedException.expectMessage("Wait condition (wait description) timed out after 1000 ms");
ConditionalWaiter conditionalWaiter = new ConditionalWaiter(new ICondition("wait description") {
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/IT/AndroidRunnerIT.java
// Path: tests/com/thoughtworks/calabash/android/IT/AllActionsIT.java // public static final String EMULATOR = "emulator-5554";
import com.thoughtworks.calabash.android.*; import org.apache.commons.io.FileUtils; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.*; import org.junit.rules.ExpectedException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static com.thoughtworks.calabash.android.IT.AllActionsIT.EMULATOR; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
} @Test public void shouldThrowExceptionIfSerialIsGivenWhenNotStarted() throws CalabashException { String serial = "emulator-x"; expectedException.expect(CalabashException.class); expectedException.expectMessage(String.format("%s not found in the device list, installation failed", serial)); configuration.setSerial(serial); AndroidRunner androidRunner = new AndroidRunner(tempAndroidApkPath.getAbsolutePath(), configuration); androidRunner.setup(); androidRunner.start(); } @Test public void shouldInstallAppOnDeviceWithName() throws CalabashException { configuration.setDeviceName("device"); configuration.setShouldReinstallApp(true); AndroidRunner androidRunner = new AndroidRunner(tempAndroidApkPath.getAbsolutePath(), configuration); androidRunner.setup(); AndroidApplication application = androidRunner.start(); assertTrue(TestUtils.isAppInstalled(packageName, application.getInstalledOnSerial())); assertTrue(TestUtils.isMainActivity(application, "MyActivity")); } @Test public void shouldInstallApplicationIfSerialIsProvided() throws CalabashException { //note: emulator should be launched with serial 'EMULATOR
// Path: tests/com/thoughtworks/calabash/android/IT/AllActionsIT.java // public static final String EMULATOR = "emulator-5554"; // Path: tests/com/thoughtworks/calabash/android/IT/AndroidRunnerIT.java import com.thoughtworks.calabash.android.*; import org.apache.commons.io.FileUtils; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.*; import org.junit.rules.ExpectedException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static com.thoughtworks.calabash.android.IT.AllActionsIT.EMULATOR; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; } @Test public void shouldThrowExceptionIfSerialIsGivenWhenNotStarted() throws CalabashException { String serial = "emulator-x"; expectedException.expect(CalabashException.class); expectedException.expectMessage(String.format("%s not found in the device list, installation failed", serial)); configuration.setSerial(serial); AndroidRunner androidRunner = new AndroidRunner(tempAndroidApkPath.getAbsolutePath(), configuration); androidRunner.setup(); androidRunner.start(); } @Test public void shouldInstallAppOnDeviceWithName() throws CalabashException { configuration.setDeviceName("device"); configuration.setShouldReinstallApp(true); AndroidRunner androidRunner = new AndroidRunner(tempAndroidApkPath.getAbsolutePath(), configuration); androidRunner.setup(); AndroidApplication application = androidRunner.start(); assertTrue(TestUtils.isAppInstalled(packageName, application.getInstalledOnSerial())); assertTrue(TestUtils.isMainActivity(application, "MyActivity")); } @Test public void shouldInstallApplicationIfSerialIsProvided() throws CalabashException { //note: emulator should be launched with serial 'EMULATOR
String serial = EMULATOR;
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/EnvironmentInitializer.java
// Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_ANDROID_HOME = "ANDROID_HOME"; // // Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_JAVA_HOME = "JAVA_HOME";
import java.io.File; import static com.thoughtworks.calabash.android.Environment.ENV_ANDROID_HOME; import static com.thoughtworks.calabash.android.Environment.ENV_JAVA_HOME;
package com.thoughtworks.calabash.android; public class EnvironmentInitializer { public static final String KEYTOOL = Environment.getPlatformExecutable("keytool"); public static final String JARSIGNER = Environment.getPlatformExecutable("jarsigner"); public static final String PROPERTY_JAVA_HOME = "java.home"; public static final String PATH_SEPARATOR = Environment.getPathSeparator(); public static Environment initialize(AndroidConfiguration configuration) throws CalabashException { String javaHome = null; String androidHome = findAndroidHome(configuration); String keytool = findExecutableFromPath(KEYTOOL); String jarsigner = findExecutableFromPath(JARSIGNER); if (keytool == null || jarsigner == null) {
// Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_ANDROID_HOME = "ANDROID_HOME"; // // Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_JAVA_HOME = "JAVA_HOME"; // Path: src/com/thoughtworks/calabash/android/EnvironmentInitializer.java import java.io.File; import static com.thoughtworks.calabash.android.Environment.ENV_ANDROID_HOME; import static com.thoughtworks.calabash.android.Environment.ENV_JAVA_HOME; package com.thoughtworks.calabash.android; public class EnvironmentInitializer { public static final String KEYTOOL = Environment.getPlatformExecutable("keytool"); public static final String JARSIGNER = Environment.getPlatformExecutable("jarsigner"); public static final String PROPERTY_JAVA_HOME = "java.home"; public static final String PATH_SEPARATOR = Environment.getPathSeparator(); public static Environment initialize(AndroidConfiguration configuration) throws CalabashException { String javaHome = null; String androidHome = findAndroidHome(configuration); String keytool = findExecutableFromPath(KEYTOOL); String jarsigner = findExecutableFromPath(JARSIGNER); if (keytool == null || jarsigner == null) {
CalabashLogger.info("Finding executables relative to " + ENV_JAVA_HOME);
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/EnvironmentInitializer.java
// Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_ANDROID_HOME = "ANDROID_HOME"; // // Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_JAVA_HOME = "JAVA_HOME";
import java.io.File; import static com.thoughtworks.calabash.android.Environment.ENV_ANDROID_HOME; import static com.thoughtworks.calabash.android.Environment.ENV_JAVA_HOME;
private static String findJavaHome(AndroidConfiguration configuration) throws CalabashException { String javaHomeFromConfig = configuration.getJavaHome(); if (isNotEmpty(javaHomeFromConfig)) { CalabashLogger.info(String.format("%s = %s from configuration", ENV_JAVA_HOME, javaHomeFromConfig)); return javaHomeFromConfig; } String javaHomeFromSystemProp = System.getProperty(PROPERTY_JAVA_HOME); if (isNotEmpty(javaHomeFromSystemProp)) { CalabashLogger.info(String.format("%s = %s from system property", PROPERTY_JAVA_HOME, javaHomeFromSystemProp)); return javaHomeFromSystemProp; } String javaHomeFromEnv = System.getenv(ENV_JAVA_HOME); if (isNotEmpty(javaHomeFromEnv)) { CalabashLogger.info(String.format("%s = %s from environment variable", ENV_JAVA_HOME, javaHomeFromEnv)); return javaHomeFromEnv; } return null; } private static String findAndroidHome(AndroidConfiguration configuration) throws CalabashException { String androidHome = null; String androidHomeFromConfig = configuration.getAndroidHome(); if (isNotEmpty(androidHomeFromConfig)) { androidHome = androidHomeFromConfig;
// Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_ANDROID_HOME = "ANDROID_HOME"; // // Path: src/com/thoughtworks/calabash/android/Environment.java // public static final String ENV_JAVA_HOME = "JAVA_HOME"; // Path: src/com/thoughtworks/calabash/android/EnvironmentInitializer.java import java.io.File; import static com.thoughtworks.calabash.android.Environment.ENV_ANDROID_HOME; import static com.thoughtworks.calabash.android.Environment.ENV_JAVA_HOME; private static String findJavaHome(AndroidConfiguration configuration) throws CalabashException { String javaHomeFromConfig = configuration.getJavaHome(); if (isNotEmpty(javaHomeFromConfig)) { CalabashLogger.info(String.format("%s = %s from configuration", ENV_JAVA_HOME, javaHomeFromConfig)); return javaHomeFromConfig; } String javaHomeFromSystemProp = System.getProperty(PROPERTY_JAVA_HOME); if (isNotEmpty(javaHomeFromSystemProp)) { CalabashLogger.info(String.format("%s = %s from system property", PROPERTY_JAVA_HOME, javaHomeFromSystemProp)); return javaHomeFromSystemProp; } String javaHomeFromEnv = System.getenv(ENV_JAVA_HOME); if (isNotEmpty(javaHomeFromEnv)) { CalabashLogger.info(String.format("%s = %s from environment variable", ENV_JAVA_HOME, javaHomeFromEnv)); return javaHomeFromEnv; } return null; } private static String findAndroidHome(AndroidConfiguration configuration) throws CalabashException { String androidHome = null; String androidHomeFromConfig = configuration.getAndroidHome(); if (isNotEmpty(androidHomeFromConfig)) { androidHome = androidHomeFromConfig;
CalabashLogger.info(String.format("%s = %s from configuration", ENV_ANDROID_HOME, androidHome));
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/UIElement.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // }
import org.joda.time.DateTime; import org.jruby.RubyArray; import org.jruby.RubyHash; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static java.lang.Double.parseDouble;
UIElement uiElement = (UIElement) o; if (getId() != null ? !getId().equals(uiElement.getId()) : uiElement.getId() != null) return false; if (getElementClass() != null ? !getElementClass().equals(uiElement.getElementClass()) : uiElement.getElementClass() != null) return false; if (getRect() != null ? !getRect().equals(uiElement.getRect()) : uiElement.getRect() != null) return false; if (getText() != null ? !getText().equals(uiElement.getText()) : uiElement.getText() != null) return false; return true; } @Override public int hashCode() { List<Object> objects = new ArrayList<Object>(); objects.add(getId()); objects.add(getElementClass()); objects.add(getRect()); objects.add(getText()); int result = 0; for (Object object : objects) { result = 31 * result + (object != null ? object.hashCode() : 0); } return result; } public String toString() { try { return String.format("id: %s, class: %s, text: %s, description: %s, content description: %s, enabled: %s, rect: %s", getId(), getElementClass(), getText(), getDescription(), getContentDescription(), isEnabled(), getRect()); } catch (CalabashException e) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // Path: src/com/thoughtworks/calabash/android/UIElement.java import org.joda.time.DateTime; import org.jruby.RubyArray; import org.jruby.RubyHash; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static java.lang.Double.parseDouble; UIElement uiElement = (UIElement) o; if (getId() != null ? !getId().equals(uiElement.getId()) : uiElement.getId() != null) return false; if (getElementClass() != null ? !getElementClass().equals(uiElement.getElementClass()) : uiElement.getElementClass() != null) return false; if (getRect() != null ? !getRect().equals(uiElement.getRect()) : uiElement.getRect() != null) return false; if (getText() != null ? !getText().equals(uiElement.getText()) : uiElement.getText() != null) return false; return true; } @Override public int hashCode() { List<Object> objects = new ArrayList<Object>(); objects.add(getId()); objects.add(getElementClass()); objects.add(getRect()); objects.add(getText()); int result = 0; for (Object object : objects) { result = 31 * result + (object != null ? object.hashCode() : 0); } return result; } public String toString() { try { return String.format("id: %s, class: %s, text: %s, description: %s, content description: %s, enabled: %s, rect: %s", getId(), getElementClass(), getText(), getDescription(), getContentDescription(), isEnabled(), getRect()); } catch (CalabashException e) {
error("Unable to get string value of element", e);
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/AndroidRunner.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // }
import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.exception.ZipException; import java.io.*; import java.net.URL; import java.util.Enumeration; import java.util.jar.Attributes; import java.util.jar.Manifest; import static com.thoughtworks.calabash.android.CalabashLogger.info;
* * @return the calabashWrapper */ protected CalabashWrapper getCalabashWrapper() { return calabashWrapper; } /** * generate the instrumentation test server apk, resign the application with debug keystore * * @throws CalabashException */ public void setup() throws CalabashException { try { calabashWrapper.setup(); } catch (Exception e) { String errorMessage = "calabash android setup failed: " + e.getMessage(); CalabashLogger.error(errorMessage, e); throw new CalabashException(errorMessage, e); } } /** * install the signed apk and test server apk * * @return handle to the android application * @throws CalabashException */ public AndroidApplication start() throws CalabashException { if (!alreadySetup()) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // } // Path: src/com/thoughtworks/calabash/android/AndroidRunner.java import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.exception.ZipException; import java.io.*; import java.net.URL; import java.util.Enumeration; import java.util.jar.Attributes; import java.util.jar.Manifest; import static com.thoughtworks.calabash.android.CalabashLogger.info; * * @return the calabashWrapper */ protected CalabashWrapper getCalabashWrapper() { return calabashWrapper; } /** * generate the instrumentation test server apk, resign the application with debug keystore * * @throws CalabashException */ public void setup() throws CalabashException { try { calabashWrapper.setup(); } catch (Exception e) { String errorMessage = "calabash android setup failed: " + e.getMessage(); CalabashLogger.error(errorMessage, e); throw new CalabashException(errorMessage, e); } } /** * install the signed apk and test server apk * * @return handle to the android application * @throws CalabashException */ public AndroidApplication start() throws CalabashException { if (!alreadySetup()) {
CalabashLogger.info("Application not setup. Performing setup...");
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/WebElements.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void warn(String message) { // if (shouldLog && isNotEmpty(message)) // log.warn(String.format(message)); // }
import org.jruby.RubyArray; import org.jruby.RubyHash; import java.util.ArrayList; import static com.thoughtworks.calabash.android.CalabashLogger.warn;
package com.thoughtworks.calabash.android; public class WebElements extends ArrayList<UIElement> { public WebElements(RubyArray elementsArray, String query, CalabashWrapper calabashWrapper) { query = query.trim(); for (Object element : elementsArray) { RubyHash object = (RubyHash) element; this.add(new UIElement(object, query, calabashWrapper)); } } /** * touch the webview element, if there are multiple elements, only the first one will be touched * * @throws CalabashException */ public void touch() throws CalabashException { getFirstElement().touch(); } private UIElement getFirstElement() throws CalabashException { ensureCollectionIsNotEmpty(); if (this.size() > 1) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void warn(String message) { // if (shouldLog && isNotEmpty(message)) // log.warn(String.format(message)); // } // Path: src/com/thoughtworks/calabash/android/WebElements.java import org.jruby.RubyArray; import org.jruby.RubyHash; import java.util.ArrayList; import static com.thoughtworks.calabash.android.CalabashLogger.warn; package com.thoughtworks.calabash.android; public class WebElements extends ArrayList<UIElement> { public WebElements(RubyArray elementsArray, String query, CalabashWrapper calabashWrapper) { query = query.trim(); for (Object element : elementsArray) { RubyHash object = (RubyHash) element; this.add(new UIElement(object, query, calabashWrapper)); } } /** * touch the webview element, if there are multiple elements, only the first one will be touched * * @throws CalabashException */ public void touch() throws CalabashException { getFirstElement().touch(); } private UIElement getFirstElement() throws CalabashException { ensureCollectionIsNotEmpty(); if (this.size() > 1) {
warn("There are multiple webview elements, so considering only the first element");
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/ConditionalWaiter.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // }
import static com.thoughtworks.calabash.android.CalabashLogger.info; import static java.lang.String.format;
package com.thoughtworks.calabash.android; public class ConditionalWaiter { private final ICondition condition; public ConditionalWaiter(ICondition condition) { this.condition = condition; } public void run(int times, int sleepTimeInSec) throws CalabashException { int timesTested = 0; int sleepTimeInMilli = sleepTimeInSec * 1000; while (!condition.test() && timesTested <= times) { try {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // } // Path: src/com/thoughtworks/calabash/android/ConditionalWaiter.java import static com.thoughtworks.calabash.android.CalabashLogger.info; import static java.lang.String.format; package com.thoughtworks.calabash.android; public class ConditionalWaiter { private final ICondition condition; public ConditionalWaiter(ICondition condition) { this.condition = condition; } public void run(int times, int sleepTimeInSec) throws CalabashException { int timesTested = 0; int sleepTimeInMilli = sleepTimeInSec * 1000; while (!condition.test() && timesTested <= times) { try {
info("Retrying wait condition: " + condition.getDescription());
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/CalabashWrapper.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // }
import org.joda.time.DateTime; import org.jruby.RubyArray; import org.jruby.RubyHash; import org.jruby.embed.LocalContextScope; import org.jruby.embed.LocalVariableBehavior; import org.jruby.embed.PathType; import org.jruby.embed.ScriptingContainer; import java.io.File; import java.io.FileFilter; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info; import static java.io.File.separator; import static java.lang.String.format;
File[] gems = gemsDir.listFiles(new FileFilter() { public boolean accept(File arg0) { return arg0.isDirectory(); } }); if (gems == null || gems.length == 0) throw new CalabashException("Couldn't find any gems inside " + gemsDir.getAbsolutePath()); for (File gem : gems) { File libPath = new File(gem, "lib"); loadPaths.add(libPath.getAbsolutePath()); } return loadPaths; } public void setup() throws CalabashException { try { addSystemCommandHack(); createDebugCertificateIfMissing(); String jrubyClasspath = getClasspathFor("jruby"); addContainerEnv("CLASSPATH", jrubyClasspath); container.runScriptlet(format("Dir.chdir '%s'", apk.getParent())); container.put(ARGV, new String[]{"resign", apk.getAbsolutePath()}); String calabashAndroid = new File(getCalabashGemDirectory(), "calabash-android").getAbsolutePath(); container.runScriptlet(PathType.ABSOLUTE, calabashAndroid);
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // } // Path: src/com/thoughtworks/calabash/android/CalabashWrapper.java import org.joda.time.DateTime; import org.jruby.RubyArray; import org.jruby.RubyHash; import org.jruby.embed.LocalContextScope; import org.jruby.embed.LocalVariableBehavior; import org.jruby.embed.PathType; import org.jruby.embed.ScriptingContainer; import java.io.File; import java.io.FileFilter; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info; import static java.io.File.separator; import static java.lang.String.format; File[] gems = gemsDir.listFiles(new FileFilter() { public boolean accept(File arg0) { return arg0.isDirectory(); } }); if (gems == null || gems.length == 0) throw new CalabashException("Couldn't find any gems inside " + gemsDir.getAbsolutePath()); for (File gem : gems) { File libPath = new File(gem, "lib"); loadPaths.add(libPath.getAbsolutePath()); } return loadPaths; } public void setup() throws CalabashException { try { addSystemCommandHack(); createDebugCertificateIfMissing(); String jrubyClasspath = getClasspathFor("jruby"); addContainerEnv("CLASSPATH", jrubyClasspath); container.runScriptlet(format("Dir.chdir '%s'", apk.getParent())); container.put(ARGV, new String[]{"resign", apk.getAbsolutePath()}); String calabashAndroid = new File(getCalabashGemDirectory(), "calabash-android").getAbsolutePath(); container.runScriptlet(PathType.ABSOLUTE, calabashAndroid);
info("Done signing the app");
vishnukarthikl/calabash-android-java
src/com/thoughtworks/calabash/android/CalabashWrapper.java
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // }
import org.joda.time.DateTime; import org.jruby.RubyArray; import org.jruby.RubyHash; import org.jruby.embed.LocalContextScope; import org.jruby.embed.LocalVariableBehavior; import org.jruby.embed.PathType; import org.jruby.embed.ScriptingContainer; import java.io.File; import java.io.FileFilter; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info; import static java.io.File.separator; import static java.lang.String.format;
if (gems == null || gems.length == 0) throw new CalabashException("Couldn't find any gems inside " + gemsDir.getAbsolutePath()); for (File gem : gems) { File libPath = new File(gem, "lib"); loadPaths.add(libPath.getAbsolutePath()); } return loadPaths; } public void setup() throws CalabashException { try { addSystemCommandHack(); createDebugCertificateIfMissing(); String jrubyClasspath = getClasspathFor("jruby"); addContainerEnv("CLASSPATH", jrubyClasspath); container.runScriptlet(format("Dir.chdir '%s'", apk.getParent())); container.put(ARGV, new String[]{"resign", apk.getAbsolutePath()}); String calabashAndroid = new File(getCalabashGemDirectory(), "calabash-android").getAbsolutePath(); container.runScriptlet(PathType.ABSOLUTE, calabashAndroid); info("Done signing the app"); container.put(ARGV, new String[]{"build", apk.getAbsolutePath()}); container.runScriptlet(PathType.ABSOLUTE, calabashAndroid); info("App build complete"); } catch (Exception e) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void error(Object message) { // if (shouldLog && isNotEmpty(message)) // log.error(message); // } // // Path: src/com/thoughtworks/calabash/android/CalabashLogger.java // public static void info(Object message) { // if (shouldLog && isNotEmpty(message)) { // log.info(message); // } // } // Path: src/com/thoughtworks/calabash/android/CalabashWrapper.java import org.joda.time.DateTime; import org.jruby.RubyArray; import org.jruby.RubyHash; import org.jruby.embed.LocalContextScope; import org.jruby.embed.LocalVariableBehavior; import org.jruby.embed.PathType; import org.jruby.embed.ScriptingContainer; import java.io.File; import java.io.FileFilter; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.thoughtworks.calabash.android.CalabashLogger.error; import static com.thoughtworks.calabash.android.CalabashLogger.info; import static java.io.File.separator; import static java.lang.String.format; if (gems == null || gems.length == 0) throw new CalabashException("Couldn't find any gems inside " + gemsDir.getAbsolutePath()); for (File gem : gems) { File libPath = new File(gem, "lib"); loadPaths.add(libPath.getAbsolutePath()); } return loadPaths; } public void setup() throws CalabashException { try { addSystemCommandHack(); createDebugCertificateIfMissing(); String jrubyClasspath = getClasspathFor("jruby"); addContainerEnv("CLASSPATH", jrubyClasspath); container.runScriptlet(format("Dir.chdir '%s'", apk.getParent())); container.put(ARGV, new String[]{"resign", apk.getAbsolutePath()}); String calabashAndroid = new File(getCalabashGemDirectory(), "calabash-android").getAbsolutePath(); container.runScriptlet(PathType.ABSOLUTE, calabashAndroid); info("Done signing the app"); container.put(ARGV, new String[]{"build", apk.getAbsolutePath()}); container.runScriptlet(PathType.ABSOLUTE, calabashAndroid); info("App build complete"); } catch (Exception e) {
error("Failed to setup calabash for project: %s", e, apk.getAbsolutePath());
vishnukarthikl/calabash-android-java
tests/com/thoughtworks/calabash/android/TestUtils.java
// Path: src/com/thoughtworks/calabash/android/Utils.java // public static String runCommand(String[] command, String onExceptionMessage) throws CalabashException { // int exitCode; // try { // Process process = executeCommand(command); // exitCode = process.waitFor(); // String error = toString(process.getErrorStream()); // String output = toString(process.getInputStream()); // CalabashLogger.info(output); // // if (exitCode == 0) { // return output; // } else { // CalabashLogger.error("Executing command failed"); // CalabashLogger.info(output); // CalabashLogger.error(error); // throw new CalabashException(onExceptionMessage); // } // } catch (Exception e) { // throw new CalabashException(onExceptionMessage); // } // }
import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; import java.util.HashMap; import static com.thoughtworks.calabash.android.Utils.runCommand; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail;
return tempAndroidPath; } public static void goToActivity(AndroidApplication application, final String activityName) throws CalabashException, OperationTimedoutException { application.query("* marked:'" + activityName + "'").touch(); application.waitForActivity(activityMap.get(activityName), 6); } public static AndroidApplication installAppOnEmulator(String serial, String packageName, File androidApkPath) throws CalabashException { AndroidConfiguration configuration = new AndroidConfiguration(); configuration.setLogsDirectory(new File("logs")); configuration.setSerial(serial); return installAppOnEmulator(serial, packageName, androidApkPath, configuration); } public static AndroidApplication installAppOnEmulator(String serial, String packageName, File androidApkPath, AndroidConfiguration configuration) throws CalabashException { uninstall(packageName, serial); configuration.setPauseTime(4000); AndroidRunner androidRunner = new AndroidRunner(androidApkPath.getAbsolutePath(), configuration); androidRunner.setup(); AndroidApplication application = androidRunner.start(); assertTrue(isAppInstalled(packageName, serial)); assertTrue(isMainActivity(application, activityMap.get(ACTIVITY_MAIN))); return application; } public static void uninstall(String packageName, String serial) throws CalabashException { String[] command = {TestUtils.getAdbPath(), "-s", serial, "uninstall", packageName}; try {
// Path: src/com/thoughtworks/calabash/android/Utils.java // public static String runCommand(String[] command, String onExceptionMessage) throws CalabashException { // int exitCode; // try { // Process process = executeCommand(command); // exitCode = process.waitFor(); // String error = toString(process.getErrorStream()); // String output = toString(process.getInputStream()); // CalabashLogger.info(output); // // if (exitCode == 0) { // return output; // } else { // CalabashLogger.error("Executing command failed"); // CalabashLogger.info(output); // CalabashLogger.error(error); // throw new CalabashException(onExceptionMessage); // } // } catch (Exception e) { // throw new CalabashException(onExceptionMessage); // } // } // Path: tests/com/thoughtworks/calabash/android/TestUtils.java import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; import java.util.HashMap; import static com.thoughtworks.calabash.android.Utils.runCommand; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; return tempAndroidPath; } public static void goToActivity(AndroidApplication application, final String activityName) throws CalabashException, OperationTimedoutException { application.query("* marked:'" + activityName + "'").touch(); application.waitForActivity(activityMap.get(activityName), 6); } public static AndroidApplication installAppOnEmulator(String serial, String packageName, File androidApkPath) throws CalabashException { AndroidConfiguration configuration = new AndroidConfiguration(); configuration.setLogsDirectory(new File("logs")); configuration.setSerial(serial); return installAppOnEmulator(serial, packageName, androidApkPath, configuration); } public static AndroidApplication installAppOnEmulator(String serial, String packageName, File androidApkPath, AndroidConfiguration configuration) throws CalabashException { uninstall(packageName, serial); configuration.setPauseTime(4000); AndroidRunner androidRunner = new AndroidRunner(androidApkPath.getAbsolutePath(), configuration); androidRunner.setup(); AndroidApplication application = androidRunner.start(); assertTrue(isAppInstalled(packageName, serial)); assertTrue(isMainActivity(application, activityMap.get(ACTIVITY_MAIN))); return application; } public static void uninstall(String packageName, String serial) throws CalabashException { String[] command = {TestUtils.getAdbPath(), "-s", serial, "uninstall", packageName}; try {
runCommand(command);
vsima/uber-java-client
src/main/java/com/victorsima/uber/UberAuthService.java
// Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // }
import com.victorsima.uber.model.AccessToken; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.POST; import retrofit.http.Query;
package com.victorsima.uber; /** * Uber authentication service interface */ public interface UberAuthService { public static final String SCOPE_PROFILE = "profile"; public static final String SCOPE_HISTORY_LITE = "history_lite"; public static final String SCOPE_REQUEST = "request"; public static final String GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code"; public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; /** * Exchange this authorization code for an access_token, which will allow you to make requests on * behalf of a user. The access_token expires in 30 days. The grant_type may be authorization_code or refresh_token. * * @param clientId A 32 character string (public) * @param clientSecret A 40 character string. DO NOT SHARE. This should not be available on any public facing * server or web site. If you have been compromised or shared this token accidentally please * reset your client_secret via our web interface. This will require updating your application * to use the newly issued client_secret. * @param redirectUri * @param grantType * @param authorizationCode * @param refreshToken * @return AccessToken */ @POST("/oauth/token")
// Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // Path: src/main/java/com/victorsima/uber/UberAuthService.java import com.victorsima.uber.model.AccessToken; import retrofit.Callback; import retrofit.http.GET; import retrofit.http.POST; import retrofit.http.Query; package com.victorsima.uber; /** * Uber authentication service interface */ public interface UberAuthService { public static final String SCOPE_PROFILE = "profile"; public static final String SCOPE_HISTORY_LITE = "history_lite"; public static final String SCOPE_REQUEST = "request"; public static final String GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code"; public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token"; /** * Exchange this authorization code for an access_token, which will allow you to make requests on * behalf of a user. The access_token expires in 30 days. The grant_type may be authorization_code or refresh_token. * * @param clientId A 32 character string (public) * @param clientSecret A 40 character string. DO NOT SHARE. This should not be available on any public facing * server or web site. If you have been compromised or shared this token accidentally please * reset your client_secret via our web interface. This will require updating your application * to use the newly issued client_secret. * @param redirectUri * @param grantType * @param authorizationCode * @param refreshToken * @return AccessToken */ @POST("/oauth/token")
AccessToken requestAccessToken(@Query("client_id") String clientId,
vsima/uber-java-client
src/main/java/com/victorsima/uber/model/sandbox/SandboxRequestBody.java
// Path: src/main/java/com/victorsima/uber/model/request/RequestBody.java // public class RequestBody { // // public RequestBody(String productId, double startLatitude, double startLongitude, // double endLatitude, double endLongitude, String surgeConfirmationId) { // this.productId = productId; // this.startLatitude = startLatitude; // this.startLongitude = startLongitude; // this.endLatitude = endLatitude; // this.endLongitude = endLongitude; // this.surgeConfirmationId = surgeConfirmationId; // } // // public enum Status { // /** // * The Request is matching to the most efficient available driver. // */ // @SerializedName("processing") // PROCESSING("processing"), // /** // * The Request has been accepted by a driver and is "en route" to the start_location. // */ // @SerializedName("accepted") // ACCEPTED("accepted"), // /** // * The driver has arrived or will be shortly. // */ // @SerializedName("arriving") // ARRIVING("arriving"), // /** // * The Request is "en route" from the start location to the end location. // */ // @SerializedName("in_progress") // IN_PROGRESS("in_progress"), // /** // * The Request has been canceled by the driver. // */ // @SerializedName("driver_canceled") // DRIVER_CANCELLED("driver_canceled"), // /** // * Request has been completed by the driver. // */ // @SerializedName("completed") // COMPLETED("completed"), // /** // * The Request was unfulfilled because no drivers were available. Use the Product Types sandbox endpoint to // * create a Request with this status. // */ // @SerializedName("no_drivers_available") // NO_DRIVERS_AVAILABLE("no_drivers_available"), // /** // * The Request canceled by rider. Issue a DELETE command to give a Request this status // */ // @SerializedName("rider_canceled") // RIDER_CANCELED("rider_canceled"); // // private final String status; // Status(String status) { // this.status = status; // } // public String value() { // return status; // } // } // // @Expose // @SerializedName("product_id") // private String productId; // // @Expose // @SerializedName("start_latitude") // private double startLatitude; // // @Expose // @SerializedName("start_longitude") // private double startLongitude; // // @Expose // @SerializedName("end_latitude") // private double endLatitude; // // @Expose // @SerializedName("end_longitude") // private double endLongitude; // // @Expose // @SerializedName("surge_confirmation_id") // private String surgeConfirmationId; // // // public String getProductId() { // return productId; // } // // public void setProductId(String productId) { // this.productId = productId; // } // // public double getStartLatitude() { // return startLatitude; // } // // public void setStartLatitude(double startLatitude) { // this.startLatitude = startLatitude; // } // // public double getStartLongitude() { // return startLongitude; // } // // public void setStartLongitude(double startLongitude) { // this.startLongitude = startLongitude; // } // // public double getEndLatitude() { // return endLatitude; // } // // public void setEndLatitude(double endLatitude) { // this.endLatitude = endLatitude; // } // // public double getEndLongitude() { // return endLongitude; // } // // public void setEndLongitude(double endLongitude) { // this.endLongitude = endLongitude; // } // // public String getSurgeConfirmationId() { // return surgeConfirmationId; // } // // public void setSurgeConfirmationId(String surgeConfirmationId) { // this.surgeConfirmationId = surgeConfirmationId; // } // }
import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.request.RequestBody;
package com.victorsima.uber.model.sandbox; /** * Created by victorsima on 3/23/15. */ public class SandboxRequestBody { @Expose @SerializedName("status")
// Path: src/main/java/com/victorsima/uber/model/request/RequestBody.java // public class RequestBody { // // public RequestBody(String productId, double startLatitude, double startLongitude, // double endLatitude, double endLongitude, String surgeConfirmationId) { // this.productId = productId; // this.startLatitude = startLatitude; // this.startLongitude = startLongitude; // this.endLatitude = endLatitude; // this.endLongitude = endLongitude; // this.surgeConfirmationId = surgeConfirmationId; // } // // public enum Status { // /** // * The Request is matching to the most efficient available driver. // */ // @SerializedName("processing") // PROCESSING("processing"), // /** // * The Request has been accepted by a driver and is "en route" to the start_location. // */ // @SerializedName("accepted") // ACCEPTED("accepted"), // /** // * The driver has arrived or will be shortly. // */ // @SerializedName("arriving") // ARRIVING("arriving"), // /** // * The Request is "en route" from the start location to the end location. // */ // @SerializedName("in_progress") // IN_PROGRESS("in_progress"), // /** // * The Request has been canceled by the driver. // */ // @SerializedName("driver_canceled") // DRIVER_CANCELLED("driver_canceled"), // /** // * Request has been completed by the driver. // */ // @SerializedName("completed") // COMPLETED("completed"), // /** // * The Request was unfulfilled because no drivers were available. Use the Product Types sandbox endpoint to // * create a Request with this status. // */ // @SerializedName("no_drivers_available") // NO_DRIVERS_AVAILABLE("no_drivers_available"), // /** // * The Request canceled by rider. Issue a DELETE command to give a Request this status // */ // @SerializedName("rider_canceled") // RIDER_CANCELED("rider_canceled"); // // private final String status; // Status(String status) { // this.status = status; // } // public String value() { // return status; // } // } // // @Expose // @SerializedName("product_id") // private String productId; // // @Expose // @SerializedName("start_latitude") // private double startLatitude; // // @Expose // @SerializedName("start_longitude") // private double startLongitude; // // @Expose // @SerializedName("end_latitude") // private double endLatitude; // // @Expose // @SerializedName("end_longitude") // private double endLongitude; // // @Expose // @SerializedName("surge_confirmation_id") // private String surgeConfirmationId; // // // public String getProductId() { // return productId; // } // // public void setProductId(String productId) { // this.productId = productId; // } // // public double getStartLatitude() { // return startLatitude; // } // // public void setStartLatitude(double startLatitude) { // this.startLatitude = startLatitude; // } // // public double getStartLongitude() { // return startLongitude; // } // // public void setStartLongitude(double startLongitude) { // this.startLongitude = startLongitude; // } // // public double getEndLatitude() { // return endLatitude; // } // // public void setEndLatitude(double endLatitude) { // this.endLatitude = endLatitude; // } // // public double getEndLongitude() { // return endLongitude; // } // // public void setEndLongitude(double endLongitude) { // this.endLongitude = endLongitude; // } // // public String getSurgeConfirmationId() { // return surgeConfirmationId; // } // // public void setSurgeConfirmationId(String surgeConfirmationId) { // this.surgeConfirmationId = surgeConfirmationId; // } // } // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxRequestBody.java import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.request.RequestBody; package com.victorsima.uber.model.sandbox; /** * Created by victorsima on 3/23/15. */ public class SandboxRequestBody { @Expose @SerializedName("status")
private RequestBody.Status status;
vsima/uber-java-client
src/main/java/com/victorsima/uber/model/request/Meta.java
// Path: src/main/java/com/victorsima/uber/model/request/SurgeConfirmation.java // public class SurgeConfirmation { // // /** // * The URL a user must visit to accept surge pricing. // */ // @Expose // @SerializedName("href") // private String href; // // /** // * The surge confirmation identifier used to make a Request after a user has accepted surge pricing. // */ // @Expose // @SerializedName("surge_confirmation_id") // private String surgeConfirmationId; // // public String getHref() { // return href; // } // // public void setHref(String href) { // this.href = href; // } // // public String getSurgeConfirmationId() { // return surgeConfirmationId; // } // // public void setSurgeConfirmationId(String surgeConfirmationId) { // this.surgeConfirmationId = surgeConfirmationId; // } // }
import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.request.SurgeConfirmation;
package com.victorsima.uber.model.request; /** * Request Meta model obj */ public class Meta { @Expose @SerializedName("surge_confirmation")
// Path: src/main/java/com/victorsima/uber/model/request/SurgeConfirmation.java // public class SurgeConfirmation { // // /** // * The URL a user must visit to accept surge pricing. // */ // @Expose // @SerializedName("href") // private String href; // // /** // * The surge confirmation identifier used to make a Request after a user has accepted surge pricing. // */ // @Expose // @SerializedName("surge_confirmation_id") // private String surgeConfirmationId; // // public String getHref() { // return href; // } // // public void setHref(String href) { // this.href = href; // } // // public String getSurgeConfirmationId() { // return surgeConfirmationId; // } // // public void setSurgeConfirmationId(String surgeConfirmationId) { // this.surgeConfirmationId = surgeConfirmationId; // } // } // Path: src/main/java/com/victorsima/uber/model/request/Meta.java import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.request.SurgeConfirmation; package com.victorsima.uber.model.request; /** * Request Meta model obj */ public class Meta { @Expose @SerializedName("surge_confirmation")
private SurgeConfirmation surgeConfirmation;
vsima/uber-java-client
src/main/java/com/victorsima/uber/model/Products.java
// Path: src/main/java/com/victorsima/uber/model/Product.java // public class Product { // // @Expose // @SerializedName("product_id") // private String productId; // // @Expose // @SerializedName("description") // private String description; // // @Expose // @SerializedName("display_name") // private String displayName; // // @Expose // @SerializedName("capacity") // private int capacity; // // @Expose // @SerializedName("image") // private String image; // // public String getProductId() { // return productId; // } // // public void setProductId(String productId) { // this.productId = productId; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public int getCapacity() { // return capacity; // } // // public void setCapacity(int capacity) { // this.capacity = capacity; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // }
import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Product; import java.util.List;
package com.victorsima.uber.model; /** * Products model obj */ public class Products { @Expose @SerializedName("products")
// Path: src/main/java/com/victorsima/uber/model/Product.java // public class Product { // // @Expose // @SerializedName("product_id") // private String productId; // // @Expose // @SerializedName("description") // private String description; // // @Expose // @SerializedName("display_name") // private String displayName; // // @Expose // @SerializedName("capacity") // private int capacity; // // @Expose // @SerializedName("image") // private String image; // // public String getProductId() { // return productId; // } // // public void setProductId(String productId) { // this.productId = productId; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getDisplayName() { // return displayName; // } // // public void setDisplayName(String displayName) { // this.displayName = displayName; // } // // public int getCapacity() { // return capacity; // } // // public void setCapacity(int capacity) { // this.capacity = capacity; // } // // public String getImage() { // return image; // } // // public void setImage(String image) { // this.image = image; // } // } // Path: src/main/java/com/victorsima/uber/model/Products.java import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Product; import java.util.List; package com.victorsima.uber.model; /** * Products model obj */ public class Products { @Expose @SerializedName("products")
private List<Product> products;
vsima/uber-java-client
src/main/java/com/victorsima/uber/model/request/Request.java
// Path: src/main/java/com/victorsima/uber/model/Driver.java // public class Driver { // @Expose // @SerializedName("phone_number") // private String phoneNumber; // @Expose // @SerializedName("rating") // private float rating; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // @Expose // @SerializedName("name") // private String name; // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public float getRating() { // return rating; // } // // public void setRating(float rating) { // this.rating = rating; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: src/main/java/com/victorsima/uber/model/Location.java // public class Location { // // @Expose // @SerializedName("latitude") // private float latitude; // // @Expose // @SerializedName("longitude") // private float longitude; // } // // Path: src/main/java/com/victorsima/uber/model/Vehicle.java // public class Vehicle { // // @Expose // @SerializedName("make") // private String make; // @Expose // @SerializedName("model") // private String model; // @Expose // @SerializedName("license_plate") // private String licensePlate; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // // public String getMake() { // return make; // } // // public void setMake(String make) { // this.make = make; // } // // public String getModel() { // return model; // } // // public void setModel(String model) { // this.model = model; // } // // public String getLicensePlate() { // return licensePlate; // } // // public void setLicensePlate(String licensePlate) { // this.licensePlate = licensePlate; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // }
import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Driver; import com.victorsima.uber.model.Location; import com.victorsima.uber.model.Vehicle; import java.util.List;
package com.victorsima.uber.model.request; /** * Created by victorsima on 3/22/15. */ public class Request { /** * The unique ID of the Request. */ @Expose @SerializedName("request_id") private String requestId; /** * The status of the Request indicating state. */ @Expose @SerializedName("status") private RequestBody.Status status; /** * The object that contains vehicle details. */ @Expose @SerializedName("vehicle")
// Path: src/main/java/com/victorsima/uber/model/Driver.java // public class Driver { // @Expose // @SerializedName("phone_number") // private String phoneNumber; // @Expose // @SerializedName("rating") // private float rating; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // @Expose // @SerializedName("name") // private String name; // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public float getRating() { // return rating; // } // // public void setRating(float rating) { // this.rating = rating; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: src/main/java/com/victorsima/uber/model/Location.java // public class Location { // // @Expose // @SerializedName("latitude") // private float latitude; // // @Expose // @SerializedName("longitude") // private float longitude; // } // // Path: src/main/java/com/victorsima/uber/model/Vehicle.java // public class Vehicle { // // @Expose // @SerializedName("make") // private String make; // @Expose // @SerializedName("model") // private String model; // @Expose // @SerializedName("license_plate") // private String licensePlate; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // // public String getMake() { // return make; // } // // public void setMake(String make) { // this.make = make; // } // // public String getModel() { // return model; // } // // public void setModel(String model) { // this.model = model; // } // // public String getLicensePlate() { // return licensePlate; // } // // public void setLicensePlate(String licensePlate) { // this.licensePlate = licensePlate; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // } // Path: src/main/java/com/victorsima/uber/model/request/Request.java import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Driver; import com.victorsima.uber.model.Location; import com.victorsima.uber.model.Vehicle; import java.util.List; package com.victorsima.uber.model.request; /** * Created by victorsima on 3/22/15. */ public class Request { /** * The unique ID of the Request. */ @Expose @SerializedName("request_id") private String requestId; /** * The status of the Request indicating state. */ @Expose @SerializedName("status") private RequestBody.Status status; /** * The object that contains vehicle details. */ @Expose @SerializedName("vehicle")
private Vehicle vehicle;
vsima/uber-java-client
src/main/java/com/victorsima/uber/model/request/Request.java
// Path: src/main/java/com/victorsima/uber/model/Driver.java // public class Driver { // @Expose // @SerializedName("phone_number") // private String phoneNumber; // @Expose // @SerializedName("rating") // private float rating; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // @Expose // @SerializedName("name") // private String name; // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public float getRating() { // return rating; // } // // public void setRating(float rating) { // this.rating = rating; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: src/main/java/com/victorsima/uber/model/Location.java // public class Location { // // @Expose // @SerializedName("latitude") // private float latitude; // // @Expose // @SerializedName("longitude") // private float longitude; // } // // Path: src/main/java/com/victorsima/uber/model/Vehicle.java // public class Vehicle { // // @Expose // @SerializedName("make") // private String make; // @Expose // @SerializedName("model") // private String model; // @Expose // @SerializedName("license_plate") // private String licensePlate; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // // public String getMake() { // return make; // } // // public void setMake(String make) { // this.make = make; // } // // public String getModel() { // return model; // } // // public void setModel(String model) { // this.model = model; // } // // public String getLicensePlate() { // return licensePlate; // } // // public void setLicensePlate(String licensePlate) { // this.licensePlate = licensePlate; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // }
import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Driver; import com.victorsima.uber.model.Location; import com.victorsima.uber.model.Vehicle; import java.util.List;
package com.victorsima.uber.model.request; /** * Created by victorsima on 3/22/15. */ public class Request { /** * The unique ID of the Request. */ @Expose @SerializedName("request_id") private String requestId; /** * The status of the Request indicating state. */ @Expose @SerializedName("status") private RequestBody.Status status; /** * The object that contains vehicle details. */ @Expose @SerializedName("vehicle") private Vehicle vehicle; /** * The object that contains driver details. */ @Expose @SerializedName("driver")
// Path: src/main/java/com/victorsima/uber/model/Driver.java // public class Driver { // @Expose // @SerializedName("phone_number") // private String phoneNumber; // @Expose // @SerializedName("rating") // private float rating; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // @Expose // @SerializedName("name") // private String name; // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public float getRating() { // return rating; // } // // public void setRating(float rating) { // this.rating = rating; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: src/main/java/com/victorsima/uber/model/Location.java // public class Location { // // @Expose // @SerializedName("latitude") // private float latitude; // // @Expose // @SerializedName("longitude") // private float longitude; // } // // Path: src/main/java/com/victorsima/uber/model/Vehicle.java // public class Vehicle { // // @Expose // @SerializedName("make") // private String make; // @Expose // @SerializedName("model") // private String model; // @Expose // @SerializedName("license_plate") // private String licensePlate; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // // public String getMake() { // return make; // } // // public void setMake(String make) { // this.make = make; // } // // public String getModel() { // return model; // } // // public void setModel(String model) { // this.model = model; // } // // public String getLicensePlate() { // return licensePlate; // } // // public void setLicensePlate(String licensePlate) { // this.licensePlate = licensePlate; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // } // Path: src/main/java/com/victorsima/uber/model/request/Request.java import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Driver; import com.victorsima.uber.model.Location; import com.victorsima.uber.model.Vehicle; import java.util.List; package com.victorsima.uber.model.request; /** * Created by victorsima on 3/22/15. */ public class Request { /** * The unique ID of the Request. */ @Expose @SerializedName("request_id") private String requestId; /** * The status of the Request indicating state. */ @Expose @SerializedName("status") private RequestBody.Status status; /** * The object that contains vehicle details. */ @Expose @SerializedName("vehicle") private Vehicle vehicle; /** * The object that contains driver details. */ @Expose @SerializedName("driver")
private Driver driver;
vsima/uber-java-client
src/main/java/com/victorsima/uber/model/request/Request.java
// Path: src/main/java/com/victorsima/uber/model/Driver.java // public class Driver { // @Expose // @SerializedName("phone_number") // private String phoneNumber; // @Expose // @SerializedName("rating") // private float rating; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // @Expose // @SerializedName("name") // private String name; // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public float getRating() { // return rating; // } // // public void setRating(float rating) { // this.rating = rating; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: src/main/java/com/victorsima/uber/model/Location.java // public class Location { // // @Expose // @SerializedName("latitude") // private float latitude; // // @Expose // @SerializedName("longitude") // private float longitude; // } // // Path: src/main/java/com/victorsima/uber/model/Vehicle.java // public class Vehicle { // // @Expose // @SerializedName("make") // private String make; // @Expose // @SerializedName("model") // private String model; // @Expose // @SerializedName("license_plate") // private String licensePlate; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // // public String getMake() { // return make; // } // // public void setMake(String make) { // this.make = make; // } // // public String getModel() { // return model; // } // // public void setModel(String model) { // this.model = model; // } // // public String getLicensePlate() { // return licensePlate; // } // // public void setLicensePlate(String licensePlate) { // this.licensePlate = licensePlate; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // }
import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Driver; import com.victorsima.uber.model.Location; import com.victorsima.uber.model.Vehicle; import java.util.List;
package com.victorsima.uber.model.request; /** * Created by victorsima on 3/22/15. */ public class Request { /** * The unique ID of the Request. */ @Expose @SerializedName("request_id") private String requestId; /** * The status of the Request indicating state. */ @Expose @SerializedName("status") private RequestBody.Status status; /** * The object that contains vehicle details. */ @Expose @SerializedName("vehicle") private Vehicle vehicle; /** * The object that contains driver details. */ @Expose @SerializedName("driver") private Driver driver; /** * The object that contains the location information of the vehicle and driver. */ @Expose @SerializedName("location")
// Path: src/main/java/com/victorsima/uber/model/Driver.java // public class Driver { // @Expose // @SerializedName("phone_number") // private String phoneNumber; // @Expose // @SerializedName("rating") // private float rating; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // @Expose // @SerializedName("name") // private String name; // // public String getPhoneNumber() { // return phoneNumber; // } // // public void setPhoneNumber(String phoneNumber) { // this.phoneNumber = phoneNumber; // } // // public float getRating() { // return rating; // } // // public void setRating(float rating) { // this.rating = rating; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: src/main/java/com/victorsima/uber/model/Location.java // public class Location { // // @Expose // @SerializedName("latitude") // private float latitude; // // @Expose // @SerializedName("longitude") // private float longitude; // } // // Path: src/main/java/com/victorsima/uber/model/Vehicle.java // public class Vehicle { // // @Expose // @SerializedName("make") // private String make; // @Expose // @SerializedName("model") // private String model; // @Expose // @SerializedName("license_plate") // private String licensePlate; // @Expose // @SerializedName("picture_url") // private String pictureUrl; // // public String getMake() { // return make; // } // // public void setMake(String make) { // this.make = make; // } // // public String getModel() { // return model; // } // // public void setModel(String model) { // this.model = model; // } // // public String getLicensePlate() { // return licensePlate; // } // // public void setLicensePlate(String licensePlate) { // this.licensePlate = licensePlate; // } // // public String getPictureUrl() { // return pictureUrl; // } // // public void setPictureUrl(String pictureUrl) { // this.pictureUrl = pictureUrl; // } // } // Path: src/main/java/com/victorsima/uber/model/request/Request.java import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.victorsima.uber.model.Driver; import com.victorsima.uber.model.Location; import com.victorsima.uber.model.Vehicle; import java.util.List; package com.victorsima.uber.model.request; /** * Created by victorsima on 3/22/15. */ public class Request { /** * The unique ID of the Request. */ @Expose @SerializedName("request_id") private String requestId; /** * The status of the Request indicating state. */ @Expose @SerializedName("status") private RequestBody.Status status; /** * The object that contains vehicle details. */ @Expose @SerializedName("vehicle") private Vehicle vehicle; /** * The object that contains driver details. */ @Expose @SerializedName("driver") private Driver driver; /** * The object that contains the location information of the vehicle and driver. */ @Expose @SerializedName("location")
private Location location;
vsima/uber-java-client
src/main/java/com/victorsima/uber/UberClient.java
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java // public class ForbiddenException extends Exception { // // public ForbiddenException() { // super("HTTP 403 error"); // } // } // // Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java // public class UnauthorizedException extends Exception { // // public UnauthorizedException() { // super("HTTP 401 error"); // } // } // // Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java // public interface SandboxService { // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Currently the sandbox does not change states automatically the way a real Request in production would, // * so this endpoint gives the ability to walk an application through the different states of a Request.</p> // * // * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p> // * @param requestId // * @param request // * @return // */ // @PUT("/v1/sandbox/requests/{request_id}") // Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request); // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p> // * @param productId // * @param sandboxProductBody // * @return // */ // @PUT("/v1/sandbox/products/{product_id}") // Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody); // }
import com.google.gson.*; import com.squareup.okhttp.OkHttpClient; import com.victorsima.uber.exception.ForbiddenException; import com.victorsima.uber.exception.UnauthorizedException; import com.victorsima.uber.model.AccessToken; import com.victorsima.uber.model.sandbox.SandboxService; import retrofit.*; import retrofit.client.Client; import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.converter.GsonConverter; import java.lang.reflect.Type; import java.util.Date;
package com.victorsima.uber; /** * The Uber api client object */ public class UberClient { private static final String oAuthUri = "https://login.uber.com"; private static final String apiUri = "https://api.uber.com"; private static final String sandboxApiUri = "https://sandbox-api.uber.com"; private String version; private String accessToken; private String refreshToken; private String serverToken; private String clientId; private String clientSecret; private String clientRedirectUri; private UberService apiService; private UberAuthService authService;
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java // public class ForbiddenException extends Exception { // // public ForbiddenException() { // super("HTTP 403 error"); // } // } // // Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java // public class UnauthorizedException extends Exception { // // public UnauthorizedException() { // super("HTTP 401 error"); // } // } // // Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java // public interface SandboxService { // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Currently the sandbox does not change states automatically the way a real Request in production would, // * so this endpoint gives the ability to walk an application through the different states of a Request.</p> // * // * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p> // * @param requestId // * @param request // * @return // */ // @PUT("/v1/sandbox/requests/{request_id}") // Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request); // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p> // * @param productId // * @param sandboxProductBody // * @return // */ // @PUT("/v1/sandbox/products/{product_id}") // Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody); // } // Path: src/main/java/com/victorsima/uber/UberClient.java import com.google.gson.*; import com.squareup.okhttp.OkHttpClient; import com.victorsima.uber.exception.ForbiddenException; import com.victorsima.uber.exception.UnauthorizedException; import com.victorsima.uber.model.AccessToken; import com.victorsima.uber.model.sandbox.SandboxService; import retrofit.*; import retrofit.client.Client; import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.converter.GsonConverter; import java.lang.reflect.Type; import java.util.Date; package com.victorsima.uber; /** * The Uber api client object */ public class UberClient { private static final String oAuthUri = "https://login.uber.com"; private static final String apiUri = "https://api.uber.com"; private static final String sandboxApiUri = "https://sandbox-api.uber.com"; private String version; private String accessToken; private String refreshToken; private String serverToken; private String clientId; private String clientSecret; private String clientRedirectUri; private UberService apiService; private UberAuthService authService;
private SandboxService sandboxService;
vsima/uber-java-client
src/main/java/com/victorsima/uber/UberClient.java
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java // public class ForbiddenException extends Exception { // // public ForbiddenException() { // super("HTTP 403 error"); // } // } // // Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java // public class UnauthorizedException extends Exception { // // public UnauthorizedException() { // super("HTTP 401 error"); // } // } // // Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java // public interface SandboxService { // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Currently the sandbox does not change states automatically the way a real Request in production would, // * so this endpoint gives the ability to walk an application through the different states of a Request.</p> // * // * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p> // * @param requestId // * @param request // * @return // */ // @PUT("/v1/sandbox/requests/{request_id}") // Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request); // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p> // * @param productId // * @param sandboxProductBody // * @return // */ // @PUT("/v1/sandbox/products/{product_id}") // Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody); // }
import com.google.gson.*; import com.squareup.okhttp.OkHttpClient; import com.victorsima.uber.exception.ForbiddenException; import com.victorsima.uber.exception.UnauthorizedException; import com.victorsima.uber.model.AccessToken; import com.victorsima.uber.model.sandbox.SandboxService; import retrofit.*; import retrofit.client.Client; import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.converter.GsonConverter; import java.lang.reflect.Type; import java.util.Date;
GsonBuilder gsonBuilder = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Date(json.getAsJsonPrimitive().getAsLong()); } }); OkHttpClient okHttpClient = new OkHttpClient(); gson = gsonBuilder.create(); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(useSandbox ? sandboxApiUri : apiUri) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade requestFacade) { if (hasAccessToken()) { requestFacade.addHeader("Authorization", "Bearer " + getAccessToken()); return; } else if (hasServerToken()) { requestFacade.addHeader("Authorization", "Token " + getServerToken()); } } }) .setErrorHandler(new ErrorHandler() { @Override public Throwable handleError(RetrofitError retrofitError) { if (retrofitError != null && retrofitError.getResponse() != null) { switch (retrofitError.getResponse().getStatus()) { case 401: //Unauthorized
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java // public class ForbiddenException extends Exception { // // public ForbiddenException() { // super("HTTP 403 error"); // } // } // // Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java // public class UnauthorizedException extends Exception { // // public UnauthorizedException() { // super("HTTP 401 error"); // } // } // // Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java // public interface SandboxService { // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Currently the sandbox does not change states automatically the way a real Request in production would, // * so this endpoint gives the ability to walk an application through the different states of a Request.</p> // * // * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p> // * @param requestId // * @param request // * @return // */ // @PUT("/v1/sandbox/requests/{request_id}") // Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request); // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p> // * @param productId // * @param sandboxProductBody // * @return // */ // @PUT("/v1/sandbox/products/{product_id}") // Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody); // } // Path: src/main/java/com/victorsima/uber/UberClient.java import com.google.gson.*; import com.squareup.okhttp.OkHttpClient; import com.victorsima.uber.exception.ForbiddenException; import com.victorsima.uber.exception.UnauthorizedException; import com.victorsima.uber.model.AccessToken; import com.victorsima.uber.model.sandbox.SandboxService; import retrofit.*; import retrofit.client.Client; import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.converter.GsonConverter; import java.lang.reflect.Type; import java.util.Date; GsonBuilder gsonBuilder = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Date(json.getAsJsonPrimitive().getAsLong()); } }); OkHttpClient okHttpClient = new OkHttpClient(); gson = gsonBuilder.create(); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(useSandbox ? sandboxApiUri : apiUri) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade requestFacade) { if (hasAccessToken()) { requestFacade.addHeader("Authorization", "Bearer " + getAccessToken()); return; } else if (hasServerToken()) { requestFacade.addHeader("Authorization", "Token " + getServerToken()); } } }) .setErrorHandler(new ErrorHandler() { @Override public Throwable handleError(RetrofitError retrofitError) { if (retrofitError != null && retrofitError.getResponse() != null) { switch (retrofitError.getResponse().getStatus()) { case 401: //Unauthorized
return new UnauthorizedException();
vsima/uber-java-client
src/main/java/com/victorsima/uber/UberClient.java
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java // public class ForbiddenException extends Exception { // // public ForbiddenException() { // super("HTTP 403 error"); // } // } // // Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java // public class UnauthorizedException extends Exception { // // public UnauthorizedException() { // super("HTTP 401 error"); // } // } // // Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java // public interface SandboxService { // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Currently the sandbox does not change states automatically the way a real Request in production would, // * so this endpoint gives the ability to walk an application through the different states of a Request.</p> // * // * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p> // * @param requestId // * @param request // * @return // */ // @PUT("/v1/sandbox/requests/{request_id}") // Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request); // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p> // * @param productId // * @param sandboxProductBody // * @return // */ // @PUT("/v1/sandbox/products/{product_id}") // Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody); // }
import com.google.gson.*; import com.squareup.okhttp.OkHttpClient; import com.victorsima.uber.exception.ForbiddenException; import com.victorsima.uber.exception.UnauthorizedException; import com.victorsima.uber.model.AccessToken; import com.victorsima.uber.model.sandbox.SandboxService; import retrofit.*; import retrofit.client.Client; import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.converter.GsonConverter; import java.lang.reflect.Type; import java.util.Date;
.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Date(json.getAsJsonPrimitive().getAsLong()); } }); OkHttpClient okHttpClient = new OkHttpClient(); gson = gsonBuilder.create(); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(useSandbox ? sandboxApiUri : apiUri) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade requestFacade) { if (hasAccessToken()) { requestFacade.addHeader("Authorization", "Bearer " + getAccessToken()); return; } else if (hasServerToken()) { requestFacade.addHeader("Authorization", "Token " + getServerToken()); } } }) .setErrorHandler(new ErrorHandler() { @Override public Throwable handleError(RetrofitError retrofitError) { if (retrofitError != null && retrofitError.getResponse() != null) { switch (retrofitError.getResponse().getStatus()) { case 401: //Unauthorized return new UnauthorizedException(); case 403: //Forbidden
// Path: src/main/java/com/victorsima/uber/exception/ForbiddenException.java // public class ForbiddenException extends Exception { // // public ForbiddenException() { // super("HTTP 403 error"); // } // } // // Path: src/main/java/com/victorsima/uber/exception/UnauthorizedException.java // public class UnauthorizedException extends Exception { // // public UnauthorizedException() { // super("HTTP 401 error"); // } // } // // Path: src/main/java/com/victorsima/uber/model/AccessToken.java // public class AccessToken { // // @Expose // @SerializedName("access_token") // private String accessToken; // // @Expose // @SerializedName("refresh_token") // private String refreshToken; // // @Expose // @SerializedName("token_type") // private String tokenType; // // @Expose // @SerializedName("expires_in") // private String expiresIn; // // @Expose // @SerializedName("scope") // private String scope; // // public AccessToken() { // } // // public String getAccessToken() { // return this.accessToken; // } // // public String getTokenType() { // return this.tokenType; // } // // public void setAccessToken(String paramString) { // this.accessToken = paramString; // } // // public void setTokenType(String paramString) { // this.tokenType = paramString; // } // // public String getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(String expiresIn) { // this.expiresIn = expiresIn; // } // // public String getScope() { // return scope; // } // // public void setScope(String scope) { // this.scope = scope; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // } // // Path: src/main/java/com/victorsima/uber/model/sandbox/SandboxService.java // public interface SandboxService { // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Currently the sandbox does not change states automatically the way a real Request in production would, // * so this endpoint gives the ability to walk an application through the different states of a Request.</p> // * // * <p>This endpoint effectively just modifies the status of an ongoing sandbox Request.</p> // * @param requestId // * @param request // * @return // */ // @PUT("/v1/sandbox/requests/{request_id}") // Response putRequest(@Path("request_id") String requestId, @Body SandboxRequestBody request); // // /** // * <p><b>FOR SANDBOX USE ONLY</b></p> // * <p>Accepts a JSON body indicating what you would like the surge_multiplier to be when making a Request to a particular Product.</p> // * @param productId // * @param sandboxProductBody // * @return // */ // @PUT("/v1/sandbox/products/{product_id}") // Response putProducts(@Path("product_id") String productId, @Body SandboxProductBody sandboxProductBody); // } // Path: src/main/java/com/victorsima/uber/UberClient.java import com.google.gson.*; import com.squareup.okhttp.OkHttpClient; import com.victorsima.uber.exception.ForbiddenException; import com.victorsima.uber.exception.UnauthorizedException; import com.victorsima.uber.model.AccessToken; import com.victorsima.uber.model.sandbox.SandboxService; import retrofit.*; import retrofit.client.Client; import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.converter.GsonConverter; import java.lang.reflect.Type; import java.util.Date; .registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Date(json.getAsJsonPrimitive().getAsLong()); } }); OkHttpClient okHttpClient = new OkHttpClient(); gson = gsonBuilder.create(); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(useSandbox ? sandboxApiUri : apiUri) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade requestFacade) { if (hasAccessToken()) { requestFacade.addHeader("Authorization", "Bearer " + getAccessToken()); return; } else if (hasServerToken()) { requestFacade.addHeader("Authorization", "Token " + getServerToken()); } } }) .setErrorHandler(new ErrorHandler() { @Override public Throwable handleError(RetrofitError retrofitError) { if (retrofitError != null && retrofitError.getResponse() != null) { switch (retrofitError.getResponse().getStatus()) { case 401: //Unauthorized return new UnauthorizedException(); case 403: //Forbidden
return new ForbiddenException();
ae6623/Zebra
zebra4j/zebra-boot/src/test/java/com58/zhl/concurrent/Cptt13_DBNonblock.java
// Path: zebra4j/zebra-boot/src/test/java/com58/zhl/util/DatabaseConnection.java // public class DatabaseConnection { // // private static final String DRIVER="oracle.jdbc.driver.OracleDriver"; // // private static final String URL="jdbc:oracle:thin:@localhost:1521:orcl"; // // private static final String pwd="scott"; // // private static final String name="scott"; // // public static Connection getConnection(){ // try { // Class.forName(DRIVER); // Connection conn=DriverManager.getConnection(URL, name, pwd); // return conn; // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } catch (SQLException e) { // e.printStackTrace(); // } // return null; // } // // public static void closeConnection(Connection conn){ // try { // conn.close(); // } catch (SQLException e) { // e.printStackTrace(); // } // } // // }
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.concurrent.CountDownLatch; import com58.zhl.util.DatabaseConnection;
package com58.zhl.concurrent; /** * 打造基于数据库操作的非阻塞算法 * @author 58_zhl * */ public class Cptt13_DBNonblock { /** * 并发数量 */ private static int count=10; private static CountDownLatch latch=new CountDownLatch(count); public static void testConcurrent() throws InterruptedException{ for(int i=0;i<count;i++){ Thread th=new AccessDB(i+1); th.start(); if(i+1==count){ //最后一个线程启动完毕 System.out.println("======================"); }else{ Thread.sleep(500); } } } private static class AccessDB extends Thread{ private int id; public AccessDB(int id){ this.id=id; } public void run(){
// Path: zebra4j/zebra-boot/src/test/java/com58/zhl/util/DatabaseConnection.java // public class DatabaseConnection { // // private static final String DRIVER="oracle.jdbc.driver.OracleDriver"; // // private static final String URL="jdbc:oracle:thin:@localhost:1521:orcl"; // // private static final String pwd="scott"; // // private static final String name="scott"; // // public static Connection getConnection(){ // try { // Class.forName(DRIVER); // Connection conn=DriverManager.getConnection(URL, name, pwd); // return conn; // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } catch (SQLException e) { // e.printStackTrace(); // } // return null; // } // // public static void closeConnection(Connection conn){ // try { // conn.close(); // } catch (SQLException e) { // e.printStackTrace(); // } // } // // } // Path: zebra4j/zebra-boot/src/test/java/com58/zhl/concurrent/Cptt13_DBNonblock.java import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.concurrent.CountDownLatch; import com58.zhl.util.DatabaseConnection; package com58.zhl.concurrent; /** * 打造基于数据库操作的非阻塞算法 * @author 58_zhl * */ public class Cptt13_DBNonblock { /** * 并发数量 */ private static int count=10; private static CountDownLatch latch=new CountDownLatch(count); public static void testConcurrent() throws InterruptedException{ for(int i=0;i<count;i++){ Thread th=new AccessDB(i+1); th.start(); if(i+1==count){ //最后一个线程启动完毕 System.out.println("======================"); }else{ Thread.sleep(500); } } } private static class AccessDB extends Thread{ private int id; public AccessDB(int id){ this.id=id; } public void run(){
Connection conn=DatabaseConnection.getConnection();
ae6623/Zebra
zebra4j/zebra-boot/src/main/java/com/zebra/boot/listener/ZebraListener.java
// Path: zebra4j/zebra-boot/src/main/java/com/zebra/boot/registry/IRegistry.java // public interface IRegistry { // // /** // * 服务注册信息 // * // * @param serviceName 服务名称 比如 zebra/service // * @param address 服务真实地址 比如 ip:port // */ // void register(String serviceName, String address); // // /** // * 服务卸载 // * @param serviceName // * @param address // */ // void unRegister(String serviceName, String address); // }
import com.zebra.boot.registry.IRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import java.util.Map;
package com.zebra.boot.listener; /** * Created by js-dev.cn on 2016/11/24. * 监听器:当服务启动之后,立即监听并开始向注册中心Registry注册服务,告诉注册中心,自己是一个服务节点 */ @Component @ComponentScan @WebListener public class ZebraListener implements ServletContextListener{ private static Logger logger = LoggerFactory.getLogger(ZebraListener.class); @Value("${server.address}") private String serverAddress; @Value("${server.port}") private int serverPort; @Autowired
// Path: zebra4j/zebra-boot/src/main/java/com/zebra/boot/registry/IRegistry.java // public interface IRegistry { // // /** // * 服务注册信息 // * // * @param serviceName 服务名称 比如 zebra/service // * @param address 服务真实地址 比如 ip:port // */ // void register(String serviceName, String address); // // /** // * 服务卸载 // * @param serviceName // * @param address // */ // void unRegister(String serviceName, String address); // } // Path: zebra4j/zebra-boot/src/main/java/com/zebra/boot/listener/ZebraListener.java import com.zebra.boot.registry.IRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import java.util.Map; package com.zebra.boot.listener; /** * Created by js-dev.cn on 2016/11/24. * 监听器:当服务启动之后,立即监听并开始向注册中心Registry注册服务,告诉注册中心,自己是一个服务节点 */ @Component @ComponentScan @WebListener public class ZebraListener implements ServletContextListener{ private static Logger logger = LoggerFactory.getLogger(ZebraListener.class); @Value("${server.address}") private String serverAddress; @Value("${server.port}") private int serverPort; @Autowired
private IRegistry registry;
akquinet/chameRIA
chameria-launcher/src/test/java/de/akquinet/chameria/services/ActivationUtilsTest.java
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationUtils.java // public class ActivationUtils { // // /** // * Checks if the arguments contains the argument <code>arg</code>. // * @param args the arguments // * @param arg the argument to find // * @return <code>true</code> if the // */ // public static boolean containsArgument(String[] args, String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return false; // } else { // for (String a : args) { // if (a.equalsIgnoreCase(arg)) { // return true; // } else if (a.startsWith(arg + "=")) { // return true; // } // // } // return false; // } // } // // /** // * Gets the argument value. // * <ul> // * <li>for 'arg=value' it returns 'value'</li> // * <li>for 'arg value' it returns 'value'</li> // * @param args the arguments // * @param arg the argument to find // * @return the argument value or <code>null</code> if not found. // */ // public static String getArgumentValue(String args[], String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return null; // } else { // for (int i = 0; i < args.length; i++) { // String a = args[i]; // if (a.equalsIgnoreCase(arg)) { // // Case 'arg value' : Look for arg + 1; // if (args.length > i + 1) { // return args[i+1]; // } // // } else if (a.startsWith(arg + "=")) { // // Case 'arg=value' : Parse the value // int index = a.indexOf('=') + 1; // return a.substring(index); // } // } // // return null; // } // } // // /** // * Gets the value of the '-open' argument. // * @param args the arguments // * @return the value of the '-open' argument or <code> // * null</code> if not found. // */ // public static String getOpenArgument(String args[]) { // return getArgumentValue(args, "-open"); // } // // // }
import org.junit.Assert; import org.junit.Test; import de.akquinet.chameria.services.ActivationUtils;
/* * Copyright 2010 akquinet * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.akquinet.chameria.services; public class ActivationUtilsTest { @Test public void testContainsArgument() { String[] args = new String[] { "--foo", "-bar=toto", "dede", "de" };
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationUtils.java // public class ActivationUtils { // // /** // * Checks if the arguments contains the argument <code>arg</code>. // * @param args the arguments // * @param arg the argument to find // * @return <code>true</code> if the // */ // public static boolean containsArgument(String[] args, String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return false; // } else { // for (String a : args) { // if (a.equalsIgnoreCase(arg)) { // return true; // } else if (a.startsWith(arg + "=")) { // return true; // } // // } // return false; // } // } // // /** // * Gets the argument value. // * <ul> // * <li>for 'arg=value' it returns 'value'</li> // * <li>for 'arg value' it returns 'value'</li> // * @param args the arguments // * @param arg the argument to find // * @return the argument value or <code>null</code> if not found. // */ // public static String getArgumentValue(String args[], String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return null; // } else { // for (int i = 0; i < args.length; i++) { // String a = args[i]; // if (a.equalsIgnoreCase(arg)) { // // Case 'arg value' : Look for arg + 1; // if (args.length > i + 1) { // return args[i+1]; // } // // } else if (a.startsWith(arg + "=")) { // // Case 'arg=value' : Parse the value // int index = a.indexOf('=') + 1; // return a.substring(index); // } // } // // return null; // } // } // // /** // * Gets the value of the '-open' argument. // * @param args the arguments // * @return the value of the '-open' argument or <code> // * null</code> if not found. // */ // public static String getOpenArgument(String args[]) { // return getArgumentValue(args, "-open"); // } // // // } // Path: chameria-launcher/src/test/java/de/akquinet/chameria/services/ActivationUtilsTest.java import org.junit.Assert; import org.junit.Test; import de.akquinet.chameria.services.ActivationUtils; /* * Copyright 2010 akquinet * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.akquinet.chameria.services; public class ActivationUtilsTest { @Test public void testContainsArgument() { String[] args = new String[] { "--foo", "-bar=toto", "dede", "de" };
Assert.assertTrue(ActivationUtils.containsArgument(args, "--foo"));
akquinet/chameRIA
chameria-webview-factory/src/main/java/de/akquinet/chameria/webview/WebViewFactory.java
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/BrowserService.java // public interface BrowserService { // // public static final String SCROLLBAR_AS_NEEDED = "ScrollBarAsNeeded"; // public static final String SCROLLBAR_ALWAYS_ON = "ScrollBarAlwaysOn"; // public static final String SCROLLBAR_ALWAYS_OFF = "ScrollBarAlwaysOff"; // // public boolean isFullScreen(); // // public void setFullScreen(boolean fullscreen); // // public void setURL(String url); // // public String getURL(); // // public void setSize(int width, int height); // // public int getHeight(); // // public int getWidth(); // // public boolean isResizable(); // // public void setResizable(boolean resizable); // // public boolean isMenuBarEnabled(); // // public void setMenuBar(boolean enabled); // // public boolean isContextMenuEnabled(); // // public void setContextMenu(boolean enabled); // // public boolean isPrintSupported(); // // public void setPrintSupport(boolean enabled); // // public boolean isDownloadSupported(); // // public void setDownloadSupport(boolean enabled); // // public boolean isOpenWindowSupported(); // // public void setOpenWindowSupport(boolean enabled); // // public void setHorizontalScrollBarPolicy(String policy); // // public void setVerticalScrollBarPolicy(String policy); // // public String getVerticalScrollBarPolicy(); // // public String getHorizontalScrollBarPolicy(); // // // }
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import org.apache.felix.ipojo.annotations.Component; import org.apache.felix.ipojo.annotations.Invalidate; import org.apache.felix.ipojo.annotations.Property; import org.apache.felix.ipojo.annotations.Provides; import org.apache.felix.ipojo.annotations.Validate; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.trolltech.qt.core.QFile; import com.trolltech.qt.core.QSize; import com.trolltech.qt.core.Qt.ContextMenuPolicy; import com.trolltech.qt.core.Qt.ScrollBarPolicy; import com.trolltech.qt.gui.QApplication; import com.trolltech.qt.gui.QDialog; import com.trolltech.qt.gui.QFileDialog; import com.trolltech.qt.gui.QIcon; import com.trolltech.qt.gui.QPrintDialog; import com.trolltech.qt.gui.QPrinter; import com.trolltech.qt.network.QNetworkProxy; import com.trolltech.qt.network.QNetworkReply; import com.trolltech.qt.webkit.QWebView; import de.akquinet.chameria.services.BrowserService;
/* * Copyright 2010 akquinet * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.akquinet.chameria.webview; /** * Main component of the web view factory. * This component receives the configuration and creates * the browser windows and the web view. * It also has a couple of up-calls to handle the * configuration properly. */ @Component(name="chameria.webview") @Provides
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/BrowserService.java // public interface BrowserService { // // public static final String SCROLLBAR_AS_NEEDED = "ScrollBarAsNeeded"; // public static final String SCROLLBAR_ALWAYS_ON = "ScrollBarAlwaysOn"; // public static final String SCROLLBAR_ALWAYS_OFF = "ScrollBarAlwaysOff"; // // public boolean isFullScreen(); // // public void setFullScreen(boolean fullscreen); // // public void setURL(String url); // // public String getURL(); // // public void setSize(int width, int height); // // public int getHeight(); // // public int getWidth(); // // public boolean isResizable(); // // public void setResizable(boolean resizable); // // public boolean isMenuBarEnabled(); // // public void setMenuBar(boolean enabled); // // public boolean isContextMenuEnabled(); // // public void setContextMenu(boolean enabled); // // public boolean isPrintSupported(); // // public void setPrintSupport(boolean enabled); // // public boolean isDownloadSupported(); // // public void setDownloadSupport(boolean enabled); // // public boolean isOpenWindowSupported(); // // public void setOpenWindowSupport(boolean enabled); // // public void setHorizontalScrollBarPolicy(String policy); // // public void setVerticalScrollBarPolicy(String policy); // // public String getVerticalScrollBarPolicy(); // // public String getHorizontalScrollBarPolicy(); // // // } // Path: chameria-webview-factory/src/main/java/de/akquinet/chameria/webview/WebViewFactory.java import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import org.apache.felix.ipojo.annotations.Component; import org.apache.felix.ipojo.annotations.Invalidate; import org.apache.felix.ipojo.annotations.Property; import org.apache.felix.ipojo.annotations.Provides; import org.apache.felix.ipojo.annotations.Validate; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.trolltech.qt.core.QFile; import com.trolltech.qt.core.QSize; import com.trolltech.qt.core.Qt.ContextMenuPolicy; import com.trolltech.qt.core.Qt.ScrollBarPolicy; import com.trolltech.qt.gui.QApplication; import com.trolltech.qt.gui.QDialog; import com.trolltech.qt.gui.QFileDialog; import com.trolltech.qt.gui.QIcon; import com.trolltech.qt.gui.QPrintDialog; import com.trolltech.qt.gui.QPrinter; import com.trolltech.qt.network.QNetworkProxy; import com.trolltech.qt.network.QNetworkReply; import com.trolltech.qt.webkit.QWebView; import de.akquinet.chameria.services.BrowserService; /* * Copyright 2010 akquinet * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.akquinet.chameria.webview; /** * Main component of the web view factory. * This component receives the configuration and creates * the browser windows and the web view. * It also has a couple of up-calls to handle the * configuration properly. */ @Component(name="chameria.webview") @Provides
public class WebViewFactory implements BrowserService {
akquinet/chameRIA
chameria-launcher/src/test/java/de/akquinet/chameria/activation/bundle/ActivationServiceImpl.java
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationService.java // public interface ActivationService { // // /** // * Method called by the launcher every time the application is activate. // * The given arguments are the launcher argument, and so can contain // * the <code>-open</code> argument. // * @param args the arguments // */ // public void activation(String[] args); // // /** // * Method called by the launcher when the application stops. // */ // public void deactivation(); // // // } // // Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationUtils.java // public class ActivationUtils { // // /** // * Checks if the arguments contains the argument <code>arg</code>. // * @param args the arguments // * @param arg the argument to find // * @return <code>true</code> if the // */ // public static boolean containsArgument(String[] args, String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return false; // } else { // for (String a : args) { // if (a.equalsIgnoreCase(arg)) { // return true; // } else if (a.startsWith(arg + "=")) { // return true; // } // // } // return false; // } // } // // /** // * Gets the argument value. // * <ul> // * <li>for 'arg=value' it returns 'value'</li> // * <li>for 'arg value' it returns 'value'</li> // * @param args the arguments // * @param arg the argument to find // * @return the argument value or <code>null</code> if not found. // */ // public static String getArgumentValue(String args[], String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return null; // } else { // for (int i = 0; i < args.length; i++) { // String a = args[i]; // if (a.equalsIgnoreCase(arg)) { // // Case 'arg value' : Look for arg + 1; // if (args.length > i + 1) { // return args[i+1]; // } // // } else if (a.startsWith(arg + "=")) { // // Case 'arg=value' : Parse the value // int index = a.indexOf('=') + 1; // return a.substring(index); // } // } // // return null; // } // } // // /** // * Gets the value of the '-open' argument. // * @param args the arguments // * @return the value of the '-open' argument or <code> // * null</code> if not found. // */ // public static String getOpenArgument(String args[]) { // return getArgumentValue(args, "-open"); // } // // // }
import java.util.Arrays; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import de.akquinet.chameria.services.ActivationService; import de.akquinet.chameria.services.ActivationUtils;
/* * Copyright 2010 akquinet * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.akquinet.chameria.activation.bundle; public class ActivationServiceImpl implements ActivationService, BundleActivator { private ServiceRegistration reg; public int activation_count = 0; public String[] last_args = null; public String open = null; public void activation(String[] args) { System.out.println("Activation " + Arrays.asList(args)); last_args = args; activation_count ++;
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationService.java // public interface ActivationService { // // /** // * Method called by the launcher every time the application is activate. // * The given arguments are the launcher argument, and so can contain // * the <code>-open</code> argument. // * @param args the arguments // */ // public void activation(String[] args); // // /** // * Method called by the launcher when the application stops. // */ // public void deactivation(); // // // } // // Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationUtils.java // public class ActivationUtils { // // /** // * Checks if the arguments contains the argument <code>arg</code>. // * @param args the arguments // * @param arg the argument to find // * @return <code>true</code> if the // */ // public static boolean containsArgument(String[] args, String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return false; // } else { // for (String a : args) { // if (a.equalsIgnoreCase(arg)) { // return true; // } else if (a.startsWith(arg + "=")) { // return true; // } // // } // return false; // } // } // // /** // * Gets the argument value. // * <ul> // * <li>for 'arg=value' it returns 'value'</li> // * <li>for 'arg value' it returns 'value'</li> // * @param args the arguments // * @param arg the argument to find // * @return the argument value or <code>null</code> if not found. // */ // public static String getArgumentValue(String args[], String arg) { // if (args == null || arg == null || arg.length() == 0 || args.length == 0) { // return null; // } else { // for (int i = 0; i < args.length; i++) { // String a = args[i]; // if (a.equalsIgnoreCase(arg)) { // // Case 'arg value' : Look for arg + 1; // if (args.length > i + 1) { // return args[i+1]; // } // // } else if (a.startsWith(arg + "=")) { // // Case 'arg=value' : Parse the value // int index = a.indexOf('=') + 1; // return a.substring(index); // } // } // // return null; // } // } // // /** // * Gets the value of the '-open' argument. // * @param args the arguments // * @return the value of the '-open' argument or <code> // * null</code> if not found. // */ // public static String getOpenArgument(String args[]) { // return getArgumentValue(args, "-open"); // } // // // } // Path: chameria-launcher/src/test/java/de/akquinet/chameria/activation/bundle/ActivationServiceImpl.java import java.util.Arrays; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import de.akquinet.chameria.services.ActivationService; import de.akquinet.chameria.services.ActivationUtils; /* * Copyright 2010 akquinet * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.akquinet.chameria.activation.bundle; public class ActivationServiceImpl implements ActivationService, BundleActivator { private ServiceRegistration reg; public int activation_count = 0; public String[] last_args = null; public String open = null; public void activation(String[] args) { System.out.println("Activation " + Arrays.asList(args)); last_args = args; activation_count ++;
open = ActivationUtils.getOpenArgument(args);
akquinet/chameRIA
chameria-launcher/src/main/java/de/akquinet/chameria/launcher/ChameRIA.java
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationService.java // public interface ActivationService { // // /** // * Method called by the launcher every time the application is activate. // * The given arguments are the launcher argument, and so can contain // * the <code>-open</code> argument. // * @param args the arguments // */ // public void activation(String[] args); // // /** // * Method called by the launcher when the application stops. // */ // public void deactivation(); // // // }
import org.ow2.chameleon.core.Chameleon; import de.akquinet.chameria.services.ActivationService; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; import org.osgi.framework.launch.Framework;
cache = new File(storage); } return conf; } public static File detectLocation() { String location = System.getProperty(CHAMERIA_INSTALL_LOCATION_PROP); location = SubstVars.substVars(location, CHAMERIA_INSTALL_LOCATION_PROP, null, System .getProperties()); return new File(location); } public Framework start(String[] args) throws BundleException { File lock = new File(cache, ".lock"); if (lock.exists()) { return null; } m_framework = start(); // To avoid race condition for the activation service // this must be synchronized synchronized (this) { try { m_framework.getBundleContext().addServiceListener(new ActivationListener(),
// Path: chameria-service/src/main/java/de/akquinet/chameria/services/ActivationService.java // public interface ActivationService { // // /** // * Method called by the launcher every time the application is activate. // * The given arguments are the launcher argument, and so can contain // * the <code>-open</code> argument. // * @param args the arguments // */ // public void activation(String[] args); // // /** // * Method called by the launcher when the application stops. // */ // public void deactivation(); // // // } // Path: chameria-launcher/src/main/java/de/akquinet/chameria/launcher/ChameRIA.java import org.ow2.chameleon.core.Chameleon; import de.akquinet.chameria.services.ActivationService; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; import org.osgi.framework.launch.Framework; cache = new File(storage); } return conf; } public static File detectLocation() { String location = System.getProperty(CHAMERIA_INSTALL_LOCATION_PROP); location = SubstVars.substVars(location, CHAMERIA_INSTALL_LOCATION_PROP, null, System .getProperties()); return new File(location); } public Framework start(String[] args) throws BundleException { File lock = new File(cache, ".lock"); if (lock.exists()) { return null; } m_framework = start(); // To avoid race condition for the activation service // this must be synchronized synchronized (this) { try { m_framework.getBundleContext().addServiceListener(new ActivationListener(),
"(" + Constants.OBJECTCLASS + "=" + ActivationService.class.getName() + ")");
akquinet/chameRIA
tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/impl/HelloEndpoint.java
// Path: tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/Hello.java // public interface Hello { // // public String hello(String name); // // }
import de.akquinet.chameria.tutorial.hello.Hello; import org.apache.felix.ipojo.annotations.*; import org.osgi.service.http.HttpService; import org.osgi.service.http.NamespaceException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.Writer;
package de.akquinet.chameria.tutorial.hello.impl; /** * A simple servlet invoking the Hello service, and returning the response. * * This components is requiring the Hello Service as well as the HttpService (provided by ChameRIA), to * registers the servlet. */ @Component(immediate = true) @Instantiate public class HelloEndpoint extends HttpServlet { @Requires private HttpService server; @Requires
// Path: tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/Hello.java // public interface Hello { // // public String hello(String name); // // } // Path: tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/impl/HelloEndpoint.java import de.akquinet.chameria.tutorial.hello.Hello; import org.apache.felix.ipojo.annotations.*; import org.osgi.service.http.HttpService; import org.osgi.service.http.NamespaceException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.Writer; package de.akquinet.chameria.tutorial.hello.impl; /** * A simple servlet invoking the Hello service, and returning the response. * * This components is requiring the Hello Service as well as the HttpService (provided by ChameRIA), to * registers the servlet. */ @Component(immediate = true) @Instantiate public class HelloEndpoint extends HttpServlet { @Requires private HttpService server; @Requires
private Hello hello;
akquinet/chameRIA
tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/impl/HelloProvider.java
// Path: tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/Hello.java // public interface Hello { // // public String hello(String name); // // }
import org.apache.felix.ipojo.annotations.Component; import org.apache.felix.ipojo.annotations.Instantiate; import org.apache.felix.ipojo.annotations.Provides; import de.akquinet.chameria.tutorial.hello.Hello;
package de.akquinet.chameria.tutorial.hello.impl; /** * Simple implementation of the Hello service. * * This class is an iPOJO component (http://ipojo.org). So, we can simply register the OSGi service * without touching the OSGi API or being bothered by the OSGi complexity. * * This service will be exposed to the web view using a simple servlet. * */ @Component @Provides @Instantiate(name="helloService1")
// Path: tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/Hello.java // public interface Hello { // // public String hello(String name); // // } // Path: tutorial/hello-world/hello-service/src/main/java/de/akquinet/chameria/tutorial/hello/impl/HelloProvider.java import org.apache.felix.ipojo.annotations.Component; import org.apache.felix.ipojo.annotations.Instantiate; import org.apache.felix.ipojo.annotations.Provides; import de.akquinet.chameria.tutorial.hello.Hello; package de.akquinet.chameria.tutorial.hello.impl; /** * Simple implementation of the Hello service. * * This class is an iPOJO component (http://ipojo.org). So, we can simply register the OSGi service * without touching the OSGi API or being bothered by the OSGi complexity. * * This service will be exposed to the web view using a simple servlet. * */ @Component @Provides @Instantiate(name="helloService1")
public class HelloProvider implements Hello {
eBay/xcelite
src/main/java/com/ebay/xcelite/reader/SheetReader.java
// Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // }
import java.util.Collection; import com.ebay.xcelite.sheet.XceliteSheet;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.reader; public interface SheetReader<T> { /** * Reads the sheet and returns a collection of the specified type. * * @return collection of the specified type */ Collection<T> read(); /** * Whether to skip the first row or not when reading the sheet. * * @param skipHeaderRow true to skip the header row, false otherwise */ void skipHeaderRow(boolean skipHeaderRow); /** * Gets the sheet. * * @return the sheet */
// Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // Path: src/main/java/com/ebay/xcelite/reader/SheetReader.java import java.util.Collection; import com.ebay.xcelite.sheet.XceliteSheet; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.reader; public interface SheetReader<T> { /** * Reads the sheet and returns a collection of the specified type. * * @return collection of the specified type */ Collection<T> read(); /** * Whether to skip the first row or not when reading the sheet. * * @param skipHeaderRow true to skip the header row, false otherwise */ void skipHeaderRow(boolean skipHeaderRow); /** * Gets the sheet. * * @return the sheet */
XceliteSheet getSheet();
eBay/xcelite
src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java
// Path: src/main/java/com/ebay/xcelite/reader/SheetReader.java // public interface SheetReader<T> { // // /** // * Reads the sheet and returns a collection of the specified type. // * // * @return collection of the specified type // */ // Collection<T> read(); // // /** // * Whether to skip the first row or not when reading the sheet. // * // * @param skipHeaderRow true to skip the header row, false otherwise // */ // void skipHeaderRow(boolean skipHeaderRow); // // /** // * Gets the sheet. // * // * @return the sheet // */ // XceliteSheet getSheet(); // // /** // * Adds a row post processor. The row post processors will be executed in // * insertion order. // * // * @param rowPostProcessor the post row processor to add // */ // void addRowPostProcessor(RowPostProcessor<T> rowPostProcessor); // // /** // * Removes a row post processor. // * // * @param rowPostProcessor the post row processor to remove // */ // void removeRowPostProcessor(RowPostProcessor<T> rowPostProcessor); // } // // Path: src/main/java/com/ebay/xcelite/writer/SheetWriter.java // public interface SheetWriter<T> { // // void write(Collection<T> data); // // void generateHeaderRow(boolean generateHeaderRow); // // XceliteSheet getSheet(); // }
import java.io.File; import java.util.Collection; import org.apache.poi.ss.usermodel.Sheet; import com.ebay.xcelite.reader.SheetReader; import com.ebay.xcelite.writer.SheetWriter;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.sheet; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public interface XceliteSheet { <T> SheetWriter<T> getBeanWriter(Class<T> type);
// Path: src/main/java/com/ebay/xcelite/reader/SheetReader.java // public interface SheetReader<T> { // // /** // * Reads the sheet and returns a collection of the specified type. // * // * @return collection of the specified type // */ // Collection<T> read(); // // /** // * Whether to skip the first row or not when reading the sheet. // * // * @param skipHeaderRow true to skip the header row, false otherwise // */ // void skipHeaderRow(boolean skipHeaderRow); // // /** // * Gets the sheet. // * // * @return the sheet // */ // XceliteSheet getSheet(); // // /** // * Adds a row post processor. The row post processors will be executed in // * insertion order. // * // * @param rowPostProcessor the post row processor to add // */ // void addRowPostProcessor(RowPostProcessor<T> rowPostProcessor); // // /** // * Removes a row post processor. // * // * @param rowPostProcessor the post row processor to remove // */ // void removeRowPostProcessor(RowPostProcessor<T> rowPostProcessor); // } // // Path: src/main/java/com/ebay/xcelite/writer/SheetWriter.java // public interface SheetWriter<T> { // // void write(Collection<T> data); // // void generateHeaderRow(boolean generateHeaderRow); // // XceliteSheet getSheet(); // } // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java import java.io.File; import java.util.Collection; import org.apache.poi.ss.usermodel.Sheet; import com.ebay.xcelite.reader.SheetReader; import com.ebay.xcelite.writer.SheetWriter; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.sheet; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public interface XceliteSheet { <T> SheetWriter<T> getBeanWriter(Class<T> type);
<T> SheetReader<T> getBeanReader(Class<T> type);
eBay/xcelite
src/main/java/com/ebay/xcelite/annotations/AnyColumn.java
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a {@link java.util.Map Map} field which represents K/V * as column and value in excel file. * * @author kharel ([email protected]) * @creation_date Oct 24, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface AnyColumn { /** * A converter class to use when serializing/deserializing the date to/from * excel file. Converter class must implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // } // Path: src/main/java/com/ebay/xcelite/annotations/AnyColumn.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a {@link java.util.Map Map} field which represents K/V * as column and value in excel file. * * @author kharel ([email protected]) * @creation_date Oct 24, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface AnyColumn { /** * A converter class to use when serializing/deserializing the date to/from * excel file. Converter class must implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
Class<? extends ColumnValueConverter<?, ?>> converter() default NoConverterClass.class;
eBay/xcelite
src/main/java/com/ebay/xcelite/annotations/AnyColumn.java
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a {@link java.util.Map Map} field which represents K/V * as column and value in excel file. * * @author kharel ([email protected]) * @creation_date Oct 24, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface AnyColumn { /** * A converter class to use when serializing/deserializing the date to/from * excel file. Converter class must implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // } // Path: src/main/java/com/ebay/xcelite/annotations/AnyColumn.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a {@link java.util.Map Map} field which represents K/V * as column and value in excel file. * * @author kharel ([email protected]) * @creation_date Oct 24, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface AnyColumn { /** * A converter class to use when serializing/deserializing the date to/from * excel file. Converter class must implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
Class<? extends ColumnValueConverter<?, ?>> converter() default NoConverterClass.class;
eBay/xcelite
src/main/java/com/ebay/xcelite/column/Col.java
// Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // }
import com.ebay.xcelite.converters.ColumnValueConverter;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.column; /** * Represents a Column object which holds all data about the Excel column. * * @author kharel ([email protected]) * @creation_date Aug 29, 2013 * */ public class Col implements Comparable<Col> { private final String name; private String fieldName; private Class<?> type; private String dataFormat;
// Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // } // Path: src/main/java/com/ebay/xcelite/column/Col.java import com.ebay.xcelite.converters.ColumnValueConverter; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.column; /** * Represents a Column object which holds all data about the Excel column. * * @author kharel ([email protected]) * @creation_date Aug 29, 2013 * */ public class Col implements Comparable<Col> { private final String name; private String fieldName; private Class<?> type; private String dataFormat;
private Class<? extends ColumnValueConverter<?, ?>> converter;
eBay/xcelite
src/main/java/com/ebay/xcelite/annotations/Column.java
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a field to represent a column in excel file. * * @author kharel ([email protected]) * @creation_date Aug 29, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface Column { /** * The actual name of the column that will be written to excel file. If no * name specified, the annotated field name will be taken. */ String name() default ""; /** * If true, ignores the actual field type and serializes the field value as * String. Otherwise, uses the actual field type when writing the data. */ boolean ignoreType() default false; /** * The cell format to use when writing the data to excel file. Default is no * format. */ String dataFormat() default ""; /** * Converter class to use when serializing/deserializing the data. Class must * implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // } // Path: src/main/java/com/ebay/xcelite/annotations/Column.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a field to represent a column in excel file. * * @author kharel ([email protected]) * @creation_date Aug 29, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface Column { /** * The actual name of the column that will be written to excel file. If no * name specified, the annotated field name will be taken. */ String name() default ""; /** * If true, ignores the actual field type and serializes the field value as * String. Otherwise, uses the actual field type when writing the data. */ boolean ignoreType() default false; /** * The cell format to use when writing the data to excel file. Default is no * format. */ String dataFormat() default ""; /** * Converter class to use when serializing/deserializing the data. Class must * implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
Class<? extends ColumnValueConverter<?, ?>> converter() default NoConverterClass.class;
eBay/xcelite
src/main/java/com/ebay/xcelite/annotations/Column.java
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // }
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a field to represent a column in excel file. * * @author kharel ([email protected]) * @creation_date Aug 29, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface Column { /** * The actual name of the column that will be written to excel file. If no * name specified, the annotated field name will be taken. */ String name() default ""; /** * If true, ignores the actual field type and serializes the field value as * String. Otherwise, uses the actual field type when writing the data. */ boolean ignoreType() default false; /** * The cell format to use when writing the data to excel file. Default is no * format. */ String dataFormat() default ""; /** * Converter class to use when serializing/deserializing the data. Class must * implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/converters/ColumnValueConverter.java // public interface ColumnValueConverter<T, V> { // // /** // * Serializes given value to a different type. // * // * @param value the value to serialize // * @return the serialized value // */ // T serialize(V value); // // /** // * Deserializes given value to a different type. // * // * @param value the value to deserialize // * @return the deserialized value // */ // V deserialize(T value); // } // Path: src/main/java/com/ebay/xcelite/annotations/Column.java import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.converters.ColumnValueConverter; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.annotations; /** * Annotation to annotate a field to represent a column in excel file. * * @author kharel ([email protected]) * @creation_date Aug 29, 2013 * */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD }) public @interface Column { /** * The actual name of the column that will be written to excel file. If no * name specified, the annotated field name will be taken. */ String name() default ""; /** * If true, ignores the actual field type and serializes the field value as * String. Otherwise, uses the actual field type when writing the data. */ boolean ignoreType() default false; /** * The cell format to use when writing the data to excel file. Default is no * format. */ String dataFormat() default ""; /** * Converter class to use when serializing/deserializing the data. Class must * implement * {@link com.ebay.xcelite.converters.ColumnValueConverter * ColumnValueConverter}. Default is no converter. */
Class<? extends ColumnValueConverter<?, ?>> converter() default NoConverterClass.class;
eBay/xcelite
src/main/java/com/ebay/xcelite/utils/diff/report/ReportInfo.java
// Path: src/main/java/com/ebay/xcelite/utils/diff/info/Collections.java // public class Collections<T> { // // private final Collection<T> a; // private final Collection<T> b; // private final Collection<T> difference; // // public Collections(Collection<T> a, Collection<T> b, Collection<T> difference) { // this.a = a; // this.b = b; // this.difference = difference; // } // // public Collection<T> a() { // return a; // } // // public Collection<T> b() { // return b; // } // // public Collection<T> difference() { // return difference; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Files.java // public class Files { // // private final String aFile; // private final String bFile; // // public Files(String aFile, String bFile) { // this.aFile = aFile; // this.bFile = bFile; // } // // public String aFile() { // return aFile; // } // // public String bFile() { // return bFile; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Info.java // public interface Info<T> { // // Files files(); // Sheets sheets(); // Collections<T> collections(); // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Sheets.java // public class Sheets { // // private final String aSheetname; // private final String bSheetname; // // public Sheets(String aSheetname, String bSheetname) { // this.aSheetname = aSheetname; // this.bSheetname = bSheetname; // } // // public String aSheetname() { // return aSheetname; // } // // public String bSheetname() { // return bSheetname; // } // }
import com.ebay.xcelite.utils.diff.info.Collections; import com.ebay.xcelite.utils.diff.info.Files; import com.ebay.xcelite.utils.diff.info.Info; import com.ebay.xcelite.utils.diff.info.Sheets;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.utils.diff.report; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 21, 2013 * */ public class ReportInfo<T> implements Info<T> { private final Files files;
// Path: src/main/java/com/ebay/xcelite/utils/diff/info/Collections.java // public class Collections<T> { // // private final Collection<T> a; // private final Collection<T> b; // private final Collection<T> difference; // // public Collections(Collection<T> a, Collection<T> b, Collection<T> difference) { // this.a = a; // this.b = b; // this.difference = difference; // } // // public Collection<T> a() { // return a; // } // // public Collection<T> b() { // return b; // } // // public Collection<T> difference() { // return difference; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Files.java // public class Files { // // private final String aFile; // private final String bFile; // // public Files(String aFile, String bFile) { // this.aFile = aFile; // this.bFile = bFile; // } // // public String aFile() { // return aFile; // } // // public String bFile() { // return bFile; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Info.java // public interface Info<T> { // // Files files(); // Sheets sheets(); // Collections<T> collections(); // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Sheets.java // public class Sheets { // // private final String aSheetname; // private final String bSheetname; // // public Sheets(String aSheetname, String bSheetname) { // this.aSheetname = aSheetname; // this.bSheetname = bSheetname; // } // // public String aSheetname() { // return aSheetname; // } // // public String bSheetname() { // return bSheetname; // } // } // Path: src/main/java/com/ebay/xcelite/utils/diff/report/ReportInfo.java import com.ebay.xcelite.utils.diff.info.Collections; import com.ebay.xcelite.utils.diff.info.Files; import com.ebay.xcelite.utils.diff.info.Info; import com.ebay.xcelite.utils.diff.info.Sheets; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.utils.diff.report; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 21, 2013 * */ public class ReportInfo<T> implements Info<T> { private final Files files;
private final Sheets sheets;
eBay/xcelite
src/main/java/com/ebay/xcelite/utils/diff/report/ReportInfo.java
// Path: src/main/java/com/ebay/xcelite/utils/diff/info/Collections.java // public class Collections<T> { // // private final Collection<T> a; // private final Collection<T> b; // private final Collection<T> difference; // // public Collections(Collection<T> a, Collection<T> b, Collection<T> difference) { // this.a = a; // this.b = b; // this.difference = difference; // } // // public Collection<T> a() { // return a; // } // // public Collection<T> b() { // return b; // } // // public Collection<T> difference() { // return difference; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Files.java // public class Files { // // private final String aFile; // private final String bFile; // // public Files(String aFile, String bFile) { // this.aFile = aFile; // this.bFile = bFile; // } // // public String aFile() { // return aFile; // } // // public String bFile() { // return bFile; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Info.java // public interface Info<T> { // // Files files(); // Sheets sheets(); // Collections<T> collections(); // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Sheets.java // public class Sheets { // // private final String aSheetname; // private final String bSheetname; // // public Sheets(String aSheetname, String bSheetname) { // this.aSheetname = aSheetname; // this.bSheetname = bSheetname; // } // // public String aSheetname() { // return aSheetname; // } // // public String bSheetname() { // return bSheetname; // } // }
import com.ebay.xcelite.utils.diff.info.Collections; import com.ebay.xcelite.utils.diff.info.Files; import com.ebay.xcelite.utils.diff.info.Info; import com.ebay.xcelite.utils.diff.info.Sheets;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.utils.diff.report; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 21, 2013 * */ public class ReportInfo<T> implements Info<T> { private final Files files; private final Sheets sheets;
// Path: src/main/java/com/ebay/xcelite/utils/diff/info/Collections.java // public class Collections<T> { // // private final Collection<T> a; // private final Collection<T> b; // private final Collection<T> difference; // // public Collections(Collection<T> a, Collection<T> b, Collection<T> difference) { // this.a = a; // this.b = b; // this.difference = difference; // } // // public Collection<T> a() { // return a; // } // // public Collection<T> b() { // return b; // } // // public Collection<T> difference() { // return difference; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Files.java // public class Files { // // private final String aFile; // private final String bFile; // // public Files(String aFile, String bFile) { // this.aFile = aFile; // this.bFile = bFile; // } // // public String aFile() { // return aFile; // } // // public String bFile() { // return bFile; // } // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Info.java // public interface Info<T> { // // Files files(); // Sheets sheets(); // Collections<T> collections(); // } // // Path: src/main/java/com/ebay/xcelite/utils/diff/info/Sheets.java // public class Sheets { // // private final String aSheetname; // private final String bSheetname; // // public Sheets(String aSheetname, String bSheetname) { // this.aSheetname = aSheetname; // this.bSheetname = bSheetname; // } // // public String aSheetname() { // return aSheetname; // } // // public String bSheetname() { // return bSheetname; // } // } // Path: src/main/java/com/ebay/xcelite/utils/diff/report/ReportInfo.java import com.ebay.xcelite.utils.diff.info.Collections; import com.ebay.xcelite.utils.diff.info.Files; import com.ebay.xcelite.utils.diff.info.Info; import com.ebay.xcelite.utils.diff.info.Sheets; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.utils.diff.report; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 21, 2013 * */ public class ReportInfo<T> implements Info<T> { private final Files files; private final Sheets sheets;
private final Collections<T> collections;
eBay/xcelite
src/main/java/com/ebay/xcelite/writer/SheetWriter.java
// Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // }
import java.util.Collection; import com.ebay.xcelite.sheet.XceliteSheet;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.writer; public interface SheetWriter<T> { void write(Collection<T> data); void generateHeaderRow(boolean generateHeaderRow);
// Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // Path: src/main/java/com/ebay/xcelite/writer/SheetWriter.java import java.util.Collection; import com.ebay.xcelite.sheet.XceliteSheet; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.writer; public interface SheetWriter<T> { void write(Collection<T> data); void generateHeaderRow(boolean generateHeaderRow);
XceliteSheet getSheet();
eBay/xcelite
src/main/java/com/ebay/xcelite/writer/SimpleSheetWriter.java
// Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/styles/CellStylesBank.java // public final class CellStylesBank { // // private static Map<Workbook, CellStyles> cellStylesMap; // // static { // cellStylesMap = Maps.newHashMap(); // } // // public static CellStyles get(Workbook workbook) { // if (cellStylesMap.containsKey(workbook)) { // return cellStylesMap.get(workbook); // } // CellStyles cellStyles = new CellStyles(workbook); // cellStylesMap.put(workbook, cellStyles); // return cellStyles; // } // }
import java.util.Collection; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.styles.CellStylesBank;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.writer; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 10, 2013 * */ public class SimpleSheetWriter extends SheetWriterAbs<Collection<Object>> { public SimpleSheetWriter(XceliteSheet sheet) { super(sheet, false); } @Override public void write(Collection<Collection<Object>> data) { int i = 0; for (Collection<Object> row : data) { Row excelRow = sheet.getNativeSheet().createRow(i); int j = 0; for (Object column : row) { Cell cell = excelRow.createCell(j); if (writeHeader && i == 0) {
// Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/styles/CellStylesBank.java // public final class CellStylesBank { // // private static Map<Workbook, CellStyles> cellStylesMap; // // static { // cellStylesMap = Maps.newHashMap(); // } // // public static CellStyles get(Workbook workbook) { // if (cellStylesMap.containsKey(workbook)) { // return cellStylesMap.get(workbook); // } // CellStyles cellStyles = new CellStyles(workbook); // cellStylesMap.put(workbook, cellStyles); // return cellStyles; // } // } // Path: src/main/java/com/ebay/xcelite/writer/SimpleSheetWriter.java import java.util.Collection; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.styles.CellStylesBank; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite.writer; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 10, 2013 * */ public class SimpleSheetWriter extends SheetWriterAbs<Collection<Object>> { public SimpleSheetWriter(XceliteSheet sheet) { super(sheet, false); } @Override public void write(Collection<Collection<Object>> data) { int i = 0; for (Collection<Object> row : data) { Row excelRow = sheet.getNativeSheet().createRow(i); int j = 0; for (Object column : row) { Cell cell = excelRow.createCell(j); if (writeHeader && i == 0) {
cell.setCellStyle(CellStylesBank.get(sheet.getNativeSheet().getWorkbook()).getBoldStyle());
eBay/xcelite
src/main/java/com/ebay/xcelite/Xcelite.java
// Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheetImpl.java // public class XceliteSheetImpl implements XceliteSheet { // // private final Sheet sheet; // private final File file; // // public XceliteSheetImpl(Sheet sheet) { // this(sheet, null); // } // // public XceliteSheetImpl(Sheet sheet, File file) { // this.sheet = sheet; // this.file = file; // } // // @Override // public Sheet getNativeSheet() { // return sheet; // } // // @Override // public File getFile() { // return file; // } // // @Override // public <T> SheetWriter<T> getBeanWriter(Class<T> type) { // return new BeanSheetWriter<T>(this, type); // } // // @Override // public <T> SheetReader<T> getBeanReader(Class<T> type) { // return new BeanSheetReader<T>(this, type); // } // // @Override // public SimpleSheetWriter getSimpleWriter() { // return new SimpleSheetWriter(this); // } // // @Override // public SheetReader<Collection<Object>> getSimpleReader() { // return new SimpleSheetReader(this); // } // }
import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ebay.xcelite.exceptions.XceliteException; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.sheet.XceliteSheetImpl;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public class Xcelite { private final Workbook workbook; private File file; public Xcelite() { workbook = new XSSFWorkbook(); } public Xcelite(File file) { try { this.file = file; workbook = new XSSFWorkbook(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } /** * Creates new sheet. * * @return XceliteSheet object */
// Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheetImpl.java // public class XceliteSheetImpl implements XceliteSheet { // // private final Sheet sheet; // private final File file; // // public XceliteSheetImpl(Sheet sheet) { // this(sheet, null); // } // // public XceliteSheetImpl(Sheet sheet, File file) { // this.sheet = sheet; // this.file = file; // } // // @Override // public Sheet getNativeSheet() { // return sheet; // } // // @Override // public File getFile() { // return file; // } // // @Override // public <T> SheetWriter<T> getBeanWriter(Class<T> type) { // return new BeanSheetWriter<T>(this, type); // } // // @Override // public <T> SheetReader<T> getBeanReader(Class<T> type) { // return new BeanSheetReader<T>(this, type); // } // // @Override // public SimpleSheetWriter getSimpleWriter() { // return new SimpleSheetWriter(this); // } // // @Override // public SheetReader<Collection<Object>> getSimpleReader() { // return new SimpleSheetReader(this); // } // } // Path: src/main/java/com/ebay/xcelite/Xcelite.java import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ebay.xcelite.exceptions.XceliteException; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.sheet.XceliteSheetImpl; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public class Xcelite { private final Workbook workbook; private File file; public Xcelite() { workbook = new XSSFWorkbook(); } public Xcelite(File file) { try { this.file = file; workbook = new XSSFWorkbook(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } /** * Creates new sheet. * * @return XceliteSheet object */
public XceliteSheet createSheet() {
eBay/xcelite
src/main/java/com/ebay/xcelite/Xcelite.java
// Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheetImpl.java // public class XceliteSheetImpl implements XceliteSheet { // // private final Sheet sheet; // private final File file; // // public XceliteSheetImpl(Sheet sheet) { // this(sheet, null); // } // // public XceliteSheetImpl(Sheet sheet, File file) { // this.sheet = sheet; // this.file = file; // } // // @Override // public Sheet getNativeSheet() { // return sheet; // } // // @Override // public File getFile() { // return file; // } // // @Override // public <T> SheetWriter<T> getBeanWriter(Class<T> type) { // return new BeanSheetWriter<T>(this, type); // } // // @Override // public <T> SheetReader<T> getBeanReader(Class<T> type) { // return new BeanSheetReader<T>(this, type); // } // // @Override // public SimpleSheetWriter getSimpleWriter() { // return new SimpleSheetWriter(this); // } // // @Override // public SheetReader<Collection<Object>> getSimpleReader() { // return new SimpleSheetReader(this); // } // }
import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ebay.xcelite.exceptions.XceliteException; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.sheet.XceliteSheetImpl;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public class Xcelite { private final Workbook workbook; private File file; public Xcelite() { workbook = new XSSFWorkbook(); } public Xcelite(File file) { try { this.file = file; workbook = new XSSFWorkbook(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } /** * Creates new sheet. * * @return XceliteSheet object */ public XceliteSheet createSheet() {
// Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheetImpl.java // public class XceliteSheetImpl implements XceliteSheet { // // private final Sheet sheet; // private final File file; // // public XceliteSheetImpl(Sheet sheet) { // this(sheet, null); // } // // public XceliteSheetImpl(Sheet sheet, File file) { // this.sheet = sheet; // this.file = file; // } // // @Override // public Sheet getNativeSheet() { // return sheet; // } // // @Override // public File getFile() { // return file; // } // // @Override // public <T> SheetWriter<T> getBeanWriter(Class<T> type) { // return new BeanSheetWriter<T>(this, type); // } // // @Override // public <T> SheetReader<T> getBeanReader(Class<T> type) { // return new BeanSheetReader<T>(this, type); // } // // @Override // public SimpleSheetWriter getSimpleWriter() { // return new SimpleSheetWriter(this); // } // // @Override // public SheetReader<Collection<Object>> getSimpleReader() { // return new SimpleSheetReader(this); // } // } // Path: src/main/java/com/ebay/xcelite/Xcelite.java import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ebay.xcelite.exceptions.XceliteException; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.sheet.XceliteSheetImpl; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public class Xcelite { private final Workbook workbook; private File file; public Xcelite() { workbook = new XSSFWorkbook(); } public Xcelite(File file) { try { this.file = file; workbook = new XSSFWorkbook(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } /** * Creates new sheet. * * @return XceliteSheet object */ public XceliteSheet createSheet() {
return new XceliteSheetImpl(workbook.createSheet(), file);
eBay/xcelite
src/main/java/com/ebay/xcelite/Xcelite.java
// Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheetImpl.java // public class XceliteSheetImpl implements XceliteSheet { // // private final Sheet sheet; // private final File file; // // public XceliteSheetImpl(Sheet sheet) { // this(sheet, null); // } // // public XceliteSheetImpl(Sheet sheet, File file) { // this.sheet = sheet; // this.file = file; // } // // @Override // public Sheet getNativeSheet() { // return sheet; // } // // @Override // public File getFile() { // return file; // } // // @Override // public <T> SheetWriter<T> getBeanWriter(Class<T> type) { // return new BeanSheetWriter<T>(this, type); // } // // @Override // public <T> SheetReader<T> getBeanReader(Class<T> type) { // return new BeanSheetReader<T>(this, type); // } // // @Override // public SimpleSheetWriter getSimpleWriter() { // return new SimpleSheetWriter(this); // } // // @Override // public SheetReader<Collection<Object>> getSimpleReader() { // return new SimpleSheetReader(this); // } // }
import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ebay.xcelite.exceptions.XceliteException; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.sheet.XceliteSheetImpl;
/* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public class Xcelite { private final Workbook workbook; private File file; public Xcelite() { workbook = new XSSFWorkbook(); } public Xcelite(File file) { try { this.file = file; workbook = new XSSFWorkbook(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } /** * Creates new sheet. * * @return XceliteSheet object */ public XceliteSheet createSheet() { return new XceliteSheetImpl(workbook.createSheet(), file); } /** * Creates new sheet with specified name. * * @param name the sheet name * * @return XceliteSheet object */ public XceliteSheet createSheet(String name) { return new XceliteSheetImpl(workbook.createSheet(name), file); } /** * Gets the sheet at the specified index. * * @param sheetIndex the sheet index * @return XceliteSheet object */ public XceliteSheet getSheet(int sheetIndex) { Sheet sheet = workbook.getSheetAt(sheetIndex); if (sheet == null) {
// Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheet.java // public interface XceliteSheet { // // <T> SheetWriter<T> getBeanWriter(Class<T> type); // <T> SheetReader<T> getBeanReader(Class<T> type); // SheetWriter<Collection<Object>> getSimpleWriter(); // SheetReader<Collection<Object>> getSimpleReader(); // Sheet getNativeSheet(); // File getFile(); // } // // Path: src/main/java/com/ebay/xcelite/sheet/XceliteSheetImpl.java // public class XceliteSheetImpl implements XceliteSheet { // // private final Sheet sheet; // private final File file; // // public XceliteSheetImpl(Sheet sheet) { // this(sheet, null); // } // // public XceliteSheetImpl(Sheet sheet, File file) { // this.sheet = sheet; // this.file = file; // } // // @Override // public Sheet getNativeSheet() { // return sheet; // } // // @Override // public File getFile() { // return file; // } // // @Override // public <T> SheetWriter<T> getBeanWriter(Class<T> type) { // return new BeanSheetWriter<T>(this, type); // } // // @Override // public <T> SheetReader<T> getBeanReader(Class<T> type) { // return new BeanSheetReader<T>(this, type); // } // // @Override // public SimpleSheetWriter getSimpleWriter() { // return new SimpleSheetWriter(this); // } // // @Override // public SheetReader<Collection<Object>> getSimpleReader() { // return new SimpleSheetReader(this); // } // } // Path: src/main/java/com/ebay/xcelite/Xcelite.java import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.ebay.xcelite.exceptions.XceliteException; import com.ebay.xcelite.sheet.XceliteSheet; import com.ebay.xcelite.sheet.XceliteSheetImpl; /* Copyright [2013-2014] eBay Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.ebay.xcelite; /** * Class description... * * @author kharel ([email protected]) * @creation_date Nov 9, 2013 * */ public class Xcelite { private final Workbook workbook; private File file; public Xcelite() { workbook = new XSSFWorkbook(); } public Xcelite(File file) { try { this.file = file; workbook = new XSSFWorkbook(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } /** * Creates new sheet. * * @return XceliteSheet object */ public XceliteSheet createSheet() { return new XceliteSheetImpl(workbook.createSheet(), file); } /** * Creates new sheet with specified name. * * @param name the sheet name * * @return XceliteSheet object */ public XceliteSheet createSheet(String name) { return new XceliteSheetImpl(workbook.createSheet(name), file); } /** * Gets the sheet at the specified index. * * @param sheetIndex the sheet index * @return XceliteSheet object */ public XceliteSheet getSheet(int sheetIndex) { Sheet sheet = workbook.getSheetAt(sheetIndex); if (sheet == null) {
throw new XceliteException(String.format("Could not find sheet at index %s", sheetIndex));
eBay/xcelite
src/main/java/com/ebay/xcelite/column/ColumnsExtractor.java
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // }
import com.google.common.collect.Sets; import static org.reflections.ReflectionUtils.withAnnotation; import java.lang.reflect.Field; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.reflections.ReflectionUtils; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.annotations.AnyColumn; import com.ebay.xcelite.annotations.Column; import com.ebay.xcelite.annotations.Row; import com.ebay.xcelite.exceptions.XceliteException; import com.google.common.collect.Maps;
private void columnsOrdering() { Row rowAnnotation = type.getAnnotation(Row.class); if (rowAnnotation == null || rowAnnotation.colsOrder() == null || rowAnnotation.colsOrder().length == 0) return; colsOrdering = Sets.newLinkedHashSet(); for (String column : rowAnnotation.colsOrder()) { colsOrdering.add(new Col(column)); } } @SuppressWarnings("unchecked") public void extract() { Set<Field> columnFields = ReflectionUtils.getAllFields(type, withAnnotation(Column.class)); for (Field columnField : columnFields) { Column annotation = columnField.getAnnotation(Column.class); Col col = null; if (annotation.name().isEmpty()) { col = new Col(columnField.getName(), columnField.getName()); } else { col = new Col(annotation.name(), columnField.getName()); } if (annotation.ignoreType()) { col.setType(String.class); } else { col.setType(columnField.getType()); } if (!annotation.dataFormat().isEmpty()) { col.setDataFormat(annotation.dataFormat()); }
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // Path: src/main/java/com/ebay/xcelite/column/ColumnsExtractor.java import com.google.common.collect.Sets; import static org.reflections.ReflectionUtils.withAnnotation; import java.lang.reflect.Field; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.reflections.ReflectionUtils; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.annotations.AnyColumn; import com.ebay.xcelite.annotations.Column; import com.ebay.xcelite.annotations.Row; import com.ebay.xcelite.exceptions.XceliteException; import com.google.common.collect.Maps; private void columnsOrdering() { Row rowAnnotation = type.getAnnotation(Row.class); if (rowAnnotation == null || rowAnnotation.colsOrder() == null || rowAnnotation.colsOrder().length == 0) return; colsOrdering = Sets.newLinkedHashSet(); for (String column : rowAnnotation.colsOrder()) { colsOrdering.add(new Col(column)); } } @SuppressWarnings("unchecked") public void extract() { Set<Field> columnFields = ReflectionUtils.getAllFields(type, withAnnotation(Column.class)); for (Field columnField : columnFields) { Column annotation = columnField.getAnnotation(Column.class); Col col = null; if (annotation.name().isEmpty()) { col = new Col(columnField.getName(), columnField.getName()); } else { col = new Col(annotation.name(), columnField.getName()); } if (annotation.ignoreType()) { col.setType(String.class); } else { col.setType(columnField.getType()); } if (!annotation.dataFormat().isEmpty()) { col.setDataFormat(annotation.dataFormat()); }
if (annotation.converter() != NoConverterClass.class) {
eBay/xcelite
src/main/java/com/ebay/xcelite/column/ColumnsExtractor.java
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // }
import com.google.common.collect.Sets; import static org.reflections.ReflectionUtils.withAnnotation; import java.lang.reflect.Field; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.reflections.ReflectionUtils; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.annotations.AnyColumn; import com.ebay.xcelite.annotations.Column; import com.ebay.xcelite.annotations.Row; import com.ebay.xcelite.exceptions.XceliteException; import com.google.common.collect.Maps;
} else { col = new Col(annotation.name(), columnField.getName()); } if (annotation.ignoreType()) { col.setType(String.class); } else { col.setType(columnField.getType()); } if (!annotation.dataFormat().isEmpty()) { col.setDataFormat(annotation.dataFormat()); } if (annotation.converter() != NoConverterClass.class) { col.setConverter(annotation.converter()); } columns.add(col); } if (colsOrdering != null) { orderColumns(); } extractAnyColumn(); } @SuppressWarnings("unchecked") private void extractAnyColumn() { Set<Field> anyColumnFields = ReflectionUtils.getAllFields(type, withAnnotation(AnyColumn.class)); if (anyColumnFields.size() > 0) { if (anyColumnFields.size() > 1) {
// Path: src/main/java/com/ebay/xcelite/annotate/NoConverterClass.java // public final class NoConverterClass implements ColumnValueConverter<Object, Object> { // // @Override // public Object serialize(Object value) { // return value; // } // // @Override // public Object deserialize(Object value) { // return value; // } // } // // Path: src/main/java/com/ebay/xcelite/exceptions/XceliteException.java // public class XceliteException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public XceliteException(String message) { // super(message); // } // // public XceliteException(Exception exception) { // super(exception); // } // // public XceliteException(String message, Exception exception) { // super(message, exception); // } // } // Path: src/main/java/com/ebay/xcelite/column/ColumnsExtractor.java import com.google.common.collect.Sets; import static org.reflections.ReflectionUtils.withAnnotation; import java.lang.reflect.Field; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.reflections.ReflectionUtils; import com.ebay.xcelite.annotate.NoConverterClass; import com.ebay.xcelite.annotations.AnyColumn; import com.ebay.xcelite.annotations.Column; import com.ebay.xcelite.annotations.Row; import com.ebay.xcelite.exceptions.XceliteException; import com.google.common.collect.Maps; } else { col = new Col(annotation.name(), columnField.getName()); } if (annotation.ignoreType()) { col.setType(String.class); } else { col.setType(columnField.getType()); } if (!annotation.dataFormat().isEmpty()) { col.setDataFormat(annotation.dataFormat()); } if (annotation.converter() != NoConverterClass.class) { col.setConverter(annotation.converter()); } columns.add(col); } if (colsOrdering != null) { orderColumns(); } extractAnyColumn(); } @SuppressWarnings("unchecked") private void extractAnyColumn() { Set<Field> anyColumnFields = ReflectionUtils.getAllFields(type, withAnnotation(AnyColumn.class)); if (anyColumnFields.size() > 0) { if (anyColumnFields.size() > 1) {
throw new XceliteException("Multiple AnyColumn fields are not allowed");
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/config/ConfigHandler.java
// Path: src/main/java/com/dta/extracarts/Module.java // public abstract class Module { // private Boolean isActive = true; // // public abstract String getModuleName(); // // public Boolean areRequirementsMet() { // return true; // } // // public void setIsActive(Boolean isActive) { // this.isActive = isActive; // } // // public Boolean getIsActive() { // return isActive; // } // // public void init(FMLPreInitializationEvent event) {} // public void load(FMLInitializationEvent event) {} // public void postInit(FMLPostInitializationEvent event) {} // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // }
import java.io.File; import com.dta.extracarts.Module; import net.minecraftforge.common.config.Configuration; import com.dta.extracarts.ModInfo;
package com.dta.extracarts.config; public class ConfigHandler { public static File configFile = null; public static void init(){ Configuration config = new Configuration(configFile); config.load();
// Path: src/main/java/com/dta/extracarts/Module.java // public abstract class Module { // private Boolean isActive = true; // // public abstract String getModuleName(); // // public Boolean areRequirementsMet() { // return true; // } // // public void setIsActive(Boolean isActive) { // this.isActive = isActive; // } // // public Boolean getIsActive() { // return isActive; // } // // public void init(FMLPreInitializationEvent event) {} // public void load(FMLInitializationEvent event) {} // public void postInit(FMLPostInitializationEvent event) {} // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java import java.io.File; import com.dta.extracarts.Module; import net.minecraftforge.common.config.Configuration; import com.dta.extracarts.ModInfo; package com.dta.extracarts.config; public class ConfigHandler { public static File configFile = null; public static void init(){ Configuration config = new Configuration(configFile); config.load();
for(Module module: ModInfo.getModules()) {
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/config/ConfigHandler.java
// Path: src/main/java/com/dta/extracarts/Module.java // public abstract class Module { // private Boolean isActive = true; // // public abstract String getModuleName(); // // public Boolean areRequirementsMet() { // return true; // } // // public void setIsActive(Boolean isActive) { // this.isActive = isActive; // } // // public Boolean getIsActive() { // return isActive; // } // // public void init(FMLPreInitializationEvent event) {} // public void load(FMLInitializationEvent event) {} // public void postInit(FMLPostInitializationEvent event) {} // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // }
import java.io.File; import com.dta.extracarts.Module; import net.minecraftforge.common.config.Configuration; import com.dta.extracarts.ModInfo;
package com.dta.extracarts.config; public class ConfigHandler { public static File configFile = null; public static void init(){ Configuration config = new Configuration(configFile); config.load();
// Path: src/main/java/com/dta/extracarts/Module.java // public abstract class Module { // private Boolean isActive = true; // // public abstract String getModuleName(); // // public Boolean areRequirementsMet() { // return true; // } // // public void setIsActive(Boolean isActive) { // this.isActive = isActive; // } // // public Boolean getIsActive() { // return isActive; // } // // public void init(FMLPreInitializationEvent event) {} // public void load(FMLInitializationEvent event) {} // public void postInit(FMLPostInitializationEvent event) {} // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java import java.io.File; import com.dta.extracarts.Module; import net.minecraftforge.common.config.Configuration; import com.dta.extracarts.ModInfo; package com.dta.extracarts.config; public class ConfigHandler { public static File configFile = null; public static void init(){ Configuration config = new Configuration(configFile); config.load();
for(Module module: ModInfo.getModules()) {
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ModInfo.java
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // }
import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList;
package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) {
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // } // Path: src/main/java/com/dta/extracarts/ModInfo.java import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList; package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) {
MODULES_ENABLED.add(new BaseModule());
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ModInfo.java
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // }
import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList;
package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) { MODULES_ENABLED.add(new BaseModule());
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // } // Path: src/main/java/com/dta/extracarts/ModInfo.java import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList; package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) { MODULES_ENABLED.add(new BaseModule());
MODULES_ENABLED.add(new IronChestModule());
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ModInfo.java
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // }
import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList;
package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) { MODULES_ENABLED.add(new BaseModule()); MODULES_ENABLED.add(new IronChestModule());
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // } // Path: src/main/java/com/dta/extracarts/ModInfo.java import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList; package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) { MODULES_ENABLED.add(new BaseModule()); MODULES_ENABLED.add(new IronChestModule());
MODULES_ENABLED.add(new MFRModule());
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ModInfo.java
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // }
import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList;
package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) { MODULES_ENABLED.add(new BaseModule()); MODULES_ENABLED.add(new IronChestModule()); MODULES_ENABLED.add(new MFRModule());
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java // public class IronChestModule extends Module { // @Override // public String getModuleName() { // return "IronChest"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("IronChest"); // } // // @Override // public void load(FMLInitializationEvent event) { // MinecraftForge.EVENT_BUS.register(new ECEventHandler()); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // IronChestItems.init(); // IronChestItems.registerItems(); // IronChestItems.registerRecipes(); // IronChestEntities.init(); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/MinechemModule.java // public class MinechemModule extends Module { // // public static Item itemLeadedChestCart; // public static Block leadedChest; // // @Override // public String getModuleName() { // return "MineChem"; // } // // @Override // public Boolean areRequirementsMet() { // return Loader.isModLoaded("minechem"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // itemLeadedChestCart = new ItemLeadedChestCart(); // GameRegistry.registerItem(itemLeadedChestCart, ModInfo.MODID + "_" + itemLeadedChestCart.getUnlocalizedName().substring(5)); // leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // GameRegistry.addShapelessRecipe(new ItemStack(itemLeadedChestCart, 1, 0), new ItemStack(leadedChest, 1, 0), Items.minecart); // EntityRegistry.registerModEntity(EntityLeadedChestCart.class, "EntityLeadChestCart", 10, ExtraCarts.instance, 80, 3, true); // } // } // Path: src/main/java/com/dta/extracarts/ModInfo.java import com.dta.extracarts.mods.base.BaseModule; import com.dta.extracarts.mods.ironchest.IronChestModule; import com.dta.extracarts.mods.mfr.MFRModule; import com.dta.extracarts.mods.minechem.MinechemModule; import java.util.ArrayList; package com.dta.extracarts; public class ModInfo { public static final String NAME = "Extra Carts"; public static final String MODID = "extracarts"; public static final String VERSION = "@VERSION@"; private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); public static ArrayList<Module> getModules() { if(MODULES_ENABLED.isEmpty()) { MODULES_ENABLED.add(new BaseModule()); MODULES_ENABLED.add(new IronChestModule()); MODULES_ENABLED.add(new MFRModule());
MODULES_ENABLED.add(new MinechemModule());
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java
// Path: src/main/java/com/dta/extracarts/Module.java // public abstract class Module { // private Boolean isActive = true; // // public abstract String getModuleName(); // // public Boolean areRequirementsMet() { // return true; // } // // public void setIsActive(Boolean isActive) { // this.isActive = isActive; // } // // public Boolean getIsActive() { // return isActive; // } // // public void init(FMLPreInitializationEvent event) {} // public void load(FMLInitializationEvent event) {} // public void postInit(FMLPostInitializationEvent event) {} // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/events/ECEventHandler.java // public class ECEventHandler { // // private Item WoodIronUpgrade = GameRegistry.findItem("IronChest", "woodIronUpgrade"); // private Item WoodCopperUpgrade = GameRegistry.findItem("IronChest", "woodCopperUpgrade"); // // @SubscribeEvent // public void MinecartInteractEvent(MinecartInteractEvent event) { // if (event.entity instanceof EntityMinecartChest) { // ItemStack curItem = event.player.getCurrentEquippedItem(); // EntityMinecartChest oldCart = (EntityMinecartChest) event.entity; // if (curItem != null && curItem.getItem() == WoodIronUpgrade) { // EntityIronChestCart ironCart = new EntityIronChestCart(oldCart.worldObj); // ironCart.copyDataFrom(event.entity, true); // ironCart.setDisplayTileData(0); // if (!event.entity.worldObj.isRemote) { // oldCart.worldObj.spawnEntityInWorld(ironCart); // } // for (int i = 0; i < oldCart.getSizeInventory(); i++) { // oldCart.setInventorySlotContents(i, null); // } // oldCart.setDead(); // event.player.destroyCurrentEquippedItem(); // event.setCanceled(true); // } else if (curItem != null && curItem.getItem() == WoodCopperUpgrade) { // EntityCopperChestCart copperCart = new EntityCopperChestCart(oldCart.worldObj); // copperCart.copyDataFrom(event.entity, true); // copperCart.setDisplayTileData(3); // if (!event.entity.worldObj.isRemote) { // oldCart.worldObj.spawnEntityInWorld(copperCart); // } // for (int i = 0; i < oldCart.getSizeInventory(); i++) { // oldCart.setInventorySlotContents(i, null); // } // oldCart.setDead(); // event.player.destroyCurrentEquippedItem(); // event.setCanceled(true); // } // } // } // }
import net.minecraftforge.common.MinecraftForge; import com.dta.extracarts.Module; import com.dta.extracarts.mods.ironchest.events.ECEventHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent;
package com.dta.extracarts.mods.ironchest; /** * Created by Skylar on 10/17/2014. */ public class IronChestModule extends Module { @Override public String getModuleName() { return "IronChest"; } @Override public Boolean areRequirementsMet() { return Loader.isModLoaded("IronChest"); } @Override public void load(FMLInitializationEvent event) {
// Path: src/main/java/com/dta/extracarts/Module.java // public abstract class Module { // private Boolean isActive = true; // // public abstract String getModuleName(); // // public Boolean areRequirementsMet() { // return true; // } // // public void setIsActive(Boolean isActive) { // this.isActive = isActive; // } // // public Boolean getIsActive() { // return isActive; // } // // public void init(FMLPreInitializationEvent event) {} // public void load(FMLInitializationEvent event) {} // public void postInit(FMLPostInitializationEvent event) {} // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/events/ECEventHandler.java // public class ECEventHandler { // // private Item WoodIronUpgrade = GameRegistry.findItem("IronChest", "woodIronUpgrade"); // private Item WoodCopperUpgrade = GameRegistry.findItem("IronChest", "woodCopperUpgrade"); // // @SubscribeEvent // public void MinecartInteractEvent(MinecartInteractEvent event) { // if (event.entity instanceof EntityMinecartChest) { // ItemStack curItem = event.player.getCurrentEquippedItem(); // EntityMinecartChest oldCart = (EntityMinecartChest) event.entity; // if (curItem != null && curItem.getItem() == WoodIronUpgrade) { // EntityIronChestCart ironCart = new EntityIronChestCart(oldCart.worldObj); // ironCart.copyDataFrom(event.entity, true); // ironCart.setDisplayTileData(0); // if (!event.entity.worldObj.isRemote) { // oldCart.worldObj.spawnEntityInWorld(ironCart); // } // for (int i = 0; i < oldCart.getSizeInventory(); i++) { // oldCart.setInventorySlotContents(i, null); // } // oldCart.setDead(); // event.player.destroyCurrentEquippedItem(); // event.setCanceled(true); // } else if (curItem != null && curItem.getItem() == WoodCopperUpgrade) { // EntityCopperChestCart copperCart = new EntityCopperChestCart(oldCart.worldObj); // copperCart.copyDataFrom(event.entity, true); // copperCart.setDisplayTileData(3); // if (!event.entity.worldObj.isRemote) { // oldCart.worldObj.spawnEntityInWorld(copperCart); // } // for (int i = 0; i < oldCart.getSizeInventory(); i++) { // oldCart.setInventorySlotContents(i, null); // } // oldCart.setDead(); // event.player.destroyCurrentEquippedItem(); // event.setCanceled(true); // } // } // } // } // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestModule.java import net.minecraftforge.common.MinecraftForge; import com.dta.extracarts.Module; import com.dta.extracarts.mods.ironchest.events.ECEventHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; package com.dta.extracarts.mods.ironchest; /** * Created by Skylar on 10/17/2014. */ public class IronChestModule extends Module { @Override public String getModuleName() { return "IronChest"; } @Override public Boolean areRequirementsMet() { return Loader.isModLoaded("IronChest"); } @Override public void load(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ECEventHandler());
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ExtraCarts.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // }
import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level;
package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy")
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // } // Path: src/main/java/com/dta/extracarts/ExtraCarts.java import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level; package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy")
public static CommonProxy proxy;
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ExtraCarts.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // }
import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level;
package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) {
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // } // Path: src/main/java/com/dta/extracarts/ExtraCarts.java import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level; package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) {
ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile());
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ExtraCarts.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // }
import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level;
package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) { ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); ConfigHandler.init(); for(Module module : ModInfo.getModules()) { if(!module.areRequirementsMet() && module.getIsActive()) { module.setIsActive(false);
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // } // Path: src/main/java/com/dta/extracarts/ExtraCarts.java import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level; package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) { ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); ConfigHandler.init(); for(Module module : ModInfo.getModules()) { if(!module.areRequirementsMet() && module.getIsActive()) { module.setIsActive(false);
LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating");
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ExtraCarts.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // }
import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level;
package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) { ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); ConfigHandler.init(); for(Module module : ModInfo.getModules()) { if(!module.areRequirementsMet() && module.getIsActive()) { module.setIsActive(false); LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); } if(module.getIsActive()) { LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); } } for(Module module : ModInfo.getModules()) { if(module.getIsActive()) module.init(event); }
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // } // Path: src/main/java/com/dta/extracarts/ExtraCarts.java import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level; package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) { ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); ConfigHandler.init(); for(Module module : ModInfo.getModules()) { if(!module.areRequirementsMet() && module.getIsActive()) { module.setIsActive(false); LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); } if(module.getIsActive()) { LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); } } for(Module module : ModInfo.getModules()) { if(module.getIsActive()) module.init(event); }
FakeBlockRegistry.registerBlocks();
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/ExtraCarts.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // }
import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level;
package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) { ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); ConfigHandler.init(); for(Module module : ModInfo.getModules()) { if(!module.areRequirementsMet() && module.getIsActive()) { module.setIsActive(false); LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); } if(module.getIsActive()) { LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); } } for(Module module : ModInfo.getModules()) { if(module.getIsActive()) module.init(event); } FakeBlockRegistry.registerBlocks(); proxy.init(event); } @EventHandler public void load(FMLInitializationEvent event) {
// Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java // public class GuiHandler implements IGuiHandler { // // public GuiHandler() { // NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getServerGuiElement(ID, player, world, x, y, z); // } // return null; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // Entity entity = world.getEntityByID(x); // if(entity instanceof OpenableGUI) { // return ((OpenableGUI) entity).getClientGuiElement(ID, player, world, x, y, z); // } // return null; // } // // } // // Path: src/main/java/com/dta/extracarts/config/ConfigHandler.java // public class ConfigHandler { // public static File configFile = null; // // public static void init(){ // Configuration config = new Configuration(configFile); // config.load(); // for(Module module: ModInfo.getModules()) { // module.setIsActive(config.get("Modules", module.getModuleName() + " Enabled", true).getBoolean(true)); // } // config.save(); // } // // public static void setConfigFile(File suggestedConfigurationFile) { // configFile = suggestedConfigurationFile; // } // } // // Path: src/main/java/com/dta/extracarts/proxy/CommonProxy.java // public class CommonProxy { // public void init(FMLPreInitializationEvent event) { // // } // } // // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java // public class LogUtils { // public static void log(Level level, String message) { // LogManager.getLogger(ModInfo.NAME).log(level, message); // } // // public static void debug(String message) { // log(Level.DEBUG, message); // } // } // Path: src/main/java/com/dta/extracarts/ExtraCarts.java import com.dta.extracarts.block.FakeBlockRegistry; import com.dta.extracarts.client.GuiHandler; import com.dta.extracarts.config.ConfigHandler; import com.dta.extracarts.proxy.CommonProxy; import com.dta.extracarts.utils.LogUtils; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Level; package com.dta.extracarts; @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) public class ExtraCarts { @Instance(ModInfo.MODID) public static ExtraCarts instance; @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void init(FMLPreInitializationEvent event) { ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); ConfigHandler.init(); for(Module module : ModInfo.getModules()) { if(!module.areRequirementsMet() && module.getIsActive()) { module.setIsActive(false); LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); } if(module.getIsActive()) { LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); } } for(Module module : ModInfo.getModules()) { if(module.getIsActive()) module.init(event); } FakeBlockRegistry.registerBlocks(); proxy.init(event); } @EventHandler public void load(FMLInitializationEvent event) {
new GuiHandler();
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/ironchest/IronChestEntities.java
// Path: src/main/java/com/dta/extracarts/ExtraCarts.java // @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) // public class ExtraCarts { // @Instance(ModInfo.MODID) // public static ExtraCarts instance; // // @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void init(FMLPreInitializationEvent event) { // ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); // ConfigHandler.init(); // // for(Module module : ModInfo.getModules()) { // if(!module.areRequirementsMet() && module.getIsActive()) { // module.setIsActive(false); // LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); // } // if(module.getIsActive()) { // LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); // } // } // // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) // module.init(event); // } // FakeBlockRegistry.registerBlocks(); // proxy.init(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) { // new GuiHandler(); // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.load(event); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.postInit(event); // } // } // }
import com.dta.extracarts.ExtraCarts; import com.dta.extracarts.mods.ironchest.entities.*; import cpw.mods.fml.common.registry.EntityRegistry;
package com.dta.extracarts.mods.ironchest; public class IronChestEntities { public static void init() {
// Path: src/main/java/com/dta/extracarts/ExtraCarts.java // @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) // public class ExtraCarts { // @Instance(ModInfo.MODID) // public static ExtraCarts instance; // // @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void init(FMLPreInitializationEvent event) { // ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); // ConfigHandler.init(); // // for(Module module : ModInfo.getModules()) { // if(!module.areRequirementsMet() && module.getIsActive()) { // module.setIsActive(false); // LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); // } // if(module.getIsActive()) { // LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); // } // } // // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) // module.init(event); // } // FakeBlockRegistry.registerBlocks(); // proxy.init(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) { // new GuiHandler(); // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.load(event); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.postInit(event); // } // } // } // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestEntities.java import com.dta.extracarts.ExtraCarts; import com.dta.extracarts.mods.ironchest.entities.*; import cpw.mods.fml.common.registry.EntityRegistry; package com.dta.extracarts.mods.ironchest; public class IronChestEntities { public static void init() {
EntityRegistry.registerModEntity(EntityIronChestCart.class, "EntityIronChestCart", 1, ExtraCarts.instance, 80, 3, true);
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/base/items/ItemEnderChestCart.java
// Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/base/entities/EntityEnderChestCart.java // @Optional.Interface(iface="mods.railcraft.api.carts.IMinecart", modid="RailcraftAPI|carts") // public class EntityEnderChestCart extends EntityMinecartContainer { // // public EntityEnderChestCart(World world) { // super(world); // } // // @Override // public int getSizeInventory() { // return 27; // } // // @Override // public int getMinecartType() { // return 1; // } // // @Override // public Block func_145817_o() { // return Blocks.ender_chest; // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource); // this.func_145778_a(Item.getItemFromBlock(Blocks.ender_chest), 1, 0.0F); // } // // @Override // public boolean interactFirst(EntityPlayer player) { // InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); // // if (!this.worldObj.isRemote && !player.isSneaking()) { // player.displayGUIChest(inventoryenderchest); // } // return true; // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(BaseModule.EnderChestCart, 1, 0); // if (cart instanceof EntityEnderChestCart && stack.getItem() == CartStack.getItem()) { // return true; // } // return false; // } // // }
import com.dta.extracarts.items.ExtraCartItem; import net.minecraft.block.BlockRailBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMinecart; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.base.entities.EntityEnderChestCart;
package com.dta.extracarts.mods.base.items; public class ItemEnderChestCart extends ExtraCartItem { public ItemEnderChestCart() { super(1); this.setUnlocalizedName("EnderChestCart");
// Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/base/entities/EntityEnderChestCart.java // @Optional.Interface(iface="mods.railcraft.api.carts.IMinecart", modid="RailcraftAPI|carts") // public class EntityEnderChestCart extends EntityMinecartContainer { // // public EntityEnderChestCart(World world) { // super(world); // } // // @Override // public int getSizeInventory() { // return 27; // } // // @Override // public int getMinecartType() { // return 1; // } // // @Override // public Block func_145817_o() { // return Blocks.ender_chest; // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource); // this.func_145778_a(Item.getItemFromBlock(Blocks.ender_chest), 1, 0.0F); // } // // @Override // public boolean interactFirst(EntityPlayer player) { // InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); // // if (!this.worldObj.isRemote && !player.isSneaking()) { // player.displayGUIChest(inventoryenderchest); // } // return true; // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(BaseModule.EnderChestCart, 1, 0); // if (cart instanceof EntityEnderChestCart && stack.getItem() == CartStack.getItem()) { // return true; // } // return false; // } // // } // Path: src/main/java/com/dta/extracarts/mods/base/items/ItemEnderChestCart.java import com.dta.extracarts.items.ExtraCartItem; import net.minecraft.block.BlockRailBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMinecart; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.base.entities.EntityEnderChestCart; package com.dta.extracarts.mods.base.items; public class ItemEnderChestCart extends ExtraCartItem { public ItemEnderChestCart() { super(1); this.setUnlocalizedName("EnderChestCart");
setTextureName(ModInfo.MODID + ":base/EnderChestCart");
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/base/items/ItemEnderChestCart.java
// Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/base/entities/EntityEnderChestCart.java // @Optional.Interface(iface="mods.railcraft.api.carts.IMinecart", modid="RailcraftAPI|carts") // public class EntityEnderChestCart extends EntityMinecartContainer { // // public EntityEnderChestCart(World world) { // super(world); // } // // @Override // public int getSizeInventory() { // return 27; // } // // @Override // public int getMinecartType() { // return 1; // } // // @Override // public Block func_145817_o() { // return Blocks.ender_chest; // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource); // this.func_145778_a(Item.getItemFromBlock(Blocks.ender_chest), 1, 0.0F); // } // // @Override // public boolean interactFirst(EntityPlayer player) { // InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); // // if (!this.worldObj.isRemote && !player.isSneaking()) { // player.displayGUIChest(inventoryenderchest); // } // return true; // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(BaseModule.EnderChestCart, 1, 0); // if (cart instanceof EntityEnderChestCart && stack.getItem() == CartStack.getItem()) { // return true; // } // return false; // } // // }
import com.dta.extracarts.items.ExtraCartItem; import net.minecraft.block.BlockRailBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMinecart; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.base.entities.EntityEnderChestCart;
package com.dta.extracarts.mods.base.items; public class ItemEnderChestCart extends ExtraCartItem { public ItemEnderChestCart() { super(1); this.setUnlocalizedName("EnderChestCart"); setTextureName(ModInfo.MODID + ":base/EnderChestCart"); } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
// Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/base/entities/EntityEnderChestCart.java // @Optional.Interface(iface="mods.railcraft.api.carts.IMinecart", modid="RailcraftAPI|carts") // public class EntityEnderChestCart extends EntityMinecartContainer { // // public EntityEnderChestCart(World world) { // super(world); // } // // @Override // public int getSizeInventory() { // return 27; // } // // @Override // public int getMinecartType() { // return 1; // } // // @Override // public Block func_145817_o() { // return Blocks.ender_chest; // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource); // this.func_145778_a(Item.getItemFromBlock(Blocks.ender_chest), 1, 0.0F); // } // // @Override // public boolean interactFirst(EntityPlayer player) { // InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); // // if (!this.worldObj.isRemote && !player.isSneaking()) { // player.displayGUIChest(inventoryenderchest); // } // return true; // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(BaseModule.EnderChestCart, 1, 0); // if (cart instanceof EntityEnderChestCart && stack.getItem() == CartStack.getItem()) { // return true; // } // return false; // } // // } // Path: src/main/java/com/dta/extracarts/mods/base/items/ItemEnderChestCart.java import com.dta.extracarts.items.ExtraCartItem; import net.minecraft.block.BlockRailBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMinecart; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.base.entities.EntityEnderChestCart; package com.dta.extracarts.mods.base.items; public class ItemEnderChestCart extends ExtraCartItem { public ItemEnderChestCart() { super(1); this.setUnlocalizedName("EnderChestCart"); setTextureName(ModInfo.MODID + ":base/EnderChestCart"); } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
return super.placeCart(itemstack, player, world, x, y, z, new EntityEnderChestCart(world));
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/utils/LogUtils.java
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // }
import com.dta.extracarts.ModInfo; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager;
package com.dta.extracarts.utils; /** * Created by Skylar on 10/22/2014. */ public class LogUtils { public static void log(Level level, String message) {
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // Path: src/main/java/com/dta/extracarts/utils/LogUtils.java import com.dta.extracarts.ModInfo; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; package com.dta.extracarts.utils; /** * Created by Skylar on 10/22/2014. */ public class LogUtils { public static void log(Level level, String message) {
LogManager.getLogger(ModInfo.NAME).log(level, message);
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/client/GuiHandler.java
// Path: src/main/java/com/dta/extracarts/ExtraCarts.java // @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) // public class ExtraCarts { // @Instance(ModInfo.MODID) // public static ExtraCarts instance; // // @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void init(FMLPreInitializationEvent event) { // ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); // ConfigHandler.init(); // // for(Module module : ModInfo.getModules()) { // if(!module.areRequirementsMet() && module.getIsActive()) { // module.setIsActive(false); // LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); // } // if(module.getIsActive()) { // LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); // } // } // // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) // module.init(event); // } // FakeBlockRegistry.registerBlocks(); // proxy.init(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) { // new GuiHandler(); // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.load(event); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.postInit(event); // } // } // }
import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import com.dta.extracarts.ExtraCarts; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry;
package com.dta.extracarts.client; public class GuiHandler implements IGuiHandler { public GuiHandler() {
// Path: src/main/java/com/dta/extracarts/ExtraCarts.java // @Mod(modid = ModInfo.MODID, name = ModInfo.NAME, version = ModInfo.VERSION) // public class ExtraCarts { // @Instance(ModInfo.MODID) // public static ExtraCarts instance; // // @SidedProxy(clientSide = "com.dta.extracarts.proxy.ClientProxy", serverSide = "com.dta.extracarts.proxy.CommonProxy") // public static CommonProxy proxy; // // @EventHandler // public void init(FMLPreInitializationEvent event) { // ConfigHandler.setConfigFile(event.getSuggestedConfigurationFile()); // ConfigHandler.init(); // // for(Module module : ModInfo.getModules()) { // if(!module.areRequirementsMet() && module.getIsActive()) { // module.setIsActive(false); // LogUtils.log(Level.ERROR, "Requirements are not met for " + module.getModuleName() + ". Deactivating"); // } // if(module.getIsActive()) { // LogUtils.log(Level.INFO, "Loading " + module.getModuleName() + " module"); // } // } // // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) // module.init(event); // } // FakeBlockRegistry.registerBlocks(); // proxy.init(event); // } // // @EventHandler // public void load(FMLInitializationEvent event) { // new GuiHandler(); // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.load(event); // } // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // for(Module module : ModInfo.getModules()) { // if(module.getIsActive()) module.postInit(event); // } // } // } // Path: src/main/java/com/dta/extracarts/client/GuiHandler.java import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import com.dta.extracarts.ExtraCarts; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; package com.dta.extracarts.client; public class GuiHandler implements IGuiHandler { public GuiHandler() {
NetworkRegistry.INSTANCE.registerGuiHandler(ExtraCarts.instance, this);
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/filters/ArrayStackFilter.java
// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/InvTools.java // public class InvTools { // public static boolean isWildcard(ItemStack stack) { // return isWildcard(stack.getItemDamage()); // } // // public static boolean isWildcard(int damage) { // return damage == -1 || damage == OreDictionary.WILDCARD_VALUE; // } // // /** // * A more robust item comparison function. Supports items with damage = -1 // * matching any sub-type. // * // * @param a An ItemStack // * @param b An ItemStack // * @return True if equal // */ // public static boolean isItemEqual(ItemStack a, ItemStack b) { // return isItemEqual(a, b, true, true); // } // // public static boolean isItemEqual(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) { // if (a == null || b == null) // return false; // if (a.getItem() != b.getItem()) // return false; // if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) // return false; // if (matchDamage && a.getHasSubtypes()) { // if (isWildcard(a) || isWildcard(b)) // return true; // if (a.getItemDamage() != b.getItemDamage()) // return false; // } // return true; // } // // /** // * Returns true if the item is equal to any one of several possible matches. // * // * @param stack // * @param matches // * @return // */ // public static boolean isItemEqual(ItemStack stack, ItemStack... matches) { // for (ItemStack match : matches) { // if (isItemEqual(stack, match)) // return true; // } // return false; // } // }
import com.dta.extracarts.othermodcode.railcraft.common.util.inventory.InvTools; import mods.railcraft.api.core.items.IStackFilter; import net.minecraft.item.ItemStack;
/* * Copyright (c) CovertJaguar, 2014 http://railcraft.info * * This code is the property of CovertJaguar * and may only be used with explicit written * permission unless otherwise specified on the * license page at http://railcraft.info/wiki/info:license. */ package com.dta.extracarts.othermodcode.railcraft.common.util.inventory.filters; /** * * @author CovertJaguar <http://www.railcraft.info> */ public class ArrayStackFilter implements IStackFilter { private final ItemStack[] stacks; public ArrayStackFilter(ItemStack... stacks) { this.stacks = stacks; } @Override public boolean matches(ItemStack stack) { if (stacks.length == 0 || !hasFilter()) { return true; }
// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/InvTools.java // public class InvTools { // public static boolean isWildcard(ItemStack stack) { // return isWildcard(stack.getItemDamage()); // } // // public static boolean isWildcard(int damage) { // return damage == -1 || damage == OreDictionary.WILDCARD_VALUE; // } // // /** // * A more robust item comparison function. Supports items with damage = -1 // * matching any sub-type. // * // * @param a An ItemStack // * @param b An ItemStack // * @return True if equal // */ // public static boolean isItemEqual(ItemStack a, ItemStack b) { // return isItemEqual(a, b, true, true); // } // // public static boolean isItemEqual(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) { // if (a == null || b == null) // return false; // if (a.getItem() != b.getItem()) // return false; // if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) // return false; // if (matchDamage && a.getHasSubtypes()) { // if (isWildcard(a) || isWildcard(b)) // return true; // if (a.getItemDamage() != b.getItemDamage()) // return false; // } // return true; // } // // /** // * Returns true if the item is equal to any one of several possible matches. // * // * @param stack // * @param matches // * @return // */ // public static boolean isItemEqual(ItemStack stack, ItemStack... matches) { // for (ItemStack match : matches) { // if (isItemEqual(stack, match)) // return true; // } // return false; // } // } // Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/filters/ArrayStackFilter.java import com.dta.extracarts.othermodcode.railcraft.common.util.inventory.InvTools; import mods.railcraft.api.core.items.IStackFilter; import net.minecraft.item.ItemStack; /* * Copyright (c) CovertJaguar, 2014 http://railcraft.info * * This code is the property of CovertJaguar * and may only be used with explicit written * permission unless otherwise specified on the * license page at http://railcraft.info/wiki/info:license. */ package com.dta.extracarts.othermodcode.railcraft.common.util.inventory.filters; /** * * @author CovertJaguar <http://www.railcraft.info> */ public class ArrayStackFilter implements IStackFilter { private final ItemStack[] stacks; public ArrayStackFilter(ItemStack... stacks) { this.stacks = stacks; } @Override public boolean matches(ItemStack stack) { if (stacks.length == 0 || !hasFilter()) { return true; }
return InvTools.isItemEqual(stack, stacks);
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/ironchest/IronChestItems.java
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/items/ItemIronChestCart.java // public class ItemIronChestCart extends ExtraCartItem { // // @SideOnly(Side.CLIENT) // private IIcon itemIronChestCart; // private IIcon itemGoldChestCart; // private IIcon itemDiamondChestCart; // private IIcon itemCopperChestCart; // private IIcon itemSilverChestCart; // private IIcon itemCrystalChestCart; // private IIcon itemObsidianChestCart; // private IIcon itemDirtChestCart; // // public ItemIronChestCart() { // super(1); // this.hasSubtypes=true; // } // // @Override // public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { // EntityMinecart entityMinecart; // switch (itemstack.getItemDamage()) { // default: // entityMinecart = new EntityIronChestCart(world); // break; // case 1: // entityMinecart = new EntityGoldChestCart(world); // break; // case 2: // entityMinecart = new EntityDiamondChestCart(world); // break; // case 3: // entityMinecart = new EntityCopperChestCart(world); // break; // case 4: // entityMinecart = new EntitySilverChestCart(world); // break; // case 5: // entityMinecart = new EntityCrystalChestCart(world); // break; // case 6: // entityMinecart = new EntityObsidianChestCart(world); // break; // case 7: // entityMinecart = new EntityDirtChestCart(world); // break; // } // return placeCart(itemstack, player, world, x, y, z, entityMinecart); // } // // @Override // @SideOnly(Side.CLIENT) // public void registerIcons(IIconRegister register) { // itemIronChestCart = register.registerIcon("extracarts:ironchest/IronChestCart"); // itemGoldChestCart = register.registerIcon("extracarts:ironchest/GoldChestCart"); // itemDiamondChestCart = register.registerIcon("extracarts:ironchest/DiamondChestCart"); // itemCopperChestCart = register.registerIcon("extracarts:ironchest/CopperChestCart"); // itemSilverChestCart = register.registerIcon("extracarts:ironchest/SilverChestCart"); // itemCrystalChestCart = register.registerIcon("extracarts:ironchest/CrystalChestCart"); // itemObsidianChestCart = register.registerIcon("extracarts:ironchest/ObsidianChestCart"); // itemDirtChestCart = register.registerIcon("extracarts:ironchest/DirtChestCart"); // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIconFromDamage(int dmg) { // switch (dmg) { // default: // return itemIronChestCart; // case 1: // return itemGoldChestCart; // case 2: // return itemDiamondChestCart; // case 3: // return itemCopperChestCart; // case 4: // return itemSilverChestCart; // case 5: // return itemCrystalChestCart; // case 6: // return itemObsidianChestCart; // case 7: // return itemDirtChestCart; // } // // } // // @Override // public String getUnlocalizedName(ItemStack itemstack) { // switch (itemstack.getItemDamage()) { // default: // return "item.IronChestCart"; // case 1: // return "item.GoldChestCart"; // case 2: // return "item.DiamondChestCart"; // case 3: // return "item.CopperChestCart"; // case 4: // return "item.SilverChestCart"; // case 5: // return "item.CrystalChestCart"; // case 6: // return "item.ObsidianChestCart"; // case 7: // return "item.DirtChestCart"; // } // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(Item item, CreativeTabs tab, List list) { // for (int i = 0; i < 8; i++) { // ItemStack stack = new ItemStack(item, 1, i); // list.add(stack); // } // } // }
import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.ironchest.items.ItemIronChestCart; import cpw.mods.fml.common.registry.GameRegistry;
package com.dta.extracarts.mods.ironchest; public class IronChestItems { public static Item IronChestCart; public static Block ironChest; public static void init() {
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/items/ItemIronChestCart.java // public class ItemIronChestCart extends ExtraCartItem { // // @SideOnly(Side.CLIENT) // private IIcon itemIronChestCart; // private IIcon itemGoldChestCart; // private IIcon itemDiamondChestCart; // private IIcon itemCopperChestCart; // private IIcon itemSilverChestCart; // private IIcon itemCrystalChestCart; // private IIcon itemObsidianChestCart; // private IIcon itemDirtChestCart; // // public ItemIronChestCart() { // super(1); // this.hasSubtypes=true; // } // // @Override // public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { // EntityMinecart entityMinecart; // switch (itemstack.getItemDamage()) { // default: // entityMinecart = new EntityIronChestCart(world); // break; // case 1: // entityMinecart = new EntityGoldChestCart(world); // break; // case 2: // entityMinecart = new EntityDiamondChestCart(world); // break; // case 3: // entityMinecart = new EntityCopperChestCart(world); // break; // case 4: // entityMinecart = new EntitySilverChestCart(world); // break; // case 5: // entityMinecart = new EntityCrystalChestCart(world); // break; // case 6: // entityMinecart = new EntityObsidianChestCart(world); // break; // case 7: // entityMinecart = new EntityDirtChestCart(world); // break; // } // return placeCart(itemstack, player, world, x, y, z, entityMinecart); // } // // @Override // @SideOnly(Side.CLIENT) // public void registerIcons(IIconRegister register) { // itemIronChestCart = register.registerIcon("extracarts:ironchest/IronChestCart"); // itemGoldChestCart = register.registerIcon("extracarts:ironchest/GoldChestCart"); // itemDiamondChestCart = register.registerIcon("extracarts:ironchest/DiamondChestCart"); // itemCopperChestCart = register.registerIcon("extracarts:ironchest/CopperChestCart"); // itemSilverChestCart = register.registerIcon("extracarts:ironchest/SilverChestCart"); // itemCrystalChestCart = register.registerIcon("extracarts:ironchest/CrystalChestCart"); // itemObsidianChestCart = register.registerIcon("extracarts:ironchest/ObsidianChestCart"); // itemDirtChestCart = register.registerIcon("extracarts:ironchest/DirtChestCart"); // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIconFromDamage(int dmg) { // switch (dmg) { // default: // return itemIronChestCart; // case 1: // return itemGoldChestCart; // case 2: // return itemDiamondChestCart; // case 3: // return itemCopperChestCart; // case 4: // return itemSilverChestCart; // case 5: // return itemCrystalChestCart; // case 6: // return itemObsidianChestCart; // case 7: // return itemDirtChestCart; // } // // } // // @Override // public String getUnlocalizedName(ItemStack itemstack) { // switch (itemstack.getItemDamage()) { // default: // return "item.IronChestCart"; // case 1: // return "item.GoldChestCart"; // case 2: // return "item.DiamondChestCart"; // case 3: // return "item.CopperChestCart"; // case 4: // return "item.SilverChestCart"; // case 5: // return "item.CrystalChestCart"; // case 6: // return "item.ObsidianChestCart"; // case 7: // return "item.DirtChestCart"; // } // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(Item item, CreativeTabs tab, List list) { // for (int i = 0; i < 8; i++) { // ItemStack stack = new ItemStack(item, 1, i); // list.add(stack); // } // } // } // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestItems.java import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.ironchest.items.ItemIronChestCart; import cpw.mods.fml.common.registry.GameRegistry; package com.dta.extracarts.mods.ironchest; public class IronChestItems { public static Item IronChestCart; public static Block ironChest; public static void init() {
IronChestCart = new ItemIronChestCart();
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/ironchest/IronChestItems.java
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/items/ItemIronChestCart.java // public class ItemIronChestCart extends ExtraCartItem { // // @SideOnly(Side.CLIENT) // private IIcon itemIronChestCart; // private IIcon itemGoldChestCart; // private IIcon itemDiamondChestCart; // private IIcon itemCopperChestCart; // private IIcon itemSilverChestCart; // private IIcon itemCrystalChestCart; // private IIcon itemObsidianChestCart; // private IIcon itemDirtChestCart; // // public ItemIronChestCart() { // super(1); // this.hasSubtypes=true; // } // // @Override // public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { // EntityMinecart entityMinecart; // switch (itemstack.getItemDamage()) { // default: // entityMinecart = new EntityIronChestCart(world); // break; // case 1: // entityMinecart = new EntityGoldChestCart(world); // break; // case 2: // entityMinecart = new EntityDiamondChestCart(world); // break; // case 3: // entityMinecart = new EntityCopperChestCart(world); // break; // case 4: // entityMinecart = new EntitySilverChestCart(world); // break; // case 5: // entityMinecart = new EntityCrystalChestCart(world); // break; // case 6: // entityMinecart = new EntityObsidianChestCart(world); // break; // case 7: // entityMinecart = new EntityDirtChestCart(world); // break; // } // return placeCart(itemstack, player, world, x, y, z, entityMinecart); // } // // @Override // @SideOnly(Side.CLIENT) // public void registerIcons(IIconRegister register) { // itemIronChestCart = register.registerIcon("extracarts:ironchest/IronChestCart"); // itemGoldChestCart = register.registerIcon("extracarts:ironchest/GoldChestCart"); // itemDiamondChestCart = register.registerIcon("extracarts:ironchest/DiamondChestCart"); // itemCopperChestCart = register.registerIcon("extracarts:ironchest/CopperChestCart"); // itemSilverChestCart = register.registerIcon("extracarts:ironchest/SilverChestCart"); // itemCrystalChestCart = register.registerIcon("extracarts:ironchest/CrystalChestCart"); // itemObsidianChestCart = register.registerIcon("extracarts:ironchest/ObsidianChestCart"); // itemDirtChestCart = register.registerIcon("extracarts:ironchest/DirtChestCart"); // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIconFromDamage(int dmg) { // switch (dmg) { // default: // return itemIronChestCart; // case 1: // return itemGoldChestCart; // case 2: // return itemDiamondChestCart; // case 3: // return itemCopperChestCart; // case 4: // return itemSilverChestCart; // case 5: // return itemCrystalChestCart; // case 6: // return itemObsidianChestCart; // case 7: // return itemDirtChestCart; // } // // } // // @Override // public String getUnlocalizedName(ItemStack itemstack) { // switch (itemstack.getItemDamage()) { // default: // return "item.IronChestCart"; // case 1: // return "item.GoldChestCart"; // case 2: // return "item.DiamondChestCart"; // case 3: // return "item.CopperChestCart"; // case 4: // return "item.SilverChestCart"; // case 5: // return "item.CrystalChestCart"; // case 6: // return "item.ObsidianChestCart"; // case 7: // return "item.DirtChestCart"; // } // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(Item item, CreativeTabs tab, List list) { // for (int i = 0; i < 8; i++) { // ItemStack stack = new ItemStack(item, 1, i); // list.add(stack); // } // } // }
import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.ironchest.items.ItemIronChestCart; import cpw.mods.fml.common.registry.GameRegistry;
package com.dta.extracarts.mods.ironchest; public class IronChestItems { public static Item IronChestCart; public static Block ironChest; public static void init() { IronChestCart = new ItemIronChestCart(); } public static void registerItems() {
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/mods/ironchest/items/ItemIronChestCart.java // public class ItemIronChestCart extends ExtraCartItem { // // @SideOnly(Side.CLIENT) // private IIcon itemIronChestCart; // private IIcon itemGoldChestCart; // private IIcon itemDiamondChestCart; // private IIcon itemCopperChestCart; // private IIcon itemSilverChestCart; // private IIcon itemCrystalChestCart; // private IIcon itemObsidianChestCart; // private IIcon itemDirtChestCart; // // public ItemIronChestCart() { // super(1); // this.hasSubtypes=true; // } // // @Override // public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { // EntityMinecart entityMinecart; // switch (itemstack.getItemDamage()) { // default: // entityMinecart = new EntityIronChestCart(world); // break; // case 1: // entityMinecart = new EntityGoldChestCart(world); // break; // case 2: // entityMinecart = new EntityDiamondChestCart(world); // break; // case 3: // entityMinecart = new EntityCopperChestCart(world); // break; // case 4: // entityMinecart = new EntitySilverChestCart(world); // break; // case 5: // entityMinecart = new EntityCrystalChestCart(world); // break; // case 6: // entityMinecart = new EntityObsidianChestCart(world); // break; // case 7: // entityMinecart = new EntityDirtChestCart(world); // break; // } // return placeCart(itemstack, player, world, x, y, z, entityMinecart); // } // // @Override // @SideOnly(Side.CLIENT) // public void registerIcons(IIconRegister register) { // itemIronChestCart = register.registerIcon("extracarts:ironchest/IronChestCart"); // itemGoldChestCart = register.registerIcon("extracarts:ironchest/GoldChestCart"); // itemDiamondChestCart = register.registerIcon("extracarts:ironchest/DiamondChestCart"); // itemCopperChestCart = register.registerIcon("extracarts:ironchest/CopperChestCart"); // itemSilverChestCart = register.registerIcon("extracarts:ironchest/SilverChestCart"); // itemCrystalChestCart = register.registerIcon("extracarts:ironchest/CrystalChestCart"); // itemObsidianChestCart = register.registerIcon("extracarts:ironchest/ObsidianChestCart"); // itemDirtChestCart = register.registerIcon("extracarts:ironchest/DirtChestCart"); // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIconFromDamage(int dmg) { // switch (dmg) { // default: // return itemIronChestCart; // case 1: // return itemGoldChestCart; // case 2: // return itemDiamondChestCart; // case 3: // return itemCopperChestCart; // case 4: // return itemSilverChestCart; // case 5: // return itemCrystalChestCart; // case 6: // return itemObsidianChestCart; // case 7: // return itemDirtChestCart; // } // // } // // @Override // public String getUnlocalizedName(ItemStack itemstack) { // switch (itemstack.getItemDamage()) { // default: // return "item.IronChestCart"; // case 1: // return "item.GoldChestCart"; // case 2: // return "item.DiamondChestCart"; // case 3: // return "item.CopperChestCart"; // case 4: // return "item.SilverChestCart"; // case 5: // return "item.CrystalChestCart"; // case 6: // return "item.ObsidianChestCart"; // case 7: // return "item.DirtChestCart"; // } // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(Item item, CreativeTabs tab, List list) { // for (int i = 0; i < 8; i++) { // ItemStack stack = new ItemStack(item, 1, i); // list.add(stack); // } // } // } // Path: src/main/java/com/dta/extracarts/mods/ironchest/IronChestItems.java import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import com.dta.extracarts.ModInfo; import com.dta.extracarts.mods.ironchest.items.ItemIronChestCart; import cpw.mods.fml.common.registry.GameRegistry; package com.dta.extracarts.mods.ironchest; public class IronChestItems { public static Item IronChestCart; public static Block ironChest; public static void init() { IronChestCart = new ItemIronChestCart(); } public static void registerItems() {
GameRegistry.registerItem(IronChestCart, ModInfo.MODID + "_" + IronChestCart.getUnlocalizedName().substring(5));
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/othermodcode/railcraft/common/carts/CartTransferBase.java
// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/filters/ArrayStackFilter.java // public class ArrayStackFilter implements IStackFilter { // // private final ItemStack[] stacks; // // public ArrayStackFilter(ItemStack... stacks) { // this.stacks = stacks; // } // // @Override // public boolean matches(ItemStack stack) { // if (stacks.length == 0 || !hasFilter()) { // return true; // } // return InvTools.isItemEqual(stack, stacks); // } // // public ItemStack[] getStacks() { // return stacks; // } // // public boolean hasFilter() { // for (ItemStack filter : stacks) { // if (filter != null) { // return true; // } // } // return false; // } // }
import cpw.mods.fml.common.Optional; import mods.railcraft.api.carts.CartTools; import mods.railcraft.api.carts.IItemTransfer; import mods.railcraft.api.carts.ILinkageManager; import mods.railcraft.api.core.items.IStackFilter; import com.dta.extracarts.othermodcode.railcraft.common.util.inventory.filters.ArrayStackFilter; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityMinecartContainer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.world.World;
public ItemStack offerItem(Object source, ItemStack offer) { if (!passThrough && getSizeInventory() > 0) { offer = moveItemStack(offer, this); if (offer == null) return null; } ILinkageManager lm = CartTools.getLinkageManager(worldObj); EntityMinecart linkedCart = lm.getLinkedCartA(this); if (linkedCart != source && linkedCart instanceof IItemTransfer) offer = ((IItemTransfer) linkedCart).offerItem(this, offer); if (offer == null) return null; linkedCart = lm.getLinkedCartB(this); if (linkedCart != source && linkedCart instanceof IItemTransfer) offer = ((IItemTransfer) linkedCart).offerItem(this, offer); return offer; } @Optional.Method(modid = "RailcraftAPI|carts") public ItemStack requestItem(Object source) { return requestItem(this, IStackFilter.filters.get("ALL")); } @Optional.Method(modid = "RailcraftAPI|carts") public ItemStack requestItem(Object source, ItemStack request) {
// Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/util/inventory/filters/ArrayStackFilter.java // public class ArrayStackFilter implements IStackFilter { // // private final ItemStack[] stacks; // // public ArrayStackFilter(ItemStack... stacks) { // this.stacks = stacks; // } // // @Override // public boolean matches(ItemStack stack) { // if (stacks.length == 0 || !hasFilter()) { // return true; // } // return InvTools.isItemEqual(stack, stacks); // } // // public ItemStack[] getStacks() { // return stacks; // } // // public boolean hasFilter() { // for (ItemStack filter : stacks) { // if (filter != null) { // return true; // } // } // return false; // } // } // Path: src/main/java/com/dta/extracarts/othermodcode/railcraft/common/carts/CartTransferBase.java import cpw.mods.fml.common.Optional; import mods.railcraft.api.carts.CartTools; import mods.railcraft.api.carts.IItemTransfer; import mods.railcraft.api.carts.ILinkageManager; import mods.railcraft.api.core.items.IStackFilter; import com.dta.extracarts.othermodcode.railcraft.common.util.inventory.filters.ArrayStackFilter; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityMinecartContainer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public ItemStack offerItem(Object source, ItemStack offer) { if (!passThrough && getSizeInventory() > 0) { offer = moveItemStack(offer, this); if (offer == null) return null; } ILinkageManager lm = CartTools.getLinkageManager(worldObj); EntityMinecart linkedCart = lm.getLinkedCartA(this); if (linkedCart != source && linkedCart instanceof IItemTransfer) offer = ((IItemTransfer) linkedCart).offerItem(this, offer); if (offer == null) return null; linkedCart = lm.getLinkedCartB(this); if (linkedCart != source && linkedCart instanceof IItemTransfer) offer = ((IItemTransfer) linkedCart).offerItem(this, offer); return offer; } @Optional.Method(modid = "RailcraftAPI|carts") public ItemStack requestItem(Object source) { return requestItem(this, IStackFilter.filters.get("ALL")); } @Optional.Method(modid = "RailcraftAPI|carts") public ItemStack requestItem(Object source, ItemStack request) {
return requestItem(this, new ArrayStackFilter(request));
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/NEIExtraCartsConfig.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlock.java // public class FakeBlock extends Block { // private FakeSubBlock[] fakeSubBlockArray = new FakeSubBlock[16]; // private int blockNumber; // // public FakeBlock(int blockNumber) { // super(Material.iron); // this.blockNumber = blockNumber; // } // // @Override // @SideOnly(Side.CLIENT) // public void registerBlockIcons(IIconRegister iIconRegister) { // for(FakeSubBlock fakeSubBlock: fakeSubBlockArray) { // if(fakeSubBlock != null) // fakeSubBlock.registerBlockIcons(iIconRegister); // } // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIcon(int side, int metadata) { // return fakeSubBlockArray[metadata].getIcon(side, metadata); // } // // @Override // public String getUnlocalizedName() { // return "fakeBlock." + blockNumber; // } // // public FakeSubBlock[] getFakeSubBlockArray() { // return fakeSubBlockArray; // } // // public void setFakeSubBlockArray(FakeSubBlock[] fakeSubBlockArray) { // this.fakeSubBlockArray = fakeSubBlockArray; // } // // public int getBlockNumber() { // return blockNumber; // } // // public void setBlockNumber(int blockNumber) { // this.blockNumber = blockNumber; // } // } // // Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // }
import codechicken.nei.api.IConfigureNEI; import com.dta.extracarts.block.FakeBlock; import com.dta.extracarts.block.FakeBlockRegistry;
package com.dta.extracarts; /** * Created by Skylar on 3/24/2015. */ public class NEIExtraCartsConfig implements IConfigureNEI { @Override public void loadConfig() {
// Path: src/main/java/com/dta/extracarts/block/FakeBlock.java // public class FakeBlock extends Block { // private FakeSubBlock[] fakeSubBlockArray = new FakeSubBlock[16]; // private int blockNumber; // // public FakeBlock(int blockNumber) { // super(Material.iron); // this.blockNumber = blockNumber; // } // // @Override // @SideOnly(Side.CLIENT) // public void registerBlockIcons(IIconRegister iIconRegister) { // for(FakeSubBlock fakeSubBlock: fakeSubBlockArray) { // if(fakeSubBlock != null) // fakeSubBlock.registerBlockIcons(iIconRegister); // } // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIcon(int side, int metadata) { // return fakeSubBlockArray[metadata].getIcon(side, metadata); // } // // @Override // public String getUnlocalizedName() { // return "fakeBlock." + blockNumber; // } // // public FakeSubBlock[] getFakeSubBlockArray() { // return fakeSubBlockArray; // } // // public void setFakeSubBlockArray(FakeSubBlock[] fakeSubBlockArray) { // this.fakeSubBlockArray = fakeSubBlockArray; // } // // public int getBlockNumber() { // return blockNumber; // } // // public void setBlockNumber(int blockNumber) { // this.blockNumber = blockNumber; // } // } // // Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // Path: src/main/java/com/dta/extracarts/NEIExtraCartsConfig.java import codechicken.nei.api.IConfigureNEI; import com.dta.extracarts.block.FakeBlock; import com.dta.extracarts.block.FakeBlockRegistry; package com.dta.extracarts; /** * Created by Skylar on 3/24/2015. */ public class NEIExtraCartsConfig implements IConfigureNEI { @Override public void loadConfig() {
for(FakeBlock fakeBlock: FakeBlockRegistry.getFakeBlockArrayList()) {
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/NEIExtraCartsConfig.java
// Path: src/main/java/com/dta/extracarts/block/FakeBlock.java // public class FakeBlock extends Block { // private FakeSubBlock[] fakeSubBlockArray = new FakeSubBlock[16]; // private int blockNumber; // // public FakeBlock(int blockNumber) { // super(Material.iron); // this.blockNumber = blockNumber; // } // // @Override // @SideOnly(Side.CLIENT) // public void registerBlockIcons(IIconRegister iIconRegister) { // for(FakeSubBlock fakeSubBlock: fakeSubBlockArray) { // if(fakeSubBlock != null) // fakeSubBlock.registerBlockIcons(iIconRegister); // } // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIcon(int side, int metadata) { // return fakeSubBlockArray[metadata].getIcon(side, metadata); // } // // @Override // public String getUnlocalizedName() { // return "fakeBlock." + blockNumber; // } // // public FakeSubBlock[] getFakeSubBlockArray() { // return fakeSubBlockArray; // } // // public void setFakeSubBlockArray(FakeSubBlock[] fakeSubBlockArray) { // this.fakeSubBlockArray = fakeSubBlockArray; // } // // public int getBlockNumber() { // return blockNumber; // } // // public void setBlockNumber(int blockNumber) { // this.blockNumber = blockNumber; // } // } // // Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // }
import codechicken.nei.api.IConfigureNEI; import com.dta.extracarts.block.FakeBlock; import com.dta.extracarts.block.FakeBlockRegistry;
package com.dta.extracarts; /** * Created by Skylar on 3/24/2015. */ public class NEIExtraCartsConfig implements IConfigureNEI { @Override public void loadConfig() {
// Path: src/main/java/com/dta/extracarts/block/FakeBlock.java // public class FakeBlock extends Block { // private FakeSubBlock[] fakeSubBlockArray = new FakeSubBlock[16]; // private int blockNumber; // // public FakeBlock(int blockNumber) { // super(Material.iron); // this.blockNumber = blockNumber; // } // // @Override // @SideOnly(Side.CLIENT) // public void registerBlockIcons(IIconRegister iIconRegister) { // for(FakeSubBlock fakeSubBlock: fakeSubBlockArray) { // if(fakeSubBlock != null) // fakeSubBlock.registerBlockIcons(iIconRegister); // } // } // // @Override // @SideOnly(Side.CLIENT) // public IIcon getIcon(int side, int metadata) { // return fakeSubBlockArray[metadata].getIcon(side, metadata); // } // // @Override // public String getUnlocalizedName() { // return "fakeBlock." + blockNumber; // } // // public FakeSubBlock[] getFakeSubBlockArray() { // return fakeSubBlockArray; // } // // public void setFakeSubBlockArray(FakeSubBlock[] fakeSubBlockArray) { // this.fakeSubBlockArray = fakeSubBlockArray; // } // // public int getBlockNumber() { // return blockNumber; // } // // public void setBlockNumber(int blockNumber) { // this.blockNumber = blockNumber; // } // } // // Path: src/main/java/com/dta/extracarts/block/FakeBlockRegistry.java // public class FakeBlockRegistry { // static private ArrayList<FakeSubBlock> fakeSubBlockArrayList = new ArrayList<FakeSubBlock>(); // static private ArrayList<FakeBlock> fakeBlockArrayList = new ArrayList<FakeBlock>(); // // static public void registerBlocks() { // int numberOfBlocks = (int) Math.ceil(getFakeSubBlockArrayList().size() / 16.0); // // for(int x = 0; x < numberOfBlocks; x++) { // FakeBlock fakeBlock = new FakeBlock(x); // getFakeBlockArrayList().add(fakeBlock); // GameRegistry.registerBlock(fakeBlock, fakeBlock.getUnlocalizedName()); // } // // for(int x = 0; x < getFakeSubBlockArrayList().size(); x++) { // int blockNumber = (int) Math.ceil(x / 16.0); // int metaNumber = x % 16; // getFakeSubBlockArrayList().get(x).setBlockNumber(blockNumber); // getFakeSubBlockArrayList().get(x).setMetaNumber(metaNumber); // FakeSubBlock[] fakeBlockArray = getFakeBlockArrayList().get(blockNumber).getFakeSubBlockArray(); // fakeBlockArray[metaNumber] = getFakeSubBlockArrayList().get(x); // getFakeBlockArrayList().get(blockNumber).setFakeSubBlockArray(fakeBlockArray); // } // } // // static public void registerSubBlock(FakeSubBlock fakeSubBlock) { // getFakeSubBlockArrayList().add(fakeSubBlock); // } // // public static ArrayList<FakeSubBlock> getFakeSubBlockArrayList() { // return fakeSubBlockArrayList; // } // // public static ArrayList<FakeBlock> getFakeBlockArrayList() { // return fakeBlockArrayList; // } // // public static FakeSubBlock getFakeBlockByName(String name) { // for(FakeSubBlock fakeSubBlock: getFakeSubBlockArrayList()) { // if(fakeSubBlock.getBlockName().equals(name)) // return fakeSubBlock; // } // return null; // } // } // Path: src/main/java/com/dta/extracarts/NEIExtraCartsConfig.java import codechicken.nei.api.IConfigureNEI; import com.dta.extracarts.block.FakeBlock; import com.dta.extracarts.block.FakeBlockRegistry; package com.dta.extracarts; /** * Created by Skylar on 3/24/2015. */ public class NEIExtraCartsConfig implements IConfigureNEI { @Override public void loadConfig() {
for(FakeBlock fakeBlock: FakeBlockRegistry.getFakeBlockArrayList()) {
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/minechem/client/GUILeadedChestCart.java
// Path: src/main/java/com/dta/extracarts/mods/minechem/entities/EntityLeadedChestCart.java // @Optional.Interface(iface = "mods.railcraft.api.carts.IMinecart", modid = "RailcraftAPI|carts") // public class EntityLeadedChestCart extends EntityExtraCartChestMinecart implements OpenableGUI, IMinecart { // private Block leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // // public EntityLeadedChestCart(World world) { // super(world); // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource, new ItemStack(leadedChest, 1, 0)); // } // // @Override // public int getSizeInventory() { // return 9; // } // // @Override // public Block func_145817_o() { // return leadedChest; // } // // @Override // public Block func_145820_n() { // return leadedChest; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new GUILeadedChestCart(player.inventory, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new ContainerLeadedChestCart(player.inventory, this); // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(MinechemModule.itemLeadedChestCart, 1, 0); // if (cart instanceof EntityLeadedChestCart && stack.getItem() == CartStack.getItem() && stack.getItemDamage() == 0) { // return true; // } // return false; // } // }
import com.dta.extracarts.mods.minechem.entities.EntityLeadedChestCart; import minechem.gui.GuiContainerTabbed; import minechem.gui.GuiTabHelp; import minechem.gui.GuiTabPatreon; import minechem.reference.Resources; import minechem.utils.MinechemUtil; import net.minecraft.inventory.IInventory; import org.lwjgl.opengl.GL11;
package com.dta.extracarts.mods.minechem.client; /** * Created by Skylar on 4/1/2015. */ public class GUILeadedChestCart extends GuiContainerTabbed { int guiWidth = 176; int guiHeight = 217;
// Path: src/main/java/com/dta/extracarts/mods/minechem/entities/EntityLeadedChestCart.java // @Optional.Interface(iface = "mods.railcraft.api.carts.IMinecart", modid = "RailcraftAPI|carts") // public class EntityLeadedChestCart extends EntityExtraCartChestMinecart implements OpenableGUI, IMinecart { // private Block leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // // public EntityLeadedChestCart(World world) { // super(world); // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource, new ItemStack(leadedChest, 1, 0)); // } // // @Override // public int getSizeInventory() { // return 9; // } // // @Override // public Block func_145817_o() { // return leadedChest; // } // // @Override // public Block func_145820_n() { // return leadedChest; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new GUILeadedChestCart(player.inventory, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new ContainerLeadedChestCart(player.inventory, this); // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(MinechemModule.itemLeadedChestCart, 1, 0); // if (cart instanceof EntityLeadedChestCart && stack.getItem() == CartStack.getItem() && stack.getItemDamage() == 0) { // return true; // } // return false; // } // } // Path: src/main/java/com/dta/extracarts/mods/minechem/client/GUILeadedChestCart.java import com.dta.extracarts.mods.minechem.entities.EntityLeadedChestCart; import minechem.gui.GuiContainerTabbed; import minechem.gui.GuiTabHelp; import minechem.gui.GuiTabPatreon; import minechem.reference.Resources; import minechem.utils.MinechemUtil; import net.minecraft.inventory.IInventory; import org.lwjgl.opengl.GL11; package com.dta.extracarts.mods.minechem.client; /** * Created by Skylar on 4/1/2015. */ public class GUILeadedChestCart extends GuiContainerTabbed { int guiWidth = 176; int guiHeight = 217;
public GUILeadedChestCart(IInventory invPlayer, EntityLeadedChestCart cart) {
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/minechem/items/ItemLeadedChestCart.java
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/entities/EntityLeadedChestCart.java // @Optional.Interface(iface = "mods.railcraft.api.carts.IMinecart", modid = "RailcraftAPI|carts") // public class EntityLeadedChestCart extends EntityExtraCartChestMinecart implements OpenableGUI, IMinecart { // private Block leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // // public EntityLeadedChestCart(World world) { // super(world); // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource, new ItemStack(leadedChest, 1, 0)); // } // // @Override // public int getSizeInventory() { // return 9; // } // // @Override // public Block func_145817_o() { // return leadedChest; // } // // @Override // public Block func_145820_n() { // return leadedChest; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new GUILeadedChestCart(player.inventory, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new ContainerLeadedChestCart(player.inventory, this); // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(MinechemModule.itemLeadedChestCart, 1, 0); // if (cart instanceof EntityLeadedChestCart && stack.getItem() == CartStack.getItem() && stack.getItemDamage() == 0) { // return true; // } // return false; // } // }
import com.dta.extracarts.ModInfo; import com.dta.extracarts.items.ExtraCartItem; import com.dta.extracarts.mods.minechem.entities.EntityLeadedChestCart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World;
package com.dta.extracarts.mods.minechem.items; /** * Created by Skylar on 3/30/2015. */ public class ItemLeadedChestCart extends ExtraCartItem { public ItemLeadedChestCart() { super(1); this.setUnlocalizedName("LeadedChestCart");
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/entities/EntityLeadedChestCart.java // @Optional.Interface(iface = "mods.railcraft.api.carts.IMinecart", modid = "RailcraftAPI|carts") // public class EntityLeadedChestCart extends EntityExtraCartChestMinecart implements OpenableGUI, IMinecart { // private Block leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // // public EntityLeadedChestCart(World world) { // super(world); // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource, new ItemStack(leadedChest, 1, 0)); // } // // @Override // public int getSizeInventory() { // return 9; // } // // @Override // public Block func_145817_o() { // return leadedChest; // } // // @Override // public Block func_145820_n() { // return leadedChest; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new GUILeadedChestCart(player.inventory, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new ContainerLeadedChestCart(player.inventory, this); // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(MinechemModule.itemLeadedChestCart, 1, 0); // if (cart instanceof EntityLeadedChestCart && stack.getItem() == CartStack.getItem() && stack.getItemDamage() == 0) { // return true; // } // return false; // } // } // Path: src/main/java/com/dta/extracarts/mods/minechem/items/ItemLeadedChestCart.java import com.dta.extracarts.ModInfo; import com.dta.extracarts.items.ExtraCartItem; import com.dta.extracarts.mods.minechem.entities.EntityLeadedChestCart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; package com.dta.extracarts.mods.minechem.items; /** * Created by Skylar on 3/30/2015. */ public class ItemLeadedChestCart extends ExtraCartItem { public ItemLeadedChestCart() { super(1); this.setUnlocalizedName("LeadedChestCart");
this.setTextureName(ModInfo.MODID + ":minechem/LeadedChestCart");
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/minechem/items/ItemLeadedChestCart.java
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/entities/EntityLeadedChestCart.java // @Optional.Interface(iface = "mods.railcraft.api.carts.IMinecart", modid = "RailcraftAPI|carts") // public class EntityLeadedChestCart extends EntityExtraCartChestMinecart implements OpenableGUI, IMinecart { // private Block leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // // public EntityLeadedChestCart(World world) { // super(world); // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource, new ItemStack(leadedChest, 1, 0)); // } // // @Override // public int getSizeInventory() { // return 9; // } // // @Override // public Block func_145817_o() { // return leadedChest; // } // // @Override // public Block func_145820_n() { // return leadedChest; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new GUILeadedChestCart(player.inventory, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new ContainerLeadedChestCart(player.inventory, this); // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(MinechemModule.itemLeadedChestCart, 1, 0); // if (cart instanceof EntityLeadedChestCart && stack.getItem() == CartStack.getItem() && stack.getItemDamage() == 0) { // return true; // } // return false; // } // }
import com.dta.extracarts.ModInfo; import com.dta.extracarts.items.ExtraCartItem; import com.dta.extracarts.mods.minechem.entities.EntityLeadedChestCart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World;
package com.dta.extracarts.mods.minechem.items; /** * Created by Skylar on 3/30/2015. */ public class ItemLeadedChestCart extends ExtraCartItem { public ItemLeadedChestCart() { super(1); this.setUnlocalizedName("LeadedChestCart"); this.setTextureName(ModInfo.MODID + ":minechem/LeadedChestCart"); } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
// Path: src/main/java/com/dta/extracarts/ModInfo.java // public class ModInfo { // // public static final String NAME = "Extra Carts"; // public static final String MODID = "extracarts"; // public static final String VERSION = "@VERSION@"; // // private static ArrayList<Module> MODULES_ENABLED = new ArrayList<Module>(); // // public static ArrayList<Module> getModules() { // if(MODULES_ENABLED.isEmpty()) { // MODULES_ENABLED.add(new BaseModule()); // MODULES_ENABLED.add(new IronChestModule()); // MODULES_ENABLED.add(new MFRModule()); // MODULES_ENABLED.add(new MinechemModule()); // } // return MODULES_ENABLED; // } // } // // Path: src/main/java/com/dta/extracarts/items/ExtraCartItem.java // public abstract class ExtraCartItem extends ItemMinecart { // public ExtraCartItem(int p_i45345_1_) { // super(p_i45345_1_); // this.setCreativeTab(CreativeTabs.tabTransport); // this.maxStackSize = 1; // } // // @Override // public abstract boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, // float par8, float par9, float par10); // // public boolean placeCart(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, // EntityMinecart entityMinecart) { // if (BlockRailBase.func_150051_a(world.getBlock(x, y, z))) { // if (!world.isRemote) { // entityMinecart.posX = (float)x + 0.5F; // entityMinecart.posY = (float)y + 0.5F; // entityMinecart.posZ = (float)z + 0.5F; // world.spawnEntityInWorld(entityMinecart); // } // // --itemStack.stackSize; // return true; // } else { // return false; // } // } // } // // Path: src/main/java/com/dta/extracarts/mods/minechem/entities/EntityLeadedChestCart.java // @Optional.Interface(iface = "mods.railcraft.api.carts.IMinecart", modid = "RailcraftAPI|carts") // public class EntityLeadedChestCart extends EntityExtraCartChestMinecart implements OpenableGUI, IMinecart { // private Block leadedChest = GameRegistry.findBlock("minechem", "tile.leadChest"); // // public EntityLeadedChestCart(World world) { // super(world); // } // // @Override // public void killMinecart(DamageSource par1DamageSource) { // super.killMinecart(par1DamageSource, new ItemStack(leadedChest, 1, 0)); // } // // @Override // public int getSizeInventory() { // return 9; // } // // @Override // public Block func_145817_o() { // return leadedChest; // } // // @Override // public Block func_145820_n() { // return leadedChest; // } // // @Override // public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new GUILeadedChestCart(player.inventory, this); // } // // @Override // public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { // return new ContainerLeadedChestCart(player.inventory, this); // } // // @Optional.Method(modid = "RailcraftAPI|carts") // public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) { // ItemStack CartStack = new ItemStack(MinechemModule.itemLeadedChestCart, 1, 0); // if (cart instanceof EntityLeadedChestCart && stack.getItem() == CartStack.getItem() && stack.getItemDamage() == 0) { // return true; // } // return false; // } // } // Path: src/main/java/com/dta/extracarts/mods/minechem/items/ItemLeadedChestCart.java import com.dta.extracarts.ModInfo; import com.dta.extracarts.items.ExtraCartItem; import com.dta.extracarts.mods.minechem.entities.EntityLeadedChestCart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; package com.dta.extracarts.mods.minechem.items; /** * Created by Skylar on 3/30/2015. */ public class ItemLeadedChestCart extends ExtraCartItem { public ItemLeadedChestCart() { super(1); this.setUnlocalizedName("LeadedChestCart"); this.setTextureName(ModInfo.MODID + ":minechem/LeadedChestCart"); } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
return placeCart(itemstack, player, world, x, y, z, new EntityLeadedChestCart(world));
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/base/entities/EntityEnderChestCart.java
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // }
import com.dta.extracarts.mods.base.BaseModule; import cpw.mods.fml.common.Optional; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityMinecartContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.InventoryEnderChest; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World;
} @Override public int getMinecartType() { return 1; } @Override public Block func_145817_o() { return Blocks.ender_chest; } @Override public void killMinecart(DamageSource par1DamageSource) { super.killMinecart(par1DamageSource); this.func_145778_a(Item.getItemFromBlock(Blocks.ender_chest), 1, 0.0F); } @Override public boolean interactFirst(EntityPlayer player) { InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); if (!this.worldObj.isRemote && !player.isSneaking()) { player.displayGUIChest(inventoryenderchest); } return true; } @Optional.Method(modid = "RailcraftAPI|carts") public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) {
// Path: src/main/java/com/dta/extracarts/mods/base/BaseModule.java // public class BaseModule extends Module { // public static Item EnderChestCart; // // @Override // public String getModuleName() { // return "Base"; // } // // @Override // public void init(FMLPreInitializationEvent event) { // EnderChestCart = new ItemEnderChestCart(); // GameRegistry.registerItem(EnderChestCart, ModInfo.MODID + "_" + EnderChestCart.getUnlocalizedName().substring(5)); // } // // @Override // public void load(FMLInitializationEvent event) { // GameRegistry.addShapelessRecipe(new ItemStack(EnderChestCart, 1, 0), Blocks.ender_chest, Items.minecart); // EntityRegistry.registerModEntity(EntityEnderChestCart.class, "EntityEnderChestCart", 0, ExtraCarts.instance, 80, 3, true); // } // } // Path: src/main/java/com/dta/extracarts/mods/base/entities/EntityEnderChestCart.java import com.dta.extracarts.mods.base.BaseModule; import cpw.mods.fml.common.Optional; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityMinecartContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.InventoryEnderChest; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; } @Override public int getMinecartType() { return 1; } @Override public Block func_145817_o() { return Blocks.ender_chest; } @Override public void killMinecart(DamageSource par1DamageSource) { super.killMinecart(par1DamageSource); this.func_145778_a(Item.getItemFromBlock(Blocks.ender_chest), 1, 0.0F); } @Override public boolean interactFirst(EntityPlayer player) { InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); if (!this.worldObj.isRemote && !player.isSneaking()) { player.displayGUIChest(inventoryenderchest); } return true; } @Optional.Method(modid = "RailcraftAPI|carts") public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) {
ItemStack CartStack = new ItemStack(BaseModule.EnderChestCart, 1, 0);
ScottDTA/ExtraCarts-1.7.10
src/main/java/com/dta/extracarts/mods/mfr/items/crafting/DSUCartRecipe.java
// Path: src/main/java/com/dta/extracarts/mods/mfr/MFRItems.java // public class MFRItems { // // public static Item MFRCart; // private static IRecipe dsuCart = new DSUCartRecipe(); // // public static void init() { // MFRCart = new ItemMFRCart(); // } // // public static void registerItems() { // GameRegistry.registerItem(MFRCart, ModInfo.MODID + "_" + MFRCart.getUnlocalizedName().substring(5)); // } // // public static void registerRecipes() { // GameRegistry.addRecipe(dsuCart); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // }
import com.dta.extracarts.mods.mfr.MFRItems; import com.dta.extracarts.mods.mfr.MFRModule; import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import cpw.mods.fml.common.registry.GameRegistry;
int others = 0; for (int k1 = 0; k1 < inventorycrafting.getSizeInventory(); ++k1) { ItemStack itemstack = inventorycrafting.getStackInSlot(k1); if (itemstack != null) { if (itemstack.getItem() == Items.minecart) { ++cart; } else if (itemstack.getItem() == dsuStack.getItem() && itemstack.getItemDamage() == 3) { ++dsu; } else { ++others; } } } if (cart != 1 || dsu != 1 || others > 0) { return false; } else { return true; } } @Override public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { ItemStack dsu = null; for (int x = 0; x < inventorycrafting.getSizeInventory(); ++x) { if (inventorycrafting.getStackInSlot(x) != null && inventorycrafting.getStackInSlot(x).getItem() == dsuStack.getItem()) { dsu = inventorycrafting.getStackInSlot(x).copy(); } }
// Path: src/main/java/com/dta/extracarts/mods/mfr/MFRItems.java // public class MFRItems { // // public static Item MFRCart; // private static IRecipe dsuCart = new DSUCartRecipe(); // // public static void init() { // MFRCart = new ItemMFRCart(); // } // // public static void registerItems() { // GameRegistry.registerItem(MFRCart, ModInfo.MODID + "_" + MFRCart.getUnlocalizedName().substring(5)); // } // // public static void registerRecipes() { // GameRegistry.addRecipe(dsuCart); // } // } // // Path: src/main/java/com/dta/extracarts/mods/mfr/MFRModule.java // public class MFRModule extends Module { // public static FakeDSUBlock fakeDSUBlock; // // @Override // public String getModuleName() { // return "MFR"; // } // // public Boolean areRequirementsMet() { // return Loader.isModLoaded("MineFactoryReloaded"); // } // // @Override // public void init(FMLPreInitializationEvent event) { // fakeDSUBlock = new FakeDSUBlock(); // FakeBlockRegistry.registerSubBlock(fakeDSUBlock); // } // // @Override // public void postInit(FMLPostInitializationEvent event) { // MFRItems.init(); // MFRItems.registerItems(); // MFRItems.registerRecipes(); // EntityRegistry.registerModEntity(EntityDSUCart.class, "EntityDSUCart", 9, ExtraCarts.instance, 80, 3, true); // } // } // Path: src/main/java/com/dta/extracarts/mods/mfr/items/crafting/DSUCartRecipe.java import com.dta.extracarts.mods.mfr.MFRItems; import com.dta.extracarts.mods.mfr.MFRModule; import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import cpw.mods.fml.common.registry.GameRegistry; int others = 0; for (int k1 = 0; k1 < inventorycrafting.getSizeInventory(); ++k1) { ItemStack itemstack = inventorycrafting.getStackInSlot(k1); if (itemstack != null) { if (itemstack.getItem() == Items.minecart) { ++cart; } else if (itemstack.getItem() == dsuStack.getItem() && itemstack.getItemDamage() == 3) { ++dsu; } else { ++others; } } } if (cart != 1 || dsu != 1 || others > 0) { return false; } else { return true; } } @Override public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { ItemStack dsu = null; for (int x = 0; x < inventorycrafting.getSizeInventory(); ++x) { if (inventorycrafting.getStackInSlot(x) != null && inventorycrafting.getStackInSlot(x).getItem() == dsuStack.getItem()) { dsu = inventorycrafting.getStackInSlot(x).copy(); } }
ItemStack result = new ItemStack(MFRItems.MFRCart, 1, 0);
latraccia/sd-dss-util
sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // }
import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/* * SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS. * Copyright (C) 2013 La Traccia http://www.latraccia.it/en/ * Developed by Francesco Pontillo * * This program 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ package it.latraccia.dss.util.builder.format; /** * Date: 06/12/13 * Time: 11.10 * * @author Francesco Pontillo */ public class CAdESFormatBuilder extends FormatBuilder<SignatureCAdESFormat> { // FORMAT public CAdESFormatBuilder() {
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // } // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException; /* * SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS. * Copyright (C) 2013 La Traccia http://www.latraccia.it/en/ * Developed by Francesco Pontillo * * This program 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ package it.latraccia.dss.util.builder.format; /** * Date: 06/12/13 * Time: 11.10 * * @author Francesco Pontillo */ public class CAdESFormatBuilder extends FormatBuilder<SignatureCAdESFormat> { // FORMAT public CAdESFormatBuilder() {
setFormat(SignatureFormat.CAdES);
latraccia/sd-dss-util
sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // }
import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/* * SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS. * Copyright (C) 2013 La Traccia http://www.latraccia.it/en/ * Developed by Francesco Pontillo * * This program 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ package it.latraccia.dss.util.builder.format; /** * Date: 06/12/13 * Time: 11.10 * * @author Francesco Pontillo */ public class CAdESFormatBuilder extends FormatBuilder<SignatureCAdESFormat> { // FORMAT public CAdESFormatBuilder() { setFormat(SignatureFormat.CAdES); } // LEVEL public CAdESFormatBuilder BES() {
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // } // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException; /* * SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS. * Copyright (C) 2013 La Traccia http://www.latraccia.it/en/ * Developed by Francesco Pontillo * * This program 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ package it.latraccia.dss.util.builder.format; /** * Date: 06/12/13 * Time: 11.10 * * @author Francesco Pontillo */ public class CAdESFormatBuilder extends FormatBuilder<SignatureCAdESFormat> { // FORMAT public CAdESFormatBuilder() { setFormat(SignatureFormat.CAdES); } // LEVEL public CAdESFormatBuilder BES() {
setLevel(SignatureCAdESLevel.BES);
latraccia/sd-dss-util
sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // }
import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/* * SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS. * Copyright (C) 2013 La Traccia http://www.latraccia.it/en/ * Developed by Francesco Pontillo * * This program 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ package it.latraccia.dss.util.builder.format; /** * Date: 06/12/13 * Time: 11.10 * * @author Francesco Pontillo */ public class CAdESFormatBuilder extends FormatBuilder<SignatureCAdESFormat> { // FORMAT public CAdESFormatBuilder() { setFormat(SignatureFormat.CAdES); } // LEVEL public CAdESFormatBuilder BES() { setLevel(SignatureCAdESLevel.BES); return this; } public CAdESFormatBuilder EPES() { setLevel(SignatureCAdESLevel.EPES); return this; }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // } // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException; /* * SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS. * Copyright (C) 2013 La Traccia http://www.latraccia.it/en/ * Developed by Francesco Pontillo * * This program 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see [http://www.gnu.org/licenses/]. */ package it.latraccia.dss.util.builder.format; /** * Date: 06/12/13 * Time: 11.10 * * @author Francesco Pontillo */ public class CAdESFormatBuilder extends FormatBuilder<SignatureCAdESFormat> { // FORMAT public CAdESFormatBuilder() { setFormat(SignatureFormat.CAdES); } // LEVEL public CAdESFormatBuilder BES() { setLevel(SignatureCAdESLevel.BES); return this; } public CAdESFormatBuilder EPES() { setLevel(SignatureCAdESLevel.EPES); return this; }
public CAdESFormatBuilder T(String serviceUrl) throws SignatureServiceUrlException {
latraccia/sd-dss-util
sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // }
import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException;
return this; } public CAdESFormatBuilder C(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.C); setServiceUrl(serviceUrl); return this; } public CAdESFormatBuilder X(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.BES); setServiceUrl(serviceUrl); return this; } public CAdESFormatBuilder XL(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.EPES); setServiceUrl(serviceUrl); return this; } public CAdESFormatBuilder A(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.A); setServiceUrl(serviceUrl); return this; } // PACKAGING public CAdESFormatBuilder enveloping() {
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureCAdESFormat.java // public class SignatureCAdESFormat extends SignatureFormat { // public SignatureCAdESFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java // public class SignatureFormat extends GeneralEnum { // public static final String XAdES_NAME = "XAdES"; // public static final String CAdES_NAME = "CAdES"; // public static final String PAdES_NAME = "PAdES"; // // public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME); // public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME); // public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME); // // public SignatureFormat(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureCAdESLevel.java // public class SignatureCAdESLevel extends SignatureLevel { // public static SignatureCAdESLevel BES = new SignatureCAdESLevel(SignatureLevel.BES); // public static SignatureCAdESLevel EPES = new SignatureCAdESLevel(SignatureLevel.EPES); // public static SignatureCAdESLevel T = new SignatureCAdESLevel(SignatureLevel.T); // public static SignatureCAdESLevel C = new SignatureCAdESLevel(SignatureLevel.C); // public static SignatureCAdESLevel X = new SignatureCAdESLevel(SignatureLevel.X); // public static SignatureCAdESLevel XL = new SignatureCAdESLevel(SignatureLevel.XL); // public static SignatureCAdESLevel A = new SignatureCAdESLevel(SignatureLevel.A); // // public SignatureCAdESLevel(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureCAdESPackaging.java // public class SignatureCAdESPackaging extends SignaturePackaging { // public static SignatureCAdESPackaging ENVELOPING = new SignatureCAdESPackaging(SignaturePackaging.ENVELOPING); // public static SignatureCAdESPackaging DETACHED = new SignatureCAdESPackaging(SignaturePackaging.DETACHED); // // public SignatureCAdESPackaging(String value) { // super(value); // } // } // // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java // public class SignatureServiceUrlException extends SignatureException { // public SignatureServiceUrlException() { // } // public SignatureServiceUrlException(Exception e) { // super(e); // } // // @Override // public String getMessage() { // return "The service URL was required but not specified!"; // } // } // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/CAdESFormatBuilder.java import it.latraccia.dss.util.entity.format.SignatureCAdESFormat; import it.latraccia.dss.util.entity.format.SignatureFormat; import it.latraccia.dss.util.entity.level.SignatureCAdESLevel; import it.latraccia.dss.util.entity.packaging.SignatureCAdESPackaging; import it.latraccia.dss.util.exception.SignatureServiceUrlException; return this; } public CAdESFormatBuilder C(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.C); setServiceUrl(serviceUrl); return this; } public CAdESFormatBuilder X(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.BES); setServiceUrl(serviceUrl); return this; } public CAdESFormatBuilder XL(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.EPES); setServiceUrl(serviceUrl); return this; } public CAdESFormatBuilder A(String serviceUrl) throws SignatureServiceUrlException { setLevel(SignatureCAdESLevel.A); setServiceUrl(serviceUrl); return this; } // PACKAGING public CAdESFormatBuilder enveloping() {
setPackaging(SignatureCAdESPackaging.ENVELOPING);