repo_name stringlengths 5 108 | path stringlengths 6 333 | size stringlengths 1 6 | content stringlengths 4 977k | license stringclasses 15
values |
|---|---|---|---|---|
vrto/apache-camel-invoices | src/main/java/com/vrtoonjava/invoices/ForeignPaymentCreator.java | 747 | package com.vrtoonjava.invoices;
import com.vrtoonjava.banking.Payment;
import com.vrtoonjava.banking.PaymentCreator;
import com.vrtoonjava.banking.PaymentException;
import org.springframework.stereotype.Component;
@Component
public class ForeignPaymentCreator implements PaymentCreator {
// hard coded account value for demo purposes
private static final String CURRENT_IBAN_ACC = "current-iban-acc";
@Override
public Payment createPayment(Invoice invoice) throws PaymentException {
if (null == invoice.getIban()) {
throw new PaymentException("IBAN mustn't be null when creating foreign payment!");
}
return new Payment(CURRENT_IBAN_ACC, invoice.getIban(), invoice.getDollars());
}
}
| apache-2.0 |
luojiangyu/ibatis-2 | src/main/java/com/ibatis/sqlmap/engine/cache/memory/MemoryCacheLevel.java | 3466 | /**
* Copyright 2004-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ibatis.sqlmap.engine.cache.memory;
import com.ibatis.sqlmap.client.SqlMapException;
import java.util.HashMap;
import java.util.Map;
/**
* An enumeration for the values for the memory cache levels
*/
public final class MemoryCacheLevel {
private static Map cacheLevelMap = new HashMap();
/**
* Constant for weak caching
* This cache model is probably the best choice in most cases. It will increase
* performance for popular results, but it will absolutely release the memory to
* be used in allocating other objects, assuming that the results are not currently
* in use.
*/
public final static MemoryCacheLevel WEAK;
/**
* Constant for soft caching.
* This cache model will reduce the likelihood of running out of memory in case the
* results are not currently in use and the memory is needed for other objects.
* However, this is not the most aggressive cache-model in that regard. Hence,
* memory still might be allocated and unavailable for more important objects.
*/
public final static MemoryCacheLevel SOFT;
/**
* Constant for strong caching.
* This cache model will guarantee that the results stay in memory until the cache
* is explicitly flushed. This is ideal for results that are:
* <ol>
* <li>very small</li>
* <li>absolutely static</li>
* <li>used very often</li>
* </ol>
* The advantage is that performance will be very good for this particular query.
* The disadvantage is that if the memory used by these results is needed, then it
* will not be released to make room for other objects (possibly more important
* objects).
*/
public final static MemoryCacheLevel STRONG;
private String referenceType;
static {
WEAK = new MemoryCacheLevel("WEAK");
SOFT = new MemoryCacheLevel("SOFT");
STRONG = new MemoryCacheLevel("STRONG");
cacheLevelMap.put(WEAK.referenceType, WEAK);
cacheLevelMap.put(SOFT.referenceType, SOFT);
cacheLevelMap.put(STRONG.referenceType, STRONG);
}
/**
* Creates a new instance of CacheLevel
*/
private MemoryCacheLevel(String type) {
this.referenceType = type;
}
/**
* Getter for the reference type
*
* @return the type of reference type used
*/
public String getReferenceType() {
return this.referenceType;
}
/**
* Gets a MemoryCacheLevel by name
*
* @param refType the name of the reference type
* @return the MemoryCacheLevel that the name indicates
*/
public static MemoryCacheLevel getByReferenceType(String refType) {
MemoryCacheLevel cacheLevel = (MemoryCacheLevel) cacheLevelMap.get(refType);
if (cacheLevel == null) {
throw new SqlMapException("Error getting CacheLevel (reference type) for name: '" + refType + "'.");
}
return cacheLevel;
}
}
| apache-2.0 |
AndroidX/constraintlayout | desktop/SwingDemo/app/src/androidx/constraintLayout/desktop/motion/SwingDemo4.java | 4319 | /*
* Copyright (C) 2021 The Android Open Source Project
*
* 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 androidx.constraintLayout.desktop.motion;
import androidx.constraintlayout.core.motion.utils.Utils;
import org.constraintlayout.swing.MotionLayout;
import org.constraintlayout.swing.MotionPanel;
import javax.swing.*;
public class SwingDemo4 extends MotionPanel {
static String motionScene = "{\n" +
" Header: {\n" +
" name: 'translationX28'\n" +
" },\n" +
" ConstraintSets: {\n" +
" start: {\n" +
" b1: {\n" +
" width: 90, height: 40,\n" +
" start: ['parent', 'start', 70],\n" +
" bottom: ['parent', 'bottom', 16]\n" +
" }\n" +
" b2: {\n" +
" width: 90, height: 40,\n" +
" translationX: 0,\n" +
" start: ['b1', 'end', 16],\n" +
" bottom: ['b1', 'bottom', 0]\n" +
" }\n" +
" },\n" +
" end: {\n" +
" b1: {\n" +
" width: 90, height: 40,\n" +
" end: ['parent', 'end', 16],\n" +
" top: ['parent', 'top', 16]\n" +
" }\n" +
" b2: {\n" +
" width: 90, height: 40,\n" +
" translationX: 0,\n" +
" start: ['b1', 'start', 0],\n" +
" top: ['b1', 'bottom', 16]\n" +
" }\n" +
" }\n" +
" },\n" +
" Transitions: {\n" +
" default: {\n" +
" from: 'start',\n" +
" to: 'end',\n" +
" pathMotionArc: 'startVertical',\n" +
" KeyFrames: {\n" +
" KeyAttributes: [\n" +
" {\n" +
" target: ['b2'],\n" +
" frames: [33, 86],\n" +
" translationX: [30,30 ],\n" +
" translationY: [30,10 ],\n" +
" \n" +
" }\n" +
" ]\n" +
" }\n" +
" }\n" +
" }\n" +
" }";
MotionLayout ml;
float p = 0;
public SwingDemo4() {
setLayoutDescription(motionScene);
JButton button1 = new JButton("b1");
JButton button2 = new JButton("b2");
add(button1, "b1");
add(button2, "b2");
Timer timer = new Timer(16, (e) -> setProgress(p = (p + 0.01f) % 1));
timer.setRepeats(true);
timer.start();
}
public static void main(String[] args) {
JFrame frame = new JFrame(SwingDemo4.class.getSimpleName());
Utils.log(frame.getTitle());
SwingDemo4 panel = new SwingDemo4();
frame.setContentPane(panel);
frame.setBounds(100, 100, 400, 500);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
| apache-2.0 |
qmwu2000/cat2 | cat-core-message/src/main/java/org/unidal/cat/core/message/provider/DefaultMessageProvider.java | 922 | package org.unidal.cat.core.message.provider;
import java.io.IOException;
import org.unidal.lookup.annotation.Inject;
import org.unidal.lookup.annotation.Named;
import com.dianping.cat.message.spi.MessageTree;
@Named(type = MessageProvider.class)
public class DefaultMessageProvider implements MessageProvider {
@Inject(RecentMessageProvider.ID)
private MessageProvider m_recent;
@Inject(HistoricalMessageProvider.ID)
private MessageProvider m_historical;
@Override
public boolean isEligible(MessageContext ctx) {
return true;
}
@Override
public MessageTree getMessage(MessageContext ctx) throws IOException {
if (m_historical.isEligible(ctx)) {
MessageTree tree = m_historical.getMessage(ctx);
if (tree != null) {
return tree;
} else {
// fallback to local
}
}
return m_recent.getMessage(ctx);
}
}
| apache-2.0 |
gocd/gocd | server/src/test-fast/java/com/thoughtworks/go/server/service/JobPresentationServiceTest.java | 4423 | /*
* Copyright 2022 ThoughtWorks, Inc.
*
* 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.thoughtworks.go.server.service;
import com.thoughtworks.go.config.Agent;
import com.thoughtworks.go.domain.AgentInstance;
import com.thoughtworks.go.domain.JobInstance;
import com.thoughtworks.go.domain.JobInstances;
import com.thoughtworks.go.server.domain.JobDurationStrategy;
import com.thoughtworks.go.server.ui.JobInstanceModel;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
import static com.thoughtworks.go.helper.AgentInstanceMother.building;
import static com.thoughtworks.go.helper.JobInstanceMother.*;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.*;
public class JobPresentationServiceTest {
private JobDurationStrategy jobDurationStrategy;
private AgentService agentService;
@BeforeEach
public void setUp() throws Exception {
jobDurationStrategy = mock(JobDurationStrategy.class);
agentService = mock(AgentService.class);
}
@Test
public void shouldReturnJobModel() {
JobInstance dev = assignedWithAgentId("dev", "agent1");
JobInstance DEv = assignedWithAgentId("DEv", "agent1");
JobInstance bev = assignedWithAgentId("bev", "agent2");
JobInstance tev = scheduled("tev");
JobInstance lev = assignAgent(passed("lev"), "agent3");
JobInstance kev = assignAgent(failed("kev"), "agent3");
AgentInstance agentInstance = building();
when(agentService.findAgentAndRefreshStatus(any(String.class))).thenReturn(agentInstance);
List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(dev, bev, tev, lev, kev, DEv));
assertThat(models.size(), is(6));
//failed
assertThat(models.get(0), is(new JobInstanceModel(kev, jobDurationStrategy, agentInstance)));
//in progress. sort by name (case insensitive)
assertThat(models.get(1), is(new JobInstanceModel(bev, jobDurationStrategy, agentInstance)));
assertThat(models.get(2), is(new JobInstanceModel(dev, jobDurationStrategy, agentInstance)));
assertThat(models.get(3), is(new JobInstanceModel(DEv, jobDurationStrategy, agentInstance)));
assertThat(models.get(4), is(new JobInstanceModel(tev, jobDurationStrategy)));
//passed
assertThat(models.get(5), is(new JobInstanceModel(lev, jobDurationStrategy, agentInstance)));
//assert agent info
verify(agentService, times(2)).findAgentAndRefreshStatus("agent1");
verify(agentService).findAgentAndRefreshStatus("agent2");
verify(agentService, times(2)).findAgentAndRefreshStatus("agent3");
verifyNoMoreInteractions(agentService);
}
@Test
public void shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig() {
String deletedAgentUuid = "deleted_agent";
JobInstance jobWithDeletedAgent = assignedWithAgentId("dev", deletedAgentUuid);
when(agentService.findAgentAndRefreshStatus(deletedAgentUuid)).thenReturn(null);
Agent agentFromDb = new Agent(deletedAgentUuid,"hostname", "1.2.3.4", "cookie");
when(agentService.findAgentByUUID(deletedAgentUuid)).thenReturn(agentFromDb);
List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(jobWithDeletedAgent));
assertThat(models.size(), is(1));
assertThat(models.get(0), is(new JobInstanceModel(jobWithDeletedAgent, jobDurationStrategy, agentFromDb)));
verify(agentService, times(1)).findAgentAndRefreshStatus(deletedAgentUuid);
verify(agentService, times(1)).findAgentByUUID(deletedAgentUuid);
verifyNoMoreInteractions(agentService);
}
}
| apache-2.0 |
sijie/bookkeeper | stream/distributedlog/core/src/main/java/org/apache/distributedlog/BookKeeperClientBuilder.java | 6856 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.distributedlog;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Optional;
import io.netty.channel.EventLoopGroup;
import io.netty.util.HashedWheelTimer;
import org.apache.bookkeeper.feature.FeatureProvider;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
/**
* Builder to build bookkeeper client.
*/
public class BookKeeperClientBuilder {
/**
* Create a bookkeeper client builder to build bookkeeper clients.
*
* @return bookkeeper client builder.
*/
public static BookKeeperClientBuilder newBuilder() {
return new BookKeeperClientBuilder();
}
// client name
private String name = null;
// dl config
private DistributedLogConfiguration dlConfig = null;
// bookkeeper settings
// zookeeper client
private ZooKeeperClient zkc = null;
// or zookeeper servers
private String zkServers = null;
// ledgers path
private String ledgersPath = null;
// statsLogger
private StatsLogger statsLogger = NullStatsLogger.INSTANCE;
// client channel factory
private EventLoopGroup eventLoopGroup = null;
// request timer
private HashedWheelTimer requestTimer = null;
// feature provider
private Optional<FeatureProvider> featureProvider = Optional.absent();
// Cached BookKeeper Client
private BookKeeperClient cachedClient = null;
/**
* Private bookkeeper builder.
*/
private BookKeeperClientBuilder() {}
/**
* Set client name.
*
* @param name
* client name.
* @return builder
*/
public synchronized BookKeeperClientBuilder name(String name) {
this.name = name;
return this;
}
/**
* <i>dlConfig</i> used to configure bookkeeper client.
*
* @param dlConfig
* distributedlog config.
* @return builder.
*/
public synchronized BookKeeperClientBuilder dlConfig(DistributedLogConfiguration dlConfig) {
this.dlConfig = dlConfig;
return this;
}
/**
* Set the zkc used to build bookkeeper client. If a zookeeper client is provided in this
* method, bookkeeper client will use it rather than creating a brand new one.
*
* @param zkc
* zookeeper client.
* @return builder
* @see #zkServers(String)
*/
public synchronized BookKeeperClientBuilder zkc(ZooKeeperClient zkc) {
this.zkc = zkc;
return this;
}
/**
* Set the zookeeper servers that bookkeeper client would connect to. If no zookeeper client
* is provided by {@link #zkc(ZooKeeperClient)}, bookkeeper client will use the given string
* to create a brand new zookeeper client.
*
* @param zkServers
* zookeeper servers that bookkeeper client would connect to.
* @return builder
* @see #zkc(ZooKeeperClient)
*/
public synchronized BookKeeperClientBuilder zkServers(String zkServers) {
this.zkServers = zkServers;
return this;
}
/**
* Set the ledgers path that bookkeeper client is going to access.
*
* @param ledgersPath
* ledgers path
* @return builder
* @see org.apache.bookkeeper.conf.ClientConfiguration#getZkLedgersRootPath()
*/
public synchronized BookKeeperClientBuilder ledgersPath(String ledgersPath) {
this.ledgersPath = ledgersPath;
return this;
}
/**
* Build BookKeeper client using existing <i>bkc</i> client.
*
* @param bkc
* bookkeeper client.
* @return builder
*/
public synchronized BookKeeperClientBuilder bkc(BookKeeperClient bkc) {
this.cachedClient = bkc;
return this;
}
/**
* Build BookKeeper client using existing <i>channelFactory</i>.
*
* @param eventLoopGroup
* event loop group used to build bookkeeper client.
* @return bookkeeper client builder.
*/
public synchronized BookKeeperClientBuilder eventLoopGroup(EventLoopGroup eventLoopGroup) {
this.eventLoopGroup = eventLoopGroup;
return this;
}
/**
* Build BookKeeper client using existing <i>request timer</i>.
*
* @param requestTimer
* HashedWheelTimer used to build bookkeeper client.
* @return bookkeeper client builder.
*/
public synchronized BookKeeperClientBuilder requestTimer(HashedWheelTimer requestTimer) {
this.requestTimer = requestTimer;
return this;
}
/**
* Build BookKeeper Client using given stats logger <i>statsLogger</i>.
*
* @param statsLogger
* stats logger to report stats
* @return builder.
*/
public synchronized BookKeeperClientBuilder statsLogger(StatsLogger statsLogger) {
this.statsLogger = statsLogger;
return this;
}
public synchronized BookKeeperClientBuilder featureProvider(Optional<FeatureProvider> featureProvider) {
this.featureProvider = featureProvider;
return this;
}
private void validateParameters() {
checkNotNull(name, "Missing client name.");
checkNotNull(dlConfig, "Missing DistributedLog Configuration.");
checkArgument(null == zkc || null == zkServers, "Missing zookeeper setting.");
checkNotNull(ledgersPath, "Missing Ledgers Root Path.");
}
public synchronized BookKeeperClient build() {
if (null == cachedClient) {
cachedClient = buildClient();
}
return cachedClient;
}
private BookKeeperClient buildClient() {
validateParameters();
return new BookKeeperClient(
dlConfig,
name,
zkServers,
zkc,
ledgersPath,
eventLoopGroup,
requestTimer,
statsLogger,
featureProvider);
}
}
| apache-2.0 |
gruter/cloudata | src/java/org/cloudata/core/common/conf/CConfigurable.java | 1128 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cloudata.core.common.conf;
/** Something that may be configured with a {@link CloudataConf}. */
public interface CConfigurable {
/** Set the configuration to be used by this object. */
void setConf(CloudataConf conf);
/** Return the configuration used by this object. */
CloudataConf getConf();
}
| apache-2.0 |
ning/serialization | thrift/src/main/java/com/ning/metrics/serialization/thrift/ThriftEnvelopeSerialization.java | 821 | /*
* Copyright 2010-2011 Ning, Inc.
*
* Ning licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.ning.metrics.serialization.thrift;
class ThriftEnvelopeSerialization
{
static final short TYPE_ID = 0;
static final short PAYLOAD_ID = 1;
static final short NAME_ID = 2;
}
| apache-2.0 |
wilebeast/FireFox-OS | B2G/gecko/mobile/android/base/sync/setup/activities/SendTabActivity.java | 8322 | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.sync.setup.activities;
import java.util.List;
import org.mozilla.gecko.R;
import org.mozilla.gecko.sync.CommandProcessor;
import org.mozilla.gecko.sync.CommandRunner;
import org.mozilla.gecko.sync.CredentialException;
import org.mozilla.gecko.sync.GlobalConstants;
import org.mozilla.gecko.sync.SyncConstants;
import org.mozilla.gecko.sync.GlobalSession;
import org.mozilla.gecko.sync.Logger;
import org.mozilla.gecko.sync.SyncConfiguration;
import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.sync.repositories.NullCursorException;
import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor;
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
import org.mozilla.gecko.sync.setup.Constants;
import org.mozilla.gecko.sync.setup.SyncAccounts;
import org.mozilla.gecko.sync.setup.SyncAccounts.SyncAccountParameters;
import org.mozilla.gecko.sync.stage.SyncClientsEngineStage;
import org.mozilla.gecko.sync.syncadapter.SyncAdapter;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;
public class SendTabActivity extends Activity {
public static final String LOG_TAG = "SendTabActivity";
private ClientRecordArrayAdapter arrayAdapter;
private AccountManager accountManager;
private Account localAccount;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onResume() {
ActivityUtils.prepareLogging();
Logger.info(LOG_TAG, "Called SendTabActivity.onResume.");
super.onResume();
redirectIfNoSyncAccount();
registerDisplayURICommand();
setContentView(R.layout.sync_send_tab);
final ListView listview = (ListView) findViewById(R.id.device_list);
listview.setItemsCanFocus(true);
listview.setTextFilterEnabled(true);
listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
enableSend(false);
// Fetching the client list hits the clients database, so we spin this onto
// a background task.
final Context context = this;
new AsyncTask<Void, Void, ClientRecord[]>() {
@Override
protected ClientRecord[] doInBackground(Void... params) {
return getClientArray();
}
@Override
protected void onPostExecute(final ClientRecord[] clientArray) {
// We're allowed to update the UI from here.
arrayAdapter = new ClientRecordArrayAdapter(context, R.layout.sync_list_item, clientArray);
listview.setAdapter(arrayAdapter);
}
}.execute();
}
private static void registerDisplayURICommand() {
final CommandProcessor processor = CommandProcessor.getProcessor();
processor.registerCommand("displayURI", new CommandRunner(3) {
@Override
public void executeCommand(final GlobalSession session, List<String> args) {
CommandProcessor.displayURI(args, session.getContext());
}
});
}
private void redirectIfNoSyncAccount() {
accountManager = AccountManager.get(getApplicationContext());
Account[] accts = accountManager.getAccountsByType(SyncConstants.ACCOUNTTYPE_SYNC);
// A Sync account exists.
if (accts.length > 0) {
localAccount = accts[0];
return;
}
Intent intent = new Intent(this, RedirectToSetupActivity.class);
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
startActivity(intent);
finish();
}
/**
* @return Return null if there is no account set up. Return the account GUID otherwise.
*/
private String getAccountGUID() {
if (localAccount == null) {
Logger.warn(LOG_TAG, "Null local account; aborting.");
return null;
}
SyncAccountParameters params;
try {
params = SyncAccounts.blockingFromAndroidAccountV0(this, accountManager, localAccount);
} catch (CredentialException e) {
Logger.warn(LOG_TAG, "Could not get sync account parameters; aborting.");
return null;
}
SharedPreferences prefs;
try {
final String product = GlobalConstants.BROWSER_INTENT_PACKAGE;
final String profile = Constants.DEFAULT_PROFILE;
final long version = SyncConfiguration.CURRENT_PREFS_VERSION;
prefs = Utils.getSharedPreferences(getApplicationContext(), product, params.username, params.serverURL, profile, version);
return prefs.getString(SyncConfiguration.PREF_ACCOUNT_GUID, null);
} catch (Exception e) {
return null;
}
}
public void sendClickHandler(View view) {
Logger.info(LOG_TAG, "Send was clicked.");
Bundle extras = this.getIntent().getExtras();
if (extras == null) {
Logger.warn(LOG_TAG, "extras was null; aborting without sending tab.");
notifyAndFinish(false);
return;
}
final String uri = extras.getString(Intent.EXTRA_TEXT);
final String title = extras.getString(Intent.EXTRA_SUBJECT);
final List<String> guids = arrayAdapter.getCheckedGUIDs();
if (title == null) {
Logger.warn(LOG_TAG, "title was null; ignoring and sending tab anyway.");
}
if (uri == null) {
Logger.warn(LOG_TAG, "uri was null; aborting without sending tab.");
notifyAndFinish(false);
return;
}
if (guids == null) {
// Should never happen.
Logger.warn(LOG_TAG, "guids was null; aborting without sending tab.");
notifyAndFinish(false);
return;
}
// Fetching local client GUID hits the DB, and we want to update the UI
// afterward, so we perform the tab sending on another thread.
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
final CommandProcessor processor = CommandProcessor.getProcessor();
final String accountGUID = getAccountGUID();
Logger.debug(LOG_TAG, "Retrieved local account GUID '" + accountGUID + "'.");
if (accountGUID == null) {
return false;
}
for (String guid : guids) {
processor.sendURIToClientForDisplay(uri, guid, title, accountGUID, getApplicationContext());
}
Logger.info(LOG_TAG, "Requesting immediate clients stage sync.");
SyncAdapter.requestImmediateSync(localAccount, new String[] { SyncClientsEngineStage.COLLECTION_NAME });
return true;
}
@Override
protected void onPostExecute(final Boolean success) {
// We're allowed to update the UI from here.
notifyAndFinish(success.booleanValue());
}
}.execute();
}
/**
* Notify the user about sent tabs status and then finish the activity.
* <p>
* "Success" is a bit of a misnomer: we wrote "displayURI" commands to the local
* command database, and they will be sent on next sync. There is no way to
* verify that the commands were successfully received by the intended remote
* client, so we lie and say they were sent.
*
* @param success true if tab was sent successfully; false otherwise.
*/
protected void notifyAndFinish(final boolean success) {
int textId;
if (success) {
textId = R.string.sync_text_tab_sent;
} else {
textId = R.string.sync_text_tab_not_sent;
}
Toast.makeText(this, textId, Toast.LENGTH_LONG).show();
finish();
}
public void enableSend(boolean shouldEnable) {
View sendButton = findViewById(R.id.send_button);
sendButton.setEnabled(shouldEnable);
sendButton.setClickable(shouldEnable);
}
protected ClientRecord[] getClientArray() {
ClientsDatabaseAccessor db = new ClientsDatabaseAccessor(this.getApplicationContext());
try {
return db.fetchAllClients().values().toArray(new ClientRecord[0]);
} catch (NullCursorException e) {
Logger.warn(LOG_TAG, "NullCursorException while populating device list.", e);
return null;
} finally {
db.close();
}
}
}
| apache-2.0 |
apucher/pinot | pinot-core/src/test/java/com/linkedin/pinot/core/startree/v2/PreAggregatedMinMaxRangeStarTreeV2Test.java | 1958 | /**
* Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
*
* 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.linkedin.pinot.core.startree.v2;
import com.linkedin.pinot.common.data.FieldSpec.DataType;
import com.linkedin.pinot.core.common.ObjectSerDeUtils;
import com.linkedin.pinot.core.data.aggregator.MinMaxRangeValueAggregator;
import com.linkedin.pinot.core.data.aggregator.ValueAggregator;
import com.linkedin.pinot.core.query.aggregation.function.customobject.MinMaxRangePair;
import java.util.Random;
import static org.testng.Assert.*;
public class PreAggregatedMinMaxRangeStarTreeV2Test extends BaseStarTreeV2Test<Object, MinMaxRangePair> {
@Override
ValueAggregator<Object, MinMaxRangePair> getValueAggregator() {
return new MinMaxRangeValueAggregator();
}
@Override
DataType getRawValueType() {
return DataType.BYTES;
}
@Override
Object getRandomRawValue(Random random) {
long value1 = random.nextInt();
long value2 = random.nextInt();
return ObjectSerDeUtils.MIN_MAX_RANGE_PAIR_SER_DE.serialize(
new MinMaxRangePair(Math.min(value1, value2), Math.max(value1, value2)));
}
@Override
protected void assertAggregatedValue(MinMaxRangePair starTreeResult, MinMaxRangePair nonStarTreeResult) {
assertEquals(starTreeResult.getMin(), nonStarTreeResult.getMin(), 1e-5);
assertEquals(starTreeResult.getMax(), nonStarTreeResult.getMax(), 1e-5);
}
}
| apache-2.0 |
apache/tomcat | java/org/apache/tomcat/util/net/openssl/OpenSSLConfCmd.java | 1331 | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tomcat.util.net.openssl;
import java.io.Serializable;
public class OpenSSLConfCmd implements Serializable {
private static final long serialVersionUID = 1L;
private String name = null;
private String value = null;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
| apache-2.0 |
mdogan/hazelcast | hazelcast/src/test/java/com/hazelcast/map/MergePolicyTest.java | 12239 | /*
* Copyright (c) 2008-2020, Hazelcast, Inc. All Rights Reserved.
*
* 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.hazelcast.map;
import com.hazelcast.cluster.MembershipEvent;
import com.hazelcast.cluster.MembershipListener;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleListener;
import com.hazelcast.instance.impl.HazelcastInstanceFactory;
import com.hazelcast.spi.merge.HigherHitsMergePolicy;
import com.hazelcast.spi.merge.LatestUpdateMergePolicy;
import com.hazelcast.spi.merge.PassThroughMergePolicy;
import com.hazelcast.spi.merge.PutIfAbsentMergePolicy;
import com.hazelcast.spi.properties.ClusterProperty;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
import com.hazelcast.test.annotation.NightlyTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static com.hazelcast.internal.util.ExceptionUtil.rethrow;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@RunWith(HazelcastSerialClassRunner.class)
@Category(NightlyTest.class)
public class MergePolicyTest extends HazelcastTestSupport {
@Before
@After
public void killAllHazelcastInstances() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testLatestUpdateMapMergePolicy() {
String mapName = randomMapName();
Config config = newConfig(LatestUpdateMergePolicy.class.getName(), mapName);
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
warmUpPartitions(h1, h2);
TestMemberShipListener memberShipListener = new TestMemberShipListener(1);
h2.getCluster().addMembershipListener(memberShipListener);
CountDownLatch mergeBlockingLatch = new CountDownLatch(1);
TestLifeCycleListener lifeCycleListener = new TestLifeCycleListener(1, mergeBlockingLatch);
h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
closeConnectionBetween(h1, h2);
assertOpenEventually(memberShipListener.memberRemovedLatch);
assertClusterSizeEventually(1, h1);
assertClusterSizeEventually(1, h2);
IMap<Object, Object> map1 = h1.getMap(mapName);
IMap<Object, Object> map2 = h2.getMap(mapName);
map1.put("key1", "value");
// prevent updating at the same time
sleepAtLeastMillis(1000);
map2.put("key1", "LatestUpdatedValue");
map2.put("key2", "value2");
// prevent updating at the same time
sleepAtLeastMillis(1000);
map1.put("key2", "LatestUpdatedValue2");
// allow merge process to continue
mergeBlockingLatch.countDown();
assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
assertClusterSizeEventually(2, h1, h2);
IMap<Object, Object> mapTest = h1.getMap(mapName);
assertEquals("LatestUpdatedValue", mapTest.get("key1"));
assertEquals("LatestUpdatedValue2", mapTest.get("key2"));
}
@Test
public void testHigherHitsMapMergePolicy() {
String mapName = randomMapName();
Config config = newConfig(HigherHitsMergePolicy.class.getName(), mapName);
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
warmUpPartitions(h1, h2);
TestMemberShipListener memberShipListener = new TestMemberShipListener(1);
h2.getCluster().addMembershipListener(memberShipListener);
CountDownLatch mergeBlockingLatch = new CountDownLatch(1);
TestLifeCycleListener lifeCycleListener = new TestLifeCycleListener(1, mergeBlockingLatch);
h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
closeConnectionBetween(h1, h2);
assertOpenEventually(memberShipListener.memberRemovedLatch);
assertClusterSizeEventually(1, h1);
assertClusterSizeEventually(1, h2);
IMap<Object, Object> map1 = h1.getMap(mapName);
map1.put("key1", "higherHitsValue");
map1.put("key2", "value2");
// increase hits number
map1.get("key1");
map1.get("key1");
IMap<Object, Object> map2 = h2.getMap(mapName);
map2.put("key1", "value1");
map2.put("key2", "higherHitsValue2");
// increase hits number
map2.get("key2");
map2.get("key2");
// allow merge process to continue
mergeBlockingLatch.countDown();
assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
assertClusterSizeEventually(2, h1, h2);
IMap<Object, Object> mapTest = h2.getMap(mapName);
assertEquals("higherHitsValue", mapTest.get("key1"));
assertEquals("higherHitsValue2", mapTest.get("key2"));
}
@Test
public void testPutIfAbsentMapMergePolicy() {
String mapName = randomMapName();
Config config = newConfig(PutIfAbsentMergePolicy.class.getName(), mapName);
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
warmUpPartitions(h1, h2);
TestMemberShipListener memberShipListener = new TestMemberShipListener(1);
h2.getCluster().addMembershipListener(memberShipListener);
CountDownLatch mergeBlockingLatch = new CountDownLatch(1);
TestLifeCycleListener lifeCycleListener = new TestLifeCycleListener(1, mergeBlockingLatch);
h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
closeConnectionBetween(h1, h2);
assertOpenEventually(memberShipListener.memberRemovedLatch);
assertClusterSizeEventually(1, h1);
assertClusterSizeEventually(1, h2);
IMap<Object, Object> map1 = h1.getMap(mapName);
map1.put("key1", "PutIfAbsentValue1");
IMap<Object, Object> map2 = h2.getMap(mapName);
map2.put("key1", "value");
map2.put("key2", "PutIfAbsentValue2");
// allow merge process to continue
mergeBlockingLatch.countDown();
assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
assertClusterSizeEventually(2, h1, h2);
IMap<Object, Object> mapTest = h2.getMap(mapName);
assertEquals("PutIfAbsentValue1", mapTest.get("key1"));
assertEquals("PutIfAbsentValue2", mapTest.get("key2"));
}
@Test
public void testPassThroughMapMergePolicy() {
String mapName = randomMapName();
Config config = newConfig(PassThroughMergePolicy.class.getName(), mapName);
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
warmUpPartitions(h1, h2);
TestMemberShipListener memberShipListener = new TestMemberShipListener(1);
h2.getCluster().addMembershipListener(memberShipListener);
CountDownLatch mergeBlockingLatch = new CountDownLatch(1);
TestLifeCycleListener lifeCycleListener = new TestLifeCycleListener(1, mergeBlockingLatch);
h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
closeConnectionBetween(h1, h2);
assertOpenEventually(memberShipListener.memberRemovedLatch);
assertClusterSizeEventually(1, h1);
assertClusterSizeEventually(1, h2);
IMap<Object, Object> map1 = h1.getMap(mapName);
String key = generateKeyOwnedBy(h1);
map1.put(key, "value");
IMap<Object, Object> map2 = h2.getMap(mapName);
map2.put(key, "passThroughValue");
// allow merge process to continue
mergeBlockingLatch.countDown();
assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
assertClusterSizeEventually(2, h1, h2);
IMap<Object, Object> mapTest = h2.getMap(mapName);
assertEquals("passThroughValue", mapTest.get(key));
}
@Test
public void testCustomMergePolicy() {
String mapName = randomMapName();
Config config = newConfig(TestCustomMapMergePolicy.class.getName(), mapName);
HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
warmUpPartitions(h1, h2);
TestMemberShipListener memberShipListener = new TestMemberShipListener(1);
h2.getCluster().addMembershipListener(memberShipListener);
CountDownLatch mergeBlockingLatch = new CountDownLatch(1);
TestLifeCycleListener lifeCycleListener = new TestLifeCycleListener(1, mergeBlockingLatch);
h2.getLifecycleService().addLifecycleListener(lifeCycleListener);
closeConnectionBetween(h1, h2);
assertOpenEventually(memberShipListener.memberRemovedLatch);
assertClusterSizeEventually(1, h1);
assertClusterSizeEventually(1, h2);
IMap<Object, Object> map1 = h1.getMap(mapName);
String key = generateKeyOwnedBy(h1);
map1.put(key, "value");
IMap<Object, Object> map2 = h2.getMap(mapName);
map2.put(key, 1);
// allow merge process to continue
mergeBlockingLatch.countDown();
assertOpenEventually(lifeCycleListener.mergeFinishedLatch);
assertClusterSizeEventually(2, h1, h2);
IMap<Object, Object> mapTest = h2.getMap(mapName);
assertNotNull(mapTest.get(key));
assertTrue(mapTest.get(key) instanceof Integer);
}
private Config newConfig(String mergePolicy, String mapName) {
Config config = getConfig()
.setProperty(ClusterProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5")
.setProperty(ClusterProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
config.setClusterName(generateRandomString(10));
config.getMapConfig(mapName)
.getMergePolicyConfig().setPolicy(mergePolicy);
return config;
}
private class TestLifeCycleListener implements LifecycleListener {
final CountDownLatch mergeFinishedLatch;
final CountDownLatch mergeBlockingLatch;
TestLifeCycleListener(int countdown, CountDownLatch mergeBlockingLatch) {
this.mergeFinishedLatch = new CountDownLatch(countdown);
this.mergeBlockingLatch = mergeBlockingLatch;
}
@Override
public void stateChanged(LifecycleEvent event) {
if (event.getState() == LifecycleEvent.LifecycleState.MERGING) {
try {
mergeBlockingLatch.await(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw rethrow(e);
}
} else if (event.getState() == LifecycleEvent.LifecycleState.MERGED) {
mergeFinishedLatch.countDown();
}
}
}
private class TestMemberShipListener implements MembershipListener {
final CountDownLatch memberRemovedLatch;
TestMemberShipListener(int countdown) {
memberRemovedLatch = new CountDownLatch(countdown);
}
@Override
public void memberAdded(MembershipEvent membershipEvent) {
}
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
memberRemovedLatch.countDown();
}
}
}
| apache-2.0 |
jwren/intellij-community | platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameFileFix.java | 3771 | /*
* Copyright 2000-2015 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.
*/
/*
* @author ven
*/
package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ex.MessagesEx;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
public class RenameFileFix implements IntentionAction, LocalQuickFix {
private final String myNewFileName;
/**
* @param newFileName with extension
*/
public RenameFileFix(@NotNull String newFileName) {
myNewFileName = newFileName;
}
@Override
@NotNull
public String getText() {
return CodeInsightBundle.message("rename.file.fix");
}
@Override
@NotNull
public String getName() {
return getText();
}
@Override
@NotNull
public String getFamilyName() {
return CodeInsightBundle.message("rename.file.fix");
}
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiFile file = descriptor.getPsiElement().getContainingFile();
if (isAvailable(project, null, file)) {
WriteCommandAction.writeCommandAction(project).run(() -> invoke(project, null, file));
}
}
@Override
public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (file == null || !file.isValid()) return false;
VirtualFile vFile = file.getVirtualFile();
if (vFile == null) return false;
VirtualFile parent = vFile.getParent();
if (parent == null) return false;
VirtualFile newVFile = parent.findChild(myNewFileName);
return newVFile == null || newVFile.equals(vFile);
}
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
VirtualFile vFile = file.getVirtualFile();
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
FileDocumentManager.getInstance().saveDocument(document);
try {
vFile.rename(file.getManager(), myNewFileName);
}
catch (IOException e) {
MessagesEx.error(project, e.getMessage()).showLater();
}
}
@Override
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull ProblemDescriptor previewDescriptor) {
return IntentionPreviewInfo.rename(previewDescriptor.getPsiElement().getContainingFile(), myNewFileName);
}
@Override
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return IntentionPreviewInfo.rename(file, myNewFileName);
}
@Override
public boolean startInWriteAction() {
return true;
}
} | apache-2.0 |
foomoto/easypaas | src/main/java/com/withinet/opaas/model/domain/RolePermission.java | 3075 | package com.withinet.opaas.model.domain;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@Entity
@org.hibernate.annotations.Immutable
public class RolePermission implements Serializable {
@Embeddable
public static class Id implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "ROLE_ID")
private Long roleId;
@Column(name = "PERMISSION_ID")
private Long permissionId;
public Id() {
}
public Id(Long roleId, Long permissionId) {
this.roleId = roleId;
this.permissionId = permissionId;
}
public boolean equals(Object o) {
if (o != null && o instanceof Id) {
Id that = (Id) o;
return this.roleId.equals(that.roleId)
&& this.permissionId.equals(that.permissionId);
}
return false;
}
public int hashCode() {
return roleId.hashCode() + permissionId.hashCode();
}
}
@EmbeddedId
private Id id = new Id();
@Column(updatable = false)
@NotNull
private String addedBy;
@Column(updatable = false)
@NotNull
private Date addedOn = new Date();
@ManyToOne (targetEntity = Role.class)
@JoinColumn(
name = "ROLE_ID",
insertable = false, updatable = false)
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
private Role role;
@ManyToOne (targetEntity = Permission.class)
@JoinColumn(
name = "PERMISSION_ID",
insertable = false, updatable = false)
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
private Permission permission;
public RolePermission() {
}
public RolePermission(String addedByUsername,
Role role,
Permission userPermission) {
// Set fields
this.addedBy = addedByUsername;
this.role = role;
this.permission = userPermission;
// Set identifier values
this.id.roleId = role.getId();
this.id.permissionId = userPermission.getId();
// Guarantee referential integrity if made bidirectional
role.getRolePermissions().add(this);
}
public Id getId() {
return id;
}
public String getAddedBy() {
return addedBy;
}
public Date getAddedOn() {
return addedOn;
}
public Role getRole() {
return this.role;
}
public Permission getPermission() {
return this.permission;
}
@Override
public boolean equals (Object o) {
if (o == null) return false;
else if (!(o instanceof RolePermission))
return false;
else if (((RolePermission) o).getId() != getId())
return false;
return true;
}
} | apache-2.0 |
TUBB/SwipeMenu | app/src/main/java/com/tubb/smrv/demo/BaseActivity.java | 953 | package com.tubb.smrv.demo;
import android.app.Activity;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Created by tubingbing on 16/4/11.
*/
public class BaseActivity extends Activity{
Random random = new Random();
protected List<User> getUsers() {
List<User> userList = new ArrayList<>();
for (int i=0; i<100; i++){
User user = new User();
user.setUserId(i+1000);
user.setUserName("Pobi "+(i+1));
int num = random.nextInt(4);
if(num == 0){
user.setPhotoRes(R.drawable.one);
}else if(num == 1){
user.setPhotoRes(R.drawable.two);
}else if(num == 2){
user.setPhotoRes(R.drawable.three);
}else if(num == 3){
user.setPhotoRes(R.drawable.four);
}
userList.add(user);
}
return userList;
}
}
| apache-2.0 |
zhangminglei/flink | flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducerBaseTest.java | 16908 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.streaming.connectors.kafka;
import org.apache.flink.api.common.functions.RuntimeContext;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.testutils.CheckedThread;
import org.apache.flink.core.testutils.MultiShotLatch;
import org.apache.flink.runtime.state.FunctionSnapshotContext;
import org.apache.flink.streaming.api.functions.sink.SinkContextUtil;
import org.apache.flink.streaming.api.operators.StreamSink;
import org.apache.flink.streaming.api.operators.StreamingRuntimeContext;
import org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaPartitioner;
import org.apache.flink.streaming.connectors.kafka.testutils.FakeStandardProducerConfig;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
import org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness;
import org.apache.flink.streaming.util.serialization.KeyedSerializationSchema;
import org.apache.flink.streaming.util.serialization.KeyedSerializationSchemaWrapper;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.PartitionInfo;
import org.apache.kafka.common.serialization.ByteArraySerializer;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Tests for the {@link FlinkKafkaProducerBase}.
*/
public class FlinkKafkaProducerBaseTest {
/**
* Tests that the constructor eagerly checks bootstrap servers are set in config.
*/
@Test(expected = IllegalArgumentException.class)
public void testInstantiationFailsWhenBootstrapServersMissing() throws Exception {
// no bootstrap servers set in props
Properties props = new Properties();
// should throw IllegalArgumentException
new DummyFlinkKafkaProducer<>(props, new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
}
/**
* Tests that constructor defaults to key value serializers in config to byte array deserializers if not set.
*/
@Test
public void testKeyValueDeserializersSetIfMissing() throws Exception {
Properties props = new Properties();
props.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:12345");
// should set missing key value deserializers
new DummyFlinkKafkaProducer<>(props, new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
assertTrue(props.containsKey(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG));
assertTrue(props.containsKey(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG));
assertTrue(props.getProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG).equals(ByteArraySerializer.class.getName()));
assertTrue(props.getProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG).equals(ByteArraySerializer.class.getName()));
}
/**
* Tests that partitions list is determinate and correctly provided to custom partitioner.
*/
@SuppressWarnings("unchecked")
@Test
public void testPartitionerInvokedWithDeterminatePartitionList() throws Exception {
FlinkKafkaPartitioner<String> mockPartitioner = mock(FlinkKafkaPartitioner.class);
RuntimeContext mockRuntimeContext = mock(StreamingRuntimeContext.class);
when(mockRuntimeContext.getIndexOfThisSubtask()).thenReturn(0);
when(mockRuntimeContext.getNumberOfParallelSubtasks()).thenReturn(1);
// out-of-order list of 4 partitions
List<PartitionInfo> mockPartitionsList = new ArrayList<>(4);
mockPartitionsList.add(new PartitionInfo(DummyFlinkKafkaProducer.DUMMY_TOPIC, 3, null, null, null));
mockPartitionsList.add(new PartitionInfo(DummyFlinkKafkaProducer.DUMMY_TOPIC, 1, null, null, null));
mockPartitionsList.add(new PartitionInfo(DummyFlinkKafkaProducer.DUMMY_TOPIC, 0, null, null, null));
mockPartitionsList.add(new PartitionInfo(DummyFlinkKafkaProducer.DUMMY_TOPIC, 2, null, null, null));
final DummyFlinkKafkaProducer<String> producer = new DummyFlinkKafkaProducer<>(
FakeStandardProducerConfig.get(), new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), mockPartitioner);
producer.setRuntimeContext(mockRuntimeContext);
final KafkaProducer mockProducer = producer.getMockKafkaProducer();
when(mockProducer.partitionsFor(anyString())).thenReturn(mockPartitionsList);
when(mockProducer.metrics()).thenReturn(null);
producer.open(new Configuration());
verify(mockPartitioner, times(1)).open(0, 1);
producer.invoke("foobar", SinkContextUtil.forTimestamp(0));
verify(mockPartitioner, times(1)).partition(
"foobar", null, "foobar".getBytes(), DummyFlinkKafkaProducer.DUMMY_TOPIC, new int[] {0, 1, 2, 3});
}
/**
* Test ensuring that if an invoke call happens right after an async exception is caught, it should be rethrown.
*/
@Test
public void testAsyncErrorRethrownOnInvoke() throws Throwable {
final DummyFlinkKafkaProducer<String> producer = new DummyFlinkKafkaProducer<>(
FakeStandardProducerConfig.get(), new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
OneInputStreamOperatorTestHarness<String, Object> testHarness =
new OneInputStreamOperatorTestHarness<>(new StreamSink<>(producer));
testHarness.open();
testHarness.processElement(new StreamRecord<>("msg-1"));
// let the message request return an async exception
producer.getPendingCallbacks().get(0).onCompletion(null, new Exception("artificial async exception"));
try {
testHarness.processElement(new StreamRecord<>("msg-2"));
} catch (Exception e) {
// the next invoke should rethrow the async exception
Assert.assertTrue(e.getCause().getMessage().contains("artificial async exception"));
// test succeeded
return;
}
Assert.fail();
}
/**
* Test ensuring that if a snapshot call happens right after an async exception is caught, it should be rethrown.
*/
@Test
public void testAsyncErrorRethrownOnCheckpoint() throws Throwable {
final DummyFlinkKafkaProducer<String> producer = new DummyFlinkKafkaProducer<>(
FakeStandardProducerConfig.get(), new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
OneInputStreamOperatorTestHarness<String, Object> testHarness =
new OneInputStreamOperatorTestHarness<>(new StreamSink<>(producer));
testHarness.open();
testHarness.processElement(new StreamRecord<>("msg-1"));
// let the message request return an async exception
producer.getPendingCallbacks().get(0).onCompletion(null, new Exception("artificial async exception"));
try {
testHarness.snapshot(123L, 123L);
} catch (Exception e) {
// the next invoke should rethrow the async exception
Assert.assertTrue(e.getCause().getMessage().contains("artificial async exception"));
// test succeeded
return;
}
Assert.fail();
}
/**
* Test ensuring that if an async exception is caught for one of the flushed requests on checkpoint,
* it should be rethrown; we set a timeout because the test will not finish if the logic is broken.
*
* <p>Note that this test does not test the snapshot method is blocked correctly when there are pending records.
* The test for that is covered in testAtLeastOnceProducer.
*/
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testAsyncErrorRethrownOnCheckpointAfterFlush() throws Throwable {
final DummyFlinkKafkaProducer<String> producer = new DummyFlinkKafkaProducer<>(
FakeStandardProducerConfig.get(), new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
producer.setFlushOnCheckpoint(true);
final KafkaProducer<?, ?> mockProducer = producer.getMockKafkaProducer();
final OneInputStreamOperatorTestHarness<String, Object> testHarness =
new OneInputStreamOperatorTestHarness<>(new StreamSink<>(producer));
testHarness.open();
testHarness.processElement(new StreamRecord<>("msg-1"));
testHarness.processElement(new StreamRecord<>("msg-2"));
testHarness.processElement(new StreamRecord<>("msg-3"));
verify(mockProducer, times(3)).send(any(ProducerRecord.class), any(Callback.class));
// only let the first callback succeed for now
producer.getPendingCallbacks().get(0).onCompletion(null, null);
CheckedThread snapshotThread = new CheckedThread() {
@Override
public void go() throws Exception {
// this should block at first, since there are still two pending records that needs to be flushed
testHarness.snapshot(123L, 123L);
}
};
snapshotThread.start();
// let the 2nd message fail with an async exception
producer.getPendingCallbacks().get(1).onCompletion(null, new Exception("artificial async failure for 2nd message"));
producer.getPendingCallbacks().get(2).onCompletion(null, null);
try {
snapshotThread.sync();
} catch (Exception e) {
// the snapshot should have failed with the async exception
Assert.assertTrue(e.getCause().getMessage().contains("artificial async failure for 2nd message"));
// test succeeded
return;
}
Assert.fail();
}
/**
* Test ensuring that the producer is not dropping buffered records;
* we set a timeout because the test will not finish if the logic is broken.
*/
@SuppressWarnings("unchecked")
@Test(timeout = 10000)
public void testAtLeastOnceProducer() throws Throwable {
final DummyFlinkKafkaProducer<String> producer = new DummyFlinkKafkaProducer<>(
FakeStandardProducerConfig.get(), new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
producer.setFlushOnCheckpoint(true);
final KafkaProducer<?, ?> mockProducer = producer.getMockKafkaProducer();
final OneInputStreamOperatorTestHarness<String, Object> testHarness =
new OneInputStreamOperatorTestHarness<>(new StreamSink<>(producer));
testHarness.open();
testHarness.processElement(new StreamRecord<>("msg-1"));
testHarness.processElement(new StreamRecord<>("msg-2"));
testHarness.processElement(new StreamRecord<>("msg-3"));
verify(mockProducer, times(3)).send(any(ProducerRecord.class), any(Callback.class));
Assert.assertEquals(3, producer.getPendingSize());
// start a thread to perform checkpointing
CheckedThread snapshotThread = new CheckedThread() {
@Override
public void go() throws Exception {
// this should block until all records are flushed;
// if the snapshot implementation returns before pending records are flushed,
testHarness.snapshot(123L, 123L);
}
};
snapshotThread.start();
// before proceeding, make sure that flushing has started and that the snapshot is still blocked;
// this would block forever if the snapshot didn't perform a flush
producer.waitUntilFlushStarted();
Assert.assertTrue("Snapshot returned before all records were flushed", snapshotThread.isAlive());
// now, complete the callbacks
producer.getPendingCallbacks().get(0).onCompletion(null, null);
Assert.assertTrue("Snapshot returned before all records were flushed", snapshotThread.isAlive());
Assert.assertEquals(2, producer.getPendingSize());
producer.getPendingCallbacks().get(1).onCompletion(null, null);
Assert.assertTrue("Snapshot returned before all records were flushed", snapshotThread.isAlive());
Assert.assertEquals(1, producer.getPendingSize());
producer.getPendingCallbacks().get(2).onCompletion(null, null);
Assert.assertEquals(0, producer.getPendingSize());
// this would fail with an exception if flushing wasn't completed before the snapshot method returned
snapshotThread.sync();
testHarness.close();
}
/**
* This test is meant to assure that testAtLeastOnceProducer is valid by testing that if flushing is disabled,
* the snapshot method does indeed finishes without waiting for pending records;
* we set a timeout because the test will not finish if the logic is broken.
*/
@SuppressWarnings("unchecked")
@Test(timeout = 5000)
public void testDoesNotWaitForPendingRecordsIfFlushingDisabled() throws Throwable {
final DummyFlinkKafkaProducer<String> producer = new DummyFlinkKafkaProducer<>(
FakeStandardProducerConfig.get(), new KeyedSerializationSchemaWrapper<>(new SimpleStringSchema()), null);
producer.setFlushOnCheckpoint(false);
final KafkaProducer<?, ?> mockProducer = producer.getMockKafkaProducer();
final OneInputStreamOperatorTestHarness<String, Object> testHarness =
new OneInputStreamOperatorTestHarness<>(new StreamSink<>(producer));
testHarness.open();
testHarness.processElement(new StreamRecord<>("msg"));
// make sure that all callbacks have not been completed
verify(mockProducer, times(1)).send(any(ProducerRecord.class), any(Callback.class));
// should return even if there are pending records
testHarness.snapshot(123L, 123L);
testHarness.close();
}
// ------------------------------------------------------------------------
private static class DummyFlinkKafkaProducer<T> extends FlinkKafkaProducerBase<T> {
private static final long serialVersionUID = 1L;
private static final String DUMMY_TOPIC = "dummy-topic";
private transient KafkaProducer<?, ?> mockProducer;
private transient List<Callback> pendingCallbacks;
private transient MultiShotLatch flushLatch;
private boolean isFlushed;
@SuppressWarnings("unchecked")
DummyFlinkKafkaProducer(Properties producerConfig, KeyedSerializationSchema<T> schema, FlinkKafkaPartitioner partitioner) {
super(DUMMY_TOPIC, schema, producerConfig, partitioner);
this.mockProducer = mock(KafkaProducer.class);
when(mockProducer.send(any(ProducerRecord.class), any(Callback.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
pendingCallbacks.add(invocationOnMock.getArgumentAt(1, Callback.class));
return null;
}
});
this.pendingCallbacks = new ArrayList<>();
this.flushLatch = new MultiShotLatch();
}
long getPendingSize() {
if (flushOnCheckpoint) {
return numPendingRecords();
} else {
// when flushing is disabled, the implementation does not
// maintain the current number of pending records to reduce
// the extra locking overhead required to do so
throw new UnsupportedOperationException("getPendingSize not supported when flushing is disabled");
}
}
List<Callback> getPendingCallbacks() {
return pendingCallbacks;
}
KafkaProducer<?, ?> getMockKafkaProducer() {
return mockProducer;
}
@Override
public void snapshotState(FunctionSnapshotContext ctx) throws Exception {
isFlushed = false;
super.snapshotState(ctx);
// if the snapshot implementation doesn't wait until all pending records are flushed, we should fail the test
if (flushOnCheckpoint && !isFlushed) {
throw new RuntimeException("Flushing is enabled; snapshots should be blocked until all pending records are flushed");
}
}
public void waitUntilFlushStarted() throws Exception {
flushLatch.await();
}
@SuppressWarnings("unchecked")
@Override
protected <K, V> KafkaProducer<K, V> getKafkaProducer(Properties props) {
return (KafkaProducer<K, V>) mockProducer;
}
@Override
protected void flush() {
flushLatch.trigger();
// simply wait until the producer's pending records become zero.
// This relies on the fact that the producer's Callback implementation
// and pending records tracking logic is implemented correctly, otherwise
// we will loop forever.
while (numPendingRecords() > 0) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException("Unable to flush producer, task was interrupted");
}
}
isFlushed = true;
}
}
}
| apache-2.0 |
clarkyzl/flink | flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/benchmark/scheduling/InitSchedulingStrategyBenchmarkTest.java | 1853 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package org.apache.flink.runtime.scheduler.benchmark.scheduling;
import org.apache.flink.runtime.scheduler.benchmark.JobConfiguration;
import org.apache.flink.runtime.scheduler.strategy.PipelinedRegionSchedulingStrategy;
import org.apache.flink.util.TestLogger;
import org.junit.Test;
/**
* The benchmark of initializing {@link PipelinedRegionSchedulingStrategy} in a STREAMING/BATCH job.
*/
public class InitSchedulingStrategyBenchmarkTest extends TestLogger {
@Test
public void initSchedulingStrategyBenchmarkInStreamingJob() throws Exception {
InitSchedulingStrategyBenchmark benchmark = new InitSchedulingStrategyBenchmark();
benchmark.setup(JobConfiguration.STREAMING_TEST);
benchmark.initSchedulingStrategy();
}
@Test
public void initSchedulingStrategyBenchmarkInBatchJob() throws Exception {
InitSchedulingStrategyBenchmark benchmark = new InitSchedulingStrategyBenchmark();
benchmark.setup(JobConfiguration.BATCH_TEST);
benchmark.initSchedulingStrategy();
}
}
| apache-2.0 |
apache/geronimo-yoko | yoko-spec-corba/src/main/generated-sources/idl/org/omg/SecurityLevel2/CurrentHolder.java | 839 | package org.omg.SecurityLevel2;
/**
* org/omg/SecurityLevel2/CurrentHolder.java .
* Error reading Messages File.
* Error reading Messages File.
* Thursday, January 14, 2010 1:08:59 AM PST
*/
/* */
public final class CurrentHolder implements org.omg.CORBA.portable.Streamable
{
public org.omg.SecurityLevel2.Current value = null;
public CurrentHolder ()
{
}
public CurrentHolder (org.omg.SecurityLevel2.Current initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = org.omg.SecurityLevel2.CurrentHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
org.omg.SecurityLevel2.CurrentHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return org.omg.SecurityLevel2.CurrentHelper.type ();
}
}
| apache-2.0 |
mgmik/jfunk | jfunk-core/src/main/java/com/mgmtp/jfunk/core/mail/BaseSingleMessageStep.java | 1798 | /*
* Copyright (c) 2015 mgm technology partners GmbH
*
* 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.mgmtp.jfunk.core.mail;
import com.google.common.base.Predicate;
/**
* Base step for e-mail validation. The {@link #execute()} method does nothing if mail-checking is
* disabled by setting the property {@code mail.check.active} to {@code false}.
*
* @author rnaegele
* @since 3.1.0
*/
public abstract class BaseSingleMessageStep extends BaseEmailStep {
/**
* @param dataSetKey
* the data set key
* @param accountReservationKey
* the key under which the mail account to use was reserved
*/
public BaseSingleMessageStep(final String dataSetKey, final String accountReservationKey) {
super(dataSetKey, accountReservationKey);
}
/**
* Retrieves an e-mail matching the patterns specified in the constructor. If the message is
* successfully retrieved, it is passed to {@link #validateMessage(MailMessage)} for further
* validation.
*/
@Override
protected void doExecute() {
Predicate<MailMessage> condition = createMessagePredicate();
MailMessage message = mailService.findMessage(accountReservationKey, condition);
validateMessage(message);
}
protected abstract void validateMessage(MailMessage messages);
} | apache-2.0 |
raphaelbauer/ninja | ninja-core/src/main/java/ninja/params/Header.java | 1132 | /**
* Copyright (C) 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ninja.params;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Just an idea to inject a header right into the methods...
*
* This equals context.getHeader(...)
*
* @author James Moger
*
*/
@WithArgumentExtractor(ArgumentExtractors.HeaderExtractor.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
public @interface Header {
String value();
} | apache-2.0 |
letsgoING/ArduBlock | Source/ardublock-master/ardublock-master/src/main/java/com/ardublock/translator/block/letsgoING/AnalogGetStartButton3Block.java | 1025 | package com.ardublock.translator.block.letsgoING;
import com.ardublock.translator.Translator;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;
public class AnalogGetStartButton3Block extends TranslatorBlock
{
public AnalogGetStartButton3Block(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}
private final static String serialEventFunction = " AnalogButton Button3(3);\n";
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
// Header hinzuf�gen
translator.addHeaderFile("LGI_AnalogButton.h");
// Deklarationen hinzuf�gen
translator.addDefinitionCommand(serialEventFunction);
String ret = "Button3.startButton();";
return codePrefix + ret + codeSuffix;
}
} | gpl-3.0 |
RedShinigami89/Olympus | src/main/java/com/drdee89/olympus/proxy/ServerProxy.java | 92 | package com.drdee89.olympus.proxy;
public class ServerProxy extends CommonProxy
{
}
| gpl-3.0 |
Metatavu/edelphi | edelphi-persistence/src/main/java/fi/metatavu/edelphi/domainmodel/querylayout/QueryPageTemplateSetting.java | 1003 | package fi.metatavu.edelphi.domainmodel.querylayout;
import java.lang.Long;
import javax.persistence.*;
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class QueryPageTemplateSetting {
public Long getId() {
return this.id;
}
public QueryPageSettingKey getKey() {
return key;
}
public void setKey(QueryPageSettingKey key) {
this.key = key;
}
public QueryPageTemplate getQueryPageTemplate() {
return queryPageTemplate;
}
public void setQueryPageTemplate(QueryPageTemplate queryPageTemplate) {
this.queryPageTemplate = queryPageTemplate;
}
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "QueryPageTemplateSetting")
@TableGenerator(name = "QueryPageTemplateSetting", allocationSize = 1, table = "hibernate_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_next_hi_value")
private Long id;
@ManyToOne
private QueryPageSettingKey key;
@ManyToOne
private QueryPageTemplate queryPageTemplate;
}
| gpl-3.0 |
skalva50/Filmotheque | src/main/java/com/skalvasociety/skalva/dao/SeriePersonnageDao.java | 763 | package com.skalvasociety.skalva.dao;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import com.skalvasociety.skalva.bean.Acteur;
import com.skalvasociety.skalva.bean.Serie;
import com.skalvasociety.skalva.bean.SeriePersonnage;
@Repository("SeriePersonnageDao")
public class SeriePersonnageDao extends AbstractDao<Integer, SeriePersonnage> implements ISeriePersonnageDao {
public SeriePersonnage getSeriePersonnagebySerieActeur(Serie serie, Acteur acteur) {
Criteria criteria = createEntityCriteria();
criteria.add(Restrictions.eq("serie", serie));
criteria.add(Restrictions.eq("acteur", acteur));
return (SeriePersonnage)criteria.uniqueResult();
}
}
| gpl-3.0 |
mikusher/JavaBasico | src/cv/mikusher/cursojava/aula13/OperadoresCurtoCircuito.java | 951 | /*
* Copyright (C) 2016 Miky Mikusher Wayne
*
* 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.
*
*/
package cv.mikusher.cursojava.aula13;
/**
*
* @author Miky Mikusher Wayne
*/
public class OperadoresCurtoCircuito {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
boolean verdadeiro = true;
boolean falso = false;
boolean resultado1 = falso & verdadeiro; // faz a verificação dos dois elementos
boolean resultado2 = falso && verdadeiro; // não faz a verificação dos dois pontos (levando em conta a tabela da verdade &&)
System.out.println(resultado1);
System.out.println(resultado2);
}
}
| gpl-3.0 |
apruden/magma | magma-api/src/main/java/org/obiba/magma/ValueTableUpdateListener.java | 928 | /*
* Copyright (c) 2011 OBiBa. All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0.
*
* 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.obiba.magma;
import javax.validation.constraints.NotNull;
/**
* Listener to events on ValueTable
*/
public interface ValueTableUpdateListener {
/**
* Called when a value table is being renamed.
*
* @param newName
*/
void onRename(@NotNull ValueTable vt, String newName);
/**
* Called when a variable is being renamed.
*
* @param vt
* @param v
* @param newName
*/
void onRename(@NotNull ValueTable vt, Variable v, String newName);
/**
* Called when a value table is deleted.
*
* @param vt
*/
void onDelete(@NotNull ValueTable vt);
}
| gpl-3.0 |
Mikescher/jClipCorn | src/main/de/jClipCorn/gui/guiComponents/WrapFlowLayout.java | 2390 | package de.jClipCorn.gui.guiComponents;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
public class WrapFlowLayout extends FlowLayout {
private static final long serialVersionUID = 4929193635609994517L;
public WrapFlowLayout() {
super();
}
public WrapFlowLayout(int align) {
super(align);
}
public WrapFlowLayout(int align, int hgap, int vgap) {
super(align, hgap, vgap);
}
@Override
public Dimension minimumLayoutSize(Container target) {
return computeMinSize(target);
}
@Override
public Dimension preferredLayoutSize(Container target) {
return computeSize(target);
}
private Dimension computeSize(Container target) {
synchronized (target.getTreeLock()) {
int hgap = getHgap();
int vgap = getVgap();
int wid = target.getWidth();
if (wid == 0) {
wid = Integer.MAX_VALUE;
}
Insets insets = target.getInsets();
if (insets == null) {
insets = new Insets(0, 0, 0, 0);
}
int reqdWidth = 0;
int maxwidth = wid - (insets.left + insets.right + hgap * 2);
int compcount = target.getComponentCount();
int x = 0;
int y = insets.top + vgap;
int rowHeight = 0;
for (int i = 0; i < compcount; i++) {
Component c = target.getComponent(i);
if (c.isVisible()) {
Dimension d = c.getPreferredSize();
if ((x == 0) || ((x + d.width) <= maxwidth)) {
if (x > 0) {
x += hgap;
}
x += d.width;
rowHeight = Math.max(rowHeight, d.height);
} else {
x = d.width;
y += vgap + rowHeight;
rowHeight = d.height;
}
reqdWidth = Math.max(reqdWidth, x);
}
}
y += rowHeight;
y += insets.bottom;
return new Dimension(reqdWidth + insets.left + insets.right, y);
}
}
private Dimension computeMinSize(Container target) {
synchronized (target.getTreeLock()) {
int minx = Integer.MAX_VALUE;
int miny = Integer.MIN_VALUE;
boolean found = false;
int compcount = target.getComponentCount();
for (int i = 0; i < compcount; i++) {
Component c = target.getComponent(i);
if (c.isVisible()) {
found = true;
Dimension d = c.getPreferredSize();
minx = Math.min(minx, d.width);
miny = Math.min(miny, d.height);
}
}
if (found) {
return new Dimension(minx, miny);
}
return new Dimension(0, 0);
}
}
} | gpl-3.0 |
mgerlich/MetFusion | src/test/java/de/ipbhalle/metfusion/main/EvaluateResults.java | 3760 | /**
* created by Michael Gerlich on Jun 8, 2010
* last modified Jun 8, 2010 - 12:52:33 PM
* email: mgerlich@ipb-halle.de
*/
package de.ipbhalle.metfusion.main;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import org.apache.commons.math.stat.StatUtils;
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
public class EvaluateResults {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//String path = args[0];
String path = "/home/mgerlich/workspace-3.5/MetFusion2/testdata/Hill/results/2010-06-15_16-49-42/";
File dir = new File(path);
//File[] list = dir.listFiles(new MyFileFilter(".vec"));
File[] results = dir.listFiles(new MyFileFilter("_result.log"));
Arrays.sort(results);
//if (list.length != 102 || results.length != 102) {
if (results.length != 102) {
System.err.println("wrong number of results files - aborting...");
System.err.println("expected 102 - was " + results.length + " for _result.log files.");
//System.exit(-1);
}
else System.out.println("expected 102 results found :)");
String[] cids = new String[results.length];
int[] worstRanks = new int[results.length];
int[] threshRanks = new int[results.length];
int[] threshTiedRanks = new int[results.length];
int[] weightRanks = new int[results.length];
int[] weightTiedRanks = new int[results.length];
for (int i = 0; i < results.length; i++) {
File f = results[i];
System.out.println(f);
BufferedReader br = new BufferedReader(new FileReader(f));
String line = "";
while((line = br.readLine()) != null) {
/**
* String header = "## CID\tworstRank\tthresholdRank\tweightedRank\tthresholdTiedRank\tweightedTiedRank\n";
*/
if(line.startsWith("##") || line.startsWith("CID"))
continue;
String[] split = line.split("\t");
cids[i] = split[0];
worstRanks[i] = Integer.parseInt(split[1]);
threshRanks[i] = Integer.parseInt(split[2]);
weightRanks[i] = Integer.parseInt(split[3]);
threshTiedRanks[i] = Integer.parseInt(split[4]);
weightTiedRanks[i] = Integer.parseInt(split[5]);
}
}
// Get a DescriptiveStatistics instance
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for( int i = 0; i < threshTiedRanks.length; i++) {
stats.addValue(threshTiedRanks[i]);
}
// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();
System.out.println("mean=" + mean + "\tsd=" + std);
// double mean2 = StatUtils.mean(weightTiedRanks);
// double std2 = StatUtils.variance(weightTiedRanks);
// double median = StatUtils.percentile(weightTiedRanks, 0.5);
//double median = stats.getMedian();
}
/**
* inner class which provides implementation of FilenameFilter interface
*
* @author mgerlich
*
*/
private static class MyFileFilter implements FilenameFilter {
private String suffix = "";
private String prefix = "";
public MyFileFilter() {
suffix = ".txt";
}
public MyFileFilter(String suffix) {
this.suffix = (suffix.isEmpty() ? ".txt" : suffix);
}
public MyFileFilter(String prefix, String suffix) {
this(suffix);
this.prefix = prefix;
}
@Override
public boolean accept(File dir, String name) {
if(suffix.isEmpty() && prefix.isEmpty())
return false;
else if(!suffix.isEmpty() && name.endsWith(suffix))
return true;
else if(!suffix.isEmpty() && !prefix.isEmpty() &&
name.startsWith(prefix) && name.endsWith(suffix))
return true;
else return false;
}
}
}
| gpl-3.0 |
varunjamwal/Well-Show-from-MongoDB | MongoAccess/build/generated/src/org/apache/jsp/stage3_jsp.java | 21184 | package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import com.mongodb.BasicDBObject;
import com.mongodb.client.FindIterable;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import com.mongodb.client.MongoCursor;
import static com.mongodb.client.model.Filters.*;
import com.mongodb.client.result.DeleteResult;
import static com.mongodb.client.model.Updates.*;
import com.mongodb.client.result.UpdateResult;
import java.util.ArrayList;
import java.util.List;
public final class stage3_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
private static java.util.List<String> _jspx_dependants;
private org.glassfish.jsp.api.ResourceInjector _jspx_resourceInjector;
public java.util.List<String> getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
response.setContentType("text/html");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write(" \n");
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
out.write("<head>\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
out.write("<title>Template</title>\n");
out.write("\n");
out.write(" <meta charset=\"utf-8\">\n");
out.write(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n");
out.write(" <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\">\n");
out.write(" <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\n");
out.write(" <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script>\n");
out.write(" <link rel=\"stylesheet/less\" href=\"less/sidebar.less\">\n");
out.write(" <link href=\"//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css\" rel=\"stylesheet\">\n");
out.write("\n");
out.write("\t<style>\n");
out.write(" *{margin:0px}\n");
out.write("\t\n");
out.write("\t\t\tbody{text-align:center}\n");
out.write("\t\t\t.btn \n");
out.write("\t\t\t\t{ \n");
out.write("\t\t\t\t\tmargin-top: 25px; margin-left:30px\n");
out.write("\t\t\t\t}\n");
out.write("\t\t\t.btn-arrow-right \n");
out.write("\t\t\t{\n");
out.write("\t\t\t\tposition: relative;\n");
out.write("\t\t\t\tpadding-left: 28px;\n");
out.write("\t\t\t\tpadding-right: 18px;\n");
out.write("\t\t\t}\n");
out.write("\t\t\t.btn-arrow-right:before,\n");
out.write("\t\t\t.btn-arrow-right:after,\n");
out.write("\t\t\t.btn-arrow-left:before,\n");
out.write("\t\t\t.btn-arrow-left:after \n");
out.write("\t\t\t{ \n");
out.write("\t\t\t\tcontent:\"\";\n");
out.write("\t\t\t\tposition: absolute;\n");
out.write("\t\t\t\ttop: 5px; \n");
out.write("\t\t\t\twidth: 22px; \n");
out.write("\t\t\t\theight: 22px; \n");
out.write("\t\t\t\tbackground: inherit; \n");
out.write("\t\t\t\tborder: inherit; \n");
out.write("\t\t\t\tborder-left-color: transparent; \n");
out.write("\t\t\t\tborder-bottom-color: transparent; \n");
out.write("\t\t\t\tborder-radius: 0px 4px 0px 0px; \n");
out.write("\t\t\t\t-webkit-border-radius: 0px 4px 0px 0px;\n");
out.write("\t\t\t}\n");
out.write("\t\t\t\n");
out.write("\t\t\t.btn-arrow-right:before,.btn-arrow-right:after \n");
out.write("\t\t\t{\n");
out.write("\t\t\t\ttransform: rotate(45deg); \n");
out.write("\t\t\t\t-webkit-transform: rotate(45deg);\n");
out.write("\t\t\t}\n");
out.write("\t\t\t.btn-arrow-left:before,.btn-arrow-left:after \n");
out.write("\t\t\t{\n");
out.write("\t\t\t\ttransform: rotate(225deg); \n");
out.write("\t\t\t\t-webkit-transform: rotate(225deg);\n");
out.write("\t\t\t}\n");
out.write("\t\t\t.btn-arrow-right:before,.btn-arrow-left:before \n");
out.write("\t\t\t{ \n");
out.write("\t\t\t\tleft: -11px;\n");
out.write("\t\t\t}\n");
out.write("\t\t\t.btn-arrow-right:after,.btn-arrow-left:after \n");
out.write("\t\t\t{ \n");
out.write("\t\t\t\tright: -11px;\n");
out.write("\t\t\t}\n");
out.write("\t\t\t.btn-arrow-right:after,.btn-arrow-left:before \n");
out.write("\t\t\t{ \n");
out.write("\t\t\t\tz-index: 1;\n");
out.write("\t\t\t}\n");
out.write("\t\t\t.btn-arrow-right:before,.btn-arrow-left:after \n");
out.write("\t\t\t{ \n");
out.write("\t\t\t\tbackground-color: white;\n");
out.write("\t\t\t}\n");
out.write("\t\n");
out.write("\t\t\t#table{padding-top:30px; font-size:11px; text-align:justify; color:#666;}\n");
out.write(" #StageGate{padding-bottom:18px}\n");
out.write("\t\t\t\n");
out.write("\t/*navigation*/\t\t\n");
out.write(".nav-side-menu \n");
out.write("{\n");
out.write(" padding-top:25px;\t\n");
out.write(" overflow: auto;\n");
out.write(" font-family: verdana;\n");
out.write(" font-size: 12px;\n");
out.write(" font-weight: 200;\n");
out.write(" background-color: #85c1e9;\n");
out.write(" position: fixed;\n");
out.write(" top: 0px;\n");
out.write(" width: 233px;\n");
out.write(" height: 100%;\n");
out.write(" color: #e1ffff;\n");
out.write("}\n");
out.write("\n");
out.write(".nodata\n");
out.write("{\n");
out.write(" font-family:verdana; font-size:30px; text-align:center;\n");
out.write("}\n");
out.write(".nav-side-menu ul,.nav-side-menu li \n");
out.write("{\n");
out.write(" list-style: none;\n");
out.write(" padding: 0px;\n");
out.write(" margin-left: 0px;\n");
out.write(" line-height: 35px;\n");
out.write(" cursor: pointer;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu ul .active,.nav-side-menu li .active \n");
out.write("{\n");
out.write(" border-left: 3px solid #d19b3d;\n");
out.write(" background-color: #aed6f1;\n");
out.write(" padding-left:15px;\n");
out.write("}\n");
out.write(".nav-side-menu ul .sub-menu li.active,\n");
out.write(".nav-side-menu li .sub-menu li.active \n");
out.write("{\n");
out.write(" color: #d19b3d;\n");
out.write(" padding-left:15px;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu ul .sub-menu li,.nav-side-menu li .sub-menu li \n");
out.write("{\n");
out.write(" background-color: #2874a6;\n");
out.write(" border: none;\n");
out.write(" line-height: 28px;\n");
out.write(" border-bottom: 1px solid #23282e;\n");
out.write(" margin-left: 0px;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu ul .sub-menu li:hover,.nav-side-menu li .sub-menu li:hover \n");
out.write("{\n");
out.write(" background-color: #71b2dc;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu li \n");
out.write("{\n");
out.write(" padding-left: 20px;\n");
out.write(" border-left: 3px solid #2e353d;\n");
out.write(" border-bottom: 1px solid #23282e;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu li a \n");
out.write("{\n");
out.write(" text-decoration: none;\n");
out.write(" color: #e1ffff;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu li a i \n");
out.write("{\n");
out.write(" padding-left: 10px;\n");
out.write(" width: 20px;\n");
out.write(" padding-right: 20px;\n");
out.write("}\n");
out.write("\n");
out.write(".nav-side-menu li:hover \n");
out.write("{\n");
out.write(" border-left: 3px solid #d19b3d;\n");
out.write(" background-color: #4f5b69;\n");
out.write(" -webkit-transition: all 1s ease;\n");
out.write("}\n");
out.write("@media (max-width: 767px) \n");
out.write("{\n");
out.write(" .nav-side-menu \n");
out.write(" {\n");
out.write(" position: relative;\n");
out.write(" width: 100%;\n");
out.write(" margin-bottom: 10px;\n");
out.write(" }\n");
out.write(" .nav-side-menu .toggle-btn {\n");
out.write(" display: block;\n");
out.write(" cursor: pointer;\n");
out.write(" position: absolute;\n");
out.write(" right: 10px;\n");
out.write(" top: 10px;\n");
out.write(" z-index: 10 !important;\n");
out.write(" padding: 3px;\n");
out.write(" background-color: #ffffff;\n");
out.write(" color: #000;\n");
out.write(" width: 40px;\n");
out.write(" text-align: center;\n");
out.write(" }\n");
out.write("}\n");
out.write("\n");
out.write("@media (min-width: 767px) \n");
out.write("{\n");
out.write(" .nav-side-menu .menu-list .menu-content \n");
out.write(" {\n");
out.write(" display: block;\n");
out.write(" }\n");
out.write("}\n");
out.write("\n");
out.write("body \n");
out.write("{\n");
out.write(" margin: 0px;\n");
out.write(" padding: 0px;\n");
out.write("}\n");
out.write("\t\t\n");
out.write("\t</style>\n");
out.write("\n");
out.write(" <script>\n");
out.write("\tfunction sizeSelect100()\n");
out.write("\t{\n");
out.write("\t\tdocument.getElementById(\"demo\").innerHTML=\"Well of size 100 selected\";\n");
out.write("\t}\n");
out.write("\t\n");
out.write("\tfunction sizeSelect50()\n");
out.write("\t{\n");
out.write("\t\tdocument.getElementById(\"demo\").innerHTML=\"Well of size 50 selected\";\n");
out.write("\t}\n");
out.write("\t\n");
out.write("\tfunction sizeSelect20()\n");
out.write("\t{\n");
out.write("\t\tdocument.getElementById(\"demo\").innerHTML=\"Well of size 20 selected\";\n");
out.write("\t}\n");
out.write("\t\n");
out.write("\tfunction sizeSelect10()\n");
out.write("\t{\n");
out.write("\t\tdocument.getElementById(\"demo\").innerHTML=\"Well of size 10 selected\";\n");
out.write("\t}\n");
out.write("\t\n");
out.write("\tfunction backgroundColor(color)\n");
out.write("\t{\n");
out.write("\t\tdocument.getElementById(\"click\").style.background=color;\n");
out.write("\t}\n");
out.write("\t\n");
out.write("\tfunction myFunc2()\n");
out.write("\t{\n");
out.write("\t\tdocument.getElementById(\"01\").style.color=\"red\";\n");
out.write("\t}\n");
out.write(" function myFunc3()\n");
out.write("\t{\n");
out.write(" window.location = \"index.jsp\";\n");
out.write(" }\n");
out.write(" \n");
out.write(" function toggle(source) \n");
out.write(" {\n");
out.write(" checkboxes = document.getElementsByName('foo');\n");
out.write(" for(var i=0, n=checkboxes.length;i<n;i++) \n");
out.write(" {\n");
out.write(" checkboxes[i].checked = source.checked;\n");
out.write(" }\n");
out.write(" }\n");
out.write(" \n");
out.write(" function gotoUN()\n");
out.write(" {\n");
out.write(" window.location = 'un.jsp';\n");
out.write(" }\n");
out.write(" \n");
out.write(" function gotoIndex()\n");
out.write(" {\n");
out.write(" \n");
out.write(" }\n");
out.write(" function back(){\n");
out.write(" window.location = 'test.jsp';\n");
out.write(" }\n");
out.write(" function displayall(){\n");
out.write(" window.location = 'displayall.jsp';\n");
out.write(" }\n");
out.write(" </script>\n");
out.write("\t\n");
out.write("\t\n");
out.write("</head>\n");
out.write("\n");
out.write("<body style=\"overflow:hidden\">\n");
out.write("\n");
out.write("<div id=\"StageGate\"> \n");
out.write(" <button type=\"button\" class=\"btn btn-info btn-arrow-right\" onclick=\"back()\">File Available</button>\n");
out.write(" <button id=\"click\" type=\"button\" class=\"btn btn-info btn-arrow-right\" style=\"background-color:#1d79fd\">Mnemonic analysis</button>\n");
out.write(" <button type=\"button\" class=\"btn btn-info btn-arrow-right\">Unit Normalisation</button>\n");
out.write(" <button type=\"button\" class=\"btn btn-info btn-arrow-right\">HM</button>\n");
out.write(" <button type=\"button\" class=\"btn btn-info btn-arrow-right\">Pattern Generation</button>\n");
out.write("</div>\t\n");
out.write("\t\n");
out.write(" <div class=\"row\">\n");
out.write(" \n");
out.write(" <div class=\"col-sm-4\"></div>\n");
out.write(" <div class=\"col-sm-4\">\n");
out.write(" <p id=\"demo\" style=\"padding-top:25px\"></p>\n");
out.write(" </div>\n");
out.write(" \n");
out.write(" <div class=\"col-sm-4\"> \n");
out.write(" <div class=\"btn-sm\">\n");
out.write(" \n");
out.write(" <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle\" data-toggle=\"dropdown\">Well Size\n");
out.write("\t\t\t<span class=\"caret\"></span>\n");
out.write(" </button>\n");
out.write(" <ul class=\"dropdown-menu\" role=\"menu\">\n");
out.write("\t\t\t<li class=\"dropdown-header\">Select the well size</li>\n");
out.write("\t\t\t<li class=\"divider\"></li>\n");
out.write("\t\t\t<li><a href=\"#\" onClick=\"sizeSelect100()\">100</a></li>\n");
out.write("\t\t\t<li><a href=\"#\" onClick=\"sizeSelect50()\">50</a></li>\n");
out.write("\t\t\t<li><a href=\"#\" onClick=\"sizeSelect20()\">20</a></li>\n");
out.write("\t\t\t<li><a href=\"#\" onClick=\"sizeSelect10()\">10</a></li>\n");
out.write(" </ul>\n");
out.write(" \n");
out.write(" <button type=\"button\" class=\"btn-sm btn-primary\" onclick=\"gotoUN()\">Promote</button>\n");
out.write(" <button type=\"button\" class=\"btn-sm btn-primary\" onclick=\"gotoIndex()\">Demote</button>\n");
out.write(" <button type=\"button\" class=\"btn-sm btn-primary glyphicon glyphicon-refresh\" onClick=\"window.location.reload();\"></button> \n");
out.write(" <button type=\"button\" class=\"btn-sm btn-primary\" onclick=\"displayall()\">DISPLAY ALL</button>\t\t\t\t\t\n");
out.write(" </div> \n");
out.write("\t</div>\n");
out.write("</div>\n");
out.write("</div>\n");
out.write(" \n");
out.write(" <div class=\"row\" id=\"table\">\n");
out.write(" \t<div class=\"col-sm-2\">\n");
out.write(" \t<div class=\"nav-side-menu\">\n");
out.write(" \n");
out.write(" \t<div class=\"menu-list\">\n");
out.write(" \t<ul id=\"menu-content\" class=\"menu-content collapse in\">\n");
out.write(" \t<li data-toggle=\"collapse\" data-target=\"#products\" class=\"collapsed active\">\n");
out.write(" \t\t\t<a href=\"#\"><i class=\"glyphicon glyphicon-chevron-right\"></i> DASHBOARD</a>\n");
out.write(" \t\t</li>\n");
out.write(" \t<ul class=\"sub-menu collapse\" id=\"products\">\n");
out.write(" <li><a href=\"#\"></a></li>\n");
out.write(" <li><a href=\"#\"></a></li>\n");
out.write("\t\t\t\t <li><a href=\"#\"></a></li>\n");
out.write("\t\t\t\t <li><a href=\"#\"></a></li>\n");
out.write(" </ul>\n");
out.write(" \n");
out.write(" <!--<li data-toggle=\"collapse\" data-target=\"#service\" class=\"collapsed\">\n");
out.write(" \t\t<a href=\"#\"><i class=\"glyphicon glyphicon-chevron-right\"></i>Button</a>\n");
out.write(" </li> \n");
out.write("\t\t\t\t\t\t\t\n");
out.write("\t\t\t<ul class=\"sub-menu collapse\" id=\"service\">\n");
out.write("\t\t\t <li><a href=\"#\"></a></li>\n");
out.write("\t\t\t <li><a href=\"#\"></a></li>\n");
out.write("\t\t\t</ul>\n");
out.write(" -->\n");
out.write(" </ul>\n");
out.write(" </div>\n");
out.write(" </div>\n");
out.write(" </div>\n");
out.write(" \n");
out.write(" <!-- Jsp MongoDB code -->\n");
out.write(" ");
String[] selectedNames = request.getParameterValues("values");
if(request.getParameter("values")!=null){
out.write("\n");
out.write(" \n");
out.write(" ");
MongoClient client = new MongoClient("localhost", 27017);
MongoDatabase database = client.getDatabase("rig_witsml");
MongoCollection collection = database.getCollection("well");
Document document = new Document();
BasicDBObject newDocument = new BasicDBObject();
newDocument.append("$set", new BasicDBObject().append("flag", 6));
FindIterable<Document> mydatabaserecords = database.getCollection("well").find();
MongoCursor<Document> iterator = mydatabaserecords.iterator();
for(int i=0;i<selectedNames.length;i++){
BasicDBObject searchQuery = new BasicDBObject().append("nameWell", selectedNames[i]);
collection.updateMany(searchQuery, newDocument);
}
response.sendRedirect("DisplayPromoted1.jsp");
}
else{
response.sendRedirect("DisplayPromoted1.jsp");
}
out.write("\n");
out.write("</body>\n");
out.write("</html>\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
| gpl-3.0 |
fuhongliang/taolijie | src/main/java/com/fh/taolijie/domain/EmpCertiModelExample.java | 23518 | package com.fh.taolijie.domain;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class EmpCertiModelExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table emp_certi
*
* @mbggenerated
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table emp_certi
*
* @mbggenerated
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table emp_certi
*
* @mbggenerated
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public EmpCertiModelExample() {
oredCriteria = new ArrayList<Criteria>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table emp_certi
*
* @mbggenerated
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table emp_certi
*
* @mbggenerated
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCompanyNameIsNull() {
addCriterion("company_name is null");
return (Criteria) this;
}
public Criteria andCompanyNameIsNotNull() {
addCriterion("company_name is not null");
return (Criteria) this;
}
public Criteria andCompanyNameEqualTo(String value) {
addCriterion("company_name =", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameNotEqualTo(String value) {
addCriterion("company_name <>", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameGreaterThan(String value) {
addCriterion("company_name >", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameGreaterThanOrEqualTo(String value) {
addCriterion("company_name >=", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameLessThan(String value) {
addCriterion("company_name <", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameLessThanOrEqualTo(String value) {
addCriterion("company_name <=", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameLike(String value) {
addCriterion("company_name like", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameNotLike(String value) {
addCriterion("company_name not like", value, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameIn(List<String> values) {
addCriterion("company_name in", values, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameNotIn(List<String> values) {
addCriterion("company_name not in", values, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameBetween(String value1, String value2) {
addCriterion("company_name between", value1, value2, "companyName");
return (Criteria) this;
}
public Criteria andCompanyNameNotBetween(String value1, String value2) {
addCriterion("company_name not between", value1, value2, "companyName");
return (Criteria) this;
}
public Criteria andAddressIsNull() {
addCriterion("address is null");
return (Criteria) this;
}
public Criteria andAddressIsNotNull() {
addCriterion("address is not null");
return (Criteria) this;
}
public Criteria andAddressEqualTo(String value) {
addCriterion("address =", value, "address");
return (Criteria) this;
}
public Criteria andAddressNotEqualTo(String value) {
addCriterion("address <>", value, "address");
return (Criteria) this;
}
public Criteria andAddressGreaterThan(String value) {
addCriterion("address >", value, "address");
return (Criteria) this;
}
public Criteria andAddressGreaterThanOrEqualTo(String value) {
addCriterion("address >=", value, "address");
return (Criteria) this;
}
public Criteria andAddressLessThan(String value) {
addCriterion("address <", value, "address");
return (Criteria) this;
}
public Criteria andAddressLessThanOrEqualTo(String value) {
addCriterion("address <=", value, "address");
return (Criteria) this;
}
public Criteria andAddressLike(String value) {
addCriterion("address like", value, "address");
return (Criteria) this;
}
public Criteria andAddressNotLike(String value) {
addCriterion("address not like", value, "address");
return (Criteria) this;
}
public Criteria andAddressIn(List<String> values) {
addCriterion("address in", values, "address");
return (Criteria) this;
}
public Criteria andAddressNotIn(List<String> values) {
addCriterion("address not in", values, "address");
return (Criteria) this;
}
public Criteria andAddressBetween(String value1, String value2) {
addCriterion("address between", value1, value2, "address");
return (Criteria) this;
}
public Criteria andAddressNotBetween(String value1, String value2) {
addCriterion("address not between", value1, value2, "address");
return (Criteria) this;
}
public Criteria andPicIdsIsNull() {
addCriterion("pic_ids is null");
return (Criteria) this;
}
public Criteria andPicIdsIsNotNull() {
addCriterion("pic_ids is not null");
return (Criteria) this;
}
public Criteria andPicIdsEqualTo(String value) {
addCriterion("pic_ids =", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsNotEqualTo(String value) {
addCriterion("pic_ids <>", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsGreaterThan(String value) {
addCriterion("pic_ids >", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsGreaterThanOrEqualTo(String value) {
addCriterion("pic_ids >=", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsLessThan(String value) {
addCriterion("pic_ids <", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsLessThanOrEqualTo(String value) {
addCriterion("pic_ids <=", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsLike(String value) {
addCriterion("pic_ids like", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsNotLike(String value) {
addCriterion("pic_ids not like", value, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsIn(List<String> values) {
addCriterion("pic_ids in", values, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsNotIn(List<String> values) {
addCriterion("pic_ids not in", values, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsBetween(String value1, String value2) {
addCriterion("pic_ids between", value1, value2, "picIds");
return (Criteria) this;
}
public Criteria andPicIdsNotBetween(String value1, String value2) {
addCriterion("pic_ids not between", value1, value2, "picIds");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("status is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("status is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("status =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("status <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("status >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("status >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("status <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("status <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("status like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("status not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("status in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("status not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("status between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("status not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andCreatedTimeIsNull() {
addCriterion("created_time is null");
return (Criteria) this;
}
public Criteria andCreatedTimeIsNotNull() {
addCriterion("created_time is not null");
return (Criteria) this;
}
public Criteria andCreatedTimeEqualTo(Date value) {
addCriterion("created_time =", value, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeNotEqualTo(Date value) {
addCriterion("created_time <>", value, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeGreaterThan(Date value) {
addCriterion("created_time >", value, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeGreaterThanOrEqualTo(Date value) {
addCriterion("created_time >=", value, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeLessThan(Date value) {
addCriterion("created_time <", value, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeLessThanOrEqualTo(Date value) {
addCriterion("created_time <=", value, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeIn(List<Date> values) {
addCriterion("created_time in", values, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeNotIn(List<Date> values) {
addCriterion("created_time not in", values, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeBetween(Date value1, Date value2) {
addCriterion("created_time between", value1, value2, "createdTime");
return (Criteria) this;
}
public Criteria andCreatedTimeNotBetween(Date value1, Date value2) {
addCriterion("created_time not between", value1, value2, "createdTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table emp_certi
*
* @mbggenerated do_not_delete_during_merge
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table emp_certi
*
* @mbggenerated
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | gpl-3.0 |
matcatc/Test_Parser | src/TestParser_tests/Model/sample/JUnit4_test.java | 393 | import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class JUnit4_test{
@Test
public void testOne() {
int a = 2;
int b = 2;
int sum = a + b;
int expected = 4;
assertEquals(sum, expected); // 2 + 2 = 4?
}
@Test
public void testTwo() {
int a = 2;
int b = 2;
int sum = a + b +1;
int expected = 4;
assertEquals(sum, expected); // 2 + 2 = 5?
}
}
| gpl-3.0 |
Severed-Infinity/technium | build/tmp/recompileMc/sources/net/minecraft/entity/ai/EntityAITarget.java | 8229 | package net.minecraft.entity.ai;
import javax.annotation.Nullable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityOwnable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.scoreboard.Team;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
public abstract class EntityAITarget extends EntityAIBase
{
/** The entity that this task belongs to */
protected final EntityCreature taskOwner;
/** If true, EntityAI targets must be able to be seen (cannot be blocked by walls) to be suitable targets. */
protected boolean shouldCheckSight;
/** When true, only entities that can be reached with minimal effort will be targetted. */
private final boolean nearbyOnly;
/** When nearbyOnly is true: 0 -> No target, but OK to search; 1 -> Nearby target found; 2 -> Target too far. */
private int targetSearchStatus;
/** When nearbyOnly is true, this throttles target searching to avoid excessive pathfinding. */
private int targetSearchDelay;
/**
* If @shouldCheckSight is true, the number of ticks before the interuption of this AITastk when the entity does't
* see the target
*/
private int targetUnseenTicks;
protected EntityLivingBase target;
protected int unseenMemoryTicks;
public EntityAITarget(EntityCreature creature, boolean checkSight)
{
this(creature, checkSight, false);
}
public EntityAITarget(EntityCreature creature, boolean checkSight, boolean onlyNearby)
{
this.unseenMemoryTicks = 60;
this.taskOwner = creature;
this.shouldCheckSight = checkSight;
this.nearbyOnly = onlyNearby;
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean shouldContinueExecuting()
{
EntityLivingBase entitylivingbase = this.taskOwner.getAttackTarget();
if (entitylivingbase == null)
{
entitylivingbase = this.target;
}
if (entitylivingbase == null)
{
return false;
}
else if (!entitylivingbase.isEntityAlive())
{
return false;
}
else
{
Team team = this.taskOwner.getTeam();
Team team1 = entitylivingbase.getTeam();
if (team != null && team1 == team)
{
return false;
}
else
{
double d0 = this.getTargetDistance();
if (this.taskOwner.getDistanceSq(entitylivingbase) > d0 * d0)
{
return false;
}
else
{
if (this.shouldCheckSight)
{
if (this.taskOwner.getEntitySenses().canSee(entitylivingbase))
{
this.targetUnseenTicks = 0;
}
else if (++this.targetUnseenTicks > this.unseenMemoryTicks)
{
return false;
}
}
if (entitylivingbase instanceof EntityPlayer && ((EntityPlayer)entitylivingbase).capabilities.disableDamage)
{
return false;
}
else
{
this.taskOwner.setAttackTarget(entitylivingbase);
return true;
}
}
}
}
}
protected double getTargetDistance()
{
IAttributeInstance iattributeinstance = this.taskOwner.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE);
return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
this.targetSearchStatus = 0;
this.targetSearchDelay = 0;
this.targetUnseenTicks = 0;
}
/**
* Reset the task's internal state. Called when this task is interrupted by another one
*/
public void resetTask()
{
this.taskOwner.setAttackTarget((EntityLivingBase)null);
this.target = null;
}
/**
* A static method used to see if an entity is a suitable target through a number of checks.
*/
public static boolean isSuitableTarget(EntityLiving attacker, @Nullable EntityLivingBase target, boolean includeInvincibles, boolean checkSight)
{
if (target == null)
{
return false;
}
else if (target == attacker)
{
return false;
}
else if (!target.isEntityAlive())
{
return false;
}
else if (!attacker.canAttackClass(target.getClass()))
{
return false;
}
else if (attacker.isOnSameTeam(target))
{
return false;
}
else
{
if (attacker instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId() != null)
{
if (target instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId().equals(((IEntityOwnable)target).getOwnerId()))
{
return false;
}
if (target == ((IEntityOwnable)attacker).getOwner())
{
return false;
}
}
else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer)target).capabilities.disableDamage)
{
return false;
}
return !checkSight || attacker.getEntitySenses().canSee(target);
}
}
/**
* A method used to see if an entity is a suitable target through a number of checks. Args : entity,
* canTargetInvinciblePlayer
*/
protected boolean isSuitableTarget(@Nullable EntityLivingBase target, boolean includeInvincibles)
{
if (!isSuitableTarget(this.taskOwner, target, includeInvincibles, this.shouldCheckSight))
{
return false;
}
else if (!this.taskOwner.isWithinHomeDistanceFromPosition(new BlockPos(target)))
{
return false;
}
else
{
if (this.nearbyOnly)
{
if (--this.targetSearchDelay <= 0)
{
this.targetSearchStatus = 0;
}
if (this.targetSearchStatus == 0)
{
this.targetSearchStatus = this.canEasilyReach(target) ? 1 : 2;
}
if (this.targetSearchStatus == 2)
{
return false;
}
}
return true;
}
}
/**
* Checks to see if this entity can find a short path to the given target.
*/
private boolean canEasilyReach(EntityLivingBase target)
{
this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
Path path = this.taskOwner.getNavigator().getPathToEntityLiving(target);
if (path == null)
{
return false;
}
else
{
PathPoint pathpoint = path.getFinalPathPoint();
if (pathpoint == null)
{
return false;
}
else
{
int i = pathpoint.x - MathHelper.floor(target.posX);
int j = pathpoint.z - MathHelper.floor(target.posZ);
return (double)(i * i + j * j) <= 2.25D;
}
}
}
public EntityAITarget setUnseenMemoryTicks(int p_190882_1_)
{
this.unseenMemoryTicks = p_190882_1_;
return this;
}
} | gpl-3.0 |
ldbc-dev/ldbc_snb_datagen_deprecated2015 | src/main/java/ldbc/socialnet/dbgen/util/Distribution.java | 3379 | /*
* Copyright (c) 2013 LDBC
* Linked Data Benchmark Council (http://ldbc.eu)
*
* This file is part of ldbc_socialnet_dbgen.
*
* ldbc_socialnet_dbgen 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.
*
* ldbc_socialnet_dbgen 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 ldbc_socialnet_dbgen. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2011 OpenLink Software <bdsmt@openlinksw.com>
* All Rights Reserved.
*
* 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; only Version 2 of the License dated
* June 1991.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package ldbc.socialnet.dbgen.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.ArrayList;
import java.util.Iterator;
public class Distribution {
double[] distribution;
String distributionFile;
public Distribution( String distributionFile ){
this.distributionFile = distributionFile;
}
public void initialize() {
try{
BufferedReader distributionBuffer = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(distributionFile), "UTF-8"));
ArrayList<Double> temp = new ArrayList<Double>();
String line;
while ((line = distributionBuffer.readLine()) != null){
Double prob = Double.valueOf(line);
temp.add(prob);
}
distribution = new double[temp.size()];
int index = 0;
Iterator<Double> it = temp.iterator();
while(it.hasNext()) {
distribution[index] = it.next();
++index;
}
} catch (IOException e) {
e.printStackTrace();
}
}
private int binarySearch( double prob ) {
int upperBound = distribution.length - 1;
int lowerBound = 0;
int midPoint = (upperBound + lowerBound) / 2;
while (upperBound > (lowerBound+1)){
if (distribution[midPoint] > prob ){
upperBound = midPoint;
} else{
lowerBound = midPoint;
}
midPoint = (upperBound + lowerBound) / 2;
}
return midPoint;
}
public double nextDouble( Random random) {
return (double)binarySearch(random.nextDouble())/(double)distribution.length;
}
}
| gpl-3.0 |
dgrahn/Timelinr | src/us/grahn/crf/builder/CRFDataBuilder.java | 14202 | package us.grahn.crf.builder;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;
import us.grahn.crf.CRFData;
/**
* A simple CRF data visualizer and builder.
*
* @author Dan Grahn
*/
public class CRFDataBuilder extends JFrame {
/**
* An {@code Action} which handles all the builder's actions.
*
* @author Dan Grahn
*/
private class BuilderAction extends AbstractAction {
public BuilderAction(final String name, final ImageIcon icon) {
putValue(NAME, name);
putValue(SMALL_ICON, icon);
}
public BuilderAction(final String name, final ImageIcon icon, final KeyStroke key) {
this(name, icon);
putValue(ACCELERATOR_KEY, key);
}
@Override
public void actionPerformed(final ActionEvent e) {
final String name = (String) getValue(NAME);
if (LOAD_TEXT.equals(name)) load();
else if (SAVE_TEXT.equals(name)) save();
else if (REFRESH_TEXT.equals(name)) refreshHighlights();
else if (ADD_COL_TEXT.equals(name)) addColumn();
else if (UPDATE_TEXT.equals(name)) updateData();
else if (REMOVE_TEXT.equals(name)) removeData();
}
}
private static final ImageIcon ADD_COL_ICON = getIcon("add.png");
private static final String ADD_COL_TEXT = "Add Column";
private static final String DEFAULT_HIGHLIGHTS =
"C DATE #F38630\n"
+ "F BGN #69D2E7\n"
+ "F IN #A7DBD8";
private static final ImageIcon LOAD_ICON = getIcon("open.png");
private static final String LOAD_TEXT = "Load...";
private static final ImageIcon REFRESH_ICON = getIcon("refresh.png");
private static final String REFRESH_TEXT = "Refresh";
private static final ImageIcon SAVE_ICON = getIcon("save.png");
private static final String SAVE_TEXT = "Save...";
private static final KeyStroke SAVE_KEY = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK);
private static final ImageIcon UPDATE_ICON = getIcon("star.png");
private static final KeyStroke UPDATE_KEY = KeyStroke.getKeyStroke(KeyEvent.VK_U, 0);
private static final String UPDATE_TEXT = "Update Selection";
private static final KeyStroke REMOVE_KEY = KeyStroke.getKeyStroke(KeyEvent.VK_R, 0);
private static final ImageIcon REMOVE_ICON = getIcon("remove.png");
private static final String REMOVE_TEXT = "Remove Selection";
private static ImageIcon getIcon(final String path) {
try {
return new ImageIcon(ImageIO.read(new File("data/icons/" + path)));
} catch (final IOException e) {
return null;
}
}
public static void main(final String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
final CRFDataBuilder builder = new CRFDataBuilder();
builder.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
builder.setVisible(true);
} catch(final Exception e) {
e.printStackTrace();
}
}
private final Action actionAddCol = new BuilderAction(ADD_COL_TEXT, ADD_COL_ICON);
private final Action actionLoad = new BuilderAction(LOAD_TEXT, LOAD_ICON);
private final Action actionRefresh = new BuilderAction(REFRESH_TEXT, REFRESH_ICON);
private final Action actionSave = new BuilderAction(SAVE_TEXT, SAVE_ICON, SAVE_KEY);
private final Action actionUpdate = new BuilderAction(UPDATE_TEXT, UPDATE_ICON, UPDATE_KEY);
private final Action actionRemove = new BuilderAction(REMOVE_TEXT, REMOVE_ICON, REMOVE_KEY);
private CRFData data = null;
private final JTextField defaultText = new JTextField("OUT");
private final JMenu editMenu = new JMenu("Edit");
private final JMenu fileMenu = new JMenu("File");
private final List<Highlight> highlights = new ArrayList<>();
private final JTextArea highlightText = new JTextArea();
private final JSplitPane mainSplitPane = new JSplitPane();
private final JMenuBar menubar = new JMenuBar();
private final JTextField middleText = new JTextField("IN");
private final JSplitPane sideSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
private final JTextField startText = new JTextField("BGN");
private final JTextField columnText = new JTextField("LAST");
private final JTable table = new JTable();
private final JTextArea textarea = new JTextArea();
private final JToolBar toolbar = new JToolBar();
private File loadFile = null;
private File saveFile = null;
public CRFDataBuilder() {
setTitle("Test Data Builder");
setJMenuBar(menubar);
setLayout(new BorderLayout());
add(toolbar, BorderLayout.NORTH);
add(mainSplitPane, BorderLayout.CENTER);
// Setup the main split pane
mainSplitPane.setRightComponent(new JScrollPane(textarea));
mainSplitPane.setLeftComponent(sideSplitPane);
// Setup the side split pane
sideSplitPane.setTopComponent(new JScrollPane(highlightText));
sideSplitPane.setBottomComponent(new JScrollPane(table));
// Customize the highlight pane
highlightText.setText(DEFAULT_HIGHLIGHTS);
// Customize the text fields
defaultText.setMaximumSize(new Dimension(1000, defaultText.getPreferredSize().height));
startText.setMaximumSize(new Dimension(1000, startText.getPreferredSize().height));
middleText.setMaximumSize(new Dimension(1000, middleText.getPreferredSize().height));
columnText.setMaximumSize(new Dimension(1000, columnText.getPreferredSize().height));
// Customize the text pane
textarea.setEditable(false);
textarea.setLineWrap(true);
textarea.setWrapStyleWord(true);
// File Menu
menubar.add(fileMenu);
fileMenu.add(actionLoad);
fileMenu.add(actionSave);
// Edit Menu
menubar.add(editMenu);
editMenu.add(actionRefresh);
editMenu.addSeparator();
editMenu.add(actionAddCol);
editMenu.add(actionUpdate);
editMenu.add(actionRemove);
// Toolbar
toolbar.add(actionLoad);
toolbar.add(actionSave);
toolbar.addSeparator();
toolbar.add(actionRefresh);
toolbar.addSeparator();
toolbar.add(actionAddCol);
toolbar.add(actionUpdate);
toolbar.add(actionRemove);
toolbar.add(Box.createHorizontalGlue());
toolbar.add(new JLabel("Default: "));
toolbar.add(defaultText);
toolbar.add(new JLabel(" Column: "));
toolbar.add(columnText);
toolbar.add(new JLabel(" Start: "));
toolbar.add(startText);
toolbar.add(new JLabel(" Middle: "));
toolbar.add(middleText);
pack();
setSize(1360, 768);
setLocationRelativeTo(null);
mainSplitPane.setDividerLocation(0.6);
sideSplitPane.setDividerLocation(0.4);
textarea.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(final CaretEvent arg0) {
final int startRow = data.offsetToRow(textarea.getSelectionStart());
final int endRow = data.offsetToRow(textarea.getSelectionEnd());
if (startRow == -1 || endRow == -1) return;
table.setRowSelectionInterval(startRow, endRow);
table.scrollRectToVisible(table.getCellRect(startRow, 0, true));
}
});
}
protected void addColumn() {
data.addColumn(defaultText.getText());
getModel().fireTableStructureChanged();
}
private CRFDataTableModel getModel() {
return (CRFDataTableModel) table.getModel();
}
protected void load() {
final JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new FileNameExtensionFilter("CRF Data", "crf"));
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setMultiSelectionEnabled(false);
final int returnVal = chooser.showOpenDialog(this);
if (returnVal != JFileChooser.APPROVE_OPTION) return;
load(chooser.getSelectedFile());
}
protected void load(final File file) {
this.loadFile = file;
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
System.out.print("Reading Data... ");
data = new CRFData(file);
System.out.println("Done");
return null;
}
@Override
public void done() {
refreshDisplay();
}
}.run();
}
protected void refreshDisplay() {
// Update the table
System.out.print("Updating GUI... ");
refreshHighlights();
table.setModel(new CRFDataTableModel(data));
// Update the textarea
textarea.setText(data.getText());
textarea.setCaretPosition(0);
refreshHighlights();
System.out.println("Done");
}
protected void refreshHighlights() {
// Parse the highlights.
highlights.clear();
for (final String line : highlightText.getText().split("\n")) {
final String[] parsed = line.split("\\s+");
try {
final Highlight h = new Highlight();
h.setCol(table.getColumn(parsed[0]).getModelIndex());
h.setType(parsed[1]);
h.setColor(parsed[2]);
highlights.add(h);
} catch (final IllegalArgumentException e) {
}
}
// Remove all the existing highlights
textarea.getHighlighter().removeAllHighlights();
// Add the highlights back in
int start = 0;
for (int row = 0; row < data.getRowCount(); row++) {
final int end = start + data.getWord(row).length() + 1;
for (final Highlight h : highlights) {
if (h.getType().equals(data.get(row, h.getCol()))) {
try {
textarea.getHighlighter()
.addHighlight(start, end,
new DefaultHighlightPainter(h.getColor()));
} catch (final BadLocationException e) {
e.printStackTrace();
}
}
}
start = end;
}
}
protected void save() {
final JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new FileNameExtensionFilter("CRF Data", "crf"));
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setSelectedFile(loadFile);
chooser.setMultiSelectionEnabled(false);
final int returnVal = chooser.showSaveDialog(this);
if (returnVal != JFileChooser.APPROVE_OPTION) return;
saveFile = chooser.getSelectedFile();
System.out.print("Saving... ");
data.write(saveFile);
System.out.println("Done.");
}
protected void updateData() {
final int startRow = data.offsetToRow(textarea.getSelectionStart());
final int endRow = data.offsetToRow(textarea.getSelectionEnd());
final int col = "LAST".equals(columnText.getText())
? data.getColumnCount() - 1
: table.getColumn(columnText.getText()).getModelIndex();
data.set(startRow, data.getColumnCount() - 1, startText.getText());
getModel().fireTableCellUpdated(startRow, col);
for (int row = startRow + 1; row <= endRow; row++) {
data.set(row, col, middleText.getText());
getModel().fireTableCellUpdated(row, col);
}
refreshHighlights();
}
protected void removeData() {
final int startRow = data.offsetToRow(textarea.getSelectionStart());
final int endRow = data.offsetToRow(textarea.getSelectionEnd());
final int col = "LAST".equals(columnText.getText())
? data.getColumnCount() - 1
: table.getColumn(columnText.getText()).getModelIndex();
for (int row = startRow; row <= endRow; row++) {
data.set(row, col, defaultText.getText());
getModel().fireTableCellUpdated(row, col);
}
refreshHighlights();
}
}
| gpl-3.0 |
goluch/treeCmp | src/treecmp/metric/RFMetric.java | 1989 | /** This file is part of TreeCmp, a tool for comparing phylogenetic trees
using the Matching Split distance and other metrics.
Copyright (C) 2011, Damian Bogdanowicz
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 treecmp.metric;
import treecmp.common.SplitDist;
import java.util.BitSet;
import java.util.HashSet;
import pal.misc.IdGroup;
import pal.tree.*;
/**
*
* @author Damian
*/
public class RFMetric extends BaseMetric implements Metric{
public static double getRFDistance(Tree t1, Tree t2) {
int n = t1.getExternalNodeCount();
if (n <= 3)
return 0;
IdGroup idGroup = TreeUtils.getLeafIdGroup(t1);
BitSet[] s_t1=SplitDist.getSplits(t1, idGroup);
BitSet[] s_t2=SplitDist.getSplits(t2, idGroup);
int N1=s_t1.length;
int N2=s_t2.length;
int hashSetSize=(4*(N1+1))/3;
HashSet<BitSet> s_t1_hs=new HashSet<BitSet>(hashSetSize);
int i;
for(i=0;i<N1;i++){
s_t1_hs.add(s_t1[i]);
}
int common=0;
for(i=0;i<N2;i++){
if (s_t1_hs.contains(s_t2[i])){
common++;
}
}
double dist=((double)N1+(double)N2)*0.5-(double)common;
return dist;
}
public double getDistance(Tree t1, Tree t2) {
return RFMetric.getRFDistance(t1, t2);
}
}
| gpl-3.0 |
fython/Blackbulb | libraries/timepicker/src/main/java/com/wdullaer/materialdatetimepicker/Utils.java | 6156 | /*
* Copyright (C) 2013 The Android Open Source Project
*
* 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.wdullaer.materialdatetimepicker;
import android.animation.Keyframe;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Build;
import android.util.TypedValue;
import android.view.View;
import java.util.Calendar;
/**
* Utility helper functions for time and date pickers.
*/
@SuppressWarnings("WeakerAccess")
public class Utils {
//public static final int MONDAY_BEFORE_JULIAN_EPOCH = Time.EPOCH_JULIAN_DAY - 3;
public static final int PULSE_ANIMATOR_DURATION = 544;
// Alpha level for time picker selection.
public static final int SELECTED_ALPHA = 255;
public static final int SELECTED_ALPHA_THEME_DARK = 255;
// Alpha level for fully opaque.
public static final int FULL_ALPHA = 255;
public static boolean isJellybeanOrLater() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}
/**
* Try to speak the specified text, for accessibility. Only available on JB or later.
* @param text Text to announce.
*/
@SuppressLint("NewApi")
public static void tryAccessibilityAnnounce(View view, CharSequence text) {
if (isJellybeanOrLater() && view != null && text != null) {
view.announceForAccessibility(text);
}
}
/**
* Render an animator to pulsate a view in place.
* @param labelToAnimate the view to pulsate.
* @return The animator object. Use .start() to begin.
*/
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio,
float increaseRatio) {
Keyframe k0 = Keyframe.ofFloat(0f, 1f);
Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
Keyframe k3 = Keyframe.ofFloat(1f, 1f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
ObjectAnimator pulseAnimator =
ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
}
/**
* Convert Dp to Pixel
*/
@SuppressWarnings("unused")
public static int dpToPx(float dp, Resources resources){
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
return (int) px;
}
public static int darkenColor(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] = hsv[2] * 0.8f; // value component
return Color.HSVToColor(hsv);
}
/**
* Gets the colorAccent from the current context, if possible/available
* @param context The context to use as reference for the color
* @return the accent color of the current context
*/
public static int getAccentColorFromThemeIfAvailable(Context context) {
TypedValue typedValue = new TypedValue();
// First, try the android:colorAccent
if (Build.VERSION.SDK_INT >= 21) {
context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
return typedValue.data;
}
// Next, try colorAccent from support lib
int colorAccentResId = context.getResources().getIdentifier("colorAccent", "attr", context.getPackageName());
if (colorAccentResId != 0 && context.getTheme().resolveAttribute(colorAccentResId, typedValue, true)) {
return typedValue.data;
}
// Return the value in mdtp_accent_color
return context.getResources().getColor(R.color.mdtp_accent_color);
}
/**
* Gets dialog type (Light/Dark) from current theme
* @param context The context to use as reference for the boolean
* @param current Default value to return if cannot resolve the attribute
* @return true if dark mode, false if light.
*/
public static boolean isDarkTheme(Context context, boolean current) {
return resolveBoolean(context, R.attr.mdtp_theme_dark, current);
}
/**
* Gets the required boolean value from the current context, if possible/available
* @param context The context to use as reference for the boolean
* @param attr Attribute id to resolve
* @param fallback Default value to return if no value is specified in theme
* @return the boolean value from current theme
*/
private static boolean resolveBoolean(Context context, int attr, boolean fallback) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
try {
return a.getBoolean(0, fallback);
} finally {
a.recycle();
}
}
/**
* Trims off all time information, effectively setting it to midnight
* Makes it easier to compare at just the day level
*
* @param calendar The Calendar object to trim
* @return The trimmed Calendar object
*/
public static Calendar trimToMidnight(Calendar calendar) {
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar;
}
}
| gpl-3.0 |
samysadi/acs | src/com/samysadi/acs_test/utility/structure/InfrastructureTest.java | 10842 | /*
===============================================================================
Copyright (c) 2014-2015, Samy Sadi. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This file is part of ACS - Advanced Cloud Simulator.
ACS is part of a research project undertaken by
Samy Sadi (samy.sadi.contact@gmail.com) and supervised by
Belabbas Yagoubi (byagoubi@gmail.com) in the
University of Oran1 Ahmed Benbella, Algeria.
ACS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3
as published by the Free Software Foundation.
ACS 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 ACS. If not, see <http://www.gnu.org/licenses/>.
===============================================================================
*/
package com.samysadi.acs_test.utility.structure;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.samysadi.acs.hardware.Host;
import com.samysadi.acs.hardware.HostDefault;
import com.samysadi.acs.utility.collections.infrastructure.CloudImpl;
import com.samysadi.acs.utility.collections.infrastructure.Cluster;
import com.samysadi.acs.utility.collections.infrastructure.ClusterImpl;
import com.samysadi.acs.utility.collections.infrastructure.Datacenter;
import com.samysadi.acs.utility.collections.infrastructure.DatacenterImpl;
import com.samysadi.acs.utility.collections.infrastructure.Rack;
import com.samysadi.acs.utility.collections.infrastructure.RackImpl;
/**
*
* @since 1.0
*/
@SuppressWarnings("unused")
public class InfrastructureTest {
int HOST = 7;
int RACK = 11;
int CLUSTER = 13;
int DATACENTER = 19;
CloudImpl _cl;
DatacenterImpl _d;
@Before
public void beforeTest() {
_cl = new CloudImpl();
{
for (int d = 0; d<DATACENTER; d++) {
DatacenterImpl _d = new DatacenterImpl();
_d.setCloud(_cl);
for (int c = 0; c<CLUSTER; c++) {
ClusterImpl _c = new ClusterImpl();
_c.setDatacenter(_d);
for (int r = 0; r<RACK; r++) {
RackImpl _r = new RackImpl();
_r.setCluster(_c);
for (int h = 0; h<HOST; h++) {
Host _h = new HostDefault();
_h.setProperty("d", d);
_h.setProperty("c", c);
_h.setProperty("r", r);
_h.setProperty("h", h);
_h.setName("c=" + c + "\tr=" + r + "\th=" + h);
_r.add(_h);
}
_c.add(_r);
}
_d.add(_c);
}
_cl.add(_d);
}
Assert.assertEquals(DATACENTER, _cl.size());
Assert.assertEquals(DATACENTER * CLUSTER, _cl.getClusters().size());
Assert.assertEquals(DATACENTER * CLUSTER * RACK, _cl.getRacks().size());
Assert.assertEquals(DATACENTER * CLUSTER * RACK * HOST, _cl.getHosts().size());
_d = _cl.get(0);
Assert.assertEquals(CLUSTER, _d.size());
Assert.assertEquals(CLUSTER * RACK, _d.getRacks().size());
Assert.assertEquals(CLUSTER * RACK * HOST, _d.getHosts().size());
Assert.assertEquals(RACK, _d.get(0).size());
Assert.assertEquals(RACK * HOST, _d.get(0).getHosts().size());
Assert.assertEquals(HOST, _d.get(0).get(0).size());
}
}
public static HashSet<Integer> build(int size) {
ArrayList<Integer> r = new ArrayList<Integer>(size);
while (size-->0)
r.add(Integer.valueOf(size));
return new HashSet<Integer>(r);
}
@Test
public void test0() {
{
HashSet<Integer> vd = build(CLUSTER * RACK * HOST);
for (Cluster _c : _d.getClusters()) {
for (Rack _r: _c.getRacks()) {
for (Host _h: _r.getHosts()) {
vd.remove(Integer.valueOf(
((Integer)_h.getProperty("c")) * RACK * HOST +
((Integer)_h.getProperty("r")) * HOST +
((Integer)_h.getProperty("h"))
));
}
}
}
Assert.assertEquals(0, vd.size());
}
{
HashSet<Integer> vd = build(CLUSTER * RACK * HOST);
for (Rack _r: _d.getRacks()) {
for (Host _h: _r.getHosts()) {
vd.remove(Integer.valueOf(
((Integer)_h.getProperty("c")) * RACK * HOST +
((Integer)_h.getProperty("r")) * HOST +
((Integer)_h.getProperty("h"))
));
}
}
Assert.assertEquals(0, vd.size());
}
{
HashSet<Integer> vd = build(CLUSTER * RACK * HOST);
for (Host _h: _d.getHosts()) {
vd.remove(Integer.valueOf(
((Integer)_h.getProperty("c")) * RACK * HOST +
((Integer)_h.getProperty("r")) * HOST +
((Integer)_h.getProperty("h"))
));
}
Assert.assertEquals(0, vd.size());
}
{
HashSet<Integer> vd = build(RACK * HOST);
for (Rack _r: _d.get(0).getRacks()) {
for (Host _h: _r.getHosts()) {
vd.remove(Integer.valueOf(
((Integer)_h.getProperty("r")) * HOST +
((Integer)_h.getProperty("h"))
));
}
}
Assert.assertEquals(0, vd.size());
}
{
HashSet<Integer> vd = build(RACK * HOST);
for (Host _h: _d.get(0).getHosts()) {
vd.remove(Integer.valueOf(
((Integer)_h.getProperty("r")) * HOST +
((Integer)_h.getProperty("h"))
));
}
Assert.assertEquals(0, vd.size());
}
{
HashSet<Integer> vd = build(HOST);
for (Host _h: _d.get(0).get(0).getHosts()) {
vd.remove(
_h.getProperty("h")
);
}
Assert.assertEquals(0, vd.size());
}
}
@Test(expected=ConcurrentModificationException.class)
public void test1() {
{
for (Host _h : _d.getHosts()) {
_d.get(0).get(0).add(new HostDefault());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test2() {
{
for (Host _h : _d.getHosts()) {
_d.get(0).add(new RackImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test3() {
{
for (Host _h : _d.getHosts()) {
_d.add(new ClusterImpl());
}
}
}
@Test
public void test4() {
{
for (Rack _r : _d.getRacks()) {
_d.get(0).get(0).add(new HostDefault());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test5() {
{
for (Rack _r : _d.getRacks()) {
_d.get(0).add(new RackImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test6() {
{
for (Rack _r : _d.getRacks()) {
_d.add(new ClusterImpl());
}
}
}
@Test
public void test7() {
{
for (Cluster _c : _d.getClusters()) {
_d.get(0).get(0).add(new HostDefault());
}
}
}
@Test
public void test8() {
{
for (Cluster _c : _d.getClusters()) {
_d.get(0).add(new RackImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test9() {
{
for (Cluster _c : _d.getClusters()) {
_d.add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test10() {
{
for (Host _h : _d.get(0).getHosts()) {
_d.get(0).get(0).add(new HostDefault());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test11() {
{
for (Host _h : _d.get(0).getHosts()) {
_d.get(0).add(new RackImpl());
}
}
}
@Test
public void test12() {
{
for (Host _h : _d.get(0).getHosts()) {
_d.add(new ClusterImpl());
}
}
}
@Test
public void test13() {
{
for (Rack _r : _d.get(0).getRacks()) {
_d.get(0).get(0).add(new HostDefault());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test14() {
{
for (Rack _r : _d.get(0).getRacks()) {
_d.get(0).add(new RackImpl());
}
}
}
@Test
public void test15() {
{
for (Rack _r : _d.get(0).getRacks()) {
_d.add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test16() {
{
for (Host _h : _d.get(0).get(0).getHosts()) {
_d.get(0).get(0).add(new HostDefault());
}
}
}
@Test
public void test17() {
{
for (Host _h : _d.get(0).get(0).getHosts()) {
_d.get(0).add(new RackImpl());
}
}
}
@Test
public void test18() {
{
for (Host _h : _d.get(0).get(0).getHosts()) {
_d.add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test19() {
{
for (Host _h : _cl.getHosts()) {
_cl.get(0).get(0).get(0).add(new HostDefault());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test20() {
{
for (Host _h : _cl.getHosts()) {
_cl.get(0).get(0).add(new RackImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test21() {
{
for (Host _h : _cl.getHosts()) {
_cl.get(0).add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test22() {
{
for (Host _h : _cl.getHosts()) {
_cl.add(new DatacenterImpl());
}
}
}
@Test
public void test23() {
{
for (Rack _r : _cl.getRacks()) {
_cl.get(0).get(0).get(0).add(new HostDefault());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test24() {
{
for (Rack _r : _cl.getRacks()) {
_cl.get(0).get(0).add(new RackImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test25() {
{
for (Rack _r : _cl.getRacks()) {
_cl.get(0).add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test26() {
{
for (Rack _r : _cl.getRacks()) {
_cl.add(new DatacenterImpl());
}
}
}
@Test
public void test27() {
{
for (Cluster _c : _cl.getClusters()) {
_cl.get(0).get(0).get(0).add(new HostDefault());
}
}
}
@Test
public void test28() {
{
for (Cluster _c : _cl.getClusters()) {
_cl.get(0).get(0).add(new RackImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test29() {
{
for (Cluster _c : _cl.getClusters()) {
_cl.get(0).add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test30() {
{
for (Cluster _c : _cl.getClusters()) {
_cl.add(new DatacenterImpl());
}
}
}
@Test
public void test31() {
{
for (Datacenter _d : _cl.getDatacenters()) {
_cl.get(0).get(0).get(0).add(new HostDefault());
}
}
}
@Test
public void test32() {
{
for (Datacenter _d : _cl.getDatacenters()) {
_cl.get(0).get(0).add(new RackImpl());
}
}
}
@Test
public void test33() {
{
for (Datacenter _d : _cl.getDatacenters()) {
_cl.get(0).add(new ClusterImpl());
}
}
}
@Test(expected=ConcurrentModificationException.class)
public void test34() {
{
for (Datacenter _d : _cl.getDatacenters()) {
_cl.add(new DatacenterImpl());
}
}
}
}
| gpl-3.0 |
Naoghuman/Incubator | ProjectManagement/src/main/java/com/github/naoghuman/pm/view/dailysectionsoverview/DailySectionsOverviewPresenter.java | 8115 | /*
* Copyright (C) 2016 Naoghuman
*
* 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 com.github.naoghuman.pm.view.dailysectionsoverview;
import com.github.naoghuman.lib.action.api.ActionFacade;
import com.github.naoghuman.lib.action.api.IRegisterActions;
import com.github.naoghuman.lib.action.api.TransferData;
import com.github.naoghuman.lib.logger.api.LoggerFacade;
import com.github.naoghuman.pm.configuration.INavigationOverviewConfiguration;
import com.github.naoghuman.pm.dialog.DialogProvider;
import com.github.naoghuman.pm.model.DailySectionModel;
import com.github.naoghuman.pm.model.ProjectModel;
import com.github.naoghuman.pm.view.dailysectionsoverview.dailysectioncontent.DailySectionContentPresenter;
import com.github.naoghuman.pm.view.dailysectionsoverview.dailysectioncontent.DailySectionContentView;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.Tooltip;
/**
*
* @author Naoghuman
*/
public class DailySectionsOverviewPresenter implements Initializable, INavigationOverviewConfiguration, IRegisterActions {
@FXML private Button bNewDailySection;
@FXML private TabPane tpDailySections;
@Override
public void initialize(URL location, ResourceBundle resources) {
LoggerFacade.INSTANCE.info(this.getClass(), "Initialize DailySectionPresenter"); // NOI18N
this.initializeNewDailySectionButton();
this.registerActions();
}
private void initializeNewDailySectionButton() {
LoggerFacade.INSTANCE.info(this.getClass(), "Initialize new DailySection button"); // NOI18N
bNewDailySection.setTooltip(new Tooltip("Creates a new Daily Section")); // NOI18N
LoggerFacade.INSTANCE.error(this.getClass(), "TODO use property"); // NOI18N
}
private void onActionOpenDailySection(DailySectionModel model) {
// Check if the DailyArea is always open
final String dailyDate = model.getDailyDate();
final Optional<Tab> result = tpDailySections.getTabs().stream()
.filter(tab -> {
return tab.getText().equals(dailyDate);
})
.findFirst();
if (result.isPresent()) {
tpDailySections.getSelectionModel().select(result.get());
return;
}
// Otherwise create a new Tab
final Tab tab = new Tab();
tab.setClosable(true);
final DailySectionContentView view = new DailySectionContentView();
tab.setContent(view.getView());
tab.setText(dailyDate);
tab.setUserData(view.getRealPresenter());
tpDailySections.getTabs().add(0, tab);
tpDailySections.getSelectionModel().select(tab);
LoggerFacade.INSTANCE.trace(this.getClass(), "TODO User can filter how to order the tabs"); // NOI18N
}
private void onActionOpenProjectInDailySection(ProjectModel model) {
LoggerFacade.INSTANCE.debug(this.getClass(), "On action open Project in DailySection"); // NOI18N
// Check if no DailySection is open
if (tpDailySections.getTabs().isEmpty()) {
final DailySectionModel dailySectionModel = DialogProvider.showDailySectionChooserDialog();
if (dailySectionModel != null) {
this.onActionOpenDailySection(dailySectionModel);
this.onActionOpenProjectInDailySection(model);
}
return;
}
// Add the ProjectModel to the selected DailySection
final Tab selectedTab = tpDailySections.getSelectionModel().getSelectedItem();
final DailySectionContentPresenter presenter = (DailySectionContentPresenter) selectedTab.getUserData();
presenter.addProjectToDailySection(model);
}
public void onActionShowNewDailySectionDialog() {
LoggerFacade.INSTANCE.debug(this.getClass(), "On action show new DailySection dialog"); // NOI18N
ActionFacade.INSTANCE.handle(ON_ACTION__SHOW_NEW_DAILY_SECTION_DIALOG);
}
@Override
public void registerActions() {
LoggerFacade.INSTANCE.debug(this.getClass(), "Register actions in DailySectionsOverviewPresenter"); // NOI18N
this.registerOnActionCreateNewDailySection();
this.registerOnActionOpenDailySection();
this.registerOnActionOpenProjectInDailySection();
this.registerOnActionUpdateDailySections();
}
private void registerOnActionCreateNewDailySection() {
LoggerFacade.INSTANCE.debug(this.getClass(), "Register on action create new DailySection"); // NOI18N
ActionFacade.INSTANCE.register(
ON_ACTION__CREATE_NEW_DAILY_SECTION,
(ActionEvent event) -> {
LoggerFacade.INSTANCE.debug(this.getClass(), "On action create new DailySections"); // NOI18N
/*
TODO
- get transferdata
- listview
- database
*/
}
);
}
private void registerOnActionOpenDailySection() {
LoggerFacade.INSTANCE.debug(this.getClass(), "Register on action open DailySection"); // NOI18N
ActionFacade.INSTANCE.register(
ON_ACTION__OPEN_DAILY_SECTION,
(ActionEvent event) -> {
LoggerFacade.INSTANCE.debug(this.getClass(), "On action open DailySections"); // NOI18N
final TransferData transferData = (TransferData) event.getSource();
final DailySectionModel model = (DailySectionModel) transferData.getObject();
this.onActionOpenDailySection(model);
}
);
}
private void registerOnActionOpenProjectInDailySection() {
LoggerFacade.INSTANCE.debug(this.getClass(), "Register on action open Project in DailySection"); // NOI18N
ActionFacade.INSTANCE.register(
ON_ACTION__OPEN_PROJECT_IN_DAILY_SECTION,
(ActionEvent event) -> {
LoggerFacade.INSTANCE.debug(this.getClass(), "On action open Project in DailySection"); // NOI18N
final TransferData transferData = (TransferData) event.getSource();
final ProjectModel model = (ProjectModel) transferData.getObject();
this.onActionOpenProjectInDailySection(model);
}
);
}
private void registerOnActionUpdateDailySections() {
// LoggerFacade.INSTANCE.debug(this.getClass(), "Register on action update DailySections"); // NOI18N
//
// ActionFacade.INSTANCE.register(
// ON_ACTION__UPDATE_DAILY_SECTIONS,
// (ActionEvent event) -> {
// LoggerFacade.INSTANCE.debug(this.getClass(), "On action update DailySections"); // NOI18N
//
//// this.initializeDailySectionNavigation();
// }
// );
}
}
| gpl-3.0 |
TinyGroup/tiny | framework/org.tinygroup.message/src/main/java/org/tinygroup/message/email/EmailReceiveMessage.java | 2042 | /**
* Copyright (c) 1997-2013, www.tinygroup.org (luo_guo@icloud.com).
*
* Licensed under the GPL, Version 3.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.gnu.org/licenses/gpl.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.tinygroup.message.email;
import org.tinygroup.message.Message;
import java.util.Collection;
import java.util.Date;
/**
* Created by luoguo on 2014/4/18.
*/
public class EmailReceiveMessage implements Message {
private EmailMessage message;
private Collection<EmailMessageSender> messageSenders;
private Collection<EmailMessageReceiver> messageReceivers;
private Date sendDate;
private Date receiveDate;
public Collection<EmailMessageSender> getMessageSenders() {
return messageSenders;
}
public void setMessageSenders(Collection<EmailMessageSender> messageSenders) {
this.messageSenders = messageSenders;
}
public EmailMessage getMessage() {
return message;
}
public void setMessage(EmailMessage message) {
this.message = message;
}
public Collection<EmailMessageReceiver> getMessageReceivers() {
return messageReceivers;
}
public void setMessageReceivers(Collection<EmailMessageReceiver> messageReceivers) {
this.messageReceivers = messageReceivers;
}
public Date getSendDate() {
return sendDate;
}
public void setSendDate(Date sendDate) {
this.sendDate = sendDate;
}
public Date getReceiveDate() {
return receiveDate;
}
public void setReceiveDate(Date receiveDate) {
this.receiveDate = receiveDate;
}
}
| gpl-3.0 |
ChrisCummins/open-microlabs | src/ac/openmicrolabs/test/model/DatamaskTest.java | 1669 | /* Chris Cummins - 18 Apr 2012
*
* This file is part of Open MicroLabs.
*
* Open MicroLabs 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.
*
* Open MicroLabs 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 Open MicroLabs. If not, see <http://www.gnu.org/licenses/>.
*/
package ac.openmicrolabs.test.model;
import com.jcummins.text.DividerGenerator;
import ac.openmicrolabs.model.com.Datamask;
import ac.openmicrolabs.test.OMLTestSettings;
/**
* This class tests the functionality of the Datamask class.
*
* @author Chris Cummins
*
*/
public abstract class DatamaskTest {
private static final String TITLE = "Datamask test";
/**
* Runs the Datamask test.
*
* @param args
* None.
*/
public static void main(final String[] args) {
final Datamask d = new Datamask(OMLTestSettings.SIGNAL);
final String asciiChar = new String(d.asciiChar());
System.out
.print(TITLE + "\n" + DividerGenerator.genDivider(TITLE, '='));
System.out.println("Data request size: " + asciiChar.length());
System.out.println("Character array: " + asciiChar);
System.out.println("Binary string: " + d.binaryCode());
}
}
| gpl-3.0 |
jimdowling/gvod | simulators/src/main/java/se/sics/gvod/simulator/vod/VodSimulatorInit.java | 2797 | /**
* This file is part of the Kompics P2P Framework.
*
* Copyright (C) 2009 Swedish Institute of Computer Science (SICS)
* Copyright (C) 2009 Royal Institute of Technology (KTH)
*
* Kompics 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package se.sics.gvod.simulator.vod;
import se.sics.gvod.system.vod.VodConfiguration;
import se.sics.gvod.config.BootstrapConfiguration;
import se.sics.kompics.Init;
import se.sics.gvod.config.CroupierConfiguration;
import se.sics.gvod.config.GradientConfiguration;
import se.sics.gvod.web.server.VodMonitorConfiguration;
/**
*
* @author gautier
*/
public final class VodSimulatorInit extends Init {
private final BootstrapConfiguration bootstrapConfiguration;
private final VodMonitorConfiguration monitorConfiguration;
private final CroupierConfiguration croupierConfiguration;
private final GradientConfiguration gradientConfiguration;
private final VodConfiguration gvodConfiguration;
// private final Address peer0Address;
public VodSimulatorInit(BootstrapConfiguration bootstrapConfiguration,
VodMonitorConfiguration monitorConfiguration,
CroupierConfiguration croupierConfiguration,
GradientConfiguration gradientConfiguration,
VodConfiguration gvodConfiguration) {
super();
this.bootstrapConfiguration = bootstrapConfiguration;
this.monitorConfiguration = monitorConfiguration;
this.croupierConfiguration = croupierConfiguration;
this.gradientConfiguration = gradientConfiguration;
this.gvodConfiguration = gvodConfiguration;
}
public BootstrapConfiguration getBootstrapConfiguration() {
return bootstrapConfiguration;
}
public VodMonitorConfiguration getMonitorConfiguration() {
return monitorConfiguration;
}
public VodConfiguration getGVodConfiguration() {
return gvodConfiguration;
}
public CroupierConfiguration getCroupierConfiguration() {
return croupierConfiguration;
}
public GradientConfiguration getGradientConfiguration() {
return gradientConfiguration;
}
} | gpl-3.0 |
1973Blunt/VisualSocialNetwork | webapp/src/main/java/com/relation/algorithm/clustering/Clustering.java | 5050 | /**
* Clustering
*
* @author Ludo Waltman
* @author Nees Jan van Eck
* @version 1.3.1 11/17/14
*/
package com.relation.algorithm.clustering;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
public class Clustering implements Cloneable, Serializable
{
private static final long serialVersionUID = 1;
protected int nNodes;
protected int nClusters;
protected int[] cluster;
public static Clustering load(String fileName) throws ClassNotFoundException, IOException
{
Clustering clustering;
ObjectInputStream objectInputStream;
objectInputStream = new ObjectInputStream(new FileInputStream(fileName));
clustering = (Clustering)objectInputStream.readObject();
objectInputStream.close();
return clustering;
}
public Clustering(int nNodes)
{
this.nNodes = nNodes;
cluster = new int[nNodes];
nClusters = 1;
}
public Clustering(int[] cluster)
{
nNodes = cluster.length;
this.cluster = (int[])cluster.clone();
nClusters = Arrays2.calcMaximum(cluster) + 1;
}
public Object clone()
{
Clustering clonedClustering;
try
{
clonedClustering = (Clustering)super.clone();
clonedClustering.cluster = getClusters();
return clonedClustering;
}
catch (CloneNotSupportedException e)
{
return null;
}
}
public void save(String fileName) throws IOException
{
ObjectOutputStream objectOutputStream;
objectOutputStream = new ObjectOutputStream(new FileOutputStream(fileName));
objectOutputStream.writeObject(this);
objectOutputStream.close();
}
public int getNNodes()
{
return nNodes;
}
public int getNClusters()
{
return nClusters;
}
public int[] getClusters()
{
return (int[])cluster.clone();
}
public int getCluster(int node)
{
return cluster[node];
}
public int[] getNNodesPerCluster()
{
int i;
int[] nNodesPerCluster;
nNodesPerCluster = new int[nClusters];
for (i = 0; i < nNodes; i++)
nNodesPerCluster[cluster[i]]++;
return nNodesPerCluster;
}
public int[][] getNodesPerCluster()
{
int i;
int[] nNodesPerCluster;
int[][] nodePerCluster;
nodePerCluster = new int[nClusters][];
nNodesPerCluster = getNNodesPerCluster();
for (i = 0; i < nClusters; i++)
{
nodePerCluster[i] = new int[nNodesPerCluster[i]];
nNodesPerCluster[i] = 0;
}
for (i = 0; i < nNodes; i++)
{
nodePerCluster[cluster[i]][nNodesPerCluster[cluster[i]]] = i;
nNodesPerCluster[cluster[i]]++;
}
return nodePerCluster;
}
public void setCluster(int node, int cluster)
{
this.cluster[node] = cluster;
nClusters = Math.max(nClusters, cluster + 1);
}
public void initSingletonClusters()
{
int i;
for (i = 0; i < nNodes; i++)
cluster[i] = i;
nClusters = nNodes;
}
public void orderClustersByNNodes()
{
class ClusterNNodes implements Comparable<ClusterNNodes>
{
public int cluster;
public int nNodes;
public ClusterNNodes(int cluster, int nNodes)
{
this.cluster = cluster;
this.nNodes = nNodes;
}
public int compareTo(ClusterNNodes clusterNNodes)
{
return (clusterNNodes.nNodes > nNodes) ? 1 : ((clusterNNodes.nNodes < nNodes) ? -1 : 0);
}
}
ClusterNNodes[] clusterNNodes;
int i;
int[] newCluster, nNodesPerCluster;
nNodesPerCluster = getNNodesPerCluster();
clusterNNodes = new ClusterNNodes[nClusters];
for (i = 0; i < nClusters; i++)
clusterNNodes[i] = new ClusterNNodes(i, nNodesPerCluster[i]);
Arrays.sort(clusterNNodes);
newCluster = new int[nClusters];
i = 0;
do
{
newCluster[clusterNNodes[i].cluster] = i;
i++;
}
while ((i < nClusters) && (clusterNNodes[i].nNodes > 0));
nClusters = i;
for (i = 0; i < nNodes; i++)
cluster[i] = newCluster[cluster[i]];
}
public void mergeClusters(Clustering clustering)
{
int i;
for (i = 0; i < nNodes; i++)
cluster[i] = clustering.cluster[cluster[i]];
nClusters = clustering.nClusters;
}
}
| gpl-3.0 |
Fxe/biosynth-framework | biosynth-integration/src/main/java/pt/uminho/sysbio/biosynthframework/integration/function/Neo4jExtFunction.java | 1525 | package pt.uminho.sysbio.biosynthframework.integration.function;
import java.util.function.BiFunction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetaboliteMajorLabel;
import pt.uminho.sysbio.biosynth.integration.neo4j.BiodbMetaboliteNode;
import pt.uminho.sysbio.biosynthframework.BiodbGraphDatabaseService;
public class Neo4jExtFunction implements BiFunction<Long, Long, Double> {
private static Logger logger = LoggerFactory.getLogger(Neo4jExtFunction.class);
private final BiodbGraphDatabaseService graphDataService;
public Neo4jExtFunction(GraphDatabaseService graphDataService) {
this.graphDataService = new BiodbGraphDatabaseService(graphDataService);
}
@Override
public Double apply(Long t, Long u) {
BiodbMetaboliteNode a = graphDataService.getMetabolite(t); //new BiodbMetaboliteNode(graphDataService.getNodeById(t));
BiodbMetaboliteNode b = graphDataService.getMetabolite(u); //new BiodbMetaboliteNode(graphDataService.getNodeById(u));
if (a.hasLabel(MetaboliteMajorLabel.BiGG) && b.hasLabel(MetaboliteMajorLabel.BiGGMetabolite) ||
a.hasLabel(MetaboliteMajorLabel.BiGGMetabolite) && b.hasLabel(MetaboliteMajorLabel.BiGG)) {
logger.debug("A: {}@{}, B: {}@[}", a.getEntry(), a.getDatabase(), b.getEntry(), b.getDatabase());
if (a.getEntry().equals(b.getEntry())) {
return 0.5;
}
}
return 0.0;
}
}
| gpl-3.0 |
fraunhoferfokus/fokus-upnp | upnp-gateways/src/main/java/de/fraunhofer/fokus/util/xbee/IXBeeEventListener.java | 1870 | /**
*
* Copyright (C) 2004-2008 FhG Fokus
*
* This file is part of the FhG Fokus UPnP stack - an open source UPnP implementation
* with some additional features
*
* You can redistribute the FhG Fokus UPnP stack and/or modify it
* under the terms of the GNU General Public License Version 3 as published by
* the Free Software Foundation.
*
* For a license to use the FhG Fokus UPnP stack software under conditions
* other than those described here, or to purchase support for this
* software, please contact Fraunhofer FOKUS by e-mail at the following
* addresses:
* upnpstack@fokus.fraunhofer.de
*
* The FhG Fokus UPnP stack 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/>
* or write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package de.fraunhofer.fokus.util.xbee;
import de.fraunhofer.fokus.upnp.util.network.listener.INetworkStatus;
/**
* This interface must be implemented by classes which wants to get informed about XBee events.
*
* @author Alexander Koenig
*
*
*/
public interface IXBeeEventListener
{
/** Event that the local address has been retrieved */
public void xbeeLocalAddressRetrieved(INetworkStatus sender);
/** Event that an AT command was answered */
public void xbeeATCommandResponseReceived(int frameID, String command, int status, byte[] value);
/** Event that a TX response was sent */
public void xbeeTXStatusReceived(int frameID, int status);
/** Event that a modem status was sent */
public void xbeeModemStatusReceived(int status);
}
| gpl-3.0 |
flankerhqd/JAADAS | soot/src/soot/JimpleBodyPack.java | 3200 | /* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Ondrej Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the Sable Research Group and others 1997-1999.
* See the 'credits' file distributed with Soot for the complete list of
* contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
*/
package soot;
import soot.options.*;
import soot.jimple.*;
import java.util.*;
import soot.options.JBOptions;
/** A wrapper object for a pack of optimizations.
* Provides chain-like operations, except that the key is the phase name.
* This is a specific one for the very messy jb phase. */
public class JimpleBodyPack extends BodyPack
{
public JimpleBodyPack() {
super("jb");
}
/** Applies the transformations corresponding to the given options. */
private void applyPhaseOptions(JimpleBody b, Map<String,String> opts)
{
JBOptions options = new JBOptions( opts );
if(options.use_original_names())
PhaseOptions.v().setPhaseOptionIfUnset( "jb.lns", "only-stack-locals");
if(Options.v().time()) Timers.v().splitTimer.start();
PackManager.v().getTransform( "jb.tt" ).apply( b );
PackManager.v().getTransform( "jb.ls" ).apply( b );
if(Options.v().time()) Timers.v().splitTimer.end();
PackManager.v().getTransform( "jb.a" ).apply( b );
PackManager.v().getTransform( "jb.ule" ).apply( b );
if(Options.v().time()) Timers.v().assignTimer.start();
PackManager.v().getTransform( "jb.tr" ).apply( b );
if(Options.v().time()) Timers.v().assignTimer.end();
if(options.use_original_names())
{
PackManager.v().getTransform( "jb.ulp" ).apply( b );
}
PackManager.v().getTransform( "jb.lns" ).apply( b );
PackManager.v().getTransform( "jb.cp" ).apply( b );
PackManager.v().getTransform( "jb.dae" ).apply( b );
PackManager.v().getTransform( "jb.cp-ule" ).apply( b );
PackManager.v().getTransform( "jb.lp" ).apply( b );
PackManager.v().getTransform( "jb.ne" ).apply( b );
PackManager.v().getTransform( "jb.uce" ).apply( b );
if(Options.v().time())
Timers.v().stmtCount += b.getUnits().size();
}
protected void internalApply(Body b)
{
applyPhaseOptions( (JimpleBody) b,
PhaseOptions.v().getPhaseOptions( getPhaseName() ) );
}
}
| gpl-3.0 |
fbk/fcw | fcw-linking/src/main/java/eu/fbk/dkm/pikes/twm/MachineLinking.java | 5912 | package eu.fbk.dkm.pikes.twm;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import eu.fbk.utils.core.PropertiesUtils;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: alessio
* Date: 21/07/14
* Time: 17:15
* To change this template use File | Settings | File Templates.
*/
public class MachineLinking extends Linking {
public static final double ML_CONFIDENCE = 0.5;
private static String LABEL = "ml-annotate";
private Double minWeight;
private String lang;
public MachineLinking(Properties properties) {
super(properties, properties.getProperty("address"));
minWeight = PropertiesUtils.getDouble(properties.getProperty("min_confidence"), ML_CONFIDENCE);
lang = properties.getProperty("lang", null);
}
public String lang(String text) throws IOException {
// todo: this is really bad!
String address = urlAddress.replace("annotate", "lang");
Map<String, String> pars;
pars = new HashMap<>();
pars.put("include_text", "0");
pars.put("app_id", "0");
pars.put("app_key", "0");
pars.put("text", text);
LOGGER.debug("Text length: {}", text.length());
LOGGER.debug("Pars: {}", pars);
Map<String, Object> userData;
String output = request(pars, address);
ObjectMapper mapper = new ObjectMapper();
userData = mapper.readValue(output, Map.class);
LinkedHashMap annotation = (LinkedHashMap) userData.get(new String("annotation"));
if (annotation != null) {
String lang = annotation.get("lang").toString();
return lang;
}
return null;
}
@Override
public List<LinkingTag> tag(String text) throws Exception {
ArrayList<LinkingTag> ret = new ArrayList<>();
Map<String, String> pars;
pars = new HashMap<>();
pars.put("min_weight", minWeight.toString());
pars.put("disambiguation", "1");
pars.put("topic", "1");
pars.put("include_text", "0");
pars.put("image", "1");
pars.put("class", "1");
pars.put("app_id", "0");
pars.put("app_key", "0");
pars.put("text", text);
if (lang != null) {
pars.put("lang", lang);
}
LOGGER.debug("Text length: {}", text.length());
LOGGER.debug("Pars: {}", pars);
Map<String, Object> userData;
String output = request(pars);
ObjectMapper mapper = new ObjectMapper();
userData = mapper.readValue(output, Map.class);
LinkedHashMap annotation = (LinkedHashMap) userData.get(new String("annotation"));
if (annotation != null) {
String lang = annotation.get("lang").toString();
String language = (lang == null || lang.equals("en")) ? "" : lang + ".";
ArrayList<LinkedHashMap> keywords = (ArrayList<LinkedHashMap>) annotation.get(new String("keyword"));
if (keywords != null) {
for (LinkedHashMap keyword : keywords) {
LinkedHashMap sense = (LinkedHashMap) keyword.get("sense");
ArrayList dbpClass = (ArrayList) keyword.get("class");
ArrayList<LinkedHashMap> images = (ArrayList<LinkedHashMap>) keyword.get("image");
ArrayList<LinkedHashMap> ngrams = (ArrayList<LinkedHashMap>) keyword.get("ngram");
for (LinkedHashMap ngram : ngrams) {
String originalText = (String) ngram.get("form");
LinkedHashMap span = (LinkedHashMap) ngram.get("span");
Integer start = (Integer) span.get("start");
Integer end = (Integer) span.get("end");
Double rel = Double.parseDouble(keyword.get("rel").toString());
if (rel.isNaN()) {
rel = 0d;
}
LinkingTag tag = new LinkingTag(
start,
String.format("http://" + language + "dbpedia.org/resource/%s",
(String) sense.get("page")),
rel,
originalText,
end - start,
LABEL
);
//todo: add to conf
if (images != null && images.size() > 0) {
try {
tag.setImage(images.get(0).get("image").toString());
} catch (Exception e) {
// ignored
}
}
if (extractTypes) {
tag.addTypesFromML(dbpClass);
}
ret.add(tag);
}
}
}
}
return ret;
}
public static void main(String[] args) {
Properties properties = new Properties();
properties.setProperty("address", "http://ml.apnetwork.it/annotate");
properties.setProperty("min_confidence", "0.5");
properties.setProperty("timeout", "2000");
String fileName = args[0];
MachineLinking s = new MachineLinking(properties);
try {
String text = Files.toString(new File(fileName), Charsets.UTF_8);
List<LinkingTag> tags = s.tag(text);
for (LinkingTag tag : tags) {
System.out.println(tag);
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage());
}
}
}
| gpl-3.0 |
mizangl/twitter_puller | app/src/main/java/com/mz/twitterpuller/login/LoginModule.java | 886 | package com.mz.twitterpuller.login;
import com.mz.twitterpuller.data.TwitterRepository;
import com.mz.twitterpuller.interactor.GetSessionInteractor;
import com.mz.twitterpuller.interactor.Interactor;
import com.mz.twitterpuller.util.executor.PostExecutionThread;
import com.mz.twitterpuller.util.executor.ThreadExecutor;
import dagger.Module;
import dagger.Provides;
import javax.inject.Named;
@Module public class LoginModule {
private final LoginContract.View view;
public LoginModule(LoginContract.View view) {
this.view = view;
}
@Provides @Named("session") Interactor provideSessionInteractor(ThreadExecutor threadExecutor,
PostExecutionThread postExecutionThread, TwitterRepository repository) {
return new GetSessionInteractor(threadExecutor, postExecutionThread, repository);
}
@Provides LoginContract.View provideView() {
return view;
}
}
| gpl-3.0 |
Gentleman1983/haVoxTimes | haVox_times_model_api/src/main/java/net/havox/times/model/api/package-info.java | 805 | /*
* Copyright (C) 2017 [haVox] Design
*
* 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/>.
*/
/**
* This package specifies API utility classes.
*/
package net.havox.times.model.api;
| gpl-3.0 |
Dynious/RefinedRelocation | src/main/java/com/dynious/refinedrelocation/network/packet/filter/MessageSetFilterBlacklist.java | 2031 | package com.dynious.refinedrelocation.network.packet.filter;
import com.dynious.refinedrelocation.api.filter.IFilterGUI;
import com.dynious.refinedrelocation.container.IContainerFiltered;
import com.dynious.refinedrelocation.network.NetworkHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.Container;
public class MessageSetFilterBlacklist implements IMessage, IMessageHandler<MessageSetFilterBlacklist, IMessage>
{
private int filterIndex;
private boolean blacklist;
public MessageSetFilterBlacklist()
{
}
public MessageSetFilterBlacklist(int filterIndex, boolean blacklist)
{
this.filterIndex = filterIndex;
this.blacklist = blacklist;
}
@Override
public void fromBytes(ByteBuf buf)
{
filterIndex = buf.readByte();
blacklist = buf.readBoolean();
}
@Override
public void toBytes(ByteBuf buf)
{
buf.writeByte(filterIndex);
buf.writeBoolean(blacklist);
}
@Override
public IMessage onMessage(MessageSetFilterBlacklist message, MessageContext ctx)
{
Container container = null;
if (ctx.side == Side.CLIENT)
{
container = NetworkHandler.getClientPlayerEntity().openContainer;
} else if (ctx.side == Side.SERVER)
{
container = ctx.getServerHandler().playerEntity.openContainer;
}
if (container == null || !(container instanceof IContainerFiltered))
{
return null;
}
IFilterGUI filter = ((IContainerFiltered) container).getFilter();
if(message.filterIndex >= 0 && message.filterIndex < filter.getFilterCount()) {
filter.getFilterAtIndex(message.filterIndex).setBlacklist(message.blacklist);
}
return null;
}
}
| gpl-3.0 |
thepes/spaceexplorers | app/src/main/java/org/copains/spaceexplorer/tactical/events/LifeFormBlock.java | 520 | package org.copains.spaceexplorer.tactical.events;
import org.copains.spaceexplorer.game.lifeforms.LifeForm;
public class LifeFormBlock extends EventBlock {
private LifeForm lifeForm;
public LifeFormBlock(int startX, int startY, int endX, int endY) {
super(startX, startY, endX, endY);
}
/**
* @return the lifeForm
*/
public LifeForm getLifeForm() {
return lifeForm;
}
/**
* @param lifeForm the lifeForm to set
*/
public void setLifeForm(LifeForm lifeForm) {
this.lifeForm = lifeForm;
}
}
| gpl-3.0 |
Somae/mdsd-factory-project | factory/de.mdelab.languages.factory/src/productionschema/LinkableNode.java | 2348 | /**
*/
package productionschema;
import org.eclipse.emf.common.util.EList;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Linkable Node</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link productionschema.LinkableNode#getIncomingLinks <em>Incoming Links</em>}</li>
* <li>{@link productionschema.LinkableNode#getOutgoingLinks <em>Outgoing Links</em>}</li>
* </ul>
*
* @see productionschema.ProductionschemaPackage#getLinkableNode()
* @model abstract="true"
* @generated
*/
public interface LinkableNode extends IdentifiableElement {
/**
* Returns the value of the '<em><b>Incoming Links</b></em>' reference list.
* The list contents are of type {@link productionschema.Link}.
* It is bidirectional and its opposite is '{@link productionschema.Link#getDestinationNode <em>Destination Node</em>}'.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Incoming Links</em>' reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Incoming Links</em>' reference list.
* @see productionschema.ProductionschemaPackage#getLinkableNode_IncomingLinks()
* @see productionschema.Link#getDestinationNode
* @model opposite="destinationNode"
* @generated
*/
EList<Link> getIncomingLinks();
/**
* Returns the value of the '<em><b>Outgoing Links</b></em>' reference list.
* The list contents are of type {@link productionschema.Link}.
* It is bidirectional and its opposite is '{@link productionschema.Link#getSourceNode <em>Source Node</em>}'.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Outgoing Links</em>' reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Outgoing Links</em>' reference list.
* @see productionschema.ProductionschemaPackage#getLinkableNode_OutgoingLinks()
* @see productionschema.Link#getSourceNode
* @model opposite="sourceNode"
* @generated
*/
EList<Link> getOutgoingLinks();
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model required="true"
* @generated
*/
int degree(boolean isInDegree, boolean isOutDegree);
} // LinkableNode
| gpl-3.0 |
NetHome/ProtocolAnalyzer | src/main/java/nu/nethome/tools/protocol_analyzer/MainWindow.java | 43725 | /**
* Copyright (C) 2005-2013, Stefan Strömberg <stefangs@nethome.nu>
*
* This file is part of OpenNetHome (http://www.nethome.nu).
*
* OpenNetHome 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.
*
* OpenNetHome 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 nu.nethome.tools.protocol_analyzer;
import nu.nethome.util.ps.FieldValue;
import nu.nethome.util.ps.ProtocolDecoderSink;
import nu.nethome.util.ps.ProtocolMessage;
import nu.nethome.util.ps.RawProtocolMessage;
import nu.nethome.util.ps.impl.AudioProtocolPort.Channel;
import nu.nethome.util.ps.impl.AudioPulsePlayer;
import nu.nethome.util.ps.impl.PulseProtocolPort;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import java.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.prefs.Preferences;
/**
* @author Stefan
*
* This is the main window of the sampler application.
*/
public class MainWindow implements ProtocolDecoderSink {
protected class ProtocolWindowMessage implements Runnable {
public final ProtocolMessage m_Message;
public ProtocolWindowMessage(ProtocolMessage message) {
m_Message = message;
}
public void run() {
addTableRow(m_Message);
}
}
protected class RawProtocolWindowMessage implements Runnable {
public final RawProtocolMessage message;
public RawProtocolWindowMessage(RawProtocolMessage message) {
this.message = message;
}
public void run() {
addRawTableRow(message);
}
}
protected class LevelWindowMessage implements Runnable {
int m_Level;
MainWindow m_Window;
public LevelWindowMessage(MainWindow window, int level) {
m_Level = level;
m_Window = window;
}
public void run() {
m_Window.displayLevel(m_Level);
}
}
/**
* Implements the Level Meter LED Bar which displays the signal level
* @author Stefan
*/
protected class LevelMeter {
protected Canvas m_Canvas;
protected Color black;
protected Color grey;
protected Color green;
protected Color yellow;
protected GC m_Gc;
protected int m_LastLevel = 0;
public LevelMeter(Composite shell, GridData gridData) {
m_LevelCanvas = new Canvas(shell, SWT.BORDER);
m_LevelCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setBackground(black);
e.gc.setForeground(yellow);
// Fill with black background
e.gc.fillRectangle(0, 0, LEVELWIDTH, LEVELHEIGHT);
// Draw the "bar"
for (int i = 0; i < 25; i++) {
if (i == m_LastLevel) {
e.gc.setForeground(grey);
} else if ((i >= 17) && (i < m_LastLevel)) {
m_Gc.setForeground(green);
}
e.gc.drawRectangle(i * 4, 1, 1, LEVELHEIGHT - 3);
}
}
});
m_Gc = new GC(m_LevelCanvas);
m_LevelCanvas.setLayoutData(gridData);
black = m_Display.getSystemColor(SWT.COLOR_BLACK);
grey = m_Display.getSystemColor(SWT.COLOR_DARK_GRAY);
green = m_Display.getSystemColor(SWT.COLOR_GREEN);
yellow = m_Display.getSystemColor(SWT.COLOR_YELLOW);
}
public void drawLevel(int level) {
if (level > m_LastLevel) {
// If level has risen, draw colored bars up to new level
for (int i = m_LastLevel; i < level; i++) {
if (i < 17) {
m_Gc.setForeground(yellow);
} else {
m_Gc.setForeground(green);
}
m_Gc.drawRectangle(i * 4, 1, 1, LEVELHEIGHT - 3);
}
} else if (level < m_LastLevel) {
// If the level has decreased, draw grey bars down to new level
m_Gc.setForeground(grey);
for (int i = level; i < m_LastLevel; i++) {
m_Gc.drawRectangle(i * 4, 1, 1, LEVELHEIGHT - 3);
}
}
m_LastLevel = level;
}
}
protected static final int LEVELWIDTH = 100;
protected static final int LEVELHEIGHT = 10;
protected static final int NO_COLUMNS = 6;
protected static final String extensions[] = { "*.jir" }; //$NON-NLS-1$
protected static final int UPDATE_INTERVAL = 500;
protected Shell m_Shell;
protected Display m_Display;
protected Table m_Table;
protected MenuItem m_SampleRawMenuItem;
protected Main m_Model;
protected String m_FileName = "Data.jir"; //$NON-NLS-1$
protected Label m_StatusText;
protected Canvas m_LevelCanvas;
protected LevelMeter m_LevelMeter;
protected boolean m_ShowRaw = true;
AudioPulsePlayer player = new AudioPulsePlayer();
private ToolItem m_StopScanningButton;
private ToolItem m_StartScanningButton;
private Label m_HWIcon;
private ToolItem m_FreeSampleButton;
/**
* Creates the Main Window and its content
*
* @param display
* The display used to open the window
* @param model
* the model this is a view of
*/
public MainWindow(Display display, Main model) {
m_Display = display;
m_Model = model;
m_ShowRaw = Preferences.userNodeForPackage(this.getClass()).getBoolean("ShowRaw", true); //$NON-NLS-1$
// player.old_start();
player.openLine();
player.setSwing(100);
// Create the main window of the application
m_Shell = new Shell(display);
m_Shell.setText(Messages.getString("MainWindow.IRSampler")); //$NON-NLS-1$
// Decorate the window with a nice icon at the top
m_Shell.setImage(getToolImage("radar16.png")); //$NON-NLS-1$
// Create the window menues
createMenus();
// Create Toolbar
createToolbar();
// Create a grid layout for the window
GridLayout shellLayout = new GridLayout();
shellLayout.numColumns = 1;
m_Shell.setLayout(shellLayout);
// Create the Table
createTable();
GridData gridData;
// Create status row.
// Create a composite for the row, and give it a column grid layout
Composite statusRowComposite = new Composite(m_Shell,
SWT.NO_RADIO_GROUP);
GridLayout statusRowLayout = new GridLayout();
statusRowLayout.numColumns = 4;
statusRowLayout.marginBottom = -6;
statusRowLayout.marginTop = -4;
statusRowComposite.setLayout(statusRowLayout);
// Create hw icon
m_HWIcon = new Label(statusRowComposite, 0);
m_HWIcon.setImage(getToolImage("microphone16.png")); //$NON-NLS-1$
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gridData.grabExcessVerticalSpace = false;
gridData.heightHint = 22;
m_HWIcon.setLayoutData(gridData);
// Create the status text with layout
m_StatusText = new Label(statusRowComposite, 0);
String statusText = Messages.getString("MainWindow.SamplingAt") //$NON-NLS-1$
+ Float.toString(m_Model.getAudioSampler().getSampleRate())
+ Messages.getString("MainWindow.Hz"); //$NON-NLS-1$
m_StatusText.setText(statusText);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gridData.grabExcessVerticalSpace = false;
gridData.widthHint = 180;
m_StatusText.setLayoutData(gridData);
// Create the Level meter with layout
Label levelText = new Label(statusRowComposite, 0);
levelText.setText(Messages.getString("MainWindow.Level")); //$NON-NLS-1$
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gridData.grabExcessVerticalSpace = false;
levelText.setLayoutData(gridData);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gridData.widthHint = LEVELWIDTH;
gridData.heightHint = LEVELHEIGHT;
gridData.grabExcessVerticalSpace = false;
m_LevelMeter = new LevelMeter(statusRowComposite, gridData);
updateWindowState(true);
// Create and start a timer to update status on button and status row
Runnable timer = new Runnable() {
public void run() {
if (!m_Shell.isDisposed()) {
updateWindowState(false);
}
m_Display.timerExec(UPDATE_INTERVAL, this);
}
};
m_Display.timerExec(UPDATE_INTERVAL, timer);
}
/**
* Creates all items located in the popup menu and associates all the menu
* items with their appropriate functions.
*
* @return Menu The created popup menu.
*/
private Menu createPopUpMenu() {
Menu popUpMenu = new Menu(m_Shell, SWT.POP_UP);
/**
* Adds a listener to handle enabling and disabling some items in the
* Edit submenu.
*/
popUpMenu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
Menu menu = (Menu) e.widget;
MenuItem[] items = menu.getItems();
int count = m_Table.getSelectionCount();
boolean isRaw = false;
RawProtocolMessage mess = null;
if (count == 1) {
ProtocolMessage message = (ProtocolMessage) m_Table.getSelection()[0].getData();
// Check that it is a raw sample
if (message.getProtocol().equals("Raw")) { //$NON-NLS-1$
isRaw = true;
mess = (RawProtocolMessage) message;
}
}
items[0].setEnabled(count != 0); // view
items[1].setEnabled(isRaw); // export pulse data
items[2].setEnabled(isRaw); // export pulse data
items[3].setEnabled(isRaw && mess.m_Samples.size() > 0); // export pulse data
}
});
// New
MenuItem item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.getString("MainWindow.ViewSampleMenu")); //$NON-NLS-1$
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
viewSample();
}
});
// new MenuItem(popUpMenu, SWT.SEPARATOR);
// Edit
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.getString("MainWindow.ExportPulseData")); //$NON-NLS-1$
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = m_Table.getSelection();
if (items.length == 0)
return;
exportPulseData();
}
});
// Re-analyze pulses
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.getString("MainWindow.ReanalyzePulseData")); //$NON-NLS-1$
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = m_Table.getSelection();
if (items.length == 0)
return;
reanalyzePulseData();
}
});
// Re-analyze samples
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(Messages.getString("MainWindow.ReanalyzeSignalData")); //$NON-NLS-1$
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = m_Table.getSelection();
if (items.length == 0)
return;
reanalyzeSampleData();
}
});
/*
// Copy
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(resAddressBook.getString("Pop_up_copy"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = table.getSelection();
if (items.length == 0)
return;
copyBuffer = new String[table.getColumnCount()];
for (int i = 0; i < copyBuffer.length; i++) {
copyBuffer[i] = items[0].getText(i);
}
}
});
// Paste
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(resAddressBook.getString("Pop_up_paste"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (copyBuffer == null)
return;
TableItem item = new TableItem(table, SWT.NONE);
item.setText(copyBuffer);
isModified = true;
}
});
// Delete
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(resAddressBook.getString("Pop_up_delete"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = table.getSelection();
if (items.length == 0)
return;
items[0].dispose();
isModified = true;
}
});
new MenuItem(popUpMenu, SWT.SEPARATOR);
// Find...
item = new MenuItem(popUpMenu, SWT.PUSH);
item.setText(resAddressBook.getString("Pop_up_find"));
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
searchDialog.open();
}
});
*/
return popUpMenu;
}
/**
* Create the table view where the Samples are presented as nodes
*/
private void createTable() {
m_Table = new Table(m_Shell, SWT.SINGLE | SWT.BORDER
| SWT.FULL_SELECTION);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
| GridData.VERTICAL_ALIGN_FILL);
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
m_Table.setLayoutData(gridData);
// Create the columns in the table
TableColumn tc1 = new TableColumn(m_Table, SWT.CENTER);
TableColumn tc2 = new TableColumn(m_Table, SWT.CENTER);
TableColumn tc3 = new TableColumn(m_Table, SWT.CENTER);
TableColumn tc4 = new TableColumn(m_Table, SWT.CENTER);
TableColumn tc5 = new TableColumn(m_Table, SWT.CENTER);
TableColumn tc6 = new TableColumn(m_Table, SWT.CENTER);
tc1.setText(Messages.getString("MainWindow.TimeStamp")); //$NON-NLS-1$
tc2.setText(Messages.getString("MainWindow.Protocol")); //$NON-NLS-1$
tc3.setText(Messages.getString("MainWindow.Command")); //$NON-NLS-1$
tc4.setText(Messages.getString("MainWindow.Address")); //$NON-NLS-1$
tc5.setText(Messages.getString("MainWindow.Data")); //$NON-NLS-1$
tc6.setText(Messages.getString("MainWindow.Repeat")); //$NON-NLS-1$
tc1.setWidth(80);
tc2.setWidth(70);
tc3.setWidth(70);
tc4.setWidth(80);
tc5.setWidth(100);
tc6.setWidth(70);
m_Table.setHeaderVisible(true);
// Add a selection listener to the table which will open the message
m_Table.addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
viewSample();
}
});
// Add keyboard handler
m_Table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
handleKeyPress(e);
}
});
m_Table.setMenu(createPopUpMenu());
}
/**
* Handle keyboard commands
* @param e the KeyEvent to process
*/
protected void handleKeyPress(KeyEvent e) {
if (e.character == SWT.DEL) {
deleteSelectedRow((e.stateMask & SWT.SHIFT) != 0);
}
}
Image getToolImage(String name) {
return new Image(m_Display, this.getClass().getClassLoader()
.getResourceAsStream("nu/nethome/tools/protocol_analyzer/" + name)); //$NON-NLS-1$
}
/**
* Create the Tool Bar with all buttons
*/
protected void createToolbar() {
// http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-156.htm
ToolBar bar = new ToolBar(m_Shell, 0 /* | SWT.BORDER */| SWT.FLAT);
bar.setSize(200, 48);
ToolItem separator = new ToolItem(bar, SWT.SEPARATOR);
separator.getData();
// Open... button
ToolItem item = new ToolItem(bar, 0);
item.setImage(getToolImage("document_chart_into24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.OpenSampledSession")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
loadData();
}
});
// Save button
item = new ToolItem(bar, 0);
item.setImage(getToolImage("document_chart_floppy_disk24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.SaveSampledSession")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
saveData();
}
});
// Save As... button
item = new ToolItem(bar, 0);
item.setImage(getToolImage("document_chart_floppy_disk_edit24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.SaveSampleAs")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
saveDataAs();
}
});
separator = new ToolItem(bar, SWT.SEPARATOR);
// Delete Selected
item = new ToolItem(bar, 0);
item.setImage(getToolImage("selection_delete24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.DeleteSelectedSample")); //$NON-NLS-1$
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteSelectedRow(false);
}
});
// Delete Selected
item = new ToolItem(bar, 0);
item.setImage(getToolImage("delete24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.DeleteAllSamples")); //$NON-NLS-1$
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteAllRows();
}
});
separator = new ToolItem(bar, SWT.SEPARATOR);
// Edit template button
item = new ToolItem(bar, 0);
item.setImage(getToolImage("edit24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.EditExportTemplate")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
ExportTemplateWindow w = new ExportTemplateWindow(m_Display,
m_Model);
w.open();
}
});
// Export button
item = new ToolItem(bar, 0);
item.setImage(getToolImage("document_out24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.ExportData")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
exportData();
}
});
// Settings Button
item = new ToolItem(bar, 0);
item.setImage(getToolImage("preferences_edit24.png")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("MainWindow.Settings")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
editSettings();
}
});
separator = new ToolItem(bar, SWT.SEPARATOR);
// Start scanning button
m_StartScanningButton = new ToolItem(bar, 0);
m_StartScanningButton.setImage(getToolImage("radar_play24.png")); //$NON-NLS-1$
m_StartScanningButton.setDisabledImage(getToolImage("radar_play_dis24.png")); //$NON-NLS-1$
m_StartScanningButton.setToolTipText(Messages.getString("MainWindow.StartScanning")); //$NON-NLS-1$
m_StartScanningButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
m_Model.startScanning();
updateWindowState(false);
}
});
// Stop scanning button
m_StopScanningButton = new ToolItem(bar, 0);
m_StopScanningButton.setDisabledImage(getToolImage("radar_stop_dis24.png")); //$NON-NLS-1$
m_StopScanningButton.setImage(getToolImage("radar_stop24.png")); //$NON-NLS-1$
m_StopScanningButton.setToolTipText(Messages.getString("MainWindow.StopScanning")); //$NON-NLS-1$
m_StopScanningButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
m_Model.stopScanning();
updateWindowState(false);
}
});
// Free sample button
m_FreeSampleButton = new ToolItem(bar, 0);
m_FreeSampleButton.setImage(getToolImage("document_chart_clock24.png")); //$NON-NLS-1$
m_FreeSampleButton.setDisabledImage(getToolImage("document_chart_clock_dis24.png")); //$NON-NLS-1$
m_FreeSampleButton.setToolTipText(Messages.getString("MainWindow.Sample2Secs")); //$NON-NLS-1$
m_FreeSampleButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
m_ShowRaw = true;
m_SampleRawMenuItem.setSelection(true);
m_Model.getRawDecoder().startFreeSampling(Math
.round(m_Model.getAudioSampler().getSampleRate()) * 2);
}
});
// //This button was added temporarily for testing signal generation
//
// item = new ToolItem (bar, 0); toolImage = new Image(m_Display,
// this.getClass().getClassLoader().getResourceAsStream("nu/nethome/tools/protocol_analyzer/showraw.png"));
// item.setImage (toolImage); item.setToolTipText("Play sound");
// item.addSelectionListener(new SelectionListener() { public void
// widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public
// void widgetSelected(SelectionEvent e) {
// X10Encoder encoder = new X10Encoder();
// encoder.setHouseCode(7);
// //encoder.setAddress('D');
// encoder.setButton(0);
// encoder.setCommand(m_Message);
// encoder.setRepeatCount(3);
// // encoder.houseCode = 0;
// // encoder.deviceCode = 1;
// // encoder.repeatCount = 6;
// //encoder.command = 0x54;
// // encoder.command = m_Message;
// player.playMessage(encoder.encode());
// //encoder.setSwing(75);
// // player.start();
// //encoder.encode(player);
// // player.stop();
// // m_Message ^= 0x40;
// m_Message ^= 0x1;
// }
// });
}
public void updateWindowState(boolean isConfigurationChange) {
boolean isScanning = m_Model.m_ProtocolPorts[m_Model.getSignalHardware()].isOpen();
m_StartScanningButton.setEnabled(!isScanning);
m_StopScanningButton.setEnabled(isScanning);
m_FreeSampleButton.setEnabled(isScanning && (m_Model.getSignalHardware() == 0));
String statusText;
if (!isScanning) {
statusText = Messages.getString("MainWindow.Stopped");
} else if (m_Model.getSignalHardware() == Main.AUDIO_SAMPLER) {
statusText = Messages.getString("MainWindow.SamplingAt") //$NON-NLS-1$
+ Float.toString(m_Model.getAudioSampler().getSampleRate())
+ Messages.getString("MainWindow.Hz"); //$NON-NLS-1$
} else {
statusText = Messages.getString("MainWindow.Scanning");
}
m_StatusText.setText(statusText);
if (isConfigurationChange) {
m_HWIcon.setImage(getToolImage(m_Model.getSignalHardware() == 0 ? "microphone16.png" : "arduino24.png" )); //$NON-NLS-1$ //$NON-NLS-2$
}
}
// protected int m_Message = 0x54;
// protected int m_Message = 0x1;
protected void createMenus() {
// Create the menue bar
Menu menuBar, fileMenu, viewMenu, helpMenu;
MenuItem fileMenuHeader, viewMenuHeader, helpMenuHeader;
MenuItem separatorItem, fileTemplateItem, fileExportItem, fileExitItem, fileLoadItem, fileSaveItem, fileSaveAsItem, helpGetHelpItem, decodersItem, settingsItem;
menuBar = new Menu(m_Shell, SWT.BAR);
// Create File menu
fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
fileMenuHeader.setText(Messages.getString("MainWindow.FileMenu")); //$NON-NLS-1$
fileMenu = new Menu(m_Shell, SWT.DROP_DOWN);
fileMenuHeader.setMenu(fileMenu);
// Open menu Item
fileLoadItem = new MenuItem(fileMenu, SWT.PUSH);
fileLoadItem.setText(Messages.getString("MainWindow.OpenMenu")); //$NON-NLS-1$
fileLoadItem.setAccelerator(SWT.CTRL + 'O');
fileLoadItem.setImage(getToolImage("open.png")); //$NON-NLS-1$
fileLoadItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
loadData();
}
});
// Save menu Item
fileSaveItem = new MenuItem(fileMenu, SWT.PUSH);
fileSaveItem.setText(Messages.getString("MainWindow.SaveMenu")); //$NON-NLS-1$
fileLoadItem.setAccelerator(SWT.CTRL + 'S');
fileSaveItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
saveData();
}
});
// Save As... menu Item
fileSaveAsItem = new MenuItem(fileMenu, SWT.PUSH);
fileSaveAsItem.setText(Messages.getString("MainWindow.SaveAsMenu")); //$NON-NLS-1$
fileSaveAsItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
saveDataAs();
}
});
separatorItem = new MenuItem(fileMenu, SWT.SEPARATOR);
separatorItem.getSelection(); // Just to avoid Eclipse Warning
// Export Template... menu Item
fileTemplateItem = new MenuItem(fileMenu, SWT.PUSH);
fileTemplateItem.setText(Messages.getString("MainWindow.EditExportTemplateMenu")); //$NON-NLS-1$
fileTemplateItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
ExportTemplateWindow w = new ExportTemplateWindow(m_Display,
m_Model);
w.open();
}
});
// Export menu Item
fileExportItem = new MenuItem(fileMenu, SWT.PUSH);
fileExportItem.setText(Messages.getString("MainWindow.ExportDataMenu")); //$NON-NLS-1$
fileExportItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
exportData();
}
});
separatorItem = new MenuItem(fileMenu, SWT.SEPARATOR);
// Exit menu Item
fileExitItem = new MenuItem(fileMenu, SWT.PUSH);
fileExitItem.setText(Messages.getString("MainWindow.ExitMenu")); //$NON-NLS-1$
fileExitItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
m_Shell.close(); // calls dispose() - see note below
}
});
// Create View menu
viewMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
viewMenuHeader.setText(Messages.getString("MainWindow.ViewMenu")); //$NON-NLS-1$
viewMenu = new Menu(m_Shell, SWT.DROP_DOWN);
viewMenuHeader.setMenu(viewMenu);
// Show Raw menu Item
m_SampleRawMenuItem = new MenuItem(viewMenu, SWT.CHECK);
m_SampleRawMenuItem.setText(Messages.getString("MainWindow.RawMenu")); //$NON-NLS-1$
m_SampleRawMenuItem.setAccelerator(SWT.CTRL + 'R');
m_SampleRawMenuItem.setSelection(m_ShowRaw);
m_SampleRawMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
MenuItem m = (MenuItem) e.widget;
m_ShowRaw = m.getSelection();
Preferences.userNodeForPackage(this.getClass()).putBoolean("ShowRaw", m_ShowRaw); //$NON-NLS-1$
}
});
// Decoders... menu Item
decodersItem = new MenuItem(viewMenu, SWT.PUSH);
decodersItem.setText(Messages.getString("MainWindow.DecordersMenu")); //$NON-NLS-1$
decodersItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
DecoderWindow win = new DecoderWindow(m_Display, m_Model);
win.open();
}
});
// Settings... menu Item
settingsItem = new MenuItem(viewMenu, SWT.PUSH);
settingsItem.setText(Messages.getString("MainWindow.Settingsxxx")); //$NON-NLS-1$
settingsItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
editSettings();
}
});
separatorItem = new MenuItem(viewMenu, SWT.SEPARATOR);
// Sample... menu Item
fileTemplateItem = new MenuItem(viewMenu, SWT.PUSH);
fileTemplateItem.setText(Messages.getString("MainWindow.SampleMenu")); //$NON-NLS-1$
fileTemplateItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
viewSample();
}
});
// Create Action menu
MenuItem actionMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
actionMenuHeader.setText(Messages.getString("MainWindow.ActionMenu")); //$NON-NLS-1$
Menu actionMenu = new Menu(m_Shell, SWT.DROP_DOWN);
actionMenuHeader.setMenu(actionMenu);
// Add sample choices
MenuItem sample2MenuItem = new MenuItem(actionMenu, SWT.PUSH);
sample2MenuItem.setText(Messages.getString("MainWindow.Sample2SecsMenu")); //$NON-NLS-1$
sample2MenuItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
m_ShowRaw = true;
m_SampleRawMenuItem.setSelection(true);
m_Model.getRawDecoder().startFreeSampling(Math
.round(m_Model.getAudioSampler().getSampleRate()) * 2);
}
});
// Add sample choices
MenuItem sample5MenuItem = new MenuItem(actionMenu, SWT.PUSH);
sample5MenuItem.setText(Messages.getString("MainWindow.Sample5SecsMenu")); //$NON-NLS-1$
sample5MenuItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
m_ShowRaw = true;
m_SampleRawMenuItem.setSelection(true);
m_Model.getRawDecoder().startFreeSampling(Math
.round(m_Model.getAudioSampler().getSampleRate()) * 5);
}
});
// Create Help Menu
helpMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
helpMenuHeader.setText(Messages.getString("MainWindow.HelpMenu")); //$NON-NLS-1$
helpMenu = new Menu(m_Shell, SWT.DROP_DOWN);
helpMenuHeader.setMenu(helpMenu);
// About Menu Item
helpGetHelpItem = new MenuItem(helpMenu, SWT.PUSH);
helpGetHelpItem.setText(Messages.getString("MainWindow.AboutMenu")); //$NON-NLS-1$
helpGetHelpItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
AboutWindow win = new AboutWindow(new Shell(m_Display), SWT.NULL);
win.open();
}
});
m_Shell.setMenuBar(menuBar);
}
public void parsedMessage(ProtocolMessage message) {
// Because all window operations has to be done in the Window thread,
// we have to leave this for later execusion. The IrWindowMEssage class
// run-method will call the addTableRow method.
Display.getDefault().asyncExec(new ProtocolWindowMessage(message));
}
public void parsedRawMessage(RawProtocolMessage message) {
// Because all window operations has to be done in the Window thread,
// we have to leave this for later execusion. The IrWindowMessage class
// run-method will call the addTableRow method.
if (m_ShowRaw) {
Display.getDefault().asyncExec(new RawProtocolWindowMessage(message));
}
}
protected void addTableRow(ProtocolMessage message) {
if (message.getRepeat() > 0) {
// Ok, this is a repeated message, find the original message row
for (int i = m_Table.getItemCount() - 1; i >= 0; i--) {
TableItem item = m_Table.getItem(i);
if (item.getText(1).compareTo(message.getProtocol()) == 0) {
// Update it with the new repeat count
item.setText(5, Integer.toString(message.getRepeat()));
break;
}
}
} else {
// Create a new table row
TableItem item1 = new TableItem(m_Table, SWT.NONE);
String text[] = new String[NO_COLUMNS];
DateFormat df = new SimpleDateFormat(Messages.getString("MainWindow.HHmmssSSS")); //$NON-NLS-1$
Date now = new Date();
text[0] = df.format(now);
text[1] = message.getProtocol();
text[2] = Integer.toHexString(message.getCommand());
text[3] = Integer.toHexString(message.getAddress());
text[4] = ""; //$NON-NLS-1$
for (int i = 0; i < message.getRawMessage().length; i++) {
text[4] += String.format("%02X ", message.getRawMessage()[i]); //$NON-NLS-1$
}
text[5] = Integer.toString(message.getRepeat());
item1.setText(text);
item1.setData(message);
}
}
protected void addRawTableRow(RawProtocolMessage message) {
TableItem item1 = new TableItem(m_Table, SWT.NONE);
String text[] = new String[NO_COLUMNS];
DateFormat df = new SimpleDateFormat(Messages.getString("MainWindow.HHmmssSSS")); //$NON-NLS-1$
Date now = new Date();
text[0] = df.format(now);
text[1] = "[Sample]";
text[2] = "-";
text[3] = "-";
double sampleLength = 0;
if (message.m_Samples.size() != 0) {
sampleLength = 1000D * message.m_Samples.size() / message.m_SampleFrequency;
} else {
for (Double pulse : message.m_PulseLengths) {
sampleLength += pulse;
}
sampleLength = sampleLength / 1000.0;
}
text[4] = String.format("%.2f ms", sampleLength);
text[5] = "-";
item1.setText(text);
item1.setData(message);
}
public void partiallyParsedMessage(String protocol, int bits) {
System.out.print("\nPartially parsed " + Integer.toString(bits) //$NON-NLS-1$
+ "bits of " + protocol); //$NON-NLS-1$
}
public void reportLevel(int level) {
// Because all window operations has to be done in the Window thread,
// we have to leave this for later execution.
Display.getDefault().asyncExec(new LevelWindowMessage(this, level));
}
public void displayLevel(int level) {
// Only draw level for Audio Sampling device
//if (m_Model.getSignalHardware() == 0) {
m_LevelMeter.drawLevel((25 * level) / 127);
//}
}
/**
* Opens the main window of the application
*/
public void open() {
// Open the panel
m_Shell.pack();
m_Shell.setSize(500, 650);
m_Shell.open();
}
public boolean isDisposed() {
return m_Shell.isDisposed();
}
public void exportData() {
int length = m_Table.getItems().length;
FileDialog save = new FileDialog(m_Shell, SWT.SAVE);
save.setText("Export Data"); //$NON-NLS-1$
// Ask for export file name
String fileName = save.open();
if (fileName == null) {
return;
}
try {
PrintWriter out = new PrintWriter(new FileWriter(fileName)); //$NON-NLS-1$
// Loop through all rows, except raw messages
for (int i = 0; i < length; i++) {
ProtocolMessage ir = (ProtocolMessage) (m_Table.getItems()[i].getData());
if (ir.getProtocol().compareTo("Raw") != 0) { //$NON-NLS-1$
String output = m_Model.getExportTemplate();
output = output.replaceAll("#PROTOCOL#", ir.getProtocol()); //$NON-NLS-1$
output = output.replaceAll("#NAME#", ir.getInterpretation()); //$NON-NLS-1$
output = output.replaceAll("#NAMEUP#", ir.getInterpretation() //$NON-NLS-1$
.toUpperCase());
for (int j = 0; j < ir.getRawMessage().length; j++) {
String hex = "0" //$NON-NLS-1$
+ Integer.toHexString(ir.getRawMessage()[j]);
hex = hex.substring(hex.length() - 2);
output = output.replaceAll("#BYTE" //$NON-NLS-1$
+ Integer.toString(j) + "HEX#", hex); //$NON-NLS-1$
output = output.replaceAll("#BYTE" //$NON-NLS-1$
+ Integer.toString(j) + "#", Integer //$NON-NLS-1$
.toString(ir.getRawMessage()[j]));
}
// Replace all attribute references with the attribute values
for (FieldValue field : ir.getFields()) {
String name = "#ATT:" + field.getName() + "#";
output = output.replaceAll(name, field.getStringValue() != null ?
field.getStringValue() : Integer.toString(field.getValue()));
}
out.println(output);
}
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void saveDataAs() {
FileDialog save = new FileDialog(m_Shell, SWT.SAVE);
save.setFilterExtensions(extensions);
String fileName = save.open();
if (fileName != null) {
m_FileName = fileName;
} else
return;
saveData();
}
public void saveData() {
int length = m_Table.getItems().length;
try {
FileOutputStream fos = new FileOutputStream(m_FileName);
ObjectOutputStream oos = new ObjectOutputStream(fos);
// First write the number of messages
oos.writeInt(length);
// Then write each message
for (int i = 0; i < length; i++) {
oos.writeObject(m_Table.getItems()[i].getData());
}
oos.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void loadData() {
Boolean oldShowRaw = m_ShowRaw;
ObjectInputStream ois;
FileDialog open = new FileDialog(m_Shell, SWT.OPEN);
open.setFilterExtensions(extensions);
String fileName = open.open();
if (fileName != null) {
m_FileName = fileName;
} else
return;
try {
FileInputStream fis = new FileInputStream(m_FileName);
ois = new ObjectInputStream(fis);
int length = ois.readInt();
for (int i = 0; i < length; i++) {
ProtocolMessage irm = (ProtocolMessage) ois.readObject();
// If this is a raw sample from an older version, we have to recreate pulse lengths
if (irm.getProtocol().compareTo("Raw") == 0) { //$NON-NLS-1$
RawProtocolMessage mess = (RawProtocolMessage) irm;
if (mess.m_PulseLengths == null) {
mess.m_PulseLengths = new LinkedList<Double>();
int last = 0;
for (int noSamples : mess.m_PulseList) {
mess.m_PulseLengths.add((noSamples - last) * 1000000.0 / mess.m_SampleFrequency);
last = noSamples;
}
}
}
addTableRow(irm);
}
ois.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
m_ShowRaw = oldShowRaw;
}
/**
* View the currently selected sample
*/
private void viewSample() {
if (m_Table.getSelectionCount() == 0)
return;
ProtocolMessage message = (ProtocolMessage) m_Table.getSelection()[0]
.getData();
if (message.getProtocol().compareTo("Raw") == 0) { //$NON-NLS-1$
System.out.println(message.getProtocol());
RawProtocolMessage mess = (RawProtocolMessage) message;
RawSignalWindow GUI = new RawSignalWindow(m_Display, mess);
GUI.open();
} else {
System.out.println(message.getProtocol());
MessageWindow GUI = new MessageWindow(m_Display, message);
GUI.open();
}
}
/**
* Export the pulse data of the currently selected sample
*/
protected void exportPulseData() {
// Make sure we have a line selected
if (m_Table.getSelectionCount() == 0)
return;
ProtocolMessage message = (ProtocolMessage) m_Table.getSelection()[0]
.getData();
// Check that it is a raw sample
if (!message.getProtocol().equals("Raw")) { //$NON-NLS-1$
return;
}
RawProtocolMessage mess = (RawProtocolMessage) message;
FileDialog save = new FileDialog(m_Shell, SWT.SAVE);
save.setText(Messages.getString("MainWindow.ExportData")); //$NON-NLS-1$
// Ask for export file name
String fileName = save.open();
if (fileName == null) {
return;
}
// Save all pulses
PrintWriter out;
try {
out = new PrintWriter(new FileWriter(fileName));
char pulseType = 's';
// Loop through all pulses
for (double pulse : mess.m_PulseLengths) {
out.println(String.format("%c%.0f", pulseType, pulse)); //$NON-NLS-1$
pulseType = (pulseType == 's') ? 'm' : 's';
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Reanalyze the pulse data of the currently selected sample
*/
protected void reanalyzePulseData() {
// Make sure we have a line selected
if (m_Table.getSelectionCount() == 0)
return;
ProtocolMessage message = (ProtocolMessage) m_Table.getSelection()[0]
.getData();
// Check that it is a raw sample
if (!message.getProtocol().equals("Raw")) { //$NON-NLS-1$
return;
}
RawProtocolMessage mess = (RawProtocolMessage) message;
boolean currentlySampling = m_Model.isScanning();
// Pause current sampler so we do not mix signals
m_Model.stopScanning();
// Loop through all pulses
boolean state = false;
//m_Model.getProtocolDecoders().parse(30000.0, false);
for (double pulse : mess.m_PulseLengths) {
// Feed pulses to decoders
m_Model.getProtocolDecoders().parse(pulse, state);
state = !state;
}
// Add a long quiet period to end detection
m_Model.getProtocolDecoders().parse(200000.0, false);
// Restart port (if it was sampling)
if (currentlySampling) {
m_Model.startScanning();
}
}
/**
* Export the pulse data of the currently selected sample
*/
protected void reanalyzeSampleData() {
// Make sure we have a line selected
if (m_Table.getSelectionCount() == 0)
return;
ProtocolMessage message = (ProtocolMessage) m_Table.getSelection()[0]
.getData();
// Check that it is a raw sample
if (!message.getProtocol().equals("Raw")) { //$NON-NLS-1$
return;
}
RawProtocolMessage mess = (RawProtocolMessage) message;
boolean currentlySampling = m_Model.isScanning();
// Pause current sampler so we do not mix signals
m_Model.stopScanning();
// Loop through all samples
for (int sample : mess.m_Samples) {
// Feed pulses to decoders
m_Model.getProtocolSamplers().addSample(sample);
}
// Add a quiet period (200ms)to end detection
int numberOfEndSamples = m_Model.getFlankDetector().getSampleRate() / 5;
for (int i = 0; i < numberOfEndSamples; i++) {
m_Model.getProtocolSamplers().addSample(0);
}
// Restart port (if it was sampling)
if (currentlySampling) {
m_Model.startScanning();
}
}
/**
* Open settings dialog and apply the settings
*/
protected void editSettings() {
PulseProtocolPort ports[] = {m_Model.getAudioSampler(), m_Model.getPulsePort()};
int previousHardware = m_Model.getSignalHardware();
int lastSource = m_Model.getAudioSampler().getSource();
Channel lastChannel = m_Model.getAudioSampler().getChannel();
String lastCULPort = m_Model.getPulsePort().getSerialPort();
ArduinoProtocolPort.InputChannel lastPulseChannel = m_Model.getArduinoChannel();
// Create settings dialog and open it
SettingsTabDialog win = new SettingsTabDialog(m_Shell, 0);
win.open(m_Model);
// If source or selected hardware has changed, Stop previous port and start current,
// if it was not changed it means it is restarted
if ((lastSource != m_Model.getAudioSampler().getSource()) ||
(previousHardware != m_Model.getSignalHardware()) ||
(lastPulseChannel != m_Model.getArduinoChannel()) ||
(lastChannel != m_Model.getAudioSampler().getChannel()) ||
(!lastCULPort.equals(m_Model.getPulsePort().getSerialPort()))) {
ports[previousHardware].close();
ports[m_Model.getSignalHardware()].open();
}
m_Model.saveAudioPreferences();
m_Model.saveCULPreferences();
updateWindowState(true);
}
/**
* Delete the selected sample row, just exits if no row is selected
* @param force if false, requester ask if sure
*/
protected void deleteSelectedRow(boolean force) {
if (m_Table.getSelectionCount() != 1) return;
int response;
if (force) {
response = SWT.YES;
} else {
MessageBox box = new MessageBox(m_Shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
box.setMessage(Messages.getString("MainWindow.ReallyDeleteSelected")); //$NON-NLS-1$
response = box.open();
}
if (response == SWT.YES) {
m_Table.remove(m_Table.getSelectionIndex());
}
}
/**
* Delete all sample rows
*/
protected void deleteAllRows() {
MessageBox box = new MessageBox(m_Shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO);
box.setMessage(Messages.getString("MainWindow.ReallyDeleteAll")); //$NON-NLS-1$
int response = box.open();
if (response == SWT.YES) {
m_Table.removeAll();
}
}
}
| gpl-3.0 |
4Space/4Space-5 | src/main/java/api/player/server/ServerPlayerAPI.java | 278244 | package api.player.server;
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.logging.*;
import java.lang.reflect.*;
public final class ServerPlayerAPI
{
private final static Class<?>[] Class = new Class[] { ServerPlayerAPI.class };
private final static Class<?>[] Classes = new Class[] { ServerPlayerAPI.class, String.class };
private static boolean isCreated;
private static final Logger logger = Logger.getLogger("ServerPlayerAPI");
private static void log(String text)
{
System.out.println(text);
logger.fine(text);
}
public static void register(String id, Class<?> baseClass)
{
register(id, baseClass, null);
}
public static void register(String id, Class<?> baseClass, ServerPlayerBaseSorting baseSorting)
{
try
{
register(baseClass, id, baseSorting);
}
catch(RuntimeException exception)
{
if(id != null)
log("Server Player: failed to register id '" + id + "'");
else
log("Server Player: failed to register ServerPlayerBase");
throw exception;
}
}
private static void register(Class<?> baseClass, String id, ServerPlayerBaseSorting baseSorting)
{
if(!isCreated)
{
try
{
Method mandatory = net.minecraft.entity.player.EntityPlayerMP.class.getMethod("getServerPlayerBase", String.class);
if (mandatory.getReturnType() != ServerPlayerBase.class)
throw new NoSuchMethodException(ServerPlayerBase.class.getName() + " " + net.minecraft.entity.player.EntityPlayerMP.class.getName() + ".getServerPlayerBase(" + String.class.getName() + ")");
}
catch(NoSuchMethodException exception)
{
String[] errorMessageParts = new String[]
{
"========================================",
"The API \"Server Player\" version 1.0 of the mod \"Player API core 1.0\" can not be created!",
"----------------------------------------",
"Mandatory member method \"{0} getServerPlayerBase({3})\" not found in class \"{1}\".",
"There are three scenarios this can happen:",
"* Minecraft Forge is missing a Player API core which Minecraft version matches its own.",
" Download and install the latest Player API core for the Minecraft version you were trying to run.",
"* The code of the class \"{2}\" of Player API core has been modified beyond recognition by another Minecraft Forge coremod.",
" Try temporary deinstallation of other core mods to find the culprit and deinstall it permanently to fix this specific problem.",
"* Player API core has not been installed correctly.",
" Deinstall Player API core and install it again following the installation instructions in the readme file.",
"========================================"
};
String baseEntityPlayerMPClassName = ServerPlayerBase.class.getName();
String targetClassName = net.minecraft.entity.player.EntityPlayerMP.class.getName();
String targetClassFileName = targetClassName.replace(".", File.separator);
String stringClassName = String.class.getName();
for(int i=0; i<errorMessageParts.length; i++)
errorMessageParts[i] = MessageFormat.format(errorMessageParts[i], baseEntityPlayerMPClassName, targetClassName, targetClassFileName, stringClassName);
for(String errorMessagePart : errorMessageParts)
logger.severe(errorMessagePart);
for(String errorMessagePart : errorMessageParts)
System.err.println(errorMessagePart);
String errorMessage = "\n\n";
for(String errorMessagePart : errorMessageParts)
errorMessage += "\t" + errorMessagePart + "\n";
throw new RuntimeException(errorMessage, exception);
}
log("Server Player 1.0 Created");
isCreated = true;
}
if(id == null)
throw new NullPointerException("Argument 'id' can not be null");
if(baseClass == null)
throw new NullPointerException("Argument 'baseClass' can not be null");
Constructor<?> allreadyRegistered = allBaseConstructors.get(id);
if(allreadyRegistered != null)
throw new IllegalArgumentException("The class '" + baseClass.getName() + "' can not be registered with the id '" + id + "' because the class '" + allreadyRegistered.getDeclaringClass().getName() + "' has allready been registered with the same id");
Constructor<?> baseConstructor;
try
{
baseConstructor = baseClass.getDeclaredConstructor(Classes);
}
catch (Throwable t)
{
try
{
baseConstructor = baseClass.getDeclaredConstructor(Class);
}
catch(Throwable s)
{
throw new IllegalArgumentException("Can not find necessary constructor with one argument of type '" + ServerPlayerAPI.class.getName() + "' and eventually a second argument of type 'String' in the class '" + baseClass.getName() + "'", t);
}
}
allBaseConstructors.put(id, baseConstructor);
if(baseSorting != null)
{
addSorting(id, allBaseBeforeLocalConstructingSuperiors, baseSorting.getBeforeLocalConstructingSuperiors());
addSorting(id, allBaseBeforeLocalConstructingInferiors, baseSorting.getBeforeLocalConstructingInferiors());
addSorting(id, allBaseAfterLocalConstructingSuperiors, baseSorting.getAfterLocalConstructingSuperiors());
addSorting(id, allBaseAfterLocalConstructingInferiors, baseSorting.getAfterLocalConstructingInferiors());
addDynamicSorting(id, allBaseBeforeDynamicSuperiors, baseSorting.getDynamicBeforeSuperiors());
addDynamicSorting(id, allBaseBeforeDynamicInferiors, baseSorting.getDynamicBeforeInferiors());
addDynamicSorting(id, allBaseOverrideDynamicSuperiors, baseSorting.getDynamicOverrideSuperiors());
addDynamicSorting(id, allBaseOverrideDynamicInferiors, baseSorting.getDynamicOverrideInferiors());
addDynamicSorting(id, allBaseAfterDynamicSuperiors, baseSorting.getDynamicAfterSuperiors());
addDynamicSorting(id, allBaseAfterDynamicInferiors, baseSorting.getDynamicAfterInferiors());
addSorting(id, allBaseBeforeAddExhaustionSuperiors, baseSorting.getBeforeAddExhaustionSuperiors());
addSorting(id, allBaseBeforeAddExhaustionInferiors, baseSorting.getBeforeAddExhaustionInferiors());
addSorting(id, allBaseOverrideAddExhaustionSuperiors, baseSorting.getOverrideAddExhaustionSuperiors());
addSorting(id, allBaseOverrideAddExhaustionInferiors, baseSorting.getOverrideAddExhaustionInferiors());
addSorting(id, allBaseAfterAddExhaustionSuperiors, baseSorting.getAfterAddExhaustionSuperiors());
addSorting(id, allBaseAfterAddExhaustionInferiors, baseSorting.getAfterAddExhaustionInferiors());
addSorting(id, allBaseBeforeAddExperienceSuperiors, baseSorting.getBeforeAddExperienceSuperiors());
addSorting(id, allBaseBeforeAddExperienceInferiors, baseSorting.getBeforeAddExperienceInferiors());
addSorting(id, allBaseOverrideAddExperienceSuperiors, baseSorting.getOverrideAddExperienceSuperiors());
addSorting(id, allBaseOverrideAddExperienceInferiors, baseSorting.getOverrideAddExperienceInferiors());
addSorting(id, allBaseAfterAddExperienceSuperiors, baseSorting.getAfterAddExperienceSuperiors());
addSorting(id, allBaseAfterAddExperienceInferiors, baseSorting.getAfterAddExperienceInferiors());
addSorting(id, allBaseBeforeAddExperienceLevelSuperiors, baseSorting.getBeforeAddExperienceLevelSuperiors());
addSorting(id, allBaseBeforeAddExperienceLevelInferiors, baseSorting.getBeforeAddExperienceLevelInferiors());
addSorting(id, allBaseOverrideAddExperienceLevelSuperiors, baseSorting.getOverrideAddExperienceLevelSuperiors());
addSorting(id, allBaseOverrideAddExperienceLevelInferiors, baseSorting.getOverrideAddExperienceLevelInferiors());
addSorting(id, allBaseAfterAddExperienceLevelSuperiors, baseSorting.getAfterAddExperienceLevelSuperiors());
addSorting(id, allBaseAfterAddExperienceLevelInferiors, baseSorting.getAfterAddExperienceLevelInferiors());
addSorting(id, allBaseBeforeAddMovementStatSuperiors, baseSorting.getBeforeAddMovementStatSuperiors());
addSorting(id, allBaseBeforeAddMovementStatInferiors, baseSorting.getBeforeAddMovementStatInferiors());
addSorting(id, allBaseOverrideAddMovementStatSuperiors, baseSorting.getOverrideAddMovementStatSuperiors());
addSorting(id, allBaseOverrideAddMovementStatInferiors, baseSorting.getOverrideAddMovementStatInferiors());
addSorting(id, allBaseAfterAddMovementStatSuperiors, baseSorting.getAfterAddMovementStatSuperiors());
addSorting(id, allBaseAfterAddMovementStatInferiors, baseSorting.getAfterAddMovementStatInferiors());
addSorting(id, allBaseBeforeAttackEntityFromSuperiors, baseSorting.getBeforeAttackEntityFromSuperiors());
addSorting(id, allBaseBeforeAttackEntityFromInferiors, baseSorting.getBeforeAttackEntityFromInferiors());
addSorting(id, allBaseOverrideAttackEntityFromSuperiors, baseSorting.getOverrideAttackEntityFromSuperiors());
addSorting(id, allBaseOverrideAttackEntityFromInferiors, baseSorting.getOverrideAttackEntityFromInferiors());
addSorting(id, allBaseAfterAttackEntityFromSuperiors, baseSorting.getAfterAttackEntityFromSuperiors());
addSorting(id, allBaseAfterAttackEntityFromInferiors, baseSorting.getAfterAttackEntityFromInferiors());
addSorting(id, allBaseBeforeAttackTargetEntityWithCurrentItemSuperiors, baseSorting.getBeforeAttackTargetEntityWithCurrentItemSuperiors());
addSorting(id, allBaseBeforeAttackTargetEntityWithCurrentItemInferiors, baseSorting.getBeforeAttackTargetEntityWithCurrentItemInferiors());
addSorting(id, allBaseOverrideAttackTargetEntityWithCurrentItemSuperiors, baseSorting.getOverrideAttackTargetEntityWithCurrentItemSuperiors());
addSorting(id, allBaseOverrideAttackTargetEntityWithCurrentItemInferiors, baseSorting.getOverrideAttackTargetEntityWithCurrentItemInferiors());
addSorting(id, allBaseAfterAttackTargetEntityWithCurrentItemSuperiors, baseSorting.getAfterAttackTargetEntityWithCurrentItemSuperiors());
addSorting(id, allBaseAfterAttackTargetEntityWithCurrentItemInferiors, baseSorting.getAfterAttackTargetEntityWithCurrentItemInferiors());
addSorting(id, allBaseBeforeCanBreatheUnderwaterSuperiors, baseSorting.getBeforeCanBreatheUnderwaterSuperiors());
addSorting(id, allBaseBeforeCanBreatheUnderwaterInferiors, baseSorting.getBeforeCanBreatheUnderwaterInferiors());
addSorting(id, allBaseOverrideCanBreatheUnderwaterSuperiors, baseSorting.getOverrideCanBreatheUnderwaterSuperiors());
addSorting(id, allBaseOverrideCanBreatheUnderwaterInferiors, baseSorting.getOverrideCanBreatheUnderwaterInferiors());
addSorting(id, allBaseAfterCanBreatheUnderwaterSuperiors, baseSorting.getAfterCanBreatheUnderwaterSuperiors());
addSorting(id, allBaseAfterCanBreatheUnderwaterInferiors, baseSorting.getAfterCanBreatheUnderwaterInferiors());
addSorting(id, allBaseBeforeCanHarvestBlockSuperiors, baseSorting.getBeforeCanHarvestBlockSuperiors());
addSorting(id, allBaseBeforeCanHarvestBlockInferiors, baseSorting.getBeforeCanHarvestBlockInferiors());
addSorting(id, allBaseOverrideCanHarvestBlockSuperiors, baseSorting.getOverrideCanHarvestBlockSuperiors());
addSorting(id, allBaseOverrideCanHarvestBlockInferiors, baseSorting.getOverrideCanHarvestBlockInferiors());
addSorting(id, allBaseAfterCanHarvestBlockSuperiors, baseSorting.getAfterCanHarvestBlockSuperiors());
addSorting(id, allBaseAfterCanHarvestBlockInferiors, baseSorting.getAfterCanHarvestBlockInferiors());
addSorting(id, allBaseBeforeCanPlayerEditSuperiors, baseSorting.getBeforeCanPlayerEditSuperiors());
addSorting(id, allBaseBeforeCanPlayerEditInferiors, baseSorting.getBeforeCanPlayerEditInferiors());
addSorting(id, allBaseOverrideCanPlayerEditSuperiors, baseSorting.getOverrideCanPlayerEditSuperiors());
addSorting(id, allBaseOverrideCanPlayerEditInferiors, baseSorting.getOverrideCanPlayerEditInferiors());
addSorting(id, allBaseAfterCanPlayerEditSuperiors, baseSorting.getAfterCanPlayerEditSuperiors());
addSorting(id, allBaseAfterCanPlayerEditInferiors, baseSorting.getAfterCanPlayerEditInferiors());
addSorting(id, allBaseBeforeCanTriggerWalkingSuperiors, baseSorting.getBeforeCanTriggerWalkingSuperiors());
addSorting(id, allBaseBeforeCanTriggerWalkingInferiors, baseSorting.getBeforeCanTriggerWalkingInferiors());
addSorting(id, allBaseOverrideCanTriggerWalkingSuperiors, baseSorting.getOverrideCanTriggerWalkingSuperiors());
addSorting(id, allBaseOverrideCanTriggerWalkingInferiors, baseSorting.getOverrideCanTriggerWalkingInferiors());
addSorting(id, allBaseAfterCanTriggerWalkingSuperiors, baseSorting.getAfterCanTriggerWalkingSuperiors());
addSorting(id, allBaseAfterCanTriggerWalkingInferiors, baseSorting.getAfterCanTriggerWalkingInferiors());
addSorting(id, allBaseBeforeClonePlayerSuperiors, baseSorting.getBeforeClonePlayerSuperiors());
addSorting(id, allBaseBeforeClonePlayerInferiors, baseSorting.getBeforeClonePlayerInferiors());
addSorting(id, allBaseOverrideClonePlayerSuperiors, baseSorting.getOverrideClonePlayerSuperiors());
addSorting(id, allBaseOverrideClonePlayerInferiors, baseSorting.getOverrideClonePlayerInferiors());
addSorting(id, allBaseAfterClonePlayerSuperiors, baseSorting.getAfterClonePlayerSuperiors());
addSorting(id, allBaseAfterClonePlayerInferiors, baseSorting.getAfterClonePlayerInferiors());
addSorting(id, allBaseBeforeDamageEntitySuperiors, baseSorting.getBeforeDamageEntitySuperiors());
addSorting(id, allBaseBeforeDamageEntityInferiors, baseSorting.getBeforeDamageEntityInferiors());
addSorting(id, allBaseOverrideDamageEntitySuperiors, baseSorting.getOverrideDamageEntitySuperiors());
addSorting(id, allBaseOverrideDamageEntityInferiors, baseSorting.getOverrideDamageEntityInferiors());
addSorting(id, allBaseAfterDamageEntitySuperiors, baseSorting.getAfterDamageEntitySuperiors());
addSorting(id, allBaseAfterDamageEntityInferiors, baseSorting.getAfterDamageEntityInferiors());
addSorting(id, allBaseBeforeDisplayGUIChestSuperiors, baseSorting.getBeforeDisplayGUIChestSuperiors());
addSorting(id, allBaseBeforeDisplayGUIChestInferiors, baseSorting.getBeforeDisplayGUIChestInferiors());
addSorting(id, allBaseOverrideDisplayGUIChestSuperiors, baseSorting.getOverrideDisplayGUIChestSuperiors());
addSorting(id, allBaseOverrideDisplayGUIChestInferiors, baseSorting.getOverrideDisplayGUIChestInferiors());
addSorting(id, allBaseAfterDisplayGUIChestSuperiors, baseSorting.getAfterDisplayGUIChestSuperiors());
addSorting(id, allBaseAfterDisplayGUIChestInferiors, baseSorting.getAfterDisplayGUIChestInferiors());
addSorting(id, allBaseBeforeDisplayGUIDispenserSuperiors, baseSorting.getBeforeDisplayGUIDispenserSuperiors());
addSorting(id, allBaseBeforeDisplayGUIDispenserInferiors, baseSorting.getBeforeDisplayGUIDispenserInferiors());
addSorting(id, allBaseOverrideDisplayGUIDispenserSuperiors, baseSorting.getOverrideDisplayGUIDispenserSuperiors());
addSorting(id, allBaseOverrideDisplayGUIDispenserInferiors, baseSorting.getOverrideDisplayGUIDispenserInferiors());
addSorting(id, allBaseAfterDisplayGUIDispenserSuperiors, baseSorting.getAfterDisplayGUIDispenserSuperiors());
addSorting(id, allBaseAfterDisplayGUIDispenserInferiors, baseSorting.getAfterDisplayGUIDispenserInferiors());
addSorting(id, allBaseBeforeDisplayGUIFurnaceSuperiors, baseSorting.getBeforeDisplayGUIFurnaceSuperiors());
addSorting(id, allBaseBeforeDisplayGUIFurnaceInferiors, baseSorting.getBeforeDisplayGUIFurnaceInferiors());
addSorting(id, allBaseOverrideDisplayGUIFurnaceSuperiors, baseSorting.getOverrideDisplayGUIFurnaceSuperiors());
addSorting(id, allBaseOverrideDisplayGUIFurnaceInferiors, baseSorting.getOverrideDisplayGUIFurnaceInferiors());
addSorting(id, allBaseAfterDisplayGUIFurnaceSuperiors, baseSorting.getAfterDisplayGUIFurnaceSuperiors());
addSorting(id, allBaseAfterDisplayGUIFurnaceInferiors, baseSorting.getAfterDisplayGUIFurnaceInferiors());
addSorting(id, allBaseBeforeDisplayGUIWorkbenchSuperiors, baseSorting.getBeforeDisplayGUIWorkbenchSuperiors());
addSorting(id, allBaseBeforeDisplayGUIWorkbenchInferiors, baseSorting.getBeforeDisplayGUIWorkbenchInferiors());
addSorting(id, allBaseOverrideDisplayGUIWorkbenchSuperiors, baseSorting.getOverrideDisplayGUIWorkbenchSuperiors());
addSorting(id, allBaseOverrideDisplayGUIWorkbenchInferiors, baseSorting.getOverrideDisplayGUIWorkbenchInferiors());
addSorting(id, allBaseAfterDisplayGUIWorkbenchSuperiors, baseSorting.getAfterDisplayGUIWorkbenchSuperiors());
addSorting(id, allBaseAfterDisplayGUIWorkbenchInferiors, baseSorting.getAfterDisplayGUIWorkbenchInferiors());
addSorting(id, allBaseBeforeDropOneItemSuperiors, baseSorting.getBeforeDropOneItemSuperiors());
addSorting(id, allBaseBeforeDropOneItemInferiors, baseSorting.getBeforeDropOneItemInferiors());
addSorting(id, allBaseOverrideDropOneItemSuperiors, baseSorting.getOverrideDropOneItemSuperiors());
addSorting(id, allBaseOverrideDropOneItemInferiors, baseSorting.getOverrideDropOneItemInferiors());
addSorting(id, allBaseAfterDropOneItemSuperiors, baseSorting.getAfterDropOneItemSuperiors());
addSorting(id, allBaseAfterDropOneItemInferiors, baseSorting.getAfterDropOneItemInferiors());
addSorting(id, allBaseBeforeDropPlayerItemSuperiors, baseSorting.getBeforeDropPlayerItemSuperiors());
addSorting(id, allBaseBeforeDropPlayerItemInferiors, baseSorting.getBeforeDropPlayerItemInferiors());
addSorting(id, allBaseOverrideDropPlayerItemSuperiors, baseSorting.getOverrideDropPlayerItemSuperiors());
addSorting(id, allBaseOverrideDropPlayerItemInferiors, baseSorting.getOverrideDropPlayerItemInferiors());
addSorting(id, allBaseAfterDropPlayerItemSuperiors, baseSorting.getAfterDropPlayerItemSuperiors());
addSorting(id, allBaseAfterDropPlayerItemInferiors, baseSorting.getAfterDropPlayerItemInferiors());
addSorting(id, allBaseBeforeFallSuperiors, baseSorting.getBeforeFallSuperiors());
addSorting(id, allBaseBeforeFallInferiors, baseSorting.getBeforeFallInferiors());
addSorting(id, allBaseOverrideFallSuperiors, baseSorting.getOverrideFallSuperiors());
addSorting(id, allBaseOverrideFallInferiors, baseSorting.getOverrideFallInferiors());
addSorting(id, allBaseAfterFallSuperiors, baseSorting.getAfterFallSuperiors());
addSorting(id, allBaseAfterFallInferiors, baseSorting.getAfterFallInferiors());
addSorting(id, allBaseBeforeGetAIMoveSpeedSuperiors, baseSorting.getBeforeGetAIMoveSpeedSuperiors());
addSorting(id, allBaseBeforeGetAIMoveSpeedInferiors, baseSorting.getBeforeGetAIMoveSpeedInferiors());
addSorting(id, allBaseOverrideGetAIMoveSpeedSuperiors, baseSorting.getOverrideGetAIMoveSpeedSuperiors());
addSorting(id, allBaseOverrideGetAIMoveSpeedInferiors, baseSorting.getOverrideGetAIMoveSpeedInferiors());
addSorting(id, allBaseAfterGetAIMoveSpeedSuperiors, baseSorting.getAfterGetAIMoveSpeedSuperiors());
addSorting(id, allBaseAfterGetAIMoveSpeedInferiors, baseSorting.getAfterGetAIMoveSpeedInferiors());
addSorting(id, allBaseBeforeGetCurrentPlayerStrVsBlockSuperiors, baseSorting.getBeforeGetCurrentPlayerStrVsBlockSuperiors());
addSorting(id, allBaseBeforeGetCurrentPlayerStrVsBlockInferiors, baseSorting.getBeforeGetCurrentPlayerStrVsBlockInferiors());
addSorting(id, allBaseOverrideGetCurrentPlayerStrVsBlockSuperiors, baseSorting.getOverrideGetCurrentPlayerStrVsBlockSuperiors());
addSorting(id, allBaseOverrideGetCurrentPlayerStrVsBlockInferiors, baseSorting.getOverrideGetCurrentPlayerStrVsBlockInferiors());
addSorting(id, allBaseAfterGetCurrentPlayerStrVsBlockSuperiors, baseSorting.getAfterGetCurrentPlayerStrVsBlockSuperiors());
addSorting(id, allBaseAfterGetCurrentPlayerStrVsBlockInferiors, baseSorting.getAfterGetCurrentPlayerStrVsBlockInferiors());
addSorting(id, allBaseBeforeGetCurrentPlayerStrVsBlockForgeSuperiors, baseSorting.getBeforeGetCurrentPlayerStrVsBlockForgeSuperiors());
addSorting(id, allBaseBeforeGetCurrentPlayerStrVsBlockForgeInferiors, baseSorting.getBeforeGetCurrentPlayerStrVsBlockForgeInferiors());
addSorting(id, allBaseOverrideGetCurrentPlayerStrVsBlockForgeSuperiors, baseSorting.getOverrideGetCurrentPlayerStrVsBlockForgeSuperiors());
addSorting(id, allBaseOverrideGetCurrentPlayerStrVsBlockForgeInferiors, baseSorting.getOverrideGetCurrentPlayerStrVsBlockForgeInferiors());
addSorting(id, allBaseAfterGetCurrentPlayerStrVsBlockForgeSuperiors, baseSorting.getAfterGetCurrentPlayerStrVsBlockForgeSuperiors());
addSorting(id, allBaseAfterGetCurrentPlayerStrVsBlockForgeInferiors, baseSorting.getAfterGetCurrentPlayerStrVsBlockForgeInferiors());
addSorting(id, allBaseBeforeGetDistanceSqSuperiors, baseSorting.getBeforeGetDistanceSqSuperiors());
addSorting(id, allBaseBeforeGetDistanceSqInferiors, baseSorting.getBeforeGetDistanceSqInferiors());
addSorting(id, allBaseOverrideGetDistanceSqSuperiors, baseSorting.getOverrideGetDistanceSqSuperiors());
addSorting(id, allBaseOverrideGetDistanceSqInferiors, baseSorting.getOverrideGetDistanceSqInferiors());
addSorting(id, allBaseAfterGetDistanceSqSuperiors, baseSorting.getAfterGetDistanceSqSuperiors());
addSorting(id, allBaseAfterGetDistanceSqInferiors, baseSorting.getAfterGetDistanceSqInferiors());
addSorting(id, allBaseBeforeGetBrightnessSuperiors, baseSorting.getBeforeGetBrightnessSuperiors());
addSorting(id, allBaseBeforeGetBrightnessInferiors, baseSorting.getBeforeGetBrightnessInferiors());
addSorting(id, allBaseOverrideGetBrightnessSuperiors, baseSorting.getOverrideGetBrightnessSuperiors());
addSorting(id, allBaseOverrideGetBrightnessInferiors, baseSorting.getOverrideGetBrightnessInferiors());
addSorting(id, allBaseAfterGetBrightnessSuperiors, baseSorting.getAfterGetBrightnessSuperiors());
addSorting(id, allBaseAfterGetBrightnessInferiors, baseSorting.getAfterGetBrightnessInferiors());
addSorting(id, allBaseBeforeGetEyeHeightSuperiors, baseSorting.getBeforeGetEyeHeightSuperiors());
addSorting(id, allBaseBeforeGetEyeHeightInferiors, baseSorting.getBeforeGetEyeHeightInferiors());
addSorting(id, allBaseOverrideGetEyeHeightSuperiors, baseSorting.getOverrideGetEyeHeightSuperiors());
addSorting(id, allBaseOverrideGetEyeHeightInferiors, baseSorting.getOverrideGetEyeHeightInferiors());
addSorting(id, allBaseAfterGetEyeHeightSuperiors, baseSorting.getAfterGetEyeHeightSuperiors());
addSorting(id, allBaseAfterGetEyeHeightInferiors, baseSorting.getAfterGetEyeHeightInferiors());
addSorting(id, allBaseBeforeHealSuperiors, baseSorting.getBeforeHealSuperiors());
addSorting(id, allBaseBeforeHealInferiors, baseSorting.getBeforeHealInferiors());
addSorting(id, allBaseOverrideHealSuperiors, baseSorting.getOverrideHealSuperiors());
addSorting(id, allBaseOverrideHealInferiors, baseSorting.getOverrideHealInferiors());
addSorting(id, allBaseAfterHealSuperiors, baseSorting.getAfterHealSuperiors());
addSorting(id, allBaseAfterHealInferiors, baseSorting.getAfterHealInferiors());
addSorting(id, allBaseBeforeIsEntityInsideOpaqueBlockSuperiors, baseSorting.getBeforeIsEntityInsideOpaqueBlockSuperiors());
addSorting(id, allBaseBeforeIsEntityInsideOpaqueBlockInferiors, baseSorting.getBeforeIsEntityInsideOpaqueBlockInferiors());
addSorting(id, allBaseOverrideIsEntityInsideOpaqueBlockSuperiors, baseSorting.getOverrideIsEntityInsideOpaqueBlockSuperiors());
addSorting(id, allBaseOverrideIsEntityInsideOpaqueBlockInferiors, baseSorting.getOverrideIsEntityInsideOpaqueBlockInferiors());
addSorting(id, allBaseAfterIsEntityInsideOpaqueBlockSuperiors, baseSorting.getAfterIsEntityInsideOpaqueBlockSuperiors());
addSorting(id, allBaseAfterIsEntityInsideOpaqueBlockInferiors, baseSorting.getAfterIsEntityInsideOpaqueBlockInferiors());
addSorting(id, allBaseBeforeIsInWaterSuperiors, baseSorting.getBeforeIsInWaterSuperiors());
addSorting(id, allBaseBeforeIsInWaterInferiors, baseSorting.getBeforeIsInWaterInferiors());
addSorting(id, allBaseOverrideIsInWaterSuperiors, baseSorting.getOverrideIsInWaterSuperiors());
addSorting(id, allBaseOverrideIsInWaterInferiors, baseSorting.getOverrideIsInWaterInferiors());
addSorting(id, allBaseAfterIsInWaterSuperiors, baseSorting.getAfterIsInWaterSuperiors());
addSorting(id, allBaseAfterIsInWaterInferiors, baseSorting.getAfterIsInWaterInferiors());
addSorting(id, allBaseBeforeIsInsideOfMaterialSuperiors, baseSorting.getBeforeIsInsideOfMaterialSuperiors());
addSorting(id, allBaseBeforeIsInsideOfMaterialInferiors, baseSorting.getBeforeIsInsideOfMaterialInferiors());
addSorting(id, allBaseOverrideIsInsideOfMaterialSuperiors, baseSorting.getOverrideIsInsideOfMaterialSuperiors());
addSorting(id, allBaseOverrideIsInsideOfMaterialInferiors, baseSorting.getOverrideIsInsideOfMaterialInferiors());
addSorting(id, allBaseAfterIsInsideOfMaterialSuperiors, baseSorting.getAfterIsInsideOfMaterialSuperiors());
addSorting(id, allBaseAfterIsInsideOfMaterialInferiors, baseSorting.getAfterIsInsideOfMaterialInferiors());
addSorting(id, allBaseBeforeIsOnLadderSuperiors, baseSorting.getBeforeIsOnLadderSuperiors());
addSorting(id, allBaseBeforeIsOnLadderInferiors, baseSorting.getBeforeIsOnLadderInferiors());
addSorting(id, allBaseOverrideIsOnLadderSuperiors, baseSorting.getOverrideIsOnLadderSuperiors());
addSorting(id, allBaseOverrideIsOnLadderInferiors, baseSorting.getOverrideIsOnLadderInferiors());
addSorting(id, allBaseAfterIsOnLadderSuperiors, baseSorting.getAfterIsOnLadderSuperiors());
addSorting(id, allBaseAfterIsOnLadderInferiors, baseSorting.getAfterIsOnLadderInferiors());
addSorting(id, allBaseBeforeIsPlayerSleepingSuperiors, baseSorting.getBeforeIsPlayerSleepingSuperiors());
addSorting(id, allBaseBeforeIsPlayerSleepingInferiors, baseSorting.getBeforeIsPlayerSleepingInferiors());
addSorting(id, allBaseOverrideIsPlayerSleepingSuperiors, baseSorting.getOverrideIsPlayerSleepingSuperiors());
addSorting(id, allBaseOverrideIsPlayerSleepingInferiors, baseSorting.getOverrideIsPlayerSleepingInferiors());
addSorting(id, allBaseAfterIsPlayerSleepingSuperiors, baseSorting.getAfterIsPlayerSleepingSuperiors());
addSorting(id, allBaseAfterIsPlayerSleepingInferiors, baseSorting.getAfterIsPlayerSleepingInferiors());
addSorting(id, allBaseBeforeJumpSuperiors, baseSorting.getBeforeJumpSuperiors());
addSorting(id, allBaseBeforeJumpInferiors, baseSorting.getBeforeJumpInferiors());
addSorting(id, allBaseOverrideJumpSuperiors, baseSorting.getOverrideJumpSuperiors());
addSorting(id, allBaseOverrideJumpInferiors, baseSorting.getOverrideJumpInferiors());
addSorting(id, allBaseAfterJumpSuperiors, baseSorting.getAfterJumpSuperiors());
addSorting(id, allBaseAfterJumpInferiors, baseSorting.getAfterJumpInferiors());
addSorting(id, allBaseBeforeKnockBackSuperiors, baseSorting.getBeforeKnockBackSuperiors());
addSorting(id, allBaseBeforeKnockBackInferiors, baseSorting.getBeforeKnockBackInferiors());
addSorting(id, allBaseOverrideKnockBackSuperiors, baseSorting.getOverrideKnockBackSuperiors());
addSorting(id, allBaseOverrideKnockBackInferiors, baseSorting.getOverrideKnockBackInferiors());
addSorting(id, allBaseAfterKnockBackSuperiors, baseSorting.getAfterKnockBackSuperiors());
addSorting(id, allBaseAfterKnockBackInferiors, baseSorting.getAfterKnockBackInferiors());
addSorting(id, allBaseBeforeMoveEntitySuperiors, baseSorting.getBeforeMoveEntitySuperiors());
addSorting(id, allBaseBeforeMoveEntityInferiors, baseSorting.getBeforeMoveEntityInferiors());
addSorting(id, allBaseOverrideMoveEntitySuperiors, baseSorting.getOverrideMoveEntitySuperiors());
addSorting(id, allBaseOverrideMoveEntityInferiors, baseSorting.getOverrideMoveEntityInferiors());
addSorting(id, allBaseAfterMoveEntitySuperiors, baseSorting.getAfterMoveEntitySuperiors());
addSorting(id, allBaseAfterMoveEntityInferiors, baseSorting.getAfterMoveEntityInferiors());
addSorting(id, allBaseBeforeMoveEntityWithHeadingSuperiors, baseSorting.getBeforeMoveEntityWithHeadingSuperiors());
addSorting(id, allBaseBeforeMoveEntityWithHeadingInferiors, baseSorting.getBeforeMoveEntityWithHeadingInferiors());
addSorting(id, allBaseOverrideMoveEntityWithHeadingSuperiors, baseSorting.getOverrideMoveEntityWithHeadingSuperiors());
addSorting(id, allBaseOverrideMoveEntityWithHeadingInferiors, baseSorting.getOverrideMoveEntityWithHeadingInferiors());
addSorting(id, allBaseAfterMoveEntityWithHeadingSuperiors, baseSorting.getAfterMoveEntityWithHeadingSuperiors());
addSorting(id, allBaseAfterMoveEntityWithHeadingInferiors, baseSorting.getAfterMoveEntityWithHeadingInferiors());
addSorting(id, allBaseBeforeMoveFlyingSuperiors, baseSorting.getBeforeMoveFlyingSuperiors());
addSorting(id, allBaseBeforeMoveFlyingInferiors, baseSorting.getBeforeMoveFlyingInferiors());
addSorting(id, allBaseOverrideMoveFlyingSuperiors, baseSorting.getOverrideMoveFlyingSuperiors());
addSorting(id, allBaseOverrideMoveFlyingInferiors, baseSorting.getOverrideMoveFlyingInferiors());
addSorting(id, allBaseAfterMoveFlyingSuperiors, baseSorting.getAfterMoveFlyingSuperiors());
addSorting(id, allBaseAfterMoveFlyingInferiors, baseSorting.getAfterMoveFlyingInferiors());
addSorting(id, allBaseBeforeOnDeathSuperiors, baseSorting.getBeforeOnDeathSuperiors());
addSorting(id, allBaseBeforeOnDeathInferiors, baseSorting.getBeforeOnDeathInferiors());
addSorting(id, allBaseOverrideOnDeathSuperiors, baseSorting.getOverrideOnDeathSuperiors());
addSorting(id, allBaseOverrideOnDeathInferiors, baseSorting.getOverrideOnDeathInferiors());
addSorting(id, allBaseAfterOnDeathSuperiors, baseSorting.getAfterOnDeathSuperiors());
addSorting(id, allBaseAfterOnDeathInferiors, baseSorting.getAfterOnDeathInferiors());
addSorting(id, allBaseBeforeOnLivingUpdateSuperiors, baseSorting.getBeforeOnLivingUpdateSuperiors());
addSorting(id, allBaseBeforeOnLivingUpdateInferiors, baseSorting.getBeforeOnLivingUpdateInferiors());
addSorting(id, allBaseOverrideOnLivingUpdateSuperiors, baseSorting.getOverrideOnLivingUpdateSuperiors());
addSorting(id, allBaseOverrideOnLivingUpdateInferiors, baseSorting.getOverrideOnLivingUpdateInferiors());
addSorting(id, allBaseAfterOnLivingUpdateSuperiors, baseSorting.getAfterOnLivingUpdateSuperiors());
addSorting(id, allBaseAfterOnLivingUpdateInferiors, baseSorting.getAfterOnLivingUpdateInferiors());
addSorting(id, allBaseBeforeOnKillEntitySuperiors, baseSorting.getBeforeOnKillEntitySuperiors());
addSorting(id, allBaseBeforeOnKillEntityInferiors, baseSorting.getBeforeOnKillEntityInferiors());
addSorting(id, allBaseOverrideOnKillEntitySuperiors, baseSorting.getOverrideOnKillEntitySuperiors());
addSorting(id, allBaseOverrideOnKillEntityInferiors, baseSorting.getOverrideOnKillEntityInferiors());
addSorting(id, allBaseAfterOnKillEntitySuperiors, baseSorting.getAfterOnKillEntitySuperiors());
addSorting(id, allBaseAfterOnKillEntityInferiors, baseSorting.getAfterOnKillEntityInferiors());
addSorting(id, allBaseBeforeOnStruckByLightningSuperiors, baseSorting.getBeforeOnStruckByLightningSuperiors());
addSorting(id, allBaseBeforeOnStruckByLightningInferiors, baseSorting.getBeforeOnStruckByLightningInferiors());
addSorting(id, allBaseOverrideOnStruckByLightningSuperiors, baseSorting.getOverrideOnStruckByLightningSuperiors());
addSorting(id, allBaseOverrideOnStruckByLightningInferiors, baseSorting.getOverrideOnStruckByLightningInferiors());
addSorting(id, allBaseAfterOnStruckByLightningSuperiors, baseSorting.getAfterOnStruckByLightningSuperiors());
addSorting(id, allBaseAfterOnStruckByLightningInferiors, baseSorting.getAfterOnStruckByLightningInferiors());
addSorting(id, allBaseBeforeOnUpdateSuperiors, baseSorting.getBeforeOnUpdateSuperiors());
addSorting(id, allBaseBeforeOnUpdateInferiors, baseSorting.getBeforeOnUpdateInferiors());
addSorting(id, allBaseOverrideOnUpdateSuperiors, baseSorting.getOverrideOnUpdateSuperiors());
addSorting(id, allBaseOverrideOnUpdateInferiors, baseSorting.getOverrideOnUpdateInferiors());
addSorting(id, allBaseAfterOnUpdateSuperiors, baseSorting.getAfterOnUpdateSuperiors());
addSorting(id, allBaseAfterOnUpdateInferiors, baseSorting.getAfterOnUpdateInferiors());
addSorting(id, allBaseBeforeOnUpdateEntitySuperiors, baseSorting.getBeforeOnUpdateEntitySuperiors());
addSorting(id, allBaseBeforeOnUpdateEntityInferiors, baseSorting.getBeforeOnUpdateEntityInferiors());
addSorting(id, allBaseOverrideOnUpdateEntitySuperiors, baseSorting.getOverrideOnUpdateEntitySuperiors());
addSorting(id, allBaseOverrideOnUpdateEntityInferiors, baseSorting.getOverrideOnUpdateEntityInferiors());
addSorting(id, allBaseAfterOnUpdateEntitySuperiors, baseSorting.getAfterOnUpdateEntitySuperiors());
addSorting(id, allBaseAfterOnUpdateEntityInferiors, baseSorting.getAfterOnUpdateEntityInferiors());
addSorting(id, allBaseBeforeReadEntityFromNBTSuperiors, baseSorting.getBeforeReadEntityFromNBTSuperiors());
addSorting(id, allBaseBeforeReadEntityFromNBTInferiors, baseSorting.getBeforeReadEntityFromNBTInferiors());
addSorting(id, allBaseOverrideReadEntityFromNBTSuperiors, baseSorting.getOverrideReadEntityFromNBTSuperiors());
addSorting(id, allBaseOverrideReadEntityFromNBTInferiors, baseSorting.getOverrideReadEntityFromNBTInferiors());
addSorting(id, allBaseAfterReadEntityFromNBTSuperiors, baseSorting.getAfterReadEntityFromNBTSuperiors());
addSorting(id, allBaseAfterReadEntityFromNBTInferiors, baseSorting.getAfterReadEntityFromNBTInferiors());
addSorting(id, allBaseBeforeSetDeadSuperiors, baseSorting.getBeforeSetDeadSuperiors());
addSorting(id, allBaseBeforeSetDeadInferiors, baseSorting.getBeforeSetDeadInferiors());
addSorting(id, allBaseOverrideSetDeadSuperiors, baseSorting.getOverrideSetDeadSuperiors());
addSorting(id, allBaseOverrideSetDeadInferiors, baseSorting.getOverrideSetDeadInferiors());
addSorting(id, allBaseAfterSetDeadSuperiors, baseSorting.getAfterSetDeadSuperiors());
addSorting(id, allBaseAfterSetDeadInferiors, baseSorting.getAfterSetDeadInferiors());
addSorting(id, allBaseBeforeSetEntityActionStateSuperiors, baseSorting.getBeforeSetEntityActionStateSuperiors());
addSorting(id, allBaseBeforeSetEntityActionStateInferiors, baseSorting.getBeforeSetEntityActionStateInferiors());
addSorting(id, allBaseOverrideSetEntityActionStateSuperiors, baseSorting.getOverrideSetEntityActionStateSuperiors());
addSorting(id, allBaseOverrideSetEntityActionStateInferiors, baseSorting.getOverrideSetEntityActionStateInferiors());
addSorting(id, allBaseAfterSetEntityActionStateSuperiors, baseSorting.getAfterSetEntityActionStateSuperiors());
addSorting(id, allBaseAfterSetEntityActionStateInferiors, baseSorting.getAfterSetEntityActionStateInferiors());
addSorting(id, allBaseBeforeSetPositionSuperiors, baseSorting.getBeforeSetPositionSuperiors());
addSorting(id, allBaseBeforeSetPositionInferiors, baseSorting.getBeforeSetPositionInferiors());
addSorting(id, allBaseOverrideSetPositionSuperiors, baseSorting.getOverrideSetPositionSuperiors());
addSorting(id, allBaseOverrideSetPositionInferiors, baseSorting.getOverrideSetPositionInferiors());
addSorting(id, allBaseAfterSetPositionSuperiors, baseSorting.getAfterSetPositionSuperiors());
addSorting(id, allBaseAfterSetPositionInferiors, baseSorting.getAfterSetPositionInferiors());
addSorting(id, allBaseBeforeSetSneakingSuperiors, baseSorting.getBeforeSetSneakingSuperiors());
addSorting(id, allBaseBeforeSetSneakingInferiors, baseSorting.getBeforeSetSneakingInferiors());
addSorting(id, allBaseOverrideSetSneakingSuperiors, baseSorting.getOverrideSetSneakingSuperiors());
addSorting(id, allBaseOverrideSetSneakingInferiors, baseSorting.getOverrideSetSneakingInferiors());
addSorting(id, allBaseAfterSetSneakingSuperiors, baseSorting.getAfterSetSneakingSuperiors());
addSorting(id, allBaseAfterSetSneakingInferiors, baseSorting.getAfterSetSneakingInferiors());
addSorting(id, allBaseBeforeSetSprintingSuperiors, baseSorting.getBeforeSetSprintingSuperiors());
addSorting(id, allBaseBeforeSetSprintingInferiors, baseSorting.getBeforeSetSprintingInferiors());
addSorting(id, allBaseOverrideSetSprintingSuperiors, baseSorting.getOverrideSetSprintingSuperiors());
addSorting(id, allBaseOverrideSetSprintingInferiors, baseSorting.getOverrideSetSprintingInferiors());
addSorting(id, allBaseAfterSetSprintingSuperiors, baseSorting.getAfterSetSprintingSuperiors());
addSorting(id, allBaseAfterSetSprintingInferiors, baseSorting.getAfterSetSprintingInferiors());
addSorting(id, allBaseBeforeSwingItemSuperiors, baseSorting.getBeforeSwingItemSuperiors());
addSorting(id, allBaseBeforeSwingItemInferiors, baseSorting.getBeforeSwingItemInferiors());
addSorting(id, allBaseOverrideSwingItemSuperiors, baseSorting.getOverrideSwingItemSuperiors());
addSorting(id, allBaseOverrideSwingItemInferiors, baseSorting.getOverrideSwingItemInferiors());
addSorting(id, allBaseAfterSwingItemSuperiors, baseSorting.getAfterSwingItemSuperiors());
addSorting(id, allBaseAfterSwingItemInferiors, baseSorting.getAfterSwingItemInferiors());
addSorting(id, allBaseBeforeUpdateEntityActionStateSuperiors, baseSorting.getBeforeUpdateEntityActionStateSuperiors());
addSorting(id, allBaseBeforeUpdateEntityActionStateInferiors, baseSorting.getBeforeUpdateEntityActionStateInferiors());
addSorting(id, allBaseOverrideUpdateEntityActionStateSuperiors, baseSorting.getOverrideUpdateEntityActionStateSuperiors());
addSorting(id, allBaseOverrideUpdateEntityActionStateInferiors, baseSorting.getOverrideUpdateEntityActionStateInferiors());
addSorting(id, allBaseAfterUpdateEntityActionStateSuperiors, baseSorting.getAfterUpdateEntityActionStateSuperiors());
addSorting(id, allBaseAfterUpdateEntityActionStateInferiors, baseSorting.getAfterUpdateEntityActionStateInferiors());
addSorting(id, allBaseBeforeUpdatePotionEffectsSuperiors, baseSorting.getBeforeUpdatePotionEffectsSuperiors());
addSorting(id, allBaseBeforeUpdatePotionEffectsInferiors, baseSorting.getBeforeUpdatePotionEffectsInferiors());
addSorting(id, allBaseOverrideUpdatePotionEffectsSuperiors, baseSorting.getOverrideUpdatePotionEffectsSuperiors());
addSorting(id, allBaseOverrideUpdatePotionEffectsInferiors, baseSorting.getOverrideUpdatePotionEffectsInferiors());
addSorting(id, allBaseAfterUpdatePotionEffectsSuperiors, baseSorting.getAfterUpdatePotionEffectsSuperiors());
addSorting(id, allBaseAfterUpdatePotionEffectsInferiors, baseSorting.getAfterUpdatePotionEffectsInferiors());
addSorting(id, allBaseBeforeWriteEntityToNBTSuperiors, baseSorting.getBeforeWriteEntityToNBTSuperiors());
addSorting(id, allBaseBeforeWriteEntityToNBTInferiors, baseSorting.getBeforeWriteEntityToNBTInferiors());
addSorting(id, allBaseOverrideWriteEntityToNBTSuperiors, baseSorting.getOverrideWriteEntityToNBTSuperiors());
addSorting(id, allBaseOverrideWriteEntityToNBTInferiors, baseSorting.getOverrideWriteEntityToNBTInferiors());
addSorting(id, allBaseAfterWriteEntityToNBTSuperiors, baseSorting.getAfterWriteEntityToNBTSuperiors());
addSorting(id, allBaseAfterWriteEntityToNBTInferiors, baseSorting.getAfterWriteEntityToNBTInferiors());
}
addMethod(id, baseClass, beforeLocalConstructingHookTypes, "beforeLocalConstructing", net.minecraft.server.MinecraftServer.class, net.minecraft.world.WorldServer.class, com.mojang.authlib.GameProfile.class, net.minecraft.server.management.ItemInWorldManager.class);
addMethod(id, baseClass, afterLocalConstructingHookTypes, "afterLocalConstructing", net.minecraft.server.MinecraftServer.class, net.minecraft.world.WorldServer.class, com.mojang.authlib.GameProfile.class, net.minecraft.server.management.ItemInWorldManager.class);
addMethod(id, baseClass, beforeAddExhaustionHookTypes, "beforeAddExhaustion", float.class);
addMethod(id, baseClass, overrideAddExhaustionHookTypes, "addExhaustion", float.class);
addMethod(id, baseClass, afterAddExhaustionHookTypes, "afterAddExhaustion", float.class);
addMethod(id, baseClass, beforeAddExperienceHookTypes, "beforeAddExperience", int.class);
addMethod(id, baseClass, overrideAddExperienceHookTypes, "addExperience", int.class);
addMethod(id, baseClass, afterAddExperienceHookTypes, "afterAddExperience", int.class);
addMethod(id, baseClass, beforeAddExperienceLevelHookTypes, "beforeAddExperienceLevel", int.class);
addMethod(id, baseClass, overrideAddExperienceLevelHookTypes, "addExperienceLevel", int.class);
addMethod(id, baseClass, afterAddExperienceLevelHookTypes, "afterAddExperienceLevel", int.class);
addMethod(id, baseClass, beforeAddMovementStatHookTypes, "beforeAddMovementStat", double.class, double.class, double.class);
addMethod(id, baseClass, overrideAddMovementStatHookTypes, "addMovementStat", double.class, double.class, double.class);
addMethod(id, baseClass, afterAddMovementStatHookTypes, "afterAddMovementStat", double.class, double.class, double.class);
addMethod(id, baseClass, beforeAttackEntityFromHookTypes, "beforeAttackEntityFrom", net.minecraft.util.DamageSource.class, float.class);
addMethod(id, baseClass, overrideAttackEntityFromHookTypes, "attackEntityFrom", net.minecraft.util.DamageSource.class, float.class);
addMethod(id, baseClass, afterAttackEntityFromHookTypes, "afterAttackEntityFrom", net.minecraft.util.DamageSource.class, float.class);
addMethod(id, baseClass, beforeAttackTargetEntityWithCurrentItemHookTypes, "beforeAttackTargetEntityWithCurrentItem", net.minecraft.entity.Entity.class);
addMethod(id, baseClass, overrideAttackTargetEntityWithCurrentItemHookTypes, "attackTargetEntityWithCurrentItem", net.minecraft.entity.Entity.class);
addMethod(id, baseClass, afterAttackTargetEntityWithCurrentItemHookTypes, "afterAttackTargetEntityWithCurrentItem", net.minecraft.entity.Entity.class);
addMethod(id, baseClass, beforeCanBreatheUnderwaterHookTypes, "beforeCanBreatheUnderwater");
addMethod(id, baseClass, overrideCanBreatheUnderwaterHookTypes, "canBreatheUnderwater");
addMethod(id, baseClass, afterCanBreatheUnderwaterHookTypes, "afterCanBreatheUnderwater");
addMethod(id, baseClass, beforeCanHarvestBlockHookTypes, "beforeCanHarvestBlock", net.minecraft.block.Block.class);
addMethod(id, baseClass, overrideCanHarvestBlockHookTypes, "canHarvestBlock", net.minecraft.block.Block.class);
addMethod(id, baseClass, afterCanHarvestBlockHookTypes, "afterCanHarvestBlock", net.minecraft.block.Block.class);
addMethod(id, baseClass, beforeCanPlayerEditHookTypes, "beforeCanPlayerEdit", int.class, int.class, int.class, int.class, net.minecraft.item.ItemStack.class);
addMethod(id, baseClass, overrideCanPlayerEditHookTypes, "canPlayerEdit", int.class, int.class, int.class, int.class, net.minecraft.item.ItemStack.class);
addMethod(id, baseClass, afterCanPlayerEditHookTypes, "afterCanPlayerEdit", int.class, int.class, int.class, int.class, net.minecraft.item.ItemStack.class);
addMethod(id, baseClass, beforeCanTriggerWalkingHookTypes, "beforeCanTriggerWalking");
addMethod(id, baseClass, overrideCanTriggerWalkingHookTypes, "canTriggerWalking");
addMethod(id, baseClass, afterCanTriggerWalkingHookTypes, "afterCanTriggerWalking");
addMethod(id, baseClass, beforeClonePlayerHookTypes, "beforeClonePlayer", net.minecraft.entity.player.EntityPlayer.class, boolean.class);
addMethod(id, baseClass, overrideClonePlayerHookTypes, "clonePlayer", net.minecraft.entity.player.EntityPlayer.class, boolean.class);
addMethod(id, baseClass, afterClonePlayerHookTypes, "afterClonePlayer", net.minecraft.entity.player.EntityPlayer.class, boolean.class);
addMethod(id, baseClass, beforeDamageEntityHookTypes, "beforeDamageEntity", net.minecraft.util.DamageSource.class, float.class);
addMethod(id, baseClass, overrideDamageEntityHookTypes, "damageEntity", net.minecraft.util.DamageSource.class, float.class);
addMethod(id, baseClass, afterDamageEntityHookTypes, "afterDamageEntity", net.minecraft.util.DamageSource.class, float.class);
addMethod(id, baseClass, beforeDisplayGUIChestHookTypes, "beforeDisplayGUIChest", net.minecraft.inventory.IInventory.class);
addMethod(id, baseClass, overrideDisplayGUIChestHookTypes, "displayGUIChest", net.minecraft.inventory.IInventory.class);
addMethod(id, baseClass, afterDisplayGUIChestHookTypes, "afterDisplayGUIChest", net.minecraft.inventory.IInventory.class);
addMethod(id, baseClass, beforeDisplayGUIDispenserHookTypes, "beforeDisplayGUIDispenser", net.minecraft.tileentity.TileEntityDispenser.class);
addMethod(id, baseClass, overrideDisplayGUIDispenserHookTypes, "displayGUIDispenser", net.minecraft.tileentity.TileEntityDispenser.class);
addMethod(id, baseClass, afterDisplayGUIDispenserHookTypes, "afterDisplayGUIDispenser", net.minecraft.tileentity.TileEntityDispenser.class);
addMethod(id, baseClass, beforeDisplayGUIFurnaceHookTypes, "beforeDisplayGUIFurnace", net.minecraft.tileentity.TileEntityFurnace.class);
addMethod(id, baseClass, overrideDisplayGUIFurnaceHookTypes, "displayGUIFurnace", net.minecraft.tileentity.TileEntityFurnace.class);
addMethod(id, baseClass, afterDisplayGUIFurnaceHookTypes, "afterDisplayGUIFurnace", net.minecraft.tileentity.TileEntityFurnace.class);
addMethod(id, baseClass, beforeDisplayGUIWorkbenchHookTypes, "beforeDisplayGUIWorkbench", int.class, int.class, int.class);
addMethod(id, baseClass, overrideDisplayGUIWorkbenchHookTypes, "displayGUIWorkbench", int.class, int.class, int.class);
addMethod(id, baseClass, afterDisplayGUIWorkbenchHookTypes, "afterDisplayGUIWorkbench", int.class, int.class, int.class);
addMethod(id, baseClass, beforeDropOneItemHookTypes, "beforeDropOneItem", boolean.class);
addMethod(id, baseClass, overrideDropOneItemHookTypes, "dropOneItem", boolean.class);
addMethod(id, baseClass, afterDropOneItemHookTypes, "afterDropOneItem", boolean.class);
addMethod(id, baseClass, beforeDropPlayerItemHookTypes, "beforeDropPlayerItem", net.minecraft.item.ItemStack.class, boolean.class);
addMethod(id, baseClass, overrideDropPlayerItemHookTypes, "dropPlayerItem", net.minecraft.item.ItemStack.class, boolean.class);
addMethod(id, baseClass, afterDropPlayerItemHookTypes, "afterDropPlayerItem", net.minecraft.item.ItemStack.class, boolean.class);
addMethod(id, baseClass, beforeFallHookTypes, "beforeFall", float.class);
addMethod(id, baseClass, overrideFallHookTypes, "fall", float.class);
addMethod(id, baseClass, afterFallHookTypes, "afterFall", float.class);
addMethod(id, baseClass, beforeGetAIMoveSpeedHookTypes, "beforeGetAIMoveSpeed");
addMethod(id, baseClass, overrideGetAIMoveSpeedHookTypes, "getAIMoveSpeed");
addMethod(id, baseClass, afterGetAIMoveSpeedHookTypes, "afterGetAIMoveSpeed");
addMethod(id, baseClass, beforeGetCurrentPlayerStrVsBlockHookTypes, "beforeGetCurrentPlayerStrVsBlock", net.minecraft.block.Block.class, boolean.class);
addMethod(id, baseClass, overrideGetCurrentPlayerStrVsBlockHookTypes, "getCurrentPlayerStrVsBlock", net.minecraft.block.Block.class, boolean.class);
addMethod(id, baseClass, afterGetCurrentPlayerStrVsBlockHookTypes, "afterGetCurrentPlayerStrVsBlock", net.minecraft.block.Block.class, boolean.class);
addMethod(id, baseClass, beforeGetCurrentPlayerStrVsBlockForgeHookTypes, "beforeGetCurrentPlayerStrVsBlockForge", net.minecraft.block.Block.class, boolean.class, int.class);
addMethod(id, baseClass, overrideGetCurrentPlayerStrVsBlockForgeHookTypes, "getCurrentPlayerStrVsBlockForge", net.minecraft.block.Block.class, boolean.class, int.class);
addMethod(id, baseClass, afterGetCurrentPlayerStrVsBlockForgeHookTypes, "afterGetCurrentPlayerStrVsBlockForge", net.minecraft.block.Block.class, boolean.class, int.class);
addMethod(id, baseClass, beforeGetDistanceSqHookTypes, "beforeGetDistanceSq", double.class, double.class, double.class);
addMethod(id, baseClass, overrideGetDistanceSqHookTypes, "getDistanceSq", double.class, double.class, double.class);
addMethod(id, baseClass, afterGetDistanceSqHookTypes, "afterGetDistanceSq", double.class, double.class, double.class);
addMethod(id, baseClass, beforeGetBrightnessHookTypes, "beforeGetBrightness", float.class);
addMethod(id, baseClass, overrideGetBrightnessHookTypes, "getBrightness", float.class);
addMethod(id, baseClass, afterGetBrightnessHookTypes, "afterGetBrightness", float.class);
addMethod(id, baseClass, beforeGetEyeHeightHookTypes, "beforeGetEyeHeight");
addMethod(id, baseClass, overrideGetEyeHeightHookTypes, "getEyeHeight");
addMethod(id, baseClass, afterGetEyeHeightHookTypes, "afterGetEyeHeight");
addMethod(id, baseClass, beforeHealHookTypes, "beforeHeal", float.class);
addMethod(id, baseClass, overrideHealHookTypes, "heal", float.class);
addMethod(id, baseClass, afterHealHookTypes, "afterHeal", float.class);
addMethod(id, baseClass, beforeIsEntityInsideOpaqueBlockHookTypes, "beforeIsEntityInsideOpaqueBlock");
addMethod(id, baseClass, overrideIsEntityInsideOpaqueBlockHookTypes, "isEntityInsideOpaqueBlock");
addMethod(id, baseClass, afterIsEntityInsideOpaqueBlockHookTypes, "afterIsEntityInsideOpaqueBlock");
addMethod(id, baseClass, beforeIsInWaterHookTypes, "beforeIsInWater");
addMethod(id, baseClass, overrideIsInWaterHookTypes, "isInWater");
addMethod(id, baseClass, afterIsInWaterHookTypes, "afterIsInWater");
addMethod(id, baseClass, beforeIsInsideOfMaterialHookTypes, "beforeIsInsideOfMaterial", net.minecraft.block.material.Material.class);
addMethod(id, baseClass, overrideIsInsideOfMaterialHookTypes, "isInsideOfMaterial", net.minecraft.block.material.Material.class);
addMethod(id, baseClass, afterIsInsideOfMaterialHookTypes, "afterIsInsideOfMaterial", net.minecraft.block.material.Material.class);
addMethod(id, baseClass, beforeIsOnLadderHookTypes, "beforeIsOnLadder");
addMethod(id, baseClass, overrideIsOnLadderHookTypes, "isOnLadder");
addMethod(id, baseClass, afterIsOnLadderHookTypes, "afterIsOnLadder");
addMethod(id, baseClass, beforeIsPlayerSleepingHookTypes, "beforeIsPlayerSleeping");
addMethod(id, baseClass, overrideIsPlayerSleepingHookTypes, "isPlayerSleeping");
addMethod(id, baseClass, afterIsPlayerSleepingHookTypes, "afterIsPlayerSleeping");
addMethod(id, baseClass, beforeJumpHookTypes, "beforeJump");
addMethod(id, baseClass, overrideJumpHookTypes, "jump");
addMethod(id, baseClass, afterJumpHookTypes, "afterJump");
addMethod(id, baseClass, beforeKnockBackHookTypes, "beforeKnockBack", net.minecraft.entity.Entity.class, float.class, double.class, double.class);
addMethod(id, baseClass, overrideKnockBackHookTypes, "knockBack", net.minecraft.entity.Entity.class, float.class, double.class, double.class);
addMethod(id, baseClass, afterKnockBackHookTypes, "afterKnockBack", net.minecraft.entity.Entity.class, float.class, double.class, double.class);
addMethod(id, baseClass, beforeMoveEntityHookTypes, "beforeMoveEntity", double.class, double.class, double.class);
addMethod(id, baseClass, overrideMoveEntityHookTypes, "moveEntity", double.class, double.class, double.class);
addMethod(id, baseClass, afterMoveEntityHookTypes, "afterMoveEntity", double.class, double.class, double.class);
addMethod(id, baseClass, beforeMoveEntityWithHeadingHookTypes, "beforeMoveEntityWithHeading", float.class, float.class);
addMethod(id, baseClass, overrideMoveEntityWithHeadingHookTypes, "moveEntityWithHeading", float.class, float.class);
addMethod(id, baseClass, afterMoveEntityWithHeadingHookTypes, "afterMoveEntityWithHeading", float.class, float.class);
addMethod(id, baseClass, beforeMoveFlyingHookTypes, "beforeMoveFlying", float.class, float.class, float.class);
addMethod(id, baseClass, overrideMoveFlyingHookTypes, "moveFlying", float.class, float.class, float.class);
addMethod(id, baseClass, afterMoveFlyingHookTypes, "afterMoveFlying", float.class, float.class, float.class);
addMethod(id, baseClass, beforeOnDeathHookTypes, "beforeOnDeath", net.minecraft.util.DamageSource.class);
addMethod(id, baseClass, overrideOnDeathHookTypes, "onDeath", net.minecraft.util.DamageSource.class);
addMethod(id, baseClass, afterOnDeathHookTypes, "afterOnDeath", net.minecraft.util.DamageSource.class);
addMethod(id, baseClass, beforeOnLivingUpdateHookTypes, "beforeOnLivingUpdate");
addMethod(id, baseClass, overrideOnLivingUpdateHookTypes, "onLivingUpdate");
addMethod(id, baseClass, afterOnLivingUpdateHookTypes, "afterOnLivingUpdate");
addMethod(id, baseClass, beforeOnKillEntityHookTypes, "beforeOnKillEntity", net.minecraft.entity.EntityLivingBase.class);
addMethod(id, baseClass, overrideOnKillEntityHookTypes, "onKillEntity", net.minecraft.entity.EntityLivingBase.class);
addMethod(id, baseClass, afterOnKillEntityHookTypes, "afterOnKillEntity", net.minecraft.entity.EntityLivingBase.class);
addMethod(id, baseClass, beforeOnStruckByLightningHookTypes, "beforeOnStruckByLightning", net.minecraft.entity.effect.EntityLightningBolt.class);
addMethod(id, baseClass, overrideOnStruckByLightningHookTypes, "onStruckByLightning", net.minecraft.entity.effect.EntityLightningBolt.class);
addMethod(id, baseClass, afterOnStruckByLightningHookTypes, "afterOnStruckByLightning", net.minecraft.entity.effect.EntityLightningBolt.class);
addMethod(id, baseClass, beforeOnUpdateHookTypes, "beforeOnUpdate");
addMethod(id, baseClass, overrideOnUpdateHookTypes, "onUpdate");
addMethod(id, baseClass, afterOnUpdateHookTypes, "afterOnUpdate");
addMethod(id, baseClass, beforeOnUpdateEntityHookTypes, "beforeOnUpdateEntity");
addMethod(id, baseClass, overrideOnUpdateEntityHookTypes, "onUpdateEntity");
addMethod(id, baseClass, afterOnUpdateEntityHookTypes, "afterOnUpdateEntity");
addMethod(id, baseClass, beforeReadEntityFromNBTHookTypes, "beforeReadEntityFromNBT", net.minecraft.nbt.NBTTagCompound.class);
addMethod(id, baseClass, overrideReadEntityFromNBTHookTypes, "readEntityFromNBT", net.minecraft.nbt.NBTTagCompound.class);
addMethod(id, baseClass, afterReadEntityFromNBTHookTypes, "afterReadEntityFromNBT", net.minecraft.nbt.NBTTagCompound.class);
addMethod(id, baseClass, beforeSetDeadHookTypes, "beforeSetDead");
addMethod(id, baseClass, overrideSetDeadHookTypes, "setDead");
addMethod(id, baseClass, afterSetDeadHookTypes, "afterSetDead");
addMethod(id, baseClass, beforeSetEntityActionStateHookTypes, "beforeSetEntityActionState", float.class, float.class, boolean.class, boolean.class);
addMethod(id, baseClass, overrideSetEntityActionStateHookTypes, "setEntityActionState", float.class, float.class, boolean.class, boolean.class);
addMethod(id, baseClass, afterSetEntityActionStateHookTypes, "afterSetEntityActionState", float.class, float.class, boolean.class, boolean.class);
addMethod(id, baseClass, beforeSetPositionHookTypes, "beforeSetPosition", double.class, double.class, double.class);
addMethod(id, baseClass, overrideSetPositionHookTypes, "setPosition", double.class, double.class, double.class);
addMethod(id, baseClass, afterSetPositionHookTypes, "afterSetPosition", double.class, double.class, double.class);
addMethod(id, baseClass, beforeSetSneakingHookTypes, "beforeSetSneaking", boolean.class);
addMethod(id, baseClass, overrideSetSneakingHookTypes, "setSneaking", boolean.class);
addMethod(id, baseClass, afterSetSneakingHookTypes, "afterSetSneaking", boolean.class);
addMethod(id, baseClass, beforeSetSprintingHookTypes, "beforeSetSprinting", boolean.class);
addMethod(id, baseClass, overrideSetSprintingHookTypes, "setSprinting", boolean.class);
addMethod(id, baseClass, afterSetSprintingHookTypes, "afterSetSprinting", boolean.class);
addMethod(id, baseClass, beforeSwingItemHookTypes, "beforeSwingItem");
addMethod(id, baseClass, overrideSwingItemHookTypes, "swingItem");
addMethod(id, baseClass, afterSwingItemHookTypes, "afterSwingItem");
addMethod(id, baseClass, beforeUpdateEntityActionStateHookTypes, "beforeUpdateEntityActionState");
addMethod(id, baseClass, overrideUpdateEntityActionStateHookTypes, "updateEntityActionState");
addMethod(id, baseClass, afterUpdateEntityActionStateHookTypes, "afterUpdateEntityActionState");
addMethod(id, baseClass, beforeUpdatePotionEffectsHookTypes, "beforeUpdatePotionEffects");
addMethod(id, baseClass, overrideUpdatePotionEffectsHookTypes, "updatePotionEffects");
addMethod(id, baseClass, afterUpdatePotionEffectsHookTypes, "afterUpdatePotionEffects");
addMethod(id, baseClass, beforeWriteEntityToNBTHookTypes, "beforeWriteEntityToNBT", net.minecraft.nbt.NBTTagCompound.class);
addMethod(id, baseClass, overrideWriteEntityToNBTHookTypes, "writeEntityToNBT", net.minecraft.nbt.NBTTagCompound.class);
addMethod(id, baseClass, afterWriteEntityToNBTHookTypes, "afterWriteEntityToNBT", net.minecraft.nbt.NBTTagCompound.class);
addDynamicMethods(id, baseClass);
addDynamicKeys(id, baseClass, beforeDynamicHookMethods, beforeDynamicHookTypes);
addDynamicKeys(id, baseClass, overrideDynamicHookMethods, overrideDynamicHookTypes);
addDynamicKeys(id, baseClass, afterDynamicHookMethods, afterDynamicHookTypes);
initialize();
for(IServerPlayerAPI instance : getAllInstancesList())
instance.getServerPlayerAPI().attachServerPlayerBase(id);
System.out.println("Server Player: registered " + id);
logger.fine("Server Player: registered class '" + baseClass.getName() + "' with id '" + id + "'");
initialized = false;
}
public static boolean unregister(String id)
{
if(id == null)
return false;
Constructor<?> constructor = allBaseConstructors.remove(id);
if(constructor == null)
return false;
for(IServerPlayerAPI instance : getAllInstancesList())
instance.getServerPlayerAPI().detachServerPlayerBase(id);
beforeLocalConstructingHookTypes.remove(id);
afterLocalConstructingHookTypes.remove(id);
allBaseBeforeAddExhaustionSuperiors.remove(id);
allBaseBeforeAddExhaustionInferiors.remove(id);
allBaseOverrideAddExhaustionSuperiors.remove(id);
allBaseOverrideAddExhaustionInferiors.remove(id);
allBaseAfterAddExhaustionSuperiors.remove(id);
allBaseAfterAddExhaustionInferiors.remove(id);
beforeAddExhaustionHookTypes.remove(id);
overrideAddExhaustionHookTypes.remove(id);
afterAddExhaustionHookTypes.remove(id);
allBaseBeforeAddExperienceSuperiors.remove(id);
allBaseBeforeAddExperienceInferiors.remove(id);
allBaseOverrideAddExperienceSuperiors.remove(id);
allBaseOverrideAddExperienceInferiors.remove(id);
allBaseAfterAddExperienceSuperiors.remove(id);
allBaseAfterAddExperienceInferiors.remove(id);
beforeAddExperienceHookTypes.remove(id);
overrideAddExperienceHookTypes.remove(id);
afterAddExperienceHookTypes.remove(id);
allBaseBeforeAddExperienceLevelSuperiors.remove(id);
allBaseBeforeAddExperienceLevelInferiors.remove(id);
allBaseOverrideAddExperienceLevelSuperiors.remove(id);
allBaseOverrideAddExperienceLevelInferiors.remove(id);
allBaseAfterAddExperienceLevelSuperiors.remove(id);
allBaseAfterAddExperienceLevelInferiors.remove(id);
beforeAddExperienceLevelHookTypes.remove(id);
overrideAddExperienceLevelHookTypes.remove(id);
afterAddExperienceLevelHookTypes.remove(id);
allBaseBeforeAddMovementStatSuperiors.remove(id);
allBaseBeforeAddMovementStatInferiors.remove(id);
allBaseOverrideAddMovementStatSuperiors.remove(id);
allBaseOverrideAddMovementStatInferiors.remove(id);
allBaseAfterAddMovementStatSuperiors.remove(id);
allBaseAfterAddMovementStatInferiors.remove(id);
beforeAddMovementStatHookTypes.remove(id);
overrideAddMovementStatHookTypes.remove(id);
afterAddMovementStatHookTypes.remove(id);
allBaseBeforeAttackEntityFromSuperiors.remove(id);
allBaseBeforeAttackEntityFromInferiors.remove(id);
allBaseOverrideAttackEntityFromSuperiors.remove(id);
allBaseOverrideAttackEntityFromInferiors.remove(id);
allBaseAfterAttackEntityFromSuperiors.remove(id);
allBaseAfterAttackEntityFromInferiors.remove(id);
beforeAttackEntityFromHookTypes.remove(id);
overrideAttackEntityFromHookTypes.remove(id);
afterAttackEntityFromHookTypes.remove(id);
allBaseBeforeAttackTargetEntityWithCurrentItemSuperiors.remove(id);
allBaseBeforeAttackTargetEntityWithCurrentItemInferiors.remove(id);
allBaseOverrideAttackTargetEntityWithCurrentItemSuperiors.remove(id);
allBaseOverrideAttackTargetEntityWithCurrentItemInferiors.remove(id);
allBaseAfterAttackTargetEntityWithCurrentItemSuperiors.remove(id);
allBaseAfterAttackTargetEntityWithCurrentItemInferiors.remove(id);
beforeAttackTargetEntityWithCurrentItemHookTypes.remove(id);
overrideAttackTargetEntityWithCurrentItemHookTypes.remove(id);
afterAttackTargetEntityWithCurrentItemHookTypes.remove(id);
allBaseBeforeCanBreatheUnderwaterSuperiors.remove(id);
allBaseBeforeCanBreatheUnderwaterInferiors.remove(id);
allBaseOverrideCanBreatheUnderwaterSuperiors.remove(id);
allBaseOverrideCanBreatheUnderwaterInferiors.remove(id);
allBaseAfterCanBreatheUnderwaterSuperiors.remove(id);
allBaseAfterCanBreatheUnderwaterInferiors.remove(id);
beforeCanBreatheUnderwaterHookTypes.remove(id);
overrideCanBreatheUnderwaterHookTypes.remove(id);
afterCanBreatheUnderwaterHookTypes.remove(id);
allBaseBeforeCanHarvestBlockSuperiors.remove(id);
allBaseBeforeCanHarvestBlockInferiors.remove(id);
allBaseOverrideCanHarvestBlockSuperiors.remove(id);
allBaseOverrideCanHarvestBlockInferiors.remove(id);
allBaseAfterCanHarvestBlockSuperiors.remove(id);
allBaseAfterCanHarvestBlockInferiors.remove(id);
beforeCanHarvestBlockHookTypes.remove(id);
overrideCanHarvestBlockHookTypes.remove(id);
afterCanHarvestBlockHookTypes.remove(id);
allBaseBeforeCanPlayerEditSuperiors.remove(id);
allBaseBeforeCanPlayerEditInferiors.remove(id);
allBaseOverrideCanPlayerEditSuperiors.remove(id);
allBaseOverrideCanPlayerEditInferiors.remove(id);
allBaseAfterCanPlayerEditSuperiors.remove(id);
allBaseAfterCanPlayerEditInferiors.remove(id);
beforeCanPlayerEditHookTypes.remove(id);
overrideCanPlayerEditHookTypes.remove(id);
afterCanPlayerEditHookTypes.remove(id);
allBaseBeforeCanTriggerWalkingSuperiors.remove(id);
allBaseBeforeCanTriggerWalkingInferiors.remove(id);
allBaseOverrideCanTriggerWalkingSuperiors.remove(id);
allBaseOverrideCanTriggerWalkingInferiors.remove(id);
allBaseAfterCanTriggerWalkingSuperiors.remove(id);
allBaseAfterCanTriggerWalkingInferiors.remove(id);
beforeCanTriggerWalkingHookTypes.remove(id);
overrideCanTriggerWalkingHookTypes.remove(id);
afterCanTriggerWalkingHookTypes.remove(id);
allBaseBeforeClonePlayerSuperiors.remove(id);
allBaseBeforeClonePlayerInferiors.remove(id);
allBaseOverrideClonePlayerSuperiors.remove(id);
allBaseOverrideClonePlayerInferiors.remove(id);
allBaseAfterClonePlayerSuperiors.remove(id);
allBaseAfterClonePlayerInferiors.remove(id);
beforeClonePlayerHookTypes.remove(id);
overrideClonePlayerHookTypes.remove(id);
afterClonePlayerHookTypes.remove(id);
allBaseBeforeDamageEntitySuperiors.remove(id);
allBaseBeforeDamageEntityInferiors.remove(id);
allBaseOverrideDamageEntitySuperiors.remove(id);
allBaseOverrideDamageEntityInferiors.remove(id);
allBaseAfterDamageEntitySuperiors.remove(id);
allBaseAfterDamageEntityInferiors.remove(id);
beforeDamageEntityHookTypes.remove(id);
overrideDamageEntityHookTypes.remove(id);
afterDamageEntityHookTypes.remove(id);
allBaseBeforeDisplayGUIChestSuperiors.remove(id);
allBaseBeforeDisplayGUIChestInferiors.remove(id);
allBaseOverrideDisplayGUIChestSuperiors.remove(id);
allBaseOverrideDisplayGUIChestInferiors.remove(id);
allBaseAfterDisplayGUIChestSuperiors.remove(id);
allBaseAfterDisplayGUIChestInferiors.remove(id);
beforeDisplayGUIChestHookTypes.remove(id);
overrideDisplayGUIChestHookTypes.remove(id);
afterDisplayGUIChestHookTypes.remove(id);
allBaseBeforeDisplayGUIDispenserSuperiors.remove(id);
allBaseBeforeDisplayGUIDispenserInferiors.remove(id);
allBaseOverrideDisplayGUIDispenserSuperiors.remove(id);
allBaseOverrideDisplayGUIDispenserInferiors.remove(id);
allBaseAfterDisplayGUIDispenserSuperiors.remove(id);
allBaseAfterDisplayGUIDispenserInferiors.remove(id);
beforeDisplayGUIDispenserHookTypes.remove(id);
overrideDisplayGUIDispenserHookTypes.remove(id);
afterDisplayGUIDispenserHookTypes.remove(id);
allBaseBeforeDisplayGUIFurnaceSuperiors.remove(id);
allBaseBeforeDisplayGUIFurnaceInferiors.remove(id);
allBaseOverrideDisplayGUIFurnaceSuperiors.remove(id);
allBaseOverrideDisplayGUIFurnaceInferiors.remove(id);
allBaseAfterDisplayGUIFurnaceSuperiors.remove(id);
allBaseAfterDisplayGUIFurnaceInferiors.remove(id);
beforeDisplayGUIFurnaceHookTypes.remove(id);
overrideDisplayGUIFurnaceHookTypes.remove(id);
afterDisplayGUIFurnaceHookTypes.remove(id);
allBaseBeforeDisplayGUIWorkbenchSuperiors.remove(id);
allBaseBeforeDisplayGUIWorkbenchInferiors.remove(id);
allBaseOverrideDisplayGUIWorkbenchSuperiors.remove(id);
allBaseOverrideDisplayGUIWorkbenchInferiors.remove(id);
allBaseAfterDisplayGUIWorkbenchSuperiors.remove(id);
allBaseAfterDisplayGUIWorkbenchInferiors.remove(id);
beforeDisplayGUIWorkbenchHookTypes.remove(id);
overrideDisplayGUIWorkbenchHookTypes.remove(id);
afterDisplayGUIWorkbenchHookTypes.remove(id);
allBaseBeforeDropOneItemSuperiors.remove(id);
allBaseBeforeDropOneItemInferiors.remove(id);
allBaseOverrideDropOneItemSuperiors.remove(id);
allBaseOverrideDropOneItemInferiors.remove(id);
allBaseAfterDropOneItemSuperiors.remove(id);
allBaseAfterDropOneItemInferiors.remove(id);
beforeDropOneItemHookTypes.remove(id);
overrideDropOneItemHookTypes.remove(id);
afterDropOneItemHookTypes.remove(id);
allBaseBeforeDropPlayerItemSuperiors.remove(id);
allBaseBeforeDropPlayerItemInferiors.remove(id);
allBaseOverrideDropPlayerItemSuperiors.remove(id);
allBaseOverrideDropPlayerItemInferiors.remove(id);
allBaseAfterDropPlayerItemSuperiors.remove(id);
allBaseAfterDropPlayerItemInferiors.remove(id);
beforeDropPlayerItemHookTypes.remove(id);
overrideDropPlayerItemHookTypes.remove(id);
afterDropPlayerItemHookTypes.remove(id);
allBaseBeforeFallSuperiors.remove(id);
allBaseBeforeFallInferiors.remove(id);
allBaseOverrideFallSuperiors.remove(id);
allBaseOverrideFallInferiors.remove(id);
allBaseAfterFallSuperiors.remove(id);
allBaseAfterFallInferiors.remove(id);
beforeFallHookTypes.remove(id);
overrideFallHookTypes.remove(id);
afterFallHookTypes.remove(id);
allBaseBeforeGetAIMoveSpeedSuperiors.remove(id);
allBaseBeforeGetAIMoveSpeedInferiors.remove(id);
allBaseOverrideGetAIMoveSpeedSuperiors.remove(id);
allBaseOverrideGetAIMoveSpeedInferiors.remove(id);
allBaseAfterGetAIMoveSpeedSuperiors.remove(id);
allBaseAfterGetAIMoveSpeedInferiors.remove(id);
beforeGetAIMoveSpeedHookTypes.remove(id);
overrideGetAIMoveSpeedHookTypes.remove(id);
afterGetAIMoveSpeedHookTypes.remove(id);
allBaseBeforeGetCurrentPlayerStrVsBlockSuperiors.remove(id);
allBaseBeforeGetCurrentPlayerStrVsBlockInferiors.remove(id);
allBaseOverrideGetCurrentPlayerStrVsBlockSuperiors.remove(id);
allBaseOverrideGetCurrentPlayerStrVsBlockInferiors.remove(id);
allBaseAfterGetCurrentPlayerStrVsBlockSuperiors.remove(id);
allBaseAfterGetCurrentPlayerStrVsBlockInferiors.remove(id);
beforeGetCurrentPlayerStrVsBlockHookTypes.remove(id);
overrideGetCurrentPlayerStrVsBlockHookTypes.remove(id);
afterGetCurrentPlayerStrVsBlockHookTypes.remove(id);
allBaseBeforeGetCurrentPlayerStrVsBlockForgeSuperiors.remove(id);
allBaseBeforeGetCurrentPlayerStrVsBlockForgeInferiors.remove(id);
allBaseOverrideGetCurrentPlayerStrVsBlockForgeSuperiors.remove(id);
allBaseOverrideGetCurrentPlayerStrVsBlockForgeInferiors.remove(id);
allBaseAfterGetCurrentPlayerStrVsBlockForgeSuperiors.remove(id);
allBaseAfterGetCurrentPlayerStrVsBlockForgeInferiors.remove(id);
beforeGetCurrentPlayerStrVsBlockForgeHookTypes.remove(id);
overrideGetCurrentPlayerStrVsBlockForgeHookTypes.remove(id);
afterGetCurrentPlayerStrVsBlockForgeHookTypes.remove(id);
allBaseBeforeGetDistanceSqSuperiors.remove(id);
allBaseBeforeGetDistanceSqInferiors.remove(id);
allBaseOverrideGetDistanceSqSuperiors.remove(id);
allBaseOverrideGetDistanceSqInferiors.remove(id);
allBaseAfterGetDistanceSqSuperiors.remove(id);
allBaseAfterGetDistanceSqInferiors.remove(id);
beforeGetDistanceSqHookTypes.remove(id);
overrideGetDistanceSqHookTypes.remove(id);
afterGetDistanceSqHookTypes.remove(id);
allBaseBeforeGetBrightnessSuperiors.remove(id);
allBaseBeforeGetBrightnessInferiors.remove(id);
allBaseOverrideGetBrightnessSuperiors.remove(id);
allBaseOverrideGetBrightnessInferiors.remove(id);
allBaseAfterGetBrightnessSuperiors.remove(id);
allBaseAfterGetBrightnessInferiors.remove(id);
beforeGetBrightnessHookTypes.remove(id);
overrideGetBrightnessHookTypes.remove(id);
afterGetBrightnessHookTypes.remove(id);
allBaseBeforeGetEyeHeightSuperiors.remove(id);
allBaseBeforeGetEyeHeightInferiors.remove(id);
allBaseOverrideGetEyeHeightSuperiors.remove(id);
allBaseOverrideGetEyeHeightInferiors.remove(id);
allBaseAfterGetEyeHeightSuperiors.remove(id);
allBaseAfterGetEyeHeightInferiors.remove(id);
beforeGetEyeHeightHookTypes.remove(id);
overrideGetEyeHeightHookTypes.remove(id);
afterGetEyeHeightHookTypes.remove(id);
allBaseBeforeHealSuperiors.remove(id);
allBaseBeforeHealInferiors.remove(id);
allBaseOverrideHealSuperiors.remove(id);
allBaseOverrideHealInferiors.remove(id);
allBaseAfterHealSuperiors.remove(id);
allBaseAfterHealInferiors.remove(id);
beforeHealHookTypes.remove(id);
overrideHealHookTypes.remove(id);
afterHealHookTypes.remove(id);
allBaseBeforeIsEntityInsideOpaqueBlockSuperiors.remove(id);
allBaseBeforeIsEntityInsideOpaqueBlockInferiors.remove(id);
allBaseOverrideIsEntityInsideOpaqueBlockSuperiors.remove(id);
allBaseOverrideIsEntityInsideOpaqueBlockInferiors.remove(id);
allBaseAfterIsEntityInsideOpaqueBlockSuperiors.remove(id);
allBaseAfterIsEntityInsideOpaqueBlockInferiors.remove(id);
beforeIsEntityInsideOpaqueBlockHookTypes.remove(id);
overrideIsEntityInsideOpaqueBlockHookTypes.remove(id);
afterIsEntityInsideOpaqueBlockHookTypes.remove(id);
allBaseBeforeIsInWaterSuperiors.remove(id);
allBaseBeforeIsInWaterInferiors.remove(id);
allBaseOverrideIsInWaterSuperiors.remove(id);
allBaseOverrideIsInWaterInferiors.remove(id);
allBaseAfterIsInWaterSuperiors.remove(id);
allBaseAfterIsInWaterInferiors.remove(id);
beforeIsInWaterHookTypes.remove(id);
overrideIsInWaterHookTypes.remove(id);
afterIsInWaterHookTypes.remove(id);
allBaseBeforeIsInsideOfMaterialSuperiors.remove(id);
allBaseBeforeIsInsideOfMaterialInferiors.remove(id);
allBaseOverrideIsInsideOfMaterialSuperiors.remove(id);
allBaseOverrideIsInsideOfMaterialInferiors.remove(id);
allBaseAfterIsInsideOfMaterialSuperiors.remove(id);
allBaseAfterIsInsideOfMaterialInferiors.remove(id);
beforeIsInsideOfMaterialHookTypes.remove(id);
overrideIsInsideOfMaterialHookTypes.remove(id);
afterIsInsideOfMaterialHookTypes.remove(id);
allBaseBeforeIsOnLadderSuperiors.remove(id);
allBaseBeforeIsOnLadderInferiors.remove(id);
allBaseOverrideIsOnLadderSuperiors.remove(id);
allBaseOverrideIsOnLadderInferiors.remove(id);
allBaseAfterIsOnLadderSuperiors.remove(id);
allBaseAfterIsOnLadderInferiors.remove(id);
beforeIsOnLadderHookTypes.remove(id);
overrideIsOnLadderHookTypes.remove(id);
afterIsOnLadderHookTypes.remove(id);
allBaseBeforeIsPlayerSleepingSuperiors.remove(id);
allBaseBeforeIsPlayerSleepingInferiors.remove(id);
allBaseOverrideIsPlayerSleepingSuperiors.remove(id);
allBaseOverrideIsPlayerSleepingInferiors.remove(id);
allBaseAfterIsPlayerSleepingSuperiors.remove(id);
allBaseAfterIsPlayerSleepingInferiors.remove(id);
beforeIsPlayerSleepingHookTypes.remove(id);
overrideIsPlayerSleepingHookTypes.remove(id);
afterIsPlayerSleepingHookTypes.remove(id);
allBaseBeforeJumpSuperiors.remove(id);
allBaseBeforeJumpInferiors.remove(id);
allBaseOverrideJumpSuperiors.remove(id);
allBaseOverrideJumpInferiors.remove(id);
allBaseAfterJumpSuperiors.remove(id);
allBaseAfterJumpInferiors.remove(id);
beforeJumpHookTypes.remove(id);
overrideJumpHookTypes.remove(id);
afterJumpHookTypes.remove(id);
allBaseBeforeKnockBackSuperiors.remove(id);
allBaseBeforeKnockBackInferiors.remove(id);
allBaseOverrideKnockBackSuperiors.remove(id);
allBaseOverrideKnockBackInferiors.remove(id);
allBaseAfterKnockBackSuperiors.remove(id);
allBaseAfterKnockBackInferiors.remove(id);
beforeKnockBackHookTypes.remove(id);
overrideKnockBackHookTypes.remove(id);
afterKnockBackHookTypes.remove(id);
allBaseBeforeMoveEntitySuperiors.remove(id);
allBaseBeforeMoveEntityInferiors.remove(id);
allBaseOverrideMoveEntitySuperiors.remove(id);
allBaseOverrideMoveEntityInferiors.remove(id);
allBaseAfterMoveEntitySuperiors.remove(id);
allBaseAfterMoveEntityInferiors.remove(id);
beforeMoveEntityHookTypes.remove(id);
overrideMoveEntityHookTypes.remove(id);
afterMoveEntityHookTypes.remove(id);
allBaseBeforeMoveEntityWithHeadingSuperiors.remove(id);
allBaseBeforeMoveEntityWithHeadingInferiors.remove(id);
allBaseOverrideMoveEntityWithHeadingSuperiors.remove(id);
allBaseOverrideMoveEntityWithHeadingInferiors.remove(id);
allBaseAfterMoveEntityWithHeadingSuperiors.remove(id);
allBaseAfterMoveEntityWithHeadingInferiors.remove(id);
beforeMoveEntityWithHeadingHookTypes.remove(id);
overrideMoveEntityWithHeadingHookTypes.remove(id);
afterMoveEntityWithHeadingHookTypes.remove(id);
allBaseBeforeMoveFlyingSuperiors.remove(id);
allBaseBeforeMoveFlyingInferiors.remove(id);
allBaseOverrideMoveFlyingSuperiors.remove(id);
allBaseOverrideMoveFlyingInferiors.remove(id);
allBaseAfterMoveFlyingSuperiors.remove(id);
allBaseAfterMoveFlyingInferiors.remove(id);
beforeMoveFlyingHookTypes.remove(id);
overrideMoveFlyingHookTypes.remove(id);
afterMoveFlyingHookTypes.remove(id);
allBaseBeforeOnDeathSuperiors.remove(id);
allBaseBeforeOnDeathInferiors.remove(id);
allBaseOverrideOnDeathSuperiors.remove(id);
allBaseOverrideOnDeathInferiors.remove(id);
allBaseAfterOnDeathSuperiors.remove(id);
allBaseAfterOnDeathInferiors.remove(id);
beforeOnDeathHookTypes.remove(id);
overrideOnDeathHookTypes.remove(id);
afterOnDeathHookTypes.remove(id);
allBaseBeforeOnLivingUpdateSuperiors.remove(id);
allBaseBeforeOnLivingUpdateInferiors.remove(id);
allBaseOverrideOnLivingUpdateSuperiors.remove(id);
allBaseOverrideOnLivingUpdateInferiors.remove(id);
allBaseAfterOnLivingUpdateSuperiors.remove(id);
allBaseAfterOnLivingUpdateInferiors.remove(id);
beforeOnLivingUpdateHookTypes.remove(id);
overrideOnLivingUpdateHookTypes.remove(id);
afterOnLivingUpdateHookTypes.remove(id);
allBaseBeforeOnKillEntitySuperiors.remove(id);
allBaseBeforeOnKillEntityInferiors.remove(id);
allBaseOverrideOnKillEntitySuperiors.remove(id);
allBaseOverrideOnKillEntityInferiors.remove(id);
allBaseAfterOnKillEntitySuperiors.remove(id);
allBaseAfterOnKillEntityInferiors.remove(id);
beforeOnKillEntityHookTypes.remove(id);
overrideOnKillEntityHookTypes.remove(id);
afterOnKillEntityHookTypes.remove(id);
allBaseBeforeOnStruckByLightningSuperiors.remove(id);
allBaseBeforeOnStruckByLightningInferiors.remove(id);
allBaseOverrideOnStruckByLightningSuperiors.remove(id);
allBaseOverrideOnStruckByLightningInferiors.remove(id);
allBaseAfterOnStruckByLightningSuperiors.remove(id);
allBaseAfterOnStruckByLightningInferiors.remove(id);
beforeOnStruckByLightningHookTypes.remove(id);
overrideOnStruckByLightningHookTypes.remove(id);
afterOnStruckByLightningHookTypes.remove(id);
allBaseBeforeOnUpdateSuperiors.remove(id);
allBaseBeforeOnUpdateInferiors.remove(id);
allBaseOverrideOnUpdateSuperiors.remove(id);
allBaseOverrideOnUpdateInferiors.remove(id);
allBaseAfterOnUpdateSuperiors.remove(id);
allBaseAfterOnUpdateInferiors.remove(id);
beforeOnUpdateHookTypes.remove(id);
overrideOnUpdateHookTypes.remove(id);
afterOnUpdateHookTypes.remove(id);
allBaseBeforeOnUpdateEntitySuperiors.remove(id);
allBaseBeforeOnUpdateEntityInferiors.remove(id);
allBaseOverrideOnUpdateEntitySuperiors.remove(id);
allBaseOverrideOnUpdateEntityInferiors.remove(id);
allBaseAfterOnUpdateEntitySuperiors.remove(id);
allBaseAfterOnUpdateEntityInferiors.remove(id);
beforeOnUpdateEntityHookTypes.remove(id);
overrideOnUpdateEntityHookTypes.remove(id);
afterOnUpdateEntityHookTypes.remove(id);
allBaseBeforeReadEntityFromNBTSuperiors.remove(id);
allBaseBeforeReadEntityFromNBTInferiors.remove(id);
allBaseOverrideReadEntityFromNBTSuperiors.remove(id);
allBaseOverrideReadEntityFromNBTInferiors.remove(id);
allBaseAfterReadEntityFromNBTSuperiors.remove(id);
allBaseAfterReadEntityFromNBTInferiors.remove(id);
beforeReadEntityFromNBTHookTypes.remove(id);
overrideReadEntityFromNBTHookTypes.remove(id);
afterReadEntityFromNBTHookTypes.remove(id);
allBaseBeforeSetDeadSuperiors.remove(id);
allBaseBeforeSetDeadInferiors.remove(id);
allBaseOverrideSetDeadSuperiors.remove(id);
allBaseOverrideSetDeadInferiors.remove(id);
allBaseAfterSetDeadSuperiors.remove(id);
allBaseAfterSetDeadInferiors.remove(id);
beforeSetDeadHookTypes.remove(id);
overrideSetDeadHookTypes.remove(id);
afterSetDeadHookTypes.remove(id);
allBaseBeforeSetEntityActionStateSuperiors.remove(id);
allBaseBeforeSetEntityActionStateInferiors.remove(id);
allBaseOverrideSetEntityActionStateSuperiors.remove(id);
allBaseOverrideSetEntityActionStateInferiors.remove(id);
allBaseAfterSetEntityActionStateSuperiors.remove(id);
allBaseAfterSetEntityActionStateInferiors.remove(id);
beforeSetEntityActionStateHookTypes.remove(id);
overrideSetEntityActionStateHookTypes.remove(id);
afterSetEntityActionStateHookTypes.remove(id);
allBaseBeforeSetPositionSuperiors.remove(id);
allBaseBeforeSetPositionInferiors.remove(id);
allBaseOverrideSetPositionSuperiors.remove(id);
allBaseOverrideSetPositionInferiors.remove(id);
allBaseAfterSetPositionSuperiors.remove(id);
allBaseAfterSetPositionInferiors.remove(id);
beforeSetPositionHookTypes.remove(id);
overrideSetPositionHookTypes.remove(id);
afterSetPositionHookTypes.remove(id);
allBaseBeforeSetSneakingSuperiors.remove(id);
allBaseBeforeSetSneakingInferiors.remove(id);
allBaseOverrideSetSneakingSuperiors.remove(id);
allBaseOverrideSetSneakingInferiors.remove(id);
allBaseAfterSetSneakingSuperiors.remove(id);
allBaseAfterSetSneakingInferiors.remove(id);
beforeSetSneakingHookTypes.remove(id);
overrideSetSneakingHookTypes.remove(id);
afterSetSneakingHookTypes.remove(id);
allBaseBeforeSetSprintingSuperiors.remove(id);
allBaseBeforeSetSprintingInferiors.remove(id);
allBaseOverrideSetSprintingSuperiors.remove(id);
allBaseOverrideSetSprintingInferiors.remove(id);
allBaseAfterSetSprintingSuperiors.remove(id);
allBaseAfterSetSprintingInferiors.remove(id);
beforeSetSprintingHookTypes.remove(id);
overrideSetSprintingHookTypes.remove(id);
afterSetSprintingHookTypes.remove(id);
allBaseBeforeSwingItemSuperiors.remove(id);
allBaseBeforeSwingItemInferiors.remove(id);
allBaseOverrideSwingItemSuperiors.remove(id);
allBaseOverrideSwingItemInferiors.remove(id);
allBaseAfterSwingItemSuperiors.remove(id);
allBaseAfterSwingItemInferiors.remove(id);
beforeSwingItemHookTypes.remove(id);
overrideSwingItemHookTypes.remove(id);
afterSwingItemHookTypes.remove(id);
allBaseBeforeUpdateEntityActionStateSuperiors.remove(id);
allBaseBeforeUpdateEntityActionStateInferiors.remove(id);
allBaseOverrideUpdateEntityActionStateSuperiors.remove(id);
allBaseOverrideUpdateEntityActionStateInferiors.remove(id);
allBaseAfterUpdateEntityActionStateSuperiors.remove(id);
allBaseAfterUpdateEntityActionStateInferiors.remove(id);
beforeUpdateEntityActionStateHookTypes.remove(id);
overrideUpdateEntityActionStateHookTypes.remove(id);
afterUpdateEntityActionStateHookTypes.remove(id);
allBaseBeforeUpdatePotionEffectsSuperiors.remove(id);
allBaseBeforeUpdatePotionEffectsInferiors.remove(id);
allBaseOverrideUpdatePotionEffectsSuperiors.remove(id);
allBaseOverrideUpdatePotionEffectsInferiors.remove(id);
allBaseAfterUpdatePotionEffectsSuperiors.remove(id);
allBaseAfterUpdatePotionEffectsInferiors.remove(id);
beforeUpdatePotionEffectsHookTypes.remove(id);
overrideUpdatePotionEffectsHookTypes.remove(id);
afterUpdatePotionEffectsHookTypes.remove(id);
allBaseBeforeWriteEntityToNBTSuperiors.remove(id);
allBaseBeforeWriteEntityToNBTInferiors.remove(id);
allBaseOverrideWriteEntityToNBTSuperiors.remove(id);
allBaseOverrideWriteEntityToNBTInferiors.remove(id);
allBaseAfterWriteEntityToNBTSuperiors.remove(id);
allBaseAfterWriteEntityToNBTInferiors.remove(id);
beforeWriteEntityToNBTHookTypes.remove(id);
overrideWriteEntityToNBTHookTypes.remove(id);
afterWriteEntityToNBTHookTypes.remove(id);
Iterator<String> iterator = keysToVirtualIds.keySet().iterator();
while(iterator.hasNext())
{
String key = iterator.next();
if(keysToVirtualIds.get(key).equals(id))
keysToVirtualIds.remove(key);
}
boolean otherFound = false;
Class<?> type = constructor.getDeclaringClass();
iterator = allBaseConstructors.keySet().iterator();
while(iterator.hasNext())
{
String otherId = iterator.next();
Class<?> otherType = allBaseConstructors.get(otherId).getDeclaringClass();
if(!otherId.equals(id) && otherType.equals(type))
{
otherFound = true;
break;
}
}
if(!otherFound)
{
dynamicTypes.remove(type);
virtualDynamicHookMethods.remove(type);
beforeDynamicHookMethods.remove(type);
overrideDynamicHookMethods.remove(type);
afterDynamicHookMethods.remove(type);
}
removeDynamicHookTypes(id, beforeDynamicHookTypes);
removeDynamicHookTypes(id, overrideDynamicHookTypes);
removeDynamicHookTypes(id, afterDynamicHookTypes);
allBaseBeforeDynamicSuperiors.remove(id);
allBaseBeforeDynamicInferiors.remove(id);
allBaseOverrideDynamicSuperiors.remove(id);
allBaseOverrideDynamicInferiors.remove(id);
allBaseAfterDynamicSuperiors.remove(id);
allBaseAfterDynamicInferiors.remove(id);
log("ServerPlayerAPI: unregistered id '" + id + "'");
return true;
}
public static void removeDynamicHookTypes(String id, Map<String, List<String>> map)
{
Iterator<String> keys = map.keySet().iterator();
while(keys.hasNext())
map.get(keys.next()).remove(id);
}
public static Set<String> getRegisteredIds()
{
return unmodifiableAllIds;
}
private static void addSorting(String id, Map<String, String[]> map, String[] values)
{
if(values != null && values.length > 0)
map.put(id, values);
}
private static void addDynamicSorting(String id, Map<String, Map<String, String[]>> map, Map<String, String[]> values)
{
if(values != null && values.size() > 0)
map.put(id, values);
}
private static boolean addMethod(String id, Class<?> baseClass, List<String> list, String methodName, Class<?>... _parameterTypes)
{
try
{
Method method = baseClass.getMethod(methodName, _parameterTypes);
boolean isOverridden = method.getDeclaringClass() != ServerPlayerBase.class;
if(isOverridden)
list.add(id);
return isOverridden;
}
catch(Exception e)
{
throw new RuntimeException("Can not reflect method '" + methodName + "' of class '" + baseClass.getName() + "'", e);
}
}
private static void addDynamicMethods(String id, Class<?> baseClass)
{
if(!dynamicTypes.add(baseClass))
return;
Map<String, Method> virtuals = null;
Map<String, Method> befores = null;
Map<String, Method> overrides = null;
Map<String, Method> afters = null;
Method[] methods = baseClass.getDeclaredMethods();
for(int i=0; i<methods.length; i++)
{
Method method = methods[i];
if(method.getDeclaringClass() != baseClass)
continue;
int modifiers = method.getModifiers();
if(Modifier.isAbstract(modifiers))
continue;
if(Modifier.isStatic(modifiers))
continue;
String name = method.getName();
if(name.length() < 7 || !name.substring(0, 7).equalsIgnoreCase("dynamic"))
continue;
else
name = name.substring(7);
while(name.charAt(0) == '_')
name = name.substring(1);
boolean before = false;
boolean virtual = false;
boolean override = false;
boolean after = false;
if(name.substring(0, 7).equalsIgnoreCase("virtual"))
{
virtual = true;
name = name.substring(7);
}
else
{
if(name.length() >= 8 && name.substring(0, 8).equalsIgnoreCase("override"))
{
name = name.substring(8);
override = true;
}
else if(name.length() >= 6 && name.substring(0, 6).equalsIgnoreCase("before"))
{
before = true;
name = name.substring(6);
}
else if(name.length() >= 5 && name.substring(0, 5).equalsIgnoreCase("after"))
{
after = true;
name = name.substring(5);
}
}
if(name.length() >= 1 && (before || virtual || override || after))
name = name.substring(0,1).toLowerCase() + name.substring(1);
while(name.charAt(0) == '_')
name = name.substring(1);
if(name.length() == 0)
throw new RuntimeException("Can not process dynamic hook method with no key");
keys.add(name);
if(virtual)
{
if(keysToVirtualIds.containsKey(name))
throw new RuntimeException("Can not process more than one dynamic virtual method");
keysToVirtualIds.put(name, id);
virtuals = addDynamicMethod(name, method, virtuals);
}
else if(before)
befores = addDynamicMethod(name, method, befores);
else if(after)
afters = addDynamicMethod(name, method, afters);
else
overrides = addDynamicMethod(name, method, overrides);
}
if(virtuals != null)
virtualDynamicHookMethods.put(baseClass, virtuals);
if(befores != null)
beforeDynamicHookMethods.put(baseClass, befores);
if(overrides != null)
overrideDynamicHookMethods.put(baseClass, overrides);
if(afters != null)
afterDynamicHookMethods.put(baseClass, afters);
}
private static void addDynamicKeys(String id, Class<?> baseClass, Map<Class<?>, Map<String, Method>> dynamicHookMethods, Map<String, List<String>> dynamicHookTypes)
{
Map<String, Method> methods = dynamicHookMethods.get(baseClass);
if(methods == null || methods.size() == 0)
return;
Iterator<String> keys = methods.keySet().iterator();
while(keys.hasNext())
{
String key = keys.next();
if(!dynamicHookTypes.containsKey(key))
dynamicHookTypes.put(key, new ArrayList<String>(1));
dynamicHookTypes.get(key).add(id);
}
}
private static Map<String, Method> addDynamicMethod(String key, Method method, Map<String, Method> methods)
{
if(methods == null)
methods = new HashMap<String, Method>();
if(methods.containsKey(key))
throw new RuntimeException("method with key '" + key + "' allready exists");
methods.put(key, method);
return methods;
}
public static ServerPlayerAPI create(IServerPlayerAPI serverPlayer)
{
if(allBaseConstructors.size() > 0 && !initialized)
initialize();
return new ServerPlayerAPI(serverPlayer);
}
private static void initialize()
{
sortBases(beforeLocalConstructingHookTypes, allBaseBeforeLocalConstructingSuperiors, allBaseBeforeLocalConstructingInferiors, "beforeLocalConstructing");
sortBases(afterLocalConstructingHookTypes, allBaseAfterLocalConstructingSuperiors, allBaseAfterLocalConstructingInferiors, "afterLocalConstructing");
Iterator<String> keyIterator = keys.iterator();
while(keyIterator.hasNext())
{
String key = keyIterator.next();
sortDynamicBases(beforeDynamicHookTypes, allBaseBeforeDynamicSuperiors, allBaseBeforeDynamicInferiors, key);
sortDynamicBases(overrideDynamicHookTypes, allBaseOverrideDynamicSuperiors, allBaseOverrideDynamicInferiors, key);
sortDynamicBases(afterDynamicHookTypes, allBaseAfterDynamicSuperiors, allBaseAfterDynamicInferiors, key);
}
sortBases(beforeAddExhaustionHookTypes, allBaseBeforeAddExhaustionSuperiors, allBaseBeforeAddExhaustionInferiors, "beforeAddExhaustion");
sortBases(overrideAddExhaustionHookTypes, allBaseOverrideAddExhaustionSuperiors, allBaseOverrideAddExhaustionInferiors, "overrideAddExhaustion");
sortBases(afterAddExhaustionHookTypes, allBaseAfterAddExhaustionSuperiors, allBaseAfterAddExhaustionInferiors, "afterAddExhaustion");
sortBases(beforeAddExperienceHookTypes, allBaseBeforeAddExperienceSuperiors, allBaseBeforeAddExperienceInferiors, "beforeAddExperience");
sortBases(overrideAddExperienceHookTypes, allBaseOverrideAddExperienceSuperiors, allBaseOverrideAddExperienceInferiors, "overrideAddExperience");
sortBases(afterAddExperienceHookTypes, allBaseAfterAddExperienceSuperiors, allBaseAfterAddExperienceInferiors, "afterAddExperience");
sortBases(beforeAddExperienceLevelHookTypes, allBaseBeforeAddExperienceLevelSuperiors, allBaseBeforeAddExperienceLevelInferiors, "beforeAddExperienceLevel");
sortBases(overrideAddExperienceLevelHookTypes, allBaseOverrideAddExperienceLevelSuperiors, allBaseOverrideAddExperienceLevelInferiors, "overrideAddExperienceLevel");
sortBases(afterAddExperienceLevelHookTypes, allBaseAfterAddExperienceLevelSuperiors, allBaseAfterAddExperienceLevelInferiors, "afterAddExperienceLevel");
sortBases(beforeAddMovementStatHookTypes, allBaseBeforeAddMovementStatSuperiors, allBaseBeforeAddMovementStatInferiors, "beforeAddMovementStat");
sortBases(overrideAddMovementStatHookTypes, allBaseOverrideAddMovementStatSuperiors, allBaseOverrideAddMovementStatInferiors, "overrideAddMovementStat");
sortBases(afterAddMovementStatHookTypes, allBaseAfterAddMovementStatSuperiors, allBaseAfterAddMovementStatInferiors, "afterAddMovementStat");
sortBases(beforeAttackEntityFromHookTypes, allBaseBeforeAttackEntityFromSuperiors, allBaseBeforeAttackEntityFromInferiors, "beforeAttackEntityFrom");
sortBases(overrideAttackEntityFromHookTypes, allBaseOverrideAttackEntityFromSuperiors, allBaseOverrideAttackEntityFromInferiors, "overrideAttackEntityFrom");
sortBases(afterAttackEntityFromHookTypes, allBaseAfterAttackEntityFromSuperiors, allBaseAfterAttackEntityFromInferiors, "afterAttackEntityFrom");
sortBases(beforeAttackTargetEntityWithCurrentItemHookTypes, allBaseBeforeAttackTargetEntityWithCurrentItemSuperiors, allBaseBeforeAttackTargetEntityWithCurrentItemInferiors, "beforeAttackTargetEntityWithCurrentItem");
sortBases(overrideAttackTargetEntityWithCurrentItemHookTypes, allBaseOverrideAttackTargetEntityWithCurrentItemSuperiors, allBaseOverrideAttackTargetEntityWithCurrentItemInferiors, "overrideAttackTargetEntityWithCurrentItem");
sortBases(afterAttackTargetEntityWithCurrentItemHookTypes, allBaseAfterAttackTargetEntityWithCurrentItemSuperiors, allBaseAfterAttackTargetEntityWithCurrentItemInferiors, "afterAttackTargetEntityWithCurrentItem");
sortBases(beforeCanBreatheUnderwaterHookTypes, allBaseBeforeCanBreatheUnderwaterSuperiors, allBaseBeforeCanBreatheUnderwaterInferiors, "beforeCanBreatheUnderwater");
sortBases(overrideCanBreatheUnderwaterHookTypes, allBaseOverrideCanBreatheUnderwaterSuperiors, allBaseOverrideCanBreatheUnderwaterInferiors, "overrideCanBreatheUnderwater");
sortBases(afterCanBreatheUnderwaterHookTypes, allBaseAfterCanBreatheUnderwaterSuperiors, allBaseAfterCanBreatheUnderwaterInferiors, "afterCanBreatheUnderwater");
sortBases(beforeCanHarvestBlockHookTypes, allBaseBeforeCanHarvestBlockSuperiors, allBaseBeforeCanHarvestBlockInferiors, "beforeCanHarvestBlock");
sortBases(overrideCanHarvestBlockHookTypes, allBaseOverrideCanHarvestBlockSuperiors, allBaseOverrideCanHarvestBlockInferiors, "overrideCanHarvestBlock");
sortBases(afterCanHarvestBlockHookTypes, allBaseAfterCanHarvestBlockSuperiors, allBaseAfterCanHarvestBlockInferiors, "afterCanHarvestBlock");
sortBases(beforeCanPlayerEditHookTypes, allBaseBeforeCanPlayerEditSuperiors, allBaseBeforeCanPlayerEditInferiors, "beforeCanPlayerEdit");
sortBases(overrideCanPlayerEditHookTypes, allBaseOverrideCanPlayerEditSuperiors, allBaseOverrideCanPlayerEditInferiors, "overrideCanPlayerEdit");
sortBases(afterCanPlayerEditHookTypes, allBaseAfterCanPlayerEditSuperiors, allBaseAfterCanPlayerEditInferiors, "afterCanPlayerEdit");
sortBases(beforeCanTriggerWalkingHookTypes, allBaseBeforeCanTriggerWalkingSuperiors, allBaseBeforeCanTriggerWalkingInferiors, "beforeCanTriggerWalking");
sortBases(overrideCanTriggerWalkingHookTypes, allBaseOverrideCanTriggerWalkingSuperiors, allBaseOverrideCanTriggerWalkingInferiors, "overrideCanTriggerWalking");
sortBases(afterCanTriggerWalkingHookTypes, allBaseAfterCanTriggerWalkingSuperiors, allBaseAfterCanTriggerWalkingInferiors, "afterCanTriggerWalking");
sortBases(beforeClonePlayerHookTypes, allBaseBeforeClonePlayerSuperiors, allBaseBeforeClonePlayerInferiors, "beforeClonePlayer");
sortBases(overrideClonePlayerHookTypes, allBaseOverrideClonePlayerSuperiors, allBaseOverrideClonePlayerInferiors, "overrideClonePlayer");
sortBases(afterClonePlayerHookTypes, allBaseAfterClonePlayerSuperiors, allBaseAfterClonePlayerInferiors, "afterClonePlayer");
sortBases(beforeDamageEntityHookTypes, allBaseBeforeDamageEntitySuperiors, allBaseBeforeDamageEntityInferiors, "beforeDamageEntity");
sortBases(overrideDamageEntityHookTypes, allBaseOverrideDamageEntitySuperiors, allBaseOverrideDamageEntityInferiors, "overrideDamageEntity");
sortBases(afterDamageEntityHookTypes, allBaseAfterDamageEntitySuperiors, allBaseAfterDamageEntityInferiors, "afterDamageEntity");
sortBases(beforeDisplayGUIChestHookTypes, allBaseBeforeDisplayGUIChestSuperiors, allBaseBeforeDisplayGUIChestInferiors, "beforeDisplayGUIChest");
sortBases(overrideDisplayGUIChestHookTypes, allBaseOverrideDisplayGUIChestSuperiors, allBaseOverrideDisplayGUIChestInferiors, "overrideDisplayGUIChest");
sortBases(afterDisplayGUIChestHookTypes, allBaseAfterDisplayGUIChestSuperiors, allBaseAfterDisplayGUIChestInferiors, "afterDisplayGUIChest");
sortBases(beforeDisplayGUIDispenserHookTypes, allBaseBeforeDisplayGUIDispenserSuperiors, allBaseBeforeDisplayGUIDispenserInferiors, "beforeDisplayGUIDispenser");
sortBases(overrideDisplayGUIDispenserHookTypes, allBaseOverrideDisplayGUIDispenserSuperiors, allBaseOverrideDisplayGUIDispenserInferiors, "overrideDisplayGUIDispenser");
sortBases(afterDisplayGUIDispenserHookTypes, allBaseAfterDisplayGUIDispenserSuperiors, allBaseAfterDisplayGUIDispenserInferiors, "afterDisplayGUIDispenser");
sortBases(beforeDisplayGUIFurnaceHookTypes, allBaseBeforeDisplayGUIFurnaceSuperiors, allBaseBeforeDisplayGUIFurnaceInferiors, "beforeDisplayGUIFurnace");
sortBases(overrideDisplayGUIFurnaceHookTypes, allBaseOverrideDisplayGUIFurnaceSuperiors, allBaseOverrideDisplayGUIFurnaceInferiors, "overrideDisplayGUIFurnace");
sortBases(afterDisplayGUIFurnaceHookTypes, allBaseAfterDisplayGUIFurnaceSuperiors, allBaseAfterDisplayGUIFurnaceInferiors, "afterDisplayGUIFurnace");
sortBases(beforeDisplayGUIWorkbenchHookTypes, allBaseBeforeDisplayGUIWorkbenchSuperiors, allBaseBeforeDisplayGUIWorkbenchInferiors, "beforeDisplayGUIWorkbench");
sortBases(overrideDisplayGUIWorkbenchHookTypes, allBaseOverrideDisplayGUIWorkbenchSuperiors, allBaseOverrideDisplayGUIWorkbenchInferiors, "overrideDisplayGUIWorkbench");
sortBases(afterDisplayGUIWorkbenchHookTypes, allBaseAfterDisplayGUIWorkbenchSuperiors, allBaseAfterDisplayGUIWorkbenchInferiors, "afterDisplayGUIWorkbench");
sortBases(beforeDropOneItemHookTypes, allBaseBeforeDropOneItemSuperiors, allBaseBeforeDropOneItemInferiors, "beforeDropOneItem");
sortBases(overrideDropOneItemHookTypes, allBaseOverrideDropOneItemSuperiors, allBaseOverrideDropOneItemInferiors, "overrideDropOneItem");
sortBases(afterDropOneItemHookTypes, allBaseAfterDropOneItemSuperiors, allBaseAfterDropOneItemInferiors, "afterDropOneItem");
sortBases(beforeDropPlayerItemHookTypes, allBaseBeforeDropPlayerItemSuperiors, allBaseBeforeDropPlayerItemInferiors, "beforeDropPlayerItem");
sortBases(overrideDropPlayerItemHookTypes, allBaseOverrideDropPlayerItemSuperiors, allBaseOverrideDropPlayerItemInferiors, "overrideDropPlayerItem");
sortBases(afterDropPlayerItemHookTypes, allBaseAfterDropPlayerItemSuperiors, allBaseAfterDropPlayerItemInferiors, "afterDropPlayerItem");
sortBases(beforeFallHookTypes, allBaseBeforeFallSuperiors, allBaseBeforeFallInferiors, "beforeFall");
sortBases(overrideFallHookTypes, allBaseOverrideFallSuperiors, allBaseOverrideFallInferiors, "overrideFall");
sortBases(afterFallHookTypes, allBaseAfterFallSuperiors, allBaseAfterFallInferiors, "afterFall");
sortBases(beforeGetAIMoveSpeedHookTypes, allBaseBeforeGetAIMoveSpeedSuperiors, allBaseBeforeGetAIMoveSpeedInferiors, "beforeGetAIMoveSpeed");
sortBases(overrideGetAIMoveSpeedHookTypes, allBaseOverrideGetAIMoveSpeedSuperiors, allBaseOverrideGetAIMoveSpeedInferiors, "overrideGetAIMoveSpeed");
sortBases(afterGetAIMoveSpeedHookTypes, allBaseAfterGetAIMoveSpeedSuperiors, allBaseAfterGetAIMoveSpeedInferiors, "afterGetAIMoveSpeed");
sortBases(beforeGetCurrentPlayerStrVsBlockHookTypes, allBaseBeforeGetCurrentPlayerStrVsBlockSuperiors, allBaseBeforeGetCurrentPlayerStrVsBlockInferiors, "beforeGetCurrentPlayerStrVsBlock");
sortBases(overrideGetCurrentPlayerStrVsBlockHookTypes, allBaseOverrideGetCurrentPlayerStrVsBlockSuperiors, allBaseOverrideGetCurrentPlayerStrVsBlockInferiors, "overrideGetCurrentPlayerStrVsBlock");
sortBases(afterGetCurrentPlayerStrVsBlockHookTypes, allBaseAfterGetCurrentPlayerStrVsBlockSuperiors, allBaseAfterGetCurrentPlayerStrVsBlockInferiors, "afterGetCurrentPlayerStrVsBlock");
sortBases(beforeGetCurrentPlayerStrVsBlockForgeHookTypes, allBaseBeforeGetCurrentPlayerStrVsBlockForgeSuperiors, allBaseBeforeGetCurrentPlayerStrVsBlockForgeInferiors, "beforeGetCurrentPlayerStrVsBlockForge");
sortBases(overrideGetCurrentPlayerStrVsBlockForgeHookTypes, allBaseOverrideGetCurrentPlayerStrVsBlockForgeSuperiors, allBaseOverrideGetCurrentPlayerStrVsBlockForgeInferiors, "overrideGetCurrentPlayerStrVsBlockForge");
sortBases(afterGetCurrentPlayerStrVsBlockForgeHookTypes, allBaseAfterGetCurrentPlayerStrVsBlockForgeSuperiors, allBaseAfterGetCurrentPlayerStrVsBlockForgeInferiors, "afterGetCurrentPlayerStrVsBlockForge");
sortBases(beforeGetDistanceSqHookTypes, allBaseBeforeGetDistanceSqSuperiors, allBaseBeforeGetDistanceSqInferiors, "beforeGetDistanceSq");
sortBases(overrideGetDistanceSqHookTypes, allBaseOverrideGetDistanceSqSuperiors, allBaseOverrideGetDistanceSqInferiors, "overrideGetDistanceSq");
sortBases(afterGetDistanceSqHookTypes, allBaseAfterGetDistanceSqSuperiors, allBaseAfterGetDistanceSqInferiors, "afterGetDistanceSq");
sortBases(beforeGetBrightnessHookTypes, allBaseBeforeGetBrightnessSuperiors, allBaseBeforeGetBrightnessInferiors, "beforeGetBrightness");
sortBases(overrideGetBrightnessHookTypes, allBaseOverrideGetBrightnessSuperiors, allBaseOverrideGetBrightnessInferiors, "overrideGetBrightness");
sortBases(afterGetBrightnessHookTypes, allBaseAfterGetBrightnessSuperiors, allBaseAfterGetBrightnessInferiors, "afterGetBrightness");
sortBases(beforeGetEyeHeightHookTypes, allBaseBeforeGetEyeHeightSuperiors, allBaseBeforeGetEyeHeightInferiors, "beforeGetEyeHeight");
sortBases(overrideGetEyeHeightHookTypes, allBaseOverrideGetEyeHeightSuperiors, allBaseOverrideGetEyeHeightInferiors, "overrideGetEyeHeight");
sortBases(afterGetEyeHeightHookTypes, allBaseAfterGetEyeHeightSuperiors, allBaseAfterGetEyeHeightInferiors, "afterGetEyeHeight");
sortBases(beforeHealHookTypes, allBaseBeforeHealSuperiors, allBaseBeforeHealInferiors, "beforeHeal");
sortBases(overrideHealHookTypes, allBaseOverrideHealSuperiors, allBaseOverrideHealInferiors, "overrideHeal");
sortBases(afterHealHookTypes, allBaseAfterHealSuperiors, allBaseAfterHealInferiors, "afterHeal");
sortBases(beforeIsEntityInsideOpaqueBlockHookTypes, allBaseBeforeIsEntityInsideOpaqueBlockSuperiors, allBaseBeforeIsEntityInsideOpaqueBlockInferiors, "beforeIsEntityInsideOpaqueBlock");
sortBases(overrideIsEntityInsideOpaqueBlockHookTypes, allBaseOverrideIsEntityInsideOpaqueBlockSuperiors, allBaseOverrideIsEntityInsideOpaqueBlockInferiors, "overrideIsEntityInsideOpaqueBlock");
sortBases(afterIsEntityInsideOpaqueBlockHookTypes, allBaseAfterIsEntityInsideOpaqueBlockSuperiors, allBaseAfterIsEntityInsideOpaqueBlockInferiors, "afterIsEntityInsideOpaqueBlock");
sortBases(beforeIsInWaterHookTypes, allBaseBeforeIsInWaterSuperiors, allBaseBeforeIsInWaterInferiors, "beforeIsInWater");
sortBases(overrideIsInWaterHookTypes, allBaseOverrideIsInWaterSuperiors, allBaseOverrideIsInWaterInferiors, "overrideIsInWater");
sortBases(afterIsInWaterHookTypes, allBaseAfterIsInWaterSuperiors, allBaseAfterIsInWaterInferiors, "afterIsInWater");
sortBases(beforeIsInsideOfMaterialHookTypes, allBaseBeforeIsInsideOfMaterialSuperiors, allBaseBeforeIsInsideOfMaterialInferiors, "beforeIsInsideOfMaterial");
sortBases(overrideIsInsideOfMaterialHookTypes, allBaseOverrideIsInsideOfMaterialSuperiors, allBaseOverrideIsInsideOfMaterialInferiors, "overrideIsInsideOfMaterial");
sortBases(afterIsInsideOfMaterialHookTypes, allBaseAfterIsInsideOfMaterialSuperiors, allBaseAfterIsInsideOfMaterialInferiors, "afterIsInsideOfMaterial");
sortBases(beforeIsOnLadderHookTypes, allBaseBeforeIsOnLadderSuperiors, allBaseBeforeIsOnLadderInferiors, "beforeIsOnLadder");
sortBases(overrideIsOnLadderHookTypes, allBaseOverrideIsOnLadderSuperiors, allBaseOverrideIsOnLadderInferiors, "overrideIsOnLadder");
sortBases(afterIsOnLadderHookTypes, allBaseAfterIsOnLadderSuperiors, allBaseAfterIsOnLadderInferiors, "afterIsOnLadder");
sortBases(beforeIsPlayerSleepingHookTypes, allBaseBeforeIsPlayerSleepingSuperiors, allBaseBeforeIsPlayerSleepingInferiors, "beforeIsPlayerSleeping");
sortBases(overrideIsPlayerSleepingHookTypes, allBaseOverrideIsPlayerSleepingSuperiors, allBaseOverrideIsPlayerSleepingInferiors, "overrideIsPlayerSleeping");
sortBases(afterIsPlayerSleepingHookTypes, allBaseAfterIsPlayerSleepingSuperiors, allBaseAfterIsPlayerSleepingInferiors, "afterIsPlayerSleeping");
sortBases(beforeJumpHookTypes, allBaseBeforeJumpSuperiors, allBaseBeforeJumpInferiors, "beforeJump");
sortBases(overrideJumpHookTypes, allBaseOverrideJumpSuperiors, allBaseOverrideJumpInferiors, "overrideJump");
sortBases(afterJumpHookTypes, allBaseAfterJumpSuperiors, allBaseAfterJumpInferiors, "afterJump");
sortBases(beforeKnockBackHookTypes, allBaseBeforeKnockBackSuperiors, allBaseBeforeKnockBackInferiors, "beforeKnockBack");
sortBases(overrideKnockBackHookTypes, allBaseOverrideKnockBackSuperiors, allBaseOverrideKnockBackInferiors, "overrideKnockBack");
sortBases(afterKnockBackHookTypes, allBaseAfterKnockBackSuperiors, allBaseAfterKnockBackInferiors, "afterKnockBack");
sortBases(beforeMoveEntityHookTypes, allBaseBeforeMoveEntitySuperiors, allBaseBeforeMoveEntityInferiors, "beforeMoveEntity");
sortBases(overrideMoveEntityHookTypes, allBaseOverrideMoveEntitySuperiors, allBaseOverrideMoveEntityInferiors, "overrideMoveEntity");
sortBases(afterMoveEntityHookTypes, allBaseAfterMoveEntitySuperiors, allBaseAfterMoveEntityInferiors, "afterMoveEntity");
sortBases(beforeMoveEntityWithHeadingHookTypes, allBaseBeforeMoveEntityWithHeadingSuperiors, allBaseBeforeMoveEntityWithHeadingInferiors, "beforeMoveEntityWithHeading");
sortBases(overrideMoveEntityWithHeadingHookTypes, allBaseOverrideMoveEntityWithHeadingSuperiors, allBaseOverrideMoveEntityWithHeadingInferiors, "overrideMoveEntityWithHeading");
sortBases(afterMoveEntityWithHeadingHookTypes, allBaseAfterMoveEntityWithHeadingSuperiors, allBaseAfterMoveEntityWithHeadingInferiors, "afterMoveEntityWithHeading");
sortBases(beforeMoveFlyingHookTypes, allBaseBeforeMoveFlyingSuperiors, allBaseBeforeMoveFlyingInferiors, "beforeMoveFlying");
sortBases(overrideMoveFlyingHookTypes, allBaseOverrideMoveFlyingSuperiors, allBaseOverrideMoveFlyingInferiors, "overrideMoveFlying");
sortBases(afterMoveFlyingHookTypes, allBaseAfterMoveFlyingSuperiors, allBaseAfterMoveFlyingInferiors, "afterMoveFlying");
sortBases(beforeOnDeathHookTypes, allBaseBeforeOnDeathSuperiors, allBaseBeforeOnDeathInferiors, "beforeOnDeath");
sortBases(overrideOnDeathHookTypes, allBaseOverrideOnDeathSuperiors, allBaseOverrideOnDeathInferiors, "overrideOnDeath");
sortBases(afterOnDeathHookTypes, allBaseAfterOnDeathSuperiors, allBaseAfterOnDeathInferiors, "afterOnDeath");
sortBases(beforeOnLivingUpdateHookTypes, allBaseBeforeOnLivingUpdateSuperiors, allBaseBeforeOnLivingUpdateInferiors, "beforeOnLivingUpdate");
sortBases(overrideOnLivingUpdateHookTypes, allBaseOverrideOnLivingUpdateSuperiors, allBaseOverrideOnLivingUpdateInferiors, "overrideOnLivingUpdate");
sortBases(afterOnLivingUpdateHookTypes, allBaseAfterOnLivingUpdateSuperiors, allBaseAfterOnLivingUpdateInferiors, "afterOnLivingUpdate");
sortBases(beforeOnKillEntityHookTypes, allBaseBeforeOnKillEntitySuperiors, allBaseBeforeOnKillEntityInferiors, "beforeOnKillEntity");
sortBases(overrideOnKillEntityHookTypes, allBaseOverrideOnKillEntitySuperiors, allBaseOverrideOnKillEntityInferiors, "overrideOnKillEntity");
sortBases(afterOnKillEntityHookTypes, allBaseAfterOnKillEntitySuperiors, allBaseAfterOnKillEntityInferiors, "afterOnKillEntity");
sortBases(beforeOnStruckByLightningHookTypes, allBaseBeforeOnStruckByLightningSuperiors, allBaseBeforeOnStruckByLightningInferiors, "beforeOnStruckByLightning");
sortBases(overrideOnStruckByLightningHookTypes, allBaseOverrideOnStruckByLightningSuperiors, allBaseOverrideOnStruckByLightningInferiors, "overrideOnStruckByLightning");
sortBases(afterOnStruckByLightningHookTypes, allBaseAfterOnStruckByLightningSuperiors, allBaseAfterOnStruckByLightningInferiors, "afterOnStruckByLightning");
sortBases(beforeOnUpdateHookTypes, allBaseBeforeOnUpdateSuperiors, allBaseBeforeOnUpdateInferiors, "beforeOnUpdate");
sortBases(overrideOnUpdateHookTypes, allBaseOverrideOnUpdateSuperiors, allBaseOverrideOnUpdateInferiors, "overrideOnUpdate");
sortBases(afterOnUpdateHookTypes, allBaseAfterOnUpdateSuperiors, allBaseAfterOnUpdateInferiors, "afterOnUpdate");
sortBases(beforeOnUpdateEntityHookTypes, allBaseBeforeOnUpdateEntitySuperiors, allBaseBeforeOnUpdateEntityInferiors, "beforeOnUpdateEntity");
sortBases(overrideOnUpdateEntityHookTypes, allBaseOverrideOnUpdateEntitySuperiors, allBaseOverrideOnUpdateEntityInferiors, "overrideOnUpdateEntity");
sortBases(afterOnUpdateEntityHookTypes, allBaseAfterOnUpdateEntitySuperiors, allBaseAfterOnUpdateEntityInferiors, "afterOnUpdateEntity");
sortBases(beforeReadEntityFromNBTHookTypes, allBaseBeforeReadEntityFromNBTSuperiors, allBaseBeforeReadEntityFromNBTInferiors, "beforeReadEntityFromNBT");
sortBases(overrideReadEntityFromNBTHookTypes, allBaseOverrideReadEntityFromNBTSuperiors, allBaseOverrideReadEntityFromNBTInferiors, "overrideReadEntityFromNBT");
sortBases(afterReadEntityFromNBTHookTypes, allBaseAfterReadEntityFromNBTSuperiors, allBaseAfterReadEntityFromNBTInferiors, "afterReadEntityFromNBT");
sortBases(beforeSetDeadHookTypes, allBaseBeforeSetDeadSuperiors, allBaseBeforeSetDeadInferiors, "beforeSetDead");
sortBases(overrideSetDeadHookTypes, allBaseOverrideSetDeadSuperiors, allBaseOverrideSetDeadInferiors, "overrideSetDead");
sortBases(afterSetDeadHookTypes, allBaseAfterSetDeadSuperiors, allBaseAfterSetDeadInferiors, "afterSetDead");
sortBases(beforeSetEntityActionStateHookTypes, allBaseBeforeSetEntityActionStateSuperiors, allBaseBeforeSetEntityActionStateInferiors, "beforeSetEntityActionState");
sortBases(overrideSetEntityActionStateHookTypes, allBaseOverrideSetEntityActionStateSuperiors, allBaseOverrideSetEntityActionStateInferiors, "overrideSetEntityActionState");
sortBases(afterSetEntityActionStateHookTypes, allBaseAfterSetEntityActionStateSuperiors, allBaseAfterSetEntityActionStateInferiors, "afterSetEntityActionState");
sortBases(beforeSetPositionHookTypes, allBaseBeforeSetPositionSuperiors, allBaseBeforeSetPositionInferiors, "beforeSetPosition");
sortBases(overrideSetPositionHookTypes, allBaseOverrideSetPositionSuperiors, allBaseOverrideSetPositionInferiors, "overrideSetPosition");
sortBases(afterSetPositionHookTypes, allBaseAfterSetPositionSuperiors, allBaseAfterSetPositionInferiors, "afterSetPosition");
sortBases(beforeSetSneakingHookTypes, allBaseBeforeSetSneakingSuperiors, allBaseBeforeSetSneakingInferiors, "beforeSetSneaking");
sortBases(overrideSetSneakingHookTypes, allBaseOverrideSetSneakingSuperiors, allBaseOverrideSetSneakingInferiors, "overrideSetSneaking");
sortBases(afterSetSneakingHookTypes, allBaseAfterSetSneakingSuperiors, allBaseAfterSetSneakingInferiors, "afterSetSneaking");
sortBases(beforeSetSprintingHookTypes, allBaseBeforeSetSprintingSuperiors, allBaseBeforeSetSprintingInferiors, "beforeSetSprinting");
sortBases(overrideSetSprintingHookTypes, allBaseOverrideSetSprintingSuperiors, allBaseOverrideSetSprintingInferiors, "overrideSetSprinting");
sortBases(afterSetSprintingHookTypes, allBaseAfterSetSprintingSuperiors, allBaseAfterSetSprintingInferiors, "afterSetSprinting");
sortBases(beforeSwingItemHookTypes, allBaseBeforeSwingItemSuperiors, allBaseBeforeSwingItemInferiors, "beforeSwingItem");
sortBases(overrideSwingItemHookTypes, allBaseOverrideSwingItemSuperiors, allBaseOverrideSwingItemInferiors, "overrideSwingItem");
sortBases(afterSwingItemHookTypes, allBaseAfterSwingItemSuperiors, allBaseAfterSwingItemInferiors, "afterSwingItem");
sortBases(beforeUpdateEntityActionStateHookTypes, allBaseBeforeUpdateEntityActionStateSuperiors, allBaseBeforeUpdateEntityActionStateInferiors, "beforeUpdateEntityActionState");
sortBases(overrideUpdateEntityActionStateHookTypes, allBaseOverrideUpdateEntityActionStateSuperiors, allBaseOverrideUpdateEntityActionStateInferiors, "overrideUpdateEntityActionState");
sortBases(afterUpdateEntityActionStateHookTypes, allBaseAfterUpdateEntityActionStateSuperiors, allBaseAfterUpdateEntityActionStateInferiors, "afterUpdateEntityActionState");
sortBases(beforeUpdatePotionEffectsHookTypes, allBaseBeforeUpdatePotionEffectsSuperiors, allBaseBeforeUpdatePotionEffectsInferiors, "beforeUpdatePotionEffects");
sortBases(overrideUpdatePotionEffectsHookTypes, allBaseOverrideUpdatePotionEffectsSuperiors, allBaseOverrideUpdatePotionEffectsInferiors, "overrideUpdatePotionEffects");
sortBases(afterUpdatePotionEffectsHookTypes, allBaseAfterUpdatePotionEffectsSuperiors, allBaseAfterUpdatePotionEffectsInferiors, "afterUpdatePotionEffects");
sortBases(beforeWriteEntityToNBTHookTypes, allBaseBeforeWriteEntityToNBTSuperiors, allBaseBeforeWriteEntityToNBTInferiors, "beforeWriteEntityToNBT");
sortBases(overrideWriteEntityToNBTHookTypes, allBaseOverrideWriteEntityToNBTSuperiors, allBaseOverrideWriteEntityToNBTInferiors, "overrideWriteEntityToNBT");
sortBases(afterWriteEntityToNBTHookTypes, allBaseAfterWriteEntityToNBTSuperiors, allBaseAfterWriteEntityToNBTInferiors, "afterWriteEntityToNBT");
initialized = true;
}
private static List<IServerPlayerAPI> getAllInstancesList()
{
List<IServerPlayerAPI> result = new ArrayList<IServerPlayerAPI>();
Object entityPlayerList;
try
{
Object minecraftServer = net.minecraft.server.MinecraftServer.class.getMethod("func_71276_C").invoke(null);
Object serverConfigurationManager = minecraftServer != null ? net.minecraft.server.MinecraftServer.class.getMethod("func_71203_ab").invoke(minecraftServer) : null;
entityPlayerList = serverConfigurationManager != null ? serverConfigurationManager.getClass().getField("field_72404_b").get(serverConfigurationManager) : null;
}
catch(Exception obfuscatedException)
{
try
{
Object minecraftServer = net.minecraft.server.MinecraftServer.class.getMethod("getServer").invoke(null);
Object serverConfigurationManager = minecraftServer != null ? net.minecraft.server.MinecraftServer.class.getMethod("getConfigurationManager").invoke(minecraftServer) : null;
entityPlayerList = serverConfigurationManager != null ? serverConfigurationManager.getClass().getField("playerEntityList").get(serverConfigurationManager) : null;
}
catch(Exception deobfuscatedException)
{
throw new RuntimeException("Unable to aquire list of current server players.", obfuscatedException);
}
}
if(entityPlayerList != null)
for(Object entityPlayer : (List<?>)entityPlayerList)
result.add((IServerPlayerAPI)entityPlayer);
return result;
}
public static net.minecraft.entity.player.EntityPlayerMP[] getAllInstances()
{
List<IServerPlayerAPI> allInstances = getAllInstancesList();
return allInstances.toArray(new net.minecraft.entity.player.EntityPlayerMP[allInstances.size()]);
}
public static void beforeLocalConstructing(IServerPlayerAPI serverPlayer, net.minecraft.server.MinecraftServer paramMinecraftServer, net.minecraft.world.WorldServer paramWorldServer, com.mojang.authlib.GameProfile paramGameProfile, net.minecraft.server.management.ItemInWorldManager paramItemInWorldManager)
{
ServerPlayerAPI serverPlayerAPI = serverPlayer.getServerPlayerAPI();
if(serverPlayerAPI != null)
serverPlayerAPI.load();
if(serverPlayerAPI != null)
serverPlayerAPI.beforeLocalConstructing(paramMinecraftServer, paramWorldServer, paramGameProfile, paramItemInWorldManager);
}
public static void afterLocalConstructing(IServerPlayerAPI serverPlayer, net.minecraft.server.MinecraftServer paramMinecraftServer, net.minecraft.world.WorldServer paramWorldServer, com.mojang.authlib.GameProfile paramGameProfile, net.minecraft.server.management.ItemInWorldManager paramItemInWorldManager)
{
ServerPlayerAPI serverPlayerAPI = serverPlayer.getServerPlayerAPI();
if(serverPlayerAPI != null)
serverPlayerAPI.afterLocalConstructing(paramMinecraftServer, paramWorldServer, paramGameProfile, paramItemInWorldManager);
}
public static ServerPlayerBase getServerPlayerBase(IServerPlayerAPI serverPlayer, String baseId)
{
ServerPlayerAPI serverPlayerAPI = serverPlayer.getServerPlayerAPI();
if(serverPlayerAPI != null)
return serverPlayerAPI.getServerPlayerBase(baseId);
return null;
}
public static Set<String> getServerPlayerBaseIds(IServerPlayerAPI serverPlayer)
{
ServerPlayerAPI serverPlayerAPI = serverPlayer.getServerPlayerAPI();
Set<String> result = null;
if(serverPlayerAPI != null)
result = serverPlayerAPI.getServerPlayerBaseIds();
else
result = Collections.<String>emptySet();
return result;
}
public static Object dynamic(IServerPlayerAPI serverPlayer, String key, Object[] parameters)
{
ServerPlayerAPI serverPlayerAPI = serverPlayer.getServerPlayerAPI();
if(serverPlayerAPI != null)
return serverPlayerAPI.dynamic(key, parameters);
return null;
}
private static void sortBases(List<String> list, Map<String, String[]> allBaseSuperiors, Map<String, String[]> allBaseInferiors, String methodName)
{
new ServerPlayerBaseSorter(list, allBaseSuperiors, allBaseInferiors, methodName).Sort();
}
private final static Map<String, String[]> EmptySortMap = Collections.unmodifiableMap(new HashMap<String, String[]>());
private static void sortDynamicBases(Map<String, List<String>> lists, Map<String, Map<String, String[]>> allBaseSuperiors, Map<String, Map<String, String[]>> allBaseInferiors, String key)
{
List<String> types = lists.get(key);
if(types != null && types.size() > 1)
sortBases(types, getDynamicSorters(key, types, allBaseSuperiors), getDynamicSorters(key, types, allBaseInferiors), key);
}
private static Map<String, String[]> getDynamicSorters(String key, List<String> toSort, Map<String, Map<String, String[]>> allBaseValues)
{
Map<String, String[]> superiors = null;
Iterator<String> ids = toSort.iterator();
while(ids.hasNext())
{
String id = ids.next();
Map<String, String[]> idSuperiors = allBaseValues.get(id);
if(idSuperiors == null)
continue;
String[] keySuperiorIds = idSuperiors.get(key);
if(keySuperiorIds != null && keySuperiorIds.length > 0)
{
if(superiors == null)
superiors = new HashMap<String, String[]>(1);
superiors.put(id, keySuperiorIds);
}
}
return superiors != null ? superiors : EmptySortMap;
}
private ServerPlayerAPI(IServerPlayerAPI player)
{
this.player = player;
}
private void load()
{
Iterator<String> iterator = allBaseConstructors.keySet().iterator();
while(iterator.hasNext())
{
String id = iterator.next();
ServerPlayerBase toAttach = createServerPlayerBase(id);
toAttach.beforeBaseAttach(false);
allBaseObjects.put(id, toAttach);
baseObjectsToId.put(toAttach, id);
}
beforeLocalConstructingHooks = create(beforeLocalConstructingHookTypes);
afterLocalConstructingHooks = create(afterLocalConstructingHookTypes);
updateServerPlayerBases();
iterator = allBaseObjects.keySet().iterator();
while(iterator.hasNext())
allBaseObjects.get(iterator.next()).afterBaseAttach(false);
}
private ServerPlayerBase createServerPlayerBase(String id)
{
Constructor<?> contructor = allBaseConstructors.get(id);
ServerPlayerBase base;
try
{
if(contructor.getParameterTypes().length == 1)
base = (ServerPlayerBase)contructor.newInstance(this);
else
base = (ServerPlayerBase)contructor.newInstance(this, id);
}
catch (Exception e)
{
throw new RuntimeException("Exception while creating a ServerPlayerBase of type '" + contructor.getDeclaringClass() + "'", e);
}
return base;
}
private void updateServerPlayerBases()
{
beforeAddExhaustionHooks = create(beforeAddExhaustionHookTypes);
overrideAddExhaustionHooks = create(overrideAddExhaustionHookTypes);
afterAddExhaustionHooks = create(afterAddExhaustionHookTypes);
isAddExhaustionModded =
beforeAddExhaustionHooks != null ||
overrideAddExhaustionHooks != null ||
afterAddExhaustionHooks != null;
beforeAddExperienceHooks = create(beforeAddExperienceHookTypes);
overrideAddExperienceHooks = create(overrideAddExperienceHookTypes);
afterAddExperienceHooks = create(afterAddExperienceHookTypes);
isAddExperienceModded =
beforeAddExperienceHooks != null ||
overrideAddExperienceHooks != null ||
afterAddExperienceHooks != null;
beforeAddExperienceLevelHooks = create(beforeAddExperienceLevelHookTypes);
overrideAddExperienceLevelHooks = create(overrideAddExperienceLevelHookTypes);
afterAddExperienceLevelHooks = create(afterAddExperienceLevelHookTypes);
isAddExperienceLevelModded =
beforeAddExperienceLevelHooks != null ||
overrideAddExperienceLevelHooks != null ||
afterAddExperienceLevelHooks != null;
beforeAddMovementStatHooks = create(beforeAddMovementStatHookTypes);
overrideAddMovementStatHooks = create(overrideAddMovementStatHookTypes);
afterAddMovementStatHooks = create(afterAddMovementStatHookTypes);
isAddMovementStatModded =
beforeAddMovementStatHooks != null ||
overrideAddMovementStatHooks != null ||
afterAddMovementStatHooks != null;
beforeAttackEntityFromHooks = create(beforeAttackEntityFromHookTypes);
overrideAttackEntityFromHooks = create(overrideAttackEntityFromHookTypes);
afterAttackEntityFromHooks = create(afterAttackEntityFromHookTypes);
isAttackEntityFromModded =
beforeAttackEntityFromHooks != null ||
overrideAttackEntityFromHooks != null ||
afterAttackEntityFromHooks != null;
beforeAttackTargetEntityWithCurrentItemHooks = create(beforeAttackTargetEntityWithCurrentItemHookTypes);
overrideAttackTargetEntityWithCurrentItemHooks = create(overrideAttackTargetEntityWithCurrentItemHookTypes);
afterAttackTargetEntityWithCurrentItemHooks = create(afterAttackTargetEntityWithCurrentItemHookTypes);
isAttackTargetEntityWithCurrentItemModded =
beforeAttackTargetEntityWithCurrentItemHooks != null ||
overrideAttackTargetEntityWithCurrentItemHooks != null ||
afterAttackTargetEntityWithCurrentItemHooks != null;
beforeCanBreatheUnderwaterHooks = create(beforeCanBreatheUnderwaterHookTypes);
overrideCanBreatheUnderwaterHooks = create(overrideCanBreatheUnderwaterHookTypes);
afterCanBreatheUnderwaterHooks = create(afterCanBreatheUnderwaterHookTypes);
isCanBreatheUnderwaterModded =
beforeCanBreatheUnderwaterHooks != null ||
overrideCanBreatheUnderwaterHooks != null ||
afterCanBreatheUnderwaterHooks != null;
beforeCanHarvestBlockHooks = create(beforeCanHarvestBlockHookTypes);
overrideCanHarvestBlockHooks = create(overrideCanHarvestBlockHookTypes);
afterCanHarvestBlockHooks = create(afterCanHarvestBlockHookTypes);
isCanHarvestBlockModded =
beforeCanHarvestBlockHooks != null ||
overrideCanHarvestBlockHooks != null ||
afterCanHarvestBlockHooks != null;
beforeCanPlayerEditHooks = create(beforeCanPlayerEditHookTypes);
overrideCanPlayerEditHooks = create(overrideCanPlayerEditHookTypes);
afterCanPlayerEditHooks = create(afterCanPlayerEditHookTypes);
isCanPlayerEditModded =
beforeCanPlayerEditHooks != null ||
overrideCanPlayerEditHooks != null ||
afterCanPlayerEditHooks != null;
beforeCanTriggerWalkingHooks = create(beforeCanTriggerWalkingHookTypes);
overrideCanTriggerWalkingHooks = create(overrideCanTriggerWalkingHookTypes);
afterCanTriggerWalkingHooks = create(afterCanTriggerWalkingHookTypes);
isCanTriggerWalkingModded =
beforeCanTriggerWalkingHooks != null ||
overrideCanTriggerWalkingHooks != null ||
afterCanTriggerWalkingHooks != null;
beforeClonePlayerHooks = create(beforeClonePlayerHookTypes);
overrideClonePlayerHooks = create(overrideClonePlayerHookTypes);
afterClonePlayerHooks = create(afterClonePlayerHookTypes);
isClonePlayerModded =
beforeClonePlayerHooks != null ||
overrideClonePlayerHooks != null ||
afterClonePlayerHooks != null;
beforeDamageEntityHooks = create(beforeDamageEntityHookTypes);
overrideDamageEntityHooks = create(overrideDamageEntityHookTypes);
afterDamageEntityHooks = create(afterDamageEntityHookTypes);
isDamageEntityModded =
beforeDamageEntityHooks != null ||
overrideDamageEntityHooks != null ||
afterDamageEntityHooks != null;
beforeDisplayGUIChestHooks = create(beforeDisplayGUIChestHookTypes);
overrideDisplayGUIChestHooks = create(overrideDisplayGUIChestHookTypes);
afterDisplayGUIChestHooks = create(afterDisplayGUIChestHookTypes);
isDisplayGUIChestModded =
beforeDisplayGUIChestHooks != null ||
overrideDisplayGUIChestHooks != null ||
afterDisplayGUIChestHooks != null;
beforeDisplayGUIDispenserHooks = create(beforeDisplayGUIDispenserHookTypes);
overrideDisplayGUIDispenserHooks = create(overrideDisplayGUIDispenserHookTypes);
afterDisplayGUIDispenserHooks = create(afterDisplayGUIDispenserHookTypes);
isDisplayGUIDispenserModded =
beforeDisplayGUIDispenserHooks != null ||
overrideDisplayGUIDispenserHooks != null ||
afterDisplayGUIDispenserHooks != null;
beforeDisplayGUIFurnaceHooks = create(beforeDisplayGUIFurnaceHookTypes);
overrideDisplayGUIFurnaceHooks = create(overrideDisplayGUIFurnaceHookTypes);
afterDisplayGUIFurnaceHooks = create(afterDisplayGUIFurnaceHookTypes);
isDisplayGUIFurnaceModded =
beforeDisplayGUIFurnaceHooks != null ||
overrideDisplayGUIFurnaceHooks != null ||
afterDisplayGUIFurnaceHooks != null;
beforeDisplayGUIWorkbenchHooks = create(beforeDisplayGUIWorkbenchHookTypes);
overrideDisplayGUIWorkbenchHooks = create(overrideDisplayGUIWorkbenchHookTypes);
afterDisplayGUIWorkbenchHooks = create(afterDisplayGUIWorkbenchHookTypes);
isDisplayGUIWorkbenchModded =
beforeDisplayGUIWorkbenchHooks != null ||
overrideDisplayGUIWorkbenchHooks != null ||
afterDisplayGUIWorkbenchHooks != null;
beforeDropOneItemHooks = create(beforeDropOneItemHookTypes);
overrideDropOneItemHooks = create(overrideDropOneItemHookTypes);
afterDropOneItemHooks = create(afterDropOneItemHookTypes);
isDropOneItemModded =
beforeDropOneItemHooks != null ||
overrideDropOneItemHooks != null ||
afterDropOneItemHooks != null;
beforeDropPlayerItemHooks = create(beforeDropPlayerItemHookTypes);
overrideDropPlayerItemHooks = create(overrideDropPlayerItemHookTypes);
afterDropPlayerItemHooks = create(afterDropPlayerItemHookTypes);
isDropPlayerItemModded =
beforeDropPlayerItemHooks != null ||
overrideDropPlayerItemHooks != null ||
afterDropPlayerItemHooks != null;
beforeFallHooks = create(beforeFallHookTypes);
overrideFallHooks = create(overrideFallHookTypes);
afterFallHooks = create(afterFallHookTypes);
isFallModded =
beforeFallHooks != null ||
overrideFallHooks != null ||
afterFallHooks != null;
beforeGetAIMoveSpeedHooks = create(beforeGetAIMoveSpeedHookTypes);
overrideGetAIMoveSpeedHooks = create(overrideGetAIMoveSpeedHookTypes);
afterGetAIMoveSpeedHooks = create(afterGetAIMoveSpeedHookTypes);
isGetAIMoveSpeedModded =
beforeGetAIMoveSpeedHooks != null ||
overrideGetAIMoveSpeedHooks != null ||
afterGetAIMoveSpeedHooks != null;
beforeGetCurrentPlayerStrVsBlockHooks = create(beforeGetCurrentPlayerStrVsBlockHookTypes);
overrideGetCurrentPlayerStrVsBlockHooks = create(overrideGetCurrentPlayerStrVsBlockHookTypes);
afterGetCurrentPlayerStrVsBlockHooks = create(afterGetCurrentPlayerStrVsBlockHookTypes);
isGetCurrentPlayerStrVsBlockModded =
beforeGetCurrentPlayerStrVsBlockHooks != null ||
overrideGetCurrentPlayerStrVsBlockHooks != null ||
afterGetCurrentPlayerStrVsBlockHooks != null;
beforeGetCurrentPlayerStrVsBlockForgeHooks = create(beforeGetCurrentPlayerStrVsBlockForgeHookTypes);
overrideGetCurrentPlayerStrVsBlockForgeHooks = create(overrideGetCurrentPlayerStrVsBlockForgeHookTypes);
afterGetCurrentPlayerStrVsBlockForgeHooks = create(afterGetCurrentPlayerStrVsBlockForgeHookTypes);
isGetCurrentPlayerStrVsBlockForgeModded =
beforeGetCurrentPlayerStrVsBlockForgeHooks != null ||
overrideGetCurrentPlayerStrVsBlockForgeHooks != null ||
afterGetCurrentPlayerStrVsBlockForgeHooks != null;
beforeGetDistanceSqHooks = create(beforeGetDistanceSqHookTypes);
overrideGetDistanceSqHooks = create(overrideGetDistanceSqHookTypes);
afterGetDistanceSqHooks = create(afterGetDistanceSqHookTypes);
isGetDistanceSqModded =
beforeGetDistanceSqHooks != null ||
overrideGetDistanceSqHooks != null ||
afterGetDistanceSqHooks != null;
beforeGetBrightnessHooks = create(beforeGetBrightnessHookTypes);
overrideGetBrightnessHooks = create(overrideGetBrightnessHookTypes);
afterGetBrightnessHooks = create(afterGetBrightnessHookTypes);
isGetBrightnessModded =
beforeGetBrightnessHooks != null ||
overrideGetBrightnessHooks != null ||
afterGetBrightnessHooks != null;
beforeGetEyeHeightHooks = create(beforeGetEyeHeightHookTypes);
overrideGetEyeHeightHooks = create(overrideGetEyeHeightHookTypes);
afterGetEyeHeightHooks = create(afterGetEyeHeightHookTypes);
isGetEyeHeightModded =
beforeGetEyeHeightHooks != null ||
overrideGetEyeHeightHooks != null ||
afterGetEyeHeightHooks != null;
beforeHealHooks = create(beforeHealHookTypes);
overrideHealHooks = create(overrideHealHookTypes);
afterHealHooks = create(afterHealHookTypes);
isHealModded =
beforeHealHooks != null ||
overrideHealHooks != null ||
afterHealHooks != null;
beforeIsEntityInsideOpaqueBlockHooks = create(beforeIsEntityInsideOpaqueBlockHookTypes);
overrideIsEntityInsideOpaqueBlockHooks = create(overrideIsEntityInsideOpaqueBlockHookTypes);
afterIsEntityInsideOpaqueBlockHooks = create(afterIsEntityInsideOpaqueBlockHookTypes);
isIsEntityInsideOpaqueBlockModded =
beforeIsEntityInsideOpaqueBlockHooks != null ||
overrideIsEntityInsideOpaqueBlockHooks != null ||
afterIsEntityInsideOpaqueBlockHooks != null;
beforeIsInWaterHooks = create(beforeIsInWaterHookTypes);
overrideIsInWaterHooks = create(overrideIsInWaterHookTypes);
afterIsInWaterHooks = create(afterIsInWaterHookTypes);
isIsInWaterModded =
beforeIsInWaterHooks != null ||
overrideIsInWaterHooks != null ||
afterIsInWaterHooks != null;
beforeIsInsideOfMaterialHooks = create(beforeIsInsideOfMaterialHookTypes);
overrideIsInsideOfMaterialHooks = create(overrideIsInsideOfMaterialHookTypes);
afterIsInsideOfMaterialHooks = create(afterIsInsideOfMaterialHookTypes);
isIsInsideOfMaterialModded =
beforeIsInsideOfMaterialHooks != null ||
overrideIsInsideOfMaterialHooks != null ||
afterIsInsideOfMaterialHooks != null;
beforeIsOnLadderHooks = create(beforeIsOnLadderHookTypes);
overrideIsOnLadderHooks = create(overrideIsOnLadderHookTypes);
afterIsOnLadderHooks = create(afterIsOnLadderHookTypes);
isIsOnLadderModded =
beforeIsOnLadderHooks != null ||
overrideIsOnLadderHooks != null ||
afterIsOnLadderHooks != null;
beforeIsPlayerSleepingHooks = create(beforeIsPlayerSleepingHookTypes);
overrideIsPlayerSleepingHooks = create(overrideIsPlayerSleepingHookTypes);
afterIsPlayerSleepingHooks = create(afterIsPlayerSleepingHookTypes);
isIsPlayerSleepingModded =
beforeIsPlayerSleepingHooks != null ||
overrideIsPlayerSleepingHooks != null ||
afterIsPlayerSleepingHooks != null;
beforeJumpHooks = create(beforeJumpHookTypes);
overrideJumpHooks = create(overrideJumpHookTypes);
afterJumpHooks = create(afterJumpHookTypes);
isJumpModded =
beforeJumpHooks != null ||
overrideJumpHooks != null ||
afterJumpHooks != null;
beforeKnockBackHooks = create(beforeKnockBackHookTypes);
overrideKnockBackHooks = create(overrideKnockBackHookTypes);
afterKnockBackHooks = create(afterKnockBackHookTypes);
isKnockBackModded =
beforeKnockBackHooks != null ||
overrideKnockBackHooks != null ||
afterKnockBackHooks != null;
beforeMoveEntityHooks = create(beforeMoveEntityHookTypes);
overrideMoveEntityHooks = create(overrideMoveEntityHookTypes);
afterMoveEntityHooks = create(afterMoveEntityHookTypes);
isMoveEntityModded =
beforeMoveEntityHooks != null ||
overrideMoveEntityHooks != null ||
afterMoveEntityHooks != null;
beforeMoveEntityWithHeadingHooks = create(beforeMoveEntityWithHeadingHookTypes);
overrideMoveEntityWithHeadingHooks = create(overrideMoveEntityWithHeadingHookTypes);
afterMoveEntityWithHeadingHooks = create(afterMoveEntityWithHeadingHookTypes);
isMoveEntityWithHeadingModded =
beforeMoveEntityWithHeadingHooks != null ||
overrideMoveEntityWithHeadingHooks != null ||
afterMoveEntityWithHeadingHooks != null;
beforeMoveFlyingHooks = create(beforeMoveFlyingHookTypes);
overrideMoveFlyingHooks = create(overrideMoveFlyingHookTypes);
afterMoveFlyingHooks = create(afterMoveFlyingHookTypes);
isMoveFlyingModded =
beforeMoveFlyingHooks != null ||
overrideMoveFlyingHooks != null ||
afterMoveFlyingHooks != null;
beforeOnDeathHooks = create(beforeOnDeathHookTypes);
overrideOnDeathHooks = create(overrideOnDeathHookTypes);
afterOnDeathHooks = create(afterOnDeathHookTypes);
isOnDeathModded =
beforeOnDeathHooks != null ||
overrideOnDeathHooks != null ||
afterOnDeathHooks != null;
beforeOnLivingUpdateHooks = create(beforeOnLivingUpdateHookTypes);
overrideOnLivingUpdateHooks = create(overrideOnLivingUpdateHookTypes);
afterOnLivingUpdateHooks = create(afterOnLivingUpdateHookTypes);
isOnLivingUpdateModded =
beforeOnLivingUpdateHooks != null ||
overrideOnLivingUpdateHooks != null ||
afterOnLivingUpdateHooks != null;
beforeOnKillEntityHooks = create(beforeOnKillEntityHookTypes);
overrideOnKillEntityHooks = create(overrideOnKillEntityHookTypes);
afterOnKillEntityHooks = create(afterOnKillEntityHookTypes);
isOnKillEntityModded =
beforeOnKillEntityHooks != null ||
overrideOnKillEntityHooks != null ||
afterOnKillEntityHooks != null;
beforeOnStruckByLightningHooks = create(beforeOnStruckByLightningHookTypes);
overrideOnStruckByLightningHooks = create(overrideOnStruckByLightningHookTypes);
afterOnStruckByLightningHooks = create(afterOnStruckByLightningHookTypes);
isOnStruckByLightningModded =
beforeOnStruckByLightningHooks != null ||
overrideOnStruckByLightningHooks != null ||
afterOnStruckByLightningHooks != null;
beforeOnUpdateHooks = create(beforeOnUpdateHookTypes);
overrideOnUpdateHooks = create(overrideOnUpdateHookTypes);
afterOnUpdateHooks = create(afterOnUpdateHookTypes);
isOnUpdateModded =
beforeOnUpdateHooks != null ||
overrideOnUpdateHooks != null ||
afterOnUpdateHooks != null;
beforeOnUpdateEntityHooks = create(beforeOnUpdateEntityHookTypes);
overrideOnUpdateEntityHooks = create(overrideOnUpdateEntityHookTypes);
afterOnUpdateEntityHooks = create(afterOnUpdateEntityHookTypes);
isOnUpdateEntityModded =
beforeOnUpdateEntityHooks != null ||
overrideOnUpdateEntityHooks != null ||
afterOnUpdateEntityHooks != null;
beforeReadEntityFromNBTHooks = create(beforeReadEntityFromNBTHookTypes);
overrideReadEntityFromNBTHooks = create(overrideReadEntityFromNBTHookTypes);
afterReadEntityFromNBTHooks = create(afterReadEntityFromNBTHookTypes);
isReadEntityFromNBTModded =
beforeReadEntityFromNBTHooks != null ||
overrideReadEntityFromNBTHooks != null ||
afterReadEntityFromNBTHooks != null;
beforeSetDeadHooks = create(beforeSetDeadHookTypes);
overrideSetDeadHooks = create(overrideSetDeadHookTypes);
afterSetDeadHooks = create(afterSetDeadHookTypes);
isSetDeadModded =
beforeSetDeadHooks != null ||
overrideSetDeadHooks != null ||
afterSetDeadHooks != null;
beforeSetEntityActionStateHooks = create(beforeSetEntityActionStateHookTypes);
overrideSetEntityActionStateHooks = create(overrideSetEntityActionStateHookTypes);
afterSetEntityActionStateHooks = create(afterSetEntityActionStateHookTypes);
isSetEntityActionStateModded =
beforeSetEntityActionStateHooks != null ||
overrideSetEntityActionStateHooks != null ||
afterSetEntityActionStateHooks != null;
beforeSetPositionHooks = create(beforeSetPositionHookTypes);
overrideSetPositionHooks = create(overrideSetPositionHookTypes);
afterSetPositionHooks = create(afterSetPositionHookTypes);
isSetPositionModded =
beforeSetPositionHooks != null ||
overrideSetPositionHooks != null ||
afterSetPositionHooks != null;
beforeSetSneakingHooks = create(beforeSetSneakingHookTypes);
overrideSetSneakingHooks = create(overrideSetSneakingHookTypes);
afterSetSneakingHooks = create(afterSetSneakingHookTypes);
isSetSneakingModded =
beforeSetSneakingHooks != null ||
overrideSetSneakingHooks != null ||
afterSetSneakingHooks != null;
beforeSetSprintingHooks = create(beforeSetSprintingHookTypes);
overrideSetSprintingHooks = create(overrideSetSprintingHookTypes);
afterSetSprintingHooks = create(afterSetSprintingHookTypes);
isSetSprintingModded =
beforeSetSprintingHooks != null ||
overrideSetSprintingHooks != null ||
afterSetSprintingHooks != null;
beforeSwingItemHooks = create(beforeSwingItemHookTypes);
overrideSwingItemHooks = create(overrideSwingItemHookTypes);
afterSwingItemHooks = create(afterSwingItemHookTypes);
isSwingItemModded =
beforeSwingItemHooks != null ||
overrideSwingItemHooks != null ||
afterSwingItemHooks != null;
beforeUpdateEntityActionStateHooks = create(beforeUpdateEntityActionStateHookTypes);
overrideUpdateEntityActionStateHooks = create(overrideUpdateEntityActionStateHookTypes);
afterUpdateEntityActionStateHooks = create(afterUpdateEntityActionStateHookTypes);
isUpdateEntityActionStateModded =
beforeUpdateEntityActionStateHooks != null ||
overrideUpdateEntityActionStateHooks != null ||
afterUpdateEntityActionStateHooks != null;
beforeUpdatePotionEffectsHooks = create(beforeUpdatePotionEffectsHookTypes);
overrideUpdatePotionEffectsHooks = create(overrideUpdatePotionEffectsHookTypes);
afterUpdatePotionEffectsHooks = create(afterUpdatePotionEffectsHookTypes);
isUpdatePotionEffectsModded =
beforeUpdatePotionEffectsHooks != null ||
overrideUpdatePotionEffectsHooks != null ||
afterUpdatePotionEffectsHooks != null;
beforeWriteEntityToNBTHooks = create(beforeWriteEntityToNBTHookTypes);
overrideWriteEntityToNBTHooks = create(overrideWriteEntityToNBTHookTypes);
afterWriteEntityToNBTHooks = create(afterWriteEntityToNBTHookTypes);
isWriteEntityToNBTModded =
beforeWriteEntityToNBTHooks != null ||
overrideWriteEntityToNBTHooks != null ||
afterWriteEntityToNBTHooks != null;
}
private void attachServerPlayerBase(String id)
{
ServerPlayerBase toAttach = createServerPlayerBase(id);
toAttach.beforeBaseAttach(true);
allBaseObjects.put(id, toAttach);
updateServerPlayerBases();
toAttach.afterBaseAttach(true);
}
private void detachServerPlayerBase(String id)
{
ServerPlayerBase toDetach = allBaseObjects.get(id);
toDetach.beforeBaseDetach(true);
allBaseObjects.remove(id);
updateServerPlayerBases();
toDetach.afterBaseDetach(true);
}
private ServerPlayerBase[] create(List<String> types)
{
if(types.isEmpty())
return null;
ServerPlayerBase[] result = new ServerPlayerBase[types.size()];
for(int i = 0; i < result.length; i++)
result[i] = getServerPlayerBase(types.get(i));
return result;
}
private void beforeLocalConstructing(net.minecraft.server.MinecraftServer paramMinecraftServer, net.minecraft.world.WorldServer paramWorldServer, com.mojang.authlib.GameProfile paramGameProfile, net.minecraft.server.management.ItemInWorldManager paramItemInWorldManager)
{
if(beforeLocalConstructingHooks != null)
for(int i = beforeLocalConstructingHooks.length - 1; i >= 0 ; i--)
beforeLocalConstructingHooks[i].beforeLocalConstructing(paramMinecraftServer, paramWorldServer, paramGameProfile, paramItemInWorldManager);
beforeLocalConstructingHooks = null;
}
private void afterLocalConstructing(net.minecraft.server.MinecraftServer paramMinecraftServer, net.minecraft.world.WorldServer paramWorldServer, com.mojang.authlib.GameProfile paramGameProfile, net.minecraft.server.management.ItemInWorldManager paramItemInWorldManager)
{
if(afterLocalConstructingHooks != null)
for(int i = 0; i < afterLocalConstructingHooks.length; i++)
afterLocalConstructingHooks[i].afterLocalConstructing(paramMinecraftServer, paramWorldServer, paramGameProfile, paramItemInWorldManager);
afterLocalConstructingHooks = null;
}
public ServerPlayerBase getServerPlayerBase(String id)
{
return allBaseObjects.get(id);
}
public Set<String> getServerPlayerBaseIds()
{
return unmodifiableAllBaseIds;
}
public Object dynamic(String key, Object[] parameters)
{
key = key.replace('.', '_').replace(' ', '_');
executeAll(key, parameters, beforeDynamicHookTypes, beforeDynamicHookMethods, true);
Object result = dynamicOverwritten(key, parameters, null);
executeAll(key, parameters, afterDynamicHookTypes, afterDynamicHookMethods, false);
return result;
}
public Object dynamicOverwritten(String key, Object[] parameters, ServerPlayerBase overwriter)
{
List<String> overrideIds = overrideDynamicHookTypes.get(key);
String id = null;
if(overrideIds != null)
if(overwriter != null)
{
id = baseObjectsToId.get(overwriter);
int index = overrideIds.indexOf(id);
if(index > 0)
id = overrideIds.get(index - 1);
else
id = null;
}
else if(overrideIds.size() > 0)
id = overrideIds.get(overrideIds.size() - 1);
Map<Class<?>, Map<String, Method>> methodMap;
if(id == null)
{
id = keysToVirtualIds.get(key);
if(id == null)
return null;
methodMap = virtualDynamicHookMethods;
}
else
methodMap = overrideDynamicHookMethods;
Map<String, Method> methods = methodMap.get(allBaseConstructors.get(id).getDeclaringClass());
if(methods == null)
return null;
Method method = methods.get(key);
if(methods == null)
return null;
return execute(getServerPlayerBase(id), method, parameters);
}
private void executeAll(String key, Object[] parameters, Map<String, List<String>> dynamicHookTypes, Map<Class<?>, Map<String, Method>> dynamicHookMethods, boolean reverse)
{
List<String> beforeIds = dynamicHookTypes.get(key);
if(beforeIds == null)
return;
for(int i= reverse ? beforeIds.size() - 1 : 0; reverse ? i >= 0 : i < beforeIds.size(); i = i + (reverse ? -1 : 1))
{
String id = beforeIds.get(i);
ServerPlayerBase base = getServerPlayerBase(id);
Class<?> type = base.getClass();
Map<String, Method> methods = dynamicHookMethods.get(type);
if(methods == null)
continue;
Method method = methods.get(key);
if(method == null)
continue;
execute(base, method, parameters);
}
}
private Object execute(ServerPlayerBase base, Method method, Object[] parameters)
{
try
{
return method.invoke(base, parameters);
}
catch(Exception e)
{
throw new RuntimeException("Exception while invoking dynamic method", e);
}
}
public static void addExhaustion(IServerPlayerAPI target, float paramFloat)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isAddExhaustionModded)
serverPlayerAPI.addExhaustion(paramFloat);
else
target.localAddExhaustion(paramFloat);
}
private void addExhaustion(float paramFloat)
{
if(beforeAddExhaustionHooks != null)
for(int i = beforeAddExhaustionHooks.length - 1; i >= 0 ; i--)
beforeAddExhaustionHooks[i].beforeAddExhaustion(paramFloat);
if(overrideAddExhaustionHooks != null)
overrideAddExhaustionHooks[overrideAddExhaustionHooks.length - 1].addExhaustion(paramFloat);
else
player.localAddExhaustion(paramFloat);
if(afterAddExhaustionHooks != null)
for(int i = 0; i < afterAddExhaustionHooks.length; i++)
afterAddExhaustionHooks[i].afterAddExhaustion(paramFloat);
}
protected ServerPlayerBase GetOverwrittenAddExhaustion(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideAddExhaustionHooks.length; i++)
if(overrideAddExhaustionHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideAddExhaustionHooks[i - 1];
return overWriter;
}
private final static List<String> beforeAddExhaustionHookTypes = new LinkedList<String>();
private final static List<String> overrideAddExhaustionHookTypes = new LinkedList<String>();
private final static List<String> afterAddExhaustionHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeAddExhaustionHooks;
private ServerPlayerBase[] overrideAddExhaustionHooks;
private ServerPlayerBase[] afterAddExhaustionHooks;
public boolean isAddExhaustionModded;
private static final Map<String, String[]> allBaseBeforeAddExhaustionSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeAddExhaustionInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddExhaustionSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddExhaustionInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddExhaustionSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddExhaustionInferiors = new Hashtable<String, String[]>(0);
public static void addExperience(IServerPlayerAPI target, int paramInt)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isAddExperienceModded)
serverPlayerAPI.addExperience(paramInt);
else
target.localAddExperience(paramInt);
}
private void addExperience(int paramInt)
{
if(beforeAddExperienceHooks != null)
for(int i = beforeAddExperienceHooks.length - 1; i >= 0 ; i--)
beforeAddExperienceHooks[i].beforeAddExperience(paramInt);
if(overrideAddExperienceHooks != null)
overrideAddExperienceHooks[overrideAddExperienceHooks.length - 1].addExperience(paramInt);
else
player.localAddExperience(paramInt);
if(afterAddExperienceHooks != null)
for(int i = 0; i < afterAddExperienceHooks.length; i++)
afterAddExperienceHooks[i].afterAddExperience(paramInt);
}
protected ServerPlayerBase GetOverwrittenAddExperience(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideAddExperienceHooks.length; i++)
if(overrideAddExperienceHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideAddExperienceHooks[i - 1];
return overWriter;
}
private final static List<String> beforeAddExperienceHookTypes = new LinkedList<String>();
private final static List<String> overrideAddExperienceHookTypes = new LinkedList<String>();
private final static List<String> afterAddExperienceHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeAddExperienceHooks;
private ServerPlayerBase[] overrideAddExperienceHooks;
private ServerPlayerBase[] afterAddExperienceHooks;
public boolean isAddExperienceModded;
private static final Map<String, String[]> allBaseBeforeAddExperienceSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeAddExperienceInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddExperienceSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddExperienceInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddExperienceSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddExperienceInferiors = new Hashtable<String, String[]>(0);
public static void addExperienceLevel(IServerPlayerAPI target, int paramInt)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isAddExperienceLevelModded)
serverPlayerAPI.addExperienceLevel(paramInt);
else
target.localAddExperienceLevel(paramInt);
}
private void addExperienceLevel(int paramInt)
{
if(beforeAddExperienceLevelHooks != null)
for(int i = beforeAddExperienceLevelHooks.length - 1; i >= 0 ; i--)
beforeAddExperienceLevelHooks[i].beforeAddExperienceLevel(paramInt);
if(overrideAddExperienceLevelHooks != null)
overrideAddExperienceLevelHooks[overrideAddExperienceLevelHooks.length - 1].addExperienceLevel(paramInt);
else
player.localAddExperienceLevel(paramInt);
if(afterAddExperienceLevelHooks != null)
for(int i = 0; i < afterAddExperienceLevelHooks.length; i++)
afterAddExperienceLevelHooks[i].afterAddExperienceLevel(paramInt);
}
protected ServerPlayerBase GetOverwrittenAddExperienceLevel(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideAddExperienceLevelHooks.length; i++)
if(overrideAddExperienceLevelHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideAddExperienceLevelHooks[i - 1];
return overWriter;
}
private final static List<String> beforeAddExperienceLevelHookTypes = new LinkedList<String>();
private final static List<String> overrideAddExperienceLevelHookTypes = new LinkedList<String>();
private final static List<String> afterAddExperienceLevelHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeAddExperienceLevelHooks;
private ServerPlayerBase[] overrideAddExperienceLevelHooks;
private ServerPlayerBase[] afterAddExperienceLevelHooks;
public boolean isAddExperienceLevelModded;
private static final Map<String, String[]> allBaseBeforeAddExperienceLevelSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeAddExperienceLevelInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddExperienceLevelSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddExperienceLevelInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddExperienceLevelSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddExperienceLevelInferiors = new Hashtable<String, String[]>(0);
public static void addMovementStat(IServerPlayerAPI target, double paramDouble1, double paramDouble2, double paramDouble3)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isAddMovementStatModded)
serverPlayerAPI.addMovementStat(paramDouble1, paramDouble2, paramDouble3);
else
target.localAddMovementStat(paramDouble1, paramDouble2, paramDouble3);
}
private void addMovementStat(double paramDouble1, double paramDouble2, double paramDouble3)
{
if(beforeAddMovementStatHooks != null)
for(int i = beforeAddMovementStatHooks.length - 1; i >= 0 ; i--)
beforeAddMovementStatHooks[i].beforeAddMovementStat(paramDouble1, paramDouble2, paramDouble3);
if(overrideAddMovementStatHooks != null)
overrideAddMovementStatHooks[overrideAddMovementStatHooks.length - 1].addMovementStat(paramDouble1, paramDouble2, paramDouble3);
else
player.localAddMovementStat(paramDouble1, paramDouble2, paramDouble3);
if(afterAddMovementStatHooks != null)
for(int i = 0; i < afterAddMovementStatHooks.length; i++)
afterAddMovementStatHooks[i].afterAddMovementStat(paramDouble1, paramDouble2, paramDouble3);
}
protected ServerPlayerBase GetOverwrittenAddMovementStat(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideAddMovementStatHooks.length; i++)
if(overrideAddMovementStatHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideAddMovementStatHooks[i - 1];
return overWriter;
}
private final static List<String> beforeAddMovementStatHookTypes = new LinkedList<String>();
private final static List<String> overrideAddMovementStatHookTypes = new LinkedList<String>();
private final static List<String> afterAddMovementStatHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeAddMovementStatHooks;
private ServerPlayerBase[] overrideAddMovementStatHooks;
private ServerPlayerBase[] afterAddMovementStatHooks;
public boolean isAddMovementStatModded;
private static final Map<String, String[]> allBaseBeforeAddMovementStatSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeAddMovementStatInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddMovementStatSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAddMovementStatInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddMovementStatSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAddMovementStatInferiors = new Hashtable<String, String[]>(0);
public static boolean attackEntityFrom(IServerPlayerAPI target, net.minecraft.util.DamageSource paramDamageSource, float paramFloat)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isAttackEntityFromModded)
_result = serverPlayerAPI.attackEntityFrom(paramDamageSource, paramFloat);
else
_result = target.localAttackEntityFrom(paramDamageSource, paramFloat);
return _result;
}
private boolean attackEntityFrom(net.minecraft.util.DamageSource paramDamageSource, float paramFloat)
{
if(beforeAttackEntityFromHooks != null)
for(int i = beforeAttackEntityFromHooks.length - 1; i >= 0 ; i--)
beforeAttackEntityFromHooks[i].beforeAttackEntityFrom(paramDamageSource, paramFloat);
boolean _result;
if(overrideAttackEntityFromHooks != null)
_result = overrideAttackEntityFromHooks[overrideAttackEntityFromHooks.length - 1].attackEntityFrom(paramDamageSource, paramFloat);
else
_result = player.localAttackEntityFrom(paramDamageSource, paramFloat);
if(afterAttackEntityFromHooks != null)
for(int i = 0; i < afterAttackEntityFromHooks.length; i++)
afterAttackEntityFromHooks[i].afterAttackEntityFrom(paramDamageSource, paramFloat);
return _result;
}
protected ServerPlayerBase GetOverwrittenAttackEntityFrom(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideAttackEntityFromHooks.length; i++)
if(overrideAttackEntityFromHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideAttackEntityFromHooks[i - 1];
return overWriter;
}
private final static List<String> beforeAttackEntityFromHookTypes = new LinkedList<String>();
private final static List<String> overrideAttackEntityFromHookTypes = new LinkedList<String>();
private final static List<String> afterAttackEntityFromHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeAttackEntityFromHooks;
private ServerPlayerBase[] overrideAttackEntityFromHooks;
private ServerPlayerBase[] afterAttackEntityFromHooks;
public boolean isAttackEntityFromModded;
private static final Map<String, String[]> allBaseBeforeAttackEntityFromSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeAttackEntityFromInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAttackEntityFromSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAttackEntityFromInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAttackEntityFromSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAttackEntityFromInferiors = new Hashtable<String, String[]>(0);
public static void attackTargetEntityWithCurrentItem(IServerPlayerAPI target, net.minecraft.entity.Entity paramEntity)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isAttackTargetEntityWithCurrentItemModded)
serverPlayerAPI.attackTargetEntityWithCurrentItem(paramEntity);
else
target.localAttackTargetEntityWithCurrentItem(paramEntity);
}
private void attackTargetEntityWithCurrentItem(net.minecraft.entity.Entity paramEntity)
{
if(beforeAttackTargetEntityWithCurrentItemHooks != null)
for(int i = beforeAttackTargetEntityWithCurrentItemHooks.length - 1; i >= 0 ; i--)
beforeAttackTargetEntityWithCurrentItemHooks[i].beforeAttackTargetEntityWithCurrentItem(paramEntity);
if(overrideAttackTargetEntityWithCurrentItemHooks != null)
overrideAttackTargetEntityWithCurrentItemHooks[overrideAttackTargetEntityWithCurrentItemHooks.length - 1].attackTargetEntityWithCurrentItem(paramEntity);
else
player.localAttackTargetEntityWithCurrentItem(paramEntity);
if(afterAttackTargetEntityWithCurrentItemHooks != null)
for(int i = 0; i < afterAttackTargetEntityWithCurrentItemHooks.length; i++)
afterAttackTargetEntityWithCurrentItemHooks[i].afterAttackTargetEntityWithCurrentItem(paramEntity);
}
protected ServerPlayerBase GetOverwrittenAttackTargetEntityWithCurrentItem(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideAttackTargetEntityWithCurrentItemHooks.length; i++)
if(overrideAttackTargetEntityWithCurrentItemHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideAttackTargetEntityWithCurrentItemHooks[i - 1];
return overWriter;
}
private final static List<String> beforeAttackTargetEntityWithCurrentItemHookTypes = new LinkedList<String>();
private final static List<String> overrideAttackTargetEntityWithCurrentItemHookTypes = new LinkedList<String>();
private final static List<String> afterAttackTargetEntityWithCurrentItemHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeAttackTargetEntityWithCurrentItemHooks;
private ServerPlayerBase[] overrideAttackTargetEntityWithCurrentItemHooks;
private ServerPlayerBase[] afterAttackTargetEntityWithCurrentItemHooks;
public boolean isAttackTargetEntityWithCurrentItemModded;
private static final Map<String, String[]> allBaseBeforeAttackTargetEntityWithCurrentItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeAttackTargetEntityWithCurrentItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAttackTargetEntityWithCurrentItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideAttackTargetEntityWithCurrentItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAttackTargetEntityWithCurrentItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterAttackTargetEntityWithCurrentItemInferiors = new Hashtable<String, String[]>(0);
public static boolean canBreatheUnderwater(IServerPlayerAPI target)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isCanBreatheUnderwaterModded)
_result = serverPlayerAPI.canBreatheUnderwater();
else
_result = target.localCanBreatheUnderwater();
return _result;
}
private boolean canBreatheUnderwater()
{
if(beforeCanBreatheUnderwaterHooks != null)
for(int i = beforeCanBreatheUnderwaterHooks.length - 1; i >= 0 ; i--)
beforeCanBreatheUnderwaterHooks[i].beforeCanBreatheUnderwater();
boolean _result;
if(overrideCanBreatheUnderwaterHooks != null)
_result = overrideCanBreatheUnderwaterHooks[overrideCanBreatheUnderwaterHooks.length - 1].canBreatheUnderwater();
else
_result = player.localCanBreatheUnderwater();
if(afterCanBreatheUnderwaterHooks != null)
for(int i = 0; i < afterCanBreatheUnderwaterHooks.length; i++)
afterCanBreatheUnderwaterHooks[i].afterCanBreatheUnderwater();
return _result;
}
protected ServerPlayerBase GetOverwrittenCanBreatheUnderwater(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideCanBreatheUnderwaterHooks.length; i++)
if(overrideCanBreatheUnderwaterHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideCanBreatheUnderwaterHooks[i - 1];
return overWriter;
}
private final static List<String> beforeCanBreatheUnderwaterHookTypes = new LinkedList<String>();
private final static List<String> overrideCanBreatheUnderwaterHookTypes = new LinkedList<String>();
private final static List<String> afterCanBreatheUnderwaterHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeCanBreatheUnderwaterHooks;
private ServerPlayerBase[] overrideCanBreatheUnderwaterHooks;
private ServerPlayerBase[] afterCanBreatheUnderwaterHooks;
public boolean isCanBreatheUnderwaterModded;
private static final Map<String, String[]> allBaseBeforeCanBreatheUnderwaterSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeCanBreatheUnderwaterInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanBreatheUnderwaterSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanBreatheUnderwaterInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanBreatheUnderwaterSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanBreatheUnderwaterInferiors = new Hashtable<String, String[]>(0);
public static boolean canHarvestBlock(IServerPlayerAPI target, net.minecraft.block.Block paramBlock)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isCanHarvestBlockModded)
_result = serverPlayerAPI.canHarvestBlock(paramBlock);
else
_result = target.localCanHarvestBlock(paramBlock);
return _result;
}
private boolean canHarvestBlock(net.minecraft.block.Block paramBlock)
{
if(beforeCanHarvestBlockHooks != null)
for(int i = beforeCanHarvestBlockHooks.length - 1; i >= 0 ; i--)
beforeCanHarvestBlockHooks[i].beforeCanHarvestBlock(paramBlock);
boolean _result;
if(overrideCanHarvestBlockHooks != null)
_result = overrideCanHarvestBlockHooks[overrideCanHarvestBlockHooks.length - 1].canHarvestBlock(paramBlock);
else
_result = player.localCanHarvestBlock(paramBlock);
if(afterCanHarvestBlockHooks != null)
for(int i = 0; i < afterCanHarvestBlockHooks.length; i++)
afterCanHarvestBlockHooks[i].afterCanHarvestBlock(paramBlock);
return _result;
}
protected ServerPlayerBase GetOverwrittenCanHarvestBlock(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideCanHarvestBlockHooks.length; i++)
if(overrideCanHarvestBlockHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideCanHarvestBlockHooks[i - 1];
return overWriter;
}
private final static List<String> beforeCanHarvestBlockHookTypes = new LinkedList<String>();
private final static List<String> overrideCanHarvestBlockHookTypes = new LinkedList<String>();
private final static List<String> afterCanHarvestBlockHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeCanHarvestBlockHooks;
private ServerPlayerBase[] overrideCanHarvestBlockHooks;
private ServerPlayerBase[] afterCanHarvestBlockHooks;
public boolean isCanHarvestBlockModded;
private static final Map<String, String[]> allBaseBeforeCanHarvestBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeCanHarvestBlockInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanHarvestBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanHarvestBlockInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanHarvestBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanHarvestBlockInferiors = new Hashtable<String, String[]>(0);
public static boolean canPlayerEdit(IServerPlayerAPI target, int paramInt1, int paramInt2, int paramInt3, int paramInt4, net.minecraft.item.ItemStack paramItemStack)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isCanPlayerEditModded)
_result = serverPlayerAPI.canPlayerEdit(paramInt1, paramInt2, paramInt3, paramInt4, paramItemStack);
else
_result = target.localCanPlayerEdit(paramInt1, paramInt2, paramInt3, paramInt4, paramItemStack);
return _result;
}
private boolean canPlayerEdit(int paramInt1, int paramInt2, int paramInt3, int paramInt4, net.minecraft.item.ItemStack paramItemStack)
{
if(beforeCanPlayerEditHooks != null)
for(int i = beforeCanPlayerEditHooks.length - 1; i >= 0 ; i--)
beforeCanPlayerEditHooks[i].beforeCanPlayerEdit(paramInt1, paramInt2, paramInt3, paramInt4, paramItemStack);
boolean _result;
if(overrideCanPlayerEditHooks != null)
_result = overrideCanPlayerEditHooks[overrideCanPlayerEditHooks.length - 1].canPlayerEdit(paramInt1, paramInt2, paramInt3, paramInt4, paramItemStack);
else
_result = player.localCanPlayerEdit(paramInt1, paramInt2, paramInt3, paramInt4, paramItemStack);
if(afterCanPlayerEditHooks != null)
for(int i = 0; i < afterCanPlayerEditHooks.length; i++)
afterCanPlayerEditHooks[i].afterCanPlayerEdit(paramInt1, paramInt2, paramInt3, paramInt4, paramItemStack);
return _result;
}
protected ServerPlayerBase GetOverwrittenCanPlayerEdit(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideCanPlayerEditHooks.length; i++)
if(overrideCanPlayerEditHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideCanPlayerEditHooks[i - 1];
return overWriter;
}
private final static List<String> beforeCanPlayerEditHookTypes = new LinkedList<String>();
private final static List<String> overrideCanPlayerEditHookTypes = new LinkedList<String>();
private final static List<String> afterCanPlayerEditHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeCanPlayerEditHooks;
private ServerPlayerBase[] overrideCanPlayerEditHooks;
private ServerPlayerBase[] afterCanPlayerEditHooks;
public boolean isCanPlayerEditModded;
private static final Map<String, String[]> allBaseBeforeCanPlayerEditSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeCanPlayerEditInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanPlayerEditSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanPlayerEditInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanPlayerEditSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanPlayerEditInferiors = new Hashtable<String, String[]>(0);
public static boolean canTriggerWalking(IServerPlayerAPI target)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isCanTriggerWalkingModded)
_result = serverPlayerAPI.canTriggerWalking();
else
_result = target.localCanTriggerWalking();
return _result;
}
private boolean canTriggerWalking()
{
if(beforeCanTriggerWalkingHooks != null)
for(int i = beforeCanTriggerWalkingHooks.length - 1; i >= 0 ; i--)
beforeCanTriggerWalkingHooks[i].beforeCanTriggerWalking();
boolean _result;
if(overrideCanTriggerWalkingHooks != null)
_result = overrideCanTriggerWalkingHooks[overrideCanTriggerWalkingHooks.length - 1].canTriggerWalking();
else
_result = player.localCanTriggerWalking();
if(afterCanTriggerWalkingHooks != null)
for(int i = 0; i < afterCanTriggerWalkingHooks.length; i++)
afterCanTriggerWalkingHooks[i].afterCanTriggerWalking();
return _result;
}
protected ServerPlayerBase GetOverwrittenCanTriggerWalking(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideCanTriggerWalkingHooks.length; i++)
if(overrideCanTriggerWalkingHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideCanTriggerWalkingHooks[i - 1];
return overWriter;
}
private final static List<String> beforeCanTriggerWalkingHookTypes = new LinkedList<String>();
private final static List<String> overrideCanTriggerWalkingHookTypes = new LinkedList<String>();
private final static List<String> afterCanTriggerWalkingHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeCanTriggerWalkingHooks;
private ServerPlayerBase[] overrideCanTriggerWalkingHooks;
private ServerPlayerBase[] afterCanTriggerWalkingHooks;
public boolean isCanTriggerWalkingModded;
private static final Map<String, String[]> allBaseBeforeCanTriggerWalkingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeCanTriggerWalkingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanTriggerWalkingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideCanTriggerWalkingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanTriggerWalkingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterCanTriggerWalkingInferiors = new Hashtable<String, String[]>(0);
public static void clonePlayer(IServerPlayerAPI target, net.minecraft.entity.player.EntityPlayer paramEntityPlayer, boolean paramBoolean)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isClonePlayerModded)
serverPlayerAPI.clonePlayer(paramEntityPlayer, paramBoolean);
else
target.localClonePlayer(paramEntityPlayer, paramBoolean);
}
private void clonePlayer(net.minecraft.entity.player.EntityPlayer paramEntityPlayer, boolean paramBoolean)
{
if(beforeClonePlayerHooks != null)
for(int i = beforeClonePlayerHooks.length - 1; i >= 0 ; i--)
beforeClonePlayerHooks[i].beforeClonePlayer(paramEntityPlayer, paramBoolean);
if(overrideClonePlayerHooks != null)
overrideClonePlayerHooks[overrideClonePlayerHooks.length - 1].clonePlayer(paramEntityPlayer, paramBoolean);
else
player.localClonePlayer(paramEntityPlayer, paramBoolean);
if(afterClonePlayerHooks != null)
for(int i = 0; i < afterClonePlayerHooks.length; i++)
afterClonePlayerHooks[i].afterClonePlayer(paramEntityPlayer, paramBoolean);
}
protected ServerPlayerBase GetOverwrittenClonePlayer(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideClonePlayerHooks.length; i++)
if(overrideClonePlayerHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideClonePlayerHooks[i - 1];
return overWriter;
}
private final static List<String> beforeClonePlayerHookTypes = new LinkedList<String>();
private final static List<String> overrideClonePlayerHookTypes = new LinkedList<String>();
private final static List<String> afterClonePlayerHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeClonePlayerHooks;
private ServerPlayerBase[] overrideClonePlayerHooks;
private ServerPlayerBase[] afterClonePlayerHooks;
public boolean isClonePlayerModded;
private static final Map<String, String[]> allBaseBeforeClonePlayerSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeClonePlayerInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideClonePlayerSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideClonePlayerInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterClonePlayerSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterClonePlayerInferiors = new Hashtable<String, String[]>(0);
public static void damageEntity(IServerPlayerAPI target, net.minecraft.util.DamageSource paramDamageSource, float paramFloat)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDamageEntityModded)
serverPlayerAPI.damageEntity(paramDamageSource, paramFloat);
else
target.localDamageEntity(paramDamageSource, paramFloat);
}
private void damageEntity(net.minecraft.util.DamageSource paramDamageSource, float paramFloat)
{
if(beforeDamageEntityHooks != null)
for(int i = beforeDamageEntityHooks.length - 1; i >= 0 ; i--)
beforeDamageEntityHooks[i].beforeDamageEntity(paramDamageSource, paramFloat);
if(overrideDamageEntityHooks != null)
overrideDamageEntityHooks[overrideDamageEntityHooks.length - 1].damageEntity(paramDamageSource, paramFloat);
else
player.localDamageEntity(paramDamageSource, paramFloat);
if(afterDamageEntityHooks != null)
for(int i = 0; i < afterDamageEntityHooks.length; i++)
afterDamageEntityHooks[i].afterDamageEntity(paramDamageSource, paramFloat);
}
protected ServerPlayerBase GetOverwrittenDamageEntity(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDamageEntityHooks.length; i++)
if(overrideDamageEntityHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDamageEntityHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDamageEntityHookTypes = new LinkedList<String>();
private final static List<String> overrideDamageEntityHookTypes = new LinkedList<String>();
private final static List<String> afterDamageEntityHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDamageEntityHooks;
private ServerPlayerBase[] overrideDamageEntityHooks;
private ServerPlayerBase[] afterDamageEntityHooks;
public boolean isDamageEntityModded;
private static final Map<String, String[]> allBaseBeforeDamageEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDamageEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDamageEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDamageEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDamageEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDamageEntityInferiors = new Hashtable<String, String[]>(0);
public static void displayGUIChest(IServerPlayerAPI target, net.minecraft.inventory.IInventory paramIInventory)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDisplayGUIChestModded)
serverPlayerAPI.displayGUIChest(paramIInventory);
else
target.localDisplayGUIChest(paramIInventory);
}
private void displayGUIChest(net.minecraft.inventory.IInventory paramIInventory)
{
if(beforeDisplayGUIChestHooks != null)
for(int i = beforeDisplayGUIChestHooks.length - 1; i >= 0 ; i--)
beforeDisplayGUIChestHooks[i].beforeDisplayGUIChest(paramIInventory);
if(overrideDisplayGUIChestHooks != null)
overrideDisplayGUIChestHooks[overrideDisplayGUIChestHooks.length - 1].displayGUIChest(paramIInventory);
else
player.localDisplayGUIChest(paramIInventory);
if(afterDisplayGUIChestHooks != null)
for(int i = 0; i < afterDisplayGUIChestHooks.length; i++)
afterDisplayGUIChestHooks[i].afterDisplayGUIChest(paramIInventory);
}
protected ServerPlayerBase GetOverwrittenDisplayGUIChest(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDisplayGUIChestHooks.length; i++)
if(overrideDisplayGUIChestHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDisplayGUIChestHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDisplayGUIChestHookTypes = new LinkedList<String>();
private final static List<String> overrideDisplayGUIChestHookTypes = new LinkedList<String>();
private final static List<String> afterDisplayGUIChestHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDisplayGUIChestHooks;
private ServerPlayerBase[] overrideDisplayGUIChestHooks;
private ServerPlayerBase[] afterDisplayGUIChestHooks;
public boolean isDisplayGUIChestModded;
private static final Map<String, String[]> allBaseBeforeDisplayGUIChestSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDisplayGUIChestInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIChestSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIChestInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIChestSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIChestInferiors = new Hashtable<String, String[]>(0);
public static void displayGUIDispenser(IServerPlayerAPI target, net.minecraft.tileentity.TileEntityDispenser paramTileEntityDispenser)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDisplayGUIDispenserModded)
serverPlayerAPI.displayGUIDispenser(paramTileEntityDispenser);
else
target.localDisplayGUIDispenser(paramTileEntityDispenser);
}
private void displayGUIDispenser(net.minecraft.tileentity.TileEntityDispenser paramTileEntityDispenser)
{
if(beforeDisplayGUIDispenserHooks != null)
for(int i = beforeDisplayGUIDispenserHooks.length - 1; i >= 0 ; i--)
beforeDisplayGUIDispenserHooks[i].beforeDisplayGUIDispenser(paramTileEntityDispenser);
if(overrideDisplayGUIDispenserHooks != null)
overrideDisplayGUIDispenserHooks[overrideDisplayGUIDispenserHooks.length - 1].displayGUIDispenser(paramTileEntityDispenser);
else
player.localDisplayGUIDispenser(paramTileEntityDispenser);
if(afterDisplayGUIDispenserHooks != null)
for(int i = 0; i < afterDisplayGUIDispenserHooks.length; i++)
afterDisplayGUIDispenserHooks[i].afterDisplayGUIDispenser(paramTileEntityDispenser);
}
protected ServerPlayerBase GetOverwrittenDisplayGUIDispenser(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDisplayGUIDispenserHooks.length; i++)
if(overrideDisplayGUIDispenserHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDisplayGUIDispenserHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDisplayGUIDispenserHookTypes = new LinkedList<String>();
private final static List<String> overrideDisplayGUIDispenserHookTypes = new LinkedList<String>();
private final static List<String> afterDisplayGUIDispenserHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDisplayGUIDispenserHooks;
private ServerPlayerBase[] overrideDisplayGUIDispenserHooks;
private ServerPlayerBase[] afterDisplayGUIDispenserHooks;
public boolean isDisplayGUIDispenserModded;
private static final Map<String, String[]> allBaseBeforeDisplayGUIDispenserSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDisplayGUIDispenserInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIDispenserSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIDispenserInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIDispenserSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIDispenserInferiors = new Hashtable<String, String[]>(0);
public static void displayGUIFurnace(IServerPlayerAPI target, net.minecraft.tileentity.TileEntityFurnace paramTileEntityFurnace)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDisplayGUIFurnaceModded)
serverPlayerAPI.displayGUIFurnace(paramTileEntityFurnace);
else
target.localDisplayGUIFurnace(paramTileEntityFurnace);
}
private void displayGUIFurnace(net.minecraft.tileentity.TileEntityFurnace paramTileEntityFurnace)
{
if(beforeDisplayGUIFurnaceHooks != null)
for(int i = beforeDisplayGUIFurnaceHooks.length - 1; i >= 0 ; i--)
beforeDisplayGUIFurnaceHooks[i].beforeDisplayGUIFurnace(paramTileEntityFurnace);
if(overrideDisplayGUIFurnaceHooks != null)
overrideDisplayGUIFurnaceHooks[overrideDisplayGUIFurnaceHooks.length - 1].displayGUIFurnace(paramTileEntityFurnace);
else
player.localDisplayGUIFurnace(paramTileEntityFurnace);
if(afterDisplayGUIFurnaceHooks != null)
for(int i = 0; i < afterDisplayGUIFurnaceHooks.length; i++)
afterDisplayGUIFurnaceHooks[i].afterDisplayGUIFurnace(paramTileEntityFurnace);
}
protected ServerPlayerBase GetOverwrittenDisplayGUIFurnace(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDisplayGUIFurnaceHooks.length; i++)
if(overrideDisplayGUIFurnaceHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDisplayGUIFurnaceHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDisplayGUIFurnaceHookTypes = new LinkedList<String>();
private final static List<String> overrideDisplayGUIFurnaceHookTypes = new LinkedList<String>();
private final static List<String> afterDisplayGUIFurnaceHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDisplayGUIFurnaceHooks;
private ServerPlayerBase[] overrideDisplayGUIFurnaceHooks;
private ServerPlayerBase[] afterDisplayGUIFurnaceHooks;
public boolean isDisplayGUIFurnaceModded;
private static final Map<String, String[]> allBaseBeforeDisplayGUIFurnaceSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDisplayGUIFurnaceInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIFurnaceSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIFurnaceInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIFurnaceSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIFurnaceInferiors = new Hashtable<String, String[]>(0);
public static void displayGUIWorkbench(IServerPlayerAPI target, int paramInt1, int paramInt2, int paramInt3)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDisplayGUIWorkbenchModded)
serverPlayerAPI.displayGUIWorkbench(paramInt1, paramInt2, paramInt3);
else
target.localDisplayGUIWorkbench(paramInt1, paramInt2, paramInt3);
}
private void displayGUIWorkbench(int paramInt1, int paramInt2, int paramInt3)
{
if(beforeDisplayGUIWorkbenchHooks != null)
for(int i = beforeDisplayGUIWorkbenchHooks.length - 1; i >= 0 ; i--)
beforeDisplayGUIWorkbenchHooks[i].beforeDisplayGUIWorkbench(paramInt1, paramInt2, paramInt3);
if(overrideDisplayGUIWorkbenchHooks != null)
overrideDisplayGUIWorkbenchHooks[overrideDisplayGUIWorkbenchHooks.length - 1].displayGUIWorkbench(paramInt1, paramInt2, paramInt3);
else
player.localDisplayGUIWorkbench(paramInt1, paramInt2, paramInt3);
if(afterDisplayGUIWorkbenchHooks != null)
for(int i = 0; i < afterDisplayGUIWorkbenchHooks.length; i++)
afterDisplayGUIWorkbenchHooks[i].afterDisplayGUIWorkbench(paramInt1, paramInt2, paramInt3);
}
protected ServerPlayerBase GetOverwrittenDisplayGUIWorkbench(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDisplayGUIWorkbenchHooks.length; i++)
if(overrideDisplayGUIWorkbenchHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDisplayGUIWorkbenchHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDisplayGUIWorkbenchHookTypes = new LinkedList<String>();
private final static List<String> overrideDisplayGUIWorkbenchHookTypes = new LinkedList<String>();
private final static List<String> afterDisplayGUIWorkbenchHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDisplayGUIWorkbenchHooks;
private ServerPlayerBase[] overrideDisplayGUIWorkbenchHooks;
private ServerPlayerBase[] afterDisplayGUIWorkbenchHooks;
public boolean isDisplayGUIWorkbenchModded;
private static final Map<String, String[]> allBaseBeforeDisplayGUIWorkbenchSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDisplayGUIWorkbenchInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIWorkbenchSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDisplayGUIWorkbenchInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIWorkbenchSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDisplayGUIWorkbenchInferiors = new Hashtable<String, String[]>(0);
public static net.minecraft.entity.item.EntityItem dropOneItem(IServerPlayerAPI target, boolean paramBoolean)
{
net.minecraft.entity.item.EntityItem _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDropOneItemModded)
_result = serverPlayerAPI.dropOneItem(paramBoolean);
else
_result = target.localDropOneItem(paramBoolean);
return _result;
}
private net.minecraft.entity.item.EntityItem dropOneItem(boolean paramBoolean)
{
if(beforeDropOneItemHooks != null)
for(int i = beforeDropOneItemHooks.length - 1; i >= 0 ; i--)
beforeDropOneItemHooks[i].beforeDropOneItem(paramBoolean);
net.minecraft.entity.item.EntityItem _result;
if(overrideDropOneItemHooks != null)
_result = overrideDropOneItemHooks[overrideDropOneItemHooks.length - 1].dropOneItem(paramBoolean);
else
_result = player.localDropOneItem(paramBoolean);
if(afterDropOneItemHooks != null)
for(int i = 0; i < afterDropOneItemHooks.length; i++)
afterDropOneItemHooks[i].afterDropOneItem(paramBoolean);
return _result;
}
protected ServerPlayerBase GetOverwrittenDropOneItem(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDropOneItemHooks.length; i++)
if(overrideDropOneItemHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDropOneItemHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDropOneItemHookTypes = new LinkedList<String>();
private final static List<String> overrideDropOneItemHookTypes = new LinkedList<String>();
private final static List<String> afterDropOneItemHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDropOneItemHooks;
private ServerPlayerBase[] overrideDropOneItemHooks;
private ServerPlayerBase[] afterDropOneItemHooks;
public boolean isDropOneItemModded;
private static final Map<String, String[]> allBaseBeforeDropOneItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDropOneItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDropOneItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDropOneItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDropOneItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDropOneItemInferiors = new Hashtable<String, String[]>(0);
public static net.minecraft.entity.item.EntityItem dropPlayerItem(IServerPlayerAPI target, net.minecraft.item.ItemStack paramItemStack, boolean paramBoolean)
{
net.minecraft.entity.item.EntityItem _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isDropPlayerItemModded)
_result = serverPlayerAPI.dropPlayerItem(paramItemStack, paramBoolean);
else
_result = target.localDropPlayerItem(paramItemStack, paramBoolean);
return _result;
}
private net.minecraft.entity.item.EntityItem dropPlayerItem(net.minecraft.item.ItemStack paramItemStack, boolean paramBoolean)
{
if(beforeDropPlayerItemHooks != null)
for(int i = beforeDropPlayerItemHooks.length - 1; i >= 0 ; i--)
beforeDropPlayerItemHooks[i].beforeDropPlayerItem(paramItemStack, paramBoolean);
net.minecraft.entity.item.EntityItem _result;
if(overrideDropPlayerItemHooks != null)
_result = overrideDropPlayerItemHooks[overrideDropPlayerItemHooks.length - 1].dropPlayerItem(paramItemStack, paramBoolean);
else
_result = player.localDropPlayerItem(paramItemStack, paramBoolean);
if(afterDropPlayerItemHooks != null)
for(int i = 0; i < afterDropPlayerItemHooks.length; i++)
afterDropPlayerItemHooks[i].afterDropPlayerItem(paramItemStack, paramBoolean);
return _result;
}
protected ServerPlayerBase GetOverwrittenDropPlayerItem(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideDropPlayerItemHooks.length; i++)
if(overrideDropPlayerItemHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideDropPlayerItemHooks[i - 1];
return overWriter;
}
private final static List<String> beforeDropPlayerItemHookTypes = new LinkedList<String>();
private final static List<String> overrideDropPlayerItemHookTypes = new LinkedList<String>();
private final static List<String> afterDropPlayerItemHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeDropPlayerItemHooks;
private ServerPlayerBase[] overrideDropPlayerItemHooks;
private ServerPlayerBase[] afterDropPlayerItemHooks;
public boolean isDropPlayerItemModded;
private static final Map<String, String[]> allBaseBeforeDropPlayerItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeDropPlayerItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDropPlayerItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideDropPlayerItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDropPlayerItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterDropPlayerItemInferiors = new Hashtable<String, String[]>(0);
public static void fall(IServerPlayerAPI target, float paramFloat)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isFallModded)
serverPlayerAPI.fall(paramFloat);
else
target.localFall(paramFloat);
}
private void fall(float paramFloat)
{
if(beforeFallHooks != null)
for(int i = beforeFallHooks.length - 1; i >= 0 ; i--)
beforeFallHooks[i].beforeFall(paramFloat);
if(overrideFallHooks != null)
overrideFallHooks[overrideFallHooks.length - 1].fall(paramFloat);
else
player.localFall(paramFloat);
if(afterFallHooks != null)
for(int i = 0; i < afterFallHooks.length; i++)
afterFallHooks[i].afterFall(paramFloat);
}
protected ServerPlayerBase GetOverwrittenFall(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideFallHooks.length; i++)
if(overrideFallHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideFallHooks[i - 1];
return overWriter;
}
private final static List<String> beforeFallHookTypes = new LinkedList<String>();
private final static List<String> overrideFallHookTypes = new LinkedList<String>();
private final static List<String> afterFallHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeFallHooks;
private ServerPlayerBase[] overrideFallHooks;
private ServerPlayerBase[] afterFallHooks;
public boolean isFallModded;
private static final Map<String, String[]> allBaseBeforeFallSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeFallInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideFallSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideFallInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterFallSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterFallInferiors = new Hashtable<String, String[]>(0);
public static float getAIMoveSpeed(IServerPlayerAPI target)
{
float _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isGetAIMoveSpeedModded)
_result = serverPlayerAPI.getAIMoveSpeed();
else
_result = target.localGetAIMoveSpeed();
return _result;
}
private float getAIMoveSpeed()
{
if(beforeGetAIMoveSpeedHooks != null)
for(int i = beforeGetAIMoveSpeedHooks.length - 1; i >= 0 ; i--)
beforeGetAIMoveSpeedHooks[i].beforeGetAIMoveSpeed();
float _result;
if(overrideGetAIMoveSpeedHooks != null)
_result = overrideGetAIMoveSpeedHooks[overrideGetAIMoveSpeedHooks.length - 1].getAIMoveSpeed();
else
_result = player.localGetAIMoveSpeed();
if(afterGetAIMoveSpeedHooks != null)
for(int i = 0; i < afterGetAIMoveSpeedHooks.length; i++)
afterGetAIMoveSpeedHooks[i].afterGetAIMoveSpeed();
return _result;
}
protected ServerPlayerBase GetOverwrittenGetAIMoveSpeed(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideGetAIMoveSpeedHooks.length; i++)
if(overrideGetAIMoveSpeedHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideGetAIMoveSpeedHooks[i - 1];
return overWriter;
}
private final static List<String> beforeGetAIMoveSpeedHookTypes = new LinkedList<String>();
private final static List<String> overrideGetAIMoveSpeedHookTypes = new LinkedList<String>();
private final static List<String> afterGetAIMoveSpeedHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeGetAIMoveSpeedHooks;
private ServerPlayerBase[] overrideGetAIMoveSpeedHooks;
private ServerPlayerBase[] afterGetAIMoveSpeedHooks;
public boolean isGetAIMoveSpeedModded;
private static final Map<String, String[]> allBaseBeforeGetAIMoveSpeedSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeGetAIMoveSpeedInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetAIMoveSpeedSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetAIMoveSpeedInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetAIMoveSpeedSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetAIMoveSpeedInferiors = new Hashtable<String, String[]>(0);
public static float getCurrentPlayerStrVsBlock(IServerPlayerAPI target, net.minecraft.block.Block paramBlock, boolean paramBoolean)
{
float _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isGetCurrentPlayerStrVsBlockModded)
_result = serverPlayerAPI.getCurrentPlayerStrVsBlock(paramBlock, paramBoolean);
else
_result = target.localGetCurrentPlayerStrVsBlock(paramBlock, paramBoolean);
return _result;
}
private float getCurrentPlayerStrVsBlock(net.minecraft.block.Block paramBlock, boolean paramBoolean)
{
if(beforeGetCurrentPlayerStrVsBlockHooks != null)
for(int i = beforeGetCurrentPlayerStrVsBlockHooks.length - 1; i >= 0 ; i--)
beforeGetCurrentPlayerStrVsBlockHooks[i].beforeGetCurrentPlayerStrVsBlock(paramBlock, paramBoolean);
float _result;
if(overrideGetCurrentPlayerStrVsBlockHooks != null)
_result = overrideGetCurrentPlayerStrVsBlockHooks[overrideGetCurrentPlayerStrVsBlockHooks.length - 1].getCurrentPlayerStrVsBlock(paramBlock, paramBoolean);
else
_result = player.localGetCurrentPlayerStrVsBlock(paramBlock, paramBoolean);
if(afterGetCurrentPlayerStrVsBlockHooks != null)
for(int i = 0; i < afterGetCurrentPlayerStrVsBlockHooks.length; i++)
afterGetCurrentPlayerStrVsBlockHooks[i].afterGetCurrentPlayerStrVsBlock(paramBlock, paramBoolean);
return _result;
}
protected ServerPlayerBase GetOverwrittenGetCurrentPlayerStrVsBlock(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideGetCurrentPlayerStrVsBlockHooks.length; i++)
if(overrideGetCurrentPlayerStrVsBlockHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideGetCurrentPlayerStrVsBlockHooks[i - 1];
return overWriter;
}
private final static List<String> beforeGetCurrentPlayerStrVsBlockHookTypes = new LinkedList<String>();
private final static List<String> overrideGetCurrentPlayerStrVsBlockHookTypes = new LinkedList<String>();
private final static List<String> afterGetCurrentPlayerStrVsBlockHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeGetCurrentPlayerStrVsBlockHooks;
private ServerPlayerBase[] overrideGetCurrentPlayerStrVsBlockHooks;
private ServerPlayerBase[] afterGetCurrentPlayerStrVsBlockHooks;
public boolean isGetCurrentPlayerStrVsBlockModded;
private static final Map<String, String[]> allBaseBeforeGetCurrentPlayerStrVsBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeGetCurrentPlayerStrVsBlockInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetCurrentPlayerStrVsBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetCurrentPlayerStrVsBlockInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetCurrentPlayerStrVsBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetCurrentPlayerStrVsBlockInferiors = new Hashtable<String, String[]>(0);
public static float getCurrentPlayerStrVsBlockForge(IServerPlayerAPI target, net.minecraft.block.Block paramBlock, boolean paramBoolean, int paramInt)
{
float _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isGetCurrentPlayerStrVsBlockForgeModded)
_result = serverPlayerAPI.getCurrentPlayerStrVsBlockForge(paramBlock, paramBoolean, paramInt);
else
_result = target.localGetCurrentPlayerStrVsBlockForge(paramBlock, paramBoolean, paramInt);
return _result;
}
private float getCurrentPlayerStrVsBlockForge(net.minecraft.block.Block paramBlock, boolean paramBoolean, int paramInt)
{
if(beforeGetCurrentPlayerStrVsBlockForgeHooks != null)
for(int i = beforeGetCurrentPlayerStrVsBlockForgeHooks.length - 1; i >= 0 ; i--)
beforeGetCurrentPlayerStrVsBlockForgeHooks[i].beforeGetCurrentPlayerStrVsBlockForge(paramBlock, paramBoolean, paramInt);
float _result;
if(overrideGetCurrentPlayerStrVsBlockForgeHooks != null)
_result = overrideGetCurrentPlayerStrVsBlockForgeHooks[overrideGetCurrentPlayerStrVsBlockForgeHooks.length - 1].getCurrentPlayerStrVsBlockForge(paramBlock, paramBoolean, paramInt);
else
_result = player.localGetCurrentPlayerStrVsBlockForge(paramBlock, paramBoolean, paramInt);
if(afterGetCurrentPlayerStrVsBlockForgeHooks != null)
for(int i = 0; i < afterGetCurrentPlayerStrVsBlockForgeHooks.length; i++)
afterGetCurrentPlayerStrVsBlockForgeHooks[i].afterGetCurrentPlayerStrVsBlockForge(paramBlock, paramBoolean, paramInt);
return _result;
}
protected ServerPlayerBase GetOverwrittenGetCurrentPlayerStrVsBlockForge(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideGetCurrentPlayerStrVsBlockForgeHooks.length; i++)
if(overrideGetCurrentPlayerStrVsBlockForgeHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideGetCurrentPlayerStrVsBlockForgeHooks[i - 1];
return overWriter;
}
private final static List<String> beforeGetCurrentPlayerStrVsBlockForgeHookTypes = new LinkedList<String>();
private final static List<String> overrideGetCurrentPlayerStrVsBlockForgeHookTypes = new LinkedList<String>();
private final static List<String> afterGetCurrentPlayerStrVsBlockForgeHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeGetCurrentPlayerStrVsBlockForgeHooks;
private ServerPlayerBase[] overrideGetCurrentPlayerStrVsBlockForgeHooks;
private ServerPlayerBase[] afterGetCurrentPlayerStrVsBlockForgeHooks;
public boolean isGetCurrentPlayerStrVsBlockForgeModded;
private static final Map<String, String[]> allBaseBeforeGetCurrentPlayerStrVsBlockForgeSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeGetCurrentPlayerStrVsBlockForgeInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetCurrentPlayerStrVsBlockForgeSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetCurrentPlayerStrVsBlockForgeInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetCurrentPlayerStrVsBlockForgeSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetCurrentPlayerStrVsBlockForgeInferiors = new Hashtable<String, String[]>(0);
public static double getDistanceSq(IServerPlayerAPI target, double paramDouble1, double paramDouble2, double paramDouble3)
{
double _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isGetDistanceSqModded)
_result = serverPlayerAPI.getDistanceSq(paramDouble1, paramDouble2, paramDouble3);
else
_result = target.localGetDistanceSq(paramDouble1, paramDouble2, paramDouble3);
return _result;
}
private double getDistanceSq(double paramDouble1, double paramDouble2, double paramDouble3)
{
if(beforeGetDistanceSqHooks != null)
for(int i = beforeGetDistanceSqHooks.length - 1; i >= 0 ; i--)
beforeGetDistanceSqHooks[i].beforeGetDistanceSq(paramDouble1, paramDouble2, paramDouble3);
double _result;
if(overrideGetDistanceSqHooks != null)
_result = overrideGetDistanceSqHooks[overrideGetDistanceSqHooks.length - 1].getDistanceSq(paramDouble1, paramDouble2, paramDouble3);
else
_result = player.localGetDistanceSq(paramDouble1, paramDouble2, paramDouble3);
if(afterGetDistanceSqHooks != null)
for(int i = 0; i < afterGetDistanceSqHooks.length; i++)
afterGetDistanceSqHooks[i].afterGetDistanceSq(paramDouble1, paramDouble2, paramDouble3);
return _result;
}
protected ServerPlayerBase GetOverwrittenGetDistanceSq(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideGetDistanceSqHooks.length; i++)
if(overrideGetDistanceSqHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideGetDistanceSqHooks[i - 1];
return overWriter;
}
private final static List<String> beforeGetDistanceSqHookTypes = new LinkedList<String>();
private final static List<String> overrideGetDistanceSqHookTypes = new LinkedList<String>();
private final static List<String> afterGetDistanceSqHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeGetDistanceSqHooks;
private ServerPlayerBase[] overrideGetDistanceSqHooks;
private ServerPlayerBase[] afterGetDistanceSqHooks;
public boolean isGetDistanceSqModded;
private static final Map<String, String[]> allBaseBeforeGetDistanceSqSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeGetDistanceSqInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetDistanceSqSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetDistanceSqInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetDistanceSqSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetDistanceSqInferiors = new Hashtable<String, String[]>(0);
public static float getBrightness(IServerPlayerAPI target, float paramFloat)
{
float _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isGetBrightnessModded)
_result = serverPlayerAPI.getBrightness(paramFloat);
else
_result = target.localGetBrightness(paramFloat);
return _result;
}
private float getBrightness(float paramFloat)
{
if(beforeGetBrightnessHooks != null)
for(int i = beforeGetBrightnessHooks.length - 1; i >= 0 ; i--)
beforeGetBrightnessHooks[i].beforeGetBrightness(paramFloat);
float _result;
if(overrideGetBrightnessHooks != null)
_result = overrideGetBrightnessHooks[overrideGetBrightnessHooks.length - 1].getBrightness(paramFloat);
else
_result = player.localGetBrightness(paramFloat);
if(afterGetBrightnessHooks != null)
for(int i = 0; i < afterGetBrightnessHooks.length; i++)
afterGetBrightnessHooks[i].afterGetBrightness(paramFloat);
return _result;
}
protected ServerPlayerBase GetOverwrittenGetBrightness(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideGetBrightnessHooks.length; i++)
if(overrideGetBrightnessHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideGetBrightnessHooks[i - 1];
return overWriter;
}
private final static List<String> beforeGetBrightnessHookTypes = new LinkedList<String>();
private final static List<String> overrideGetBrightnessHookTypes = new LinkedList<String>();
private final static List<String> afterGetBrightnessHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeGetBrightnessHooks;
private ServerPlayerBase[] overrideGetBrightnessHooks;
private ServerPlayerBase[] afterGetBrightnessHooks;
public boolean isGetBrightnessModded;
private static final Map<String, String[]> allBaseBeforeGetBrightnessSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeGetBrightnessInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetBrightnessSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetBrightnessInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetBrightnessSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetBrightnessInferiors = new Hashtable<String, String[]>(0);
public static float getEyeHeight(IServerPlayerAPI target)
{
float _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isGetEyeHeightModded)
_result = serverPlayerAPI.getEyeHeight();
else
_result = target.localGetEyeHeight();
return _result;
}
private float getEyeHeight()
{
if(beforeGetEyeHeightHooks != null)
for(int i = beforeGetEyeHeightHooks.length - 1; i >= 0 ; i--)
beforeGetEyeHeightHooks[i].beforeGetEyeHeight();
float _result;
if(overrideGetEyeHeightHooks != null)
_result = overrideGetEyeHeightHooks[overrideGetEyeHeightHooks.length - 1].getEyeHeight();
else
_result = player.localGetEyeHeight();
if(afterGetEyeHeightHooks != null)
for(int i = 0; i < afterGetEyeHeightHooks.length; i++)
afterGetEyeHeightHooks[i].afterGetEyeHeight();
return _result;
}
protected ServerPlayerBase GetOverwrittenGetEyeHeight(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideGetEyeHeightHooks.length; i++)
if(overrideGetEyeHeightHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideGetEyeHeightHooks[i - 1];
return overWriter;
}
private final static List<String> beforeGetEyeHeightHookTypes = new LinkedList<String>();
private final static List<String> overrideGetEyeHeightHookTypes = new LinkedList<String>();
private final static List<String> afterGetEyeHeightHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeGetEyeHeightHooks;
private ServerPlayerBase[] overrideGetEyeHeightHooks;
private ServerPlayerBase[] afterGetEyeHeightHooks;
public boolean isGetEyeHeightModded;
private static final Map<String, String[]> allBaseBeforeGetEyeHeightSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeGetEyeHeightInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetEyeHeightSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideGetEyeHeightInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetEyeHeightSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterGetEyeHeightInferiors = new Hashtable<String, String[]>(0);
public static void heal(IServerPlayerAPI target, float paramFloat)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isHealModded)
serverPlayerAPI.heal(paramFloat);
else
target.localHeal(paramFloat);
}
private void heal(float paramFloat)
{
if(beforeHealHooks != null)
for(int i = beforeHealHooks.length - 1; i >= 0 ; i--)
beforeHealHooks[i].beforeHeal(paramFloat);
if(overrideHealHooks != null)
overrideHealHooks[overrideHealHooks.length - 1].heal(paramFloat);
else
player.localHeal(paramFloat);
if(afterHealHooks != null)
for(int i = 0; i < afterHealHooks.length; i++)
afterHealHooks[i].afterHeal(paramFloat);
}
protected ServerPlayerBase GetOverwrittenHeal(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideHealHooks.length; i++)
if(overrideHealHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideHealHooks[i - 1];
return overWriter;
}
private final static List<String> beforeHealHookTypes = new LinkedList<String>();
private final static List<String> overrideHealHookTypes = new LinkedList<String>();
private final static List<String> afterHealHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeHealHooks;
private ServerPlayerBase[] overrideHealHooks;
private ServerPlayerBase[] afterHealHooks;
public boolean isHealModded;
private static final Map<String, String[]> allBaseBeforeHealSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeHealInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideHealSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideHealInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterHealSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterHealInferiors = new Hashtable<String, String[]>(0);
public static boolean isEntityInsideOpaqueBlock(IServerPlayerAPI target)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isIsEntityInsideOpaqueBlockModded)
_result = serverPlayerAPI.isEntityInsideOpaqueBlock();
else
_result = target.localIsEntityInsideOpaqueBlock();
return _result;
}
private boolean isEntityInsideOpaqueBlock()
{
if(beforeIsEntityInsideOpaqueBlockHooks != null)
for(int i = beforeIsEntityInsideOpaqueBlockHooks.length - 1; i >= 0 ; i--)
beforeIsEntityInsideOpaqueBlockHooks[i].beforeIsEntityInsideOpaqueBlock();
boolean _result;
if(overrideIsEntityInsideOpaqueBlockHooks != null)
_result = overrideIsEntityInsideOpaqueBlockHooks[overrideIsEntityInsideOpaqueBlockHooks.length - 1].isEntityInsideOpaqueBlock();
else
_result = player.localIsEntityInsideOpaqueBlock();
if(afterIsEntityInsideOpaqueBlockHooks != null)
for(int i = 0; i < afterIsEntityInsideOpaqueBlockHooks.length; i++)
afterIsEntityInsideOpaqueBlockHooks[i].afterIsEntityInsideOpaqueBlock();
return _result;
}
protected ServerPlayerBase GetOverwrittenIsEntityInsideOpaqueBlock(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideIsEntityInsideOpaqueBlockHooks.length; i++)
if(overrideIsEntityInsideOpaqueBlockHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideIsEntityInsideOpaqueBlockHooks[i - 1];
return overWriter;
}
private final static List<String> beforeIsEntityInsideOpaqueBlockHookTypes = new LinkedList<String>();
private final static List<String> overrideIsEntityInsideOpaqueBlockHookTypes = new LinkedList<String>();
private final static List<String> afterIsEntityInsideOpaqueBlockHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeIsEntityInsideOpaqueBlockHooks;
private ServerPlayerBase[] overrideIsEntityInsideOpaqueBlockHooks;
private ServerPlayerBase[] afterIsEntityInsideOpaqueBlockHooks;
public boolean isIsEntityInsideOpaqueBlockModded;
private static final Map<String, String[]> allBaseBeforeIsEntityInsideOpaqueBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeIsEntityInsideOpaqueBlockInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsEntityInsideOpaqueBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsEntityInsideOpaqueBlockInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsEntityInsideOpaqueBlockSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsEntityInsideOpaqueBlockInferiors = new Hashtable<String, String[]>(0);
public static boolean isInWater(IServerPlayerAPI target)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isIsInWaterModded)
_result = serverPlayerAPI.isInWater();
else
_result = target.localIsInWater();
return _result;
}
private boolean isInWater()
{
if(beforeIsInWaterHooks != null)
for(int i = beforeIsInWaterHooks.length - 1; i >= 0 ; i--)
beforeIsInWaterHooks[i].beforeIsInWater();
boolean _result;
if(overrideIsInWaterHooks != null)
_result = overrideIsInWaterHooks[overrideIsInWaterHooks.length - 1].isInWater();
else
_result = player.localIsInWater();
if(afterIsInWaterHooks != null)
for(int i = 0; i < afterIsInWaterHooks.length; i++)
afterIsInWaterHooks[i].afterIsInWater();
return _result;
}
protected ServerPlayerBase GetOverwrittenIsInWater(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideIsInWaterHooks.length; i++)
if(overrideIsInWaterHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideIsInWaterHooks[i - 1];
return overWriter;
}
private final static List<String> beforeIsInWaterHookTypes = new LinkedList<String>();
private final static List<String> overrideIsInWaterHookTypes = new LinkedList<String>();
private final static List<String> afterIsInWaterHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeIsInWaterHooks;
private ServerPlayerBase[] overrideIsInWaterHooks;
private ServerPlayerBase[] afterIsInWaterHooks;
public boolean isIsInWaterModded;
private static final Map<String, String[]> allBaseBeforeIsInWaterSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeIsInWaterInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsInWaterSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsInWaterInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsInWaterSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsInWaterInferiors = new Hashtable<String, String[]>(0);
public static boolean isInsideOfMaterial(IServerPlayerAPI target, net.minecraft.block.material.Material paramMaterial)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isIsInsideOfMaterialModded)
_result = serverPlayerAPI.isInsideOfMaterial(paramMaterial);
else
_result = target.localIsInsideOfMaterial(paramMaterial);
return _result;
}
private boolean isInsideOfMaterial(net.minecraft.block.material.Material paramMaterial)
{
if(beforeIsInsideOfMaterialHooks != null)
for(int i = beforeIsInsideOfMaterialHooks.length - 1; i >= 0 ; i--)
beforeIsInsideOfMaterialHooks[i].beforeIsInsideOfMaterial(paramMaterial);
boolean _result;
if(overrideIsInsideOfMaterialHooks != null)
_result = overrideIsInsideOfMaterialHooks[overrideIsInsideOfMaterialHooks.length - 1].isInsideOfMaterial(paramMaterial);
else
_result = player.localIsInsideOfMaterial(paramMaterial);
if(afterIsInsideOfMaterialHooks != null)
for(int i = 0; i < afterIsInsideOfMaterialHooks.length; i++)
afterIsInsideOfMaterialHooks[i].afterIsInsideOfMaterial(paramMaterial);
return _result;
}
protected ServerPlayerBase GetOverwrittenIsInsideOfMaterial(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideIsInsideOfMaterialHooks.length; i++)
if(overrideIsInsideOfMaterialHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideIsInsideOfMaterialHooks[i - 1];
return overWriter;
}
private final static List<String> beforeIsInsideOfMaterialHookTypes = new LinkedList<String>();
private final static List<String> overrideIsInsideOfMaterialHookTypes = new LinkedList<String>();
private final static List<String> afterIsInsideOfMaterialHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeIsInsideOfMaterialHooks;
private ServerPlayerBase[] overrideIsInsideOfMaterialHooks;
private ServerPlayerBase[] afterIsInsideOfMaterialHooks;
public boolean isIsInsideOfMaterialModded;
private static final Map<String, String[]> allBaseBeforeIsInsideOfMaterialSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeIsInsideOfMaterialInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsInsideOfMaterialSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsInsideOfMaterialInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsInsideOfMaterialSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsInsideOfMaterialInferiors = new Hashtable<String, String[]>(0);
public static boolean isOnLadder(IServerPlayerAPI target)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isIsOnLadderModded)
_result = serverPlayerAPI.isOnLadder();
else
_result = target.localIsOnLadder();
return _result;
}
private boolean isOnLadder()
{
if(beforeIsOnLadderHooks != null)
for(int i = beforeIsOnLadderHooks.length - 1; i >= 0 ; i--)
beforeIsOnLadderHooks[i].beforeIsOnLadder();
boolean _result;
if(overrideIsOnLadderHooks != null)
_result = overrideIsOnLadderHooks[overrideIsOnLadderHooks.length - 1].isOnLadder();
else
_result = player.localIsOnLadder();
if(afterIsOnLadderHooks != null)
for(int i = 0; i < afterIsOnLadderHooks.length; i++)
afterIsOnLadderHooks[i].afterIsOnLadder();
return _result;
}
protected ServerPlayerBase GetOverwrittenIsOnLadder(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideIsOnLadderHooks.length; i++)
if(overrideIsOnLadderHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideIsOnLadderHooks[i - 1];
return overWriter;
}
private final static List<String> beforeIsOnLadderHookTypes = new LinkedList<String>();
private final static List<String> overrideIsOnLadderHookTypes = new LinkedList<String>();
private final static List<String> afterIsOnLadderHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeIsOnLadderHooks;
private ServerPlayerBase[] overrideIsOnLadderHooks;
private ServerPlayerBase[] afterIsOnLadderHooks;
public boolean isIsOnLadderModded;
private static final Map<String, String[]> allBaseBeforeIsOnLadderSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeIsOnLadderInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsOnLadderSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsOnLadderInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsOnLadderSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsOnLadderInferiors = new Hashtable<String, String[]>(0);
public static boolean isPlayerSleeping(IServerPlayerAPI target)
{
boolean _result;
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isIsPlayerSleepingModded)
_result = serverPlayerAPI.isPlayerSleeping();
else
_result = target.localIsPlayerSleeping();
return _result;
}
private boolean isPlayerSleeping()
{
if(beforeIsPlayerSleepingHooks != null)
for(int i = beforeIsPlayerSleepingHooks.length - 1; i >= 0 ; i--)
beforeIsPlayerSleepingHooks[i].beforeIsPlayerSleeping();
boolean _result;
if(overrideIsPlayerSleepingHooks != null)
_result = overrideIsPlayerSleepingHooks[overrideIsPlayerSleepingHooks.length - 1].isPlayerSleeping();
else
_result = player.localIsPlayerSleeping();
if(afterIsPlayerSleepingHooks != null)
for(int i = 0; i < afterIsPlayerSleepingHooks.length; i++)
afterIsPlayerSleepingHooks[i].afterIsPlayerSleeping();
return _result;
}
protected ServerPlayerBase GetOverwrittenIsPlayerSleeping(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideIsPlayerSleepingHooks.length; i++)
if(overrideIsPlayerSleepingHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideIsPlayerSleepingHooks[i - 1];
return overWriter;
}
private final static List<String> beforeIsPlayerSleepingHookTypes = new LinkedList<String>();
private final static List<String> overrideIsPlayerSleepingHookTypes = new LinkedList<String>();
private final static List<String> afterIsPlayerSleepingHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeIsPlayerSleepingHooks;
private ServerPlayerBase[] overrideIsPlayerSleepingHooks;
private ServerPlayerBase[] afterIsPlayerSleepingHooks;
public boolean isIsPlayerSleepingModded;
private static final Map<String, String[]> allBaseBeforeIsPlayerSleepingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeIsPlayerSleepingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsPlayerSleepingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideIsPlayerSleepingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsPlayerSleepingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterIsPlayerSleepingInferiors = new Hashtable<String, String[]>(0);
public static void jump(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isJumpModded)
serverPlayerAPI.jump();
else
target.localJump();
}
private void jump()
{
if(beforeJumpHooks != null)
for(int i = beforeJumpHooks.length - 1; i >= 0 ; i--)
beforeJumpHooks[i].beforeJump();
if(overrideJumpHooks != null)
overrideJumpHooks[overrideJumpHooks.length - 1].jump();
else
player.localJump();
if(afterJumpHooks != null)
for(int i = 0; i < afterJumpHooks.length; i++)
afterJumpHooks[i].afterJump();
}
protected ServerPlayerBase GetOverwrittenJump(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideJumpHooks.length; i++)
if(overrideJumpHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideJumpHooks[i - 1];
return overWriter;
}
private final static List<String> beforeJumpHookTypes = new LinkedList<String>();
private final static List<String> overrideJumpHookTypes = new LinkedList<String>();
private final static List<String> afterJumpHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeJumpHooks;
private ServerPlayerBase[] overrideJumpHooks;
private ServerPlayerBase[] afterJumpHooks;
public boolean isJumpModded;
private static final Map<String, String[]> allBaseBeforeJumpSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeJumpInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideJumpSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideJumpInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterJumpSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterJumpInferiors = new Hashtable<String, String[]>(0);
public static void knockBack(IServerPlayerAPI target, net.minecraft.entity.Entity paramEntity, float paramFloat, double paramDouble1, double paramDouble2)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isKnockBackModded)
serverPlayerAPI.knockBack(paramEntity, paramFloat, paramDouble1, paramDouble2);
else
target.localKnockBack(paramEntity, paramFloat, paramDouble1, paramDouble2);
}
private void knockBack(net.minecraft.entity.Entity paramEntity, float paramFloat, double paramDouble1, double paramDouble2)
{
if(beforeKnockBackHooks != null)
for(int i = beforeKnockBackHooks.length - 1; i >= 0 ; i--)
beforeKnockBackHooks[i].beforeKnockBack(paramEntity, paramFloat, paramDouble1, paramDouble2);
if(overrideKnockBackHooks != null)
overrideKnockBackHooks[overrideKnockBackHooks.length - 1].knockBack(paramEntity, paramFloat, paramDouble1, paramDouble2);
else
player.localKnockBack(paramEntity, paramFloat, paramDouble1, paramDouble2);
if(afterKnockBackHooks != null)
for(int i = 0; i < afterKnockBackHooks.length; i++)
afterKnockBackHooks[i].afterKnockBack(paramEntity, paramFloat, paramDouble1, paramDouble2);
}
protected ServerPlayerBase GetOverwrittenKnockBack(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideKnockBackHooks.length; i++)
if(overrideKnockBackHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideKnockBackHooks[i - 1];
return overWriter;
}
private final static List<String> beforeKnockBackHookTypes = new LinkedList<String>();
private final static List<String> overrideKnockBackHookTypes = new LinkedList<String>();
private final static List<String> afterKnockBackHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeKnockBackHooks;
private ServerPlayerBase[] overrideKnockBackHooks;
private ServerPlayerBase[] afterKnockBackHooks;
public boolean isKnockBackModded;
private static final Map<String, String[]> allBaseBeforeKnockBackSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeKnockBackInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideKnockBackSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideKnockBackInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterKnockBackSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterKnockBackInferiors = new Hashtable<String, String[]>(0);
public static void moveEntity(IServerPlayerAPI target, double paramDouble1, double paramDouble2, double paramDouble3)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isMoveEntityModded)
serverPlayerAPI.moveEntity(paramDouble1, paramDouble2, paramDouble3);
else
target.localMoveEntity(paramDouble1, paramDouble2, paramDouble3);
}
private void moveEntity(double paramDouble1, double paramDouble2, double paramDouble3)
{
if(beforeMoveEntityHooks != null)
for(int i = beforeMoveEntityHooks.length - 1; i >= 0 ; i--)
beforeMoveEntityHooks[i].beforeMoveEntity(paramDouble1, paramDouble2, paramDouble3);
if(overrideMoveEntityHooks != null)
overrideMoveEntityHooks[overrideMoveEntityHooks.length - 1].moveEntity(paramDouble1, paramDouble2, paramDouble3);
else
player.localMoveEntity(paramDouble1, paramDouble2, paramDouble3);
if(afterMoveEntityHooks != null)
for(int i = 0; i < afterMoveEntityHooks.length; i++)
afterMoveEntityHooks[i].afterMoveEntity(paramDouble1, paramDouble2, paramDouble3);
}
protected ServerPlayerBase GetOverwrittenMoveEntity(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideMoveEntityHooks.length; i++)
if(overrideMoveEntityHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideMoveEntityHooks[i - 1];
return overWriter;
}
private final static List<String> beforeMoveEntityHookTypes = new LinkedList<String>();
private final static List<String> overrideMoveEntityHookTypes = new LinkedList<String>();
private final static List<String> afterMoveEntityHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeMoveEntityHooks;
private ServerPlayerBase[] overrideMoveEntityHooks;
private ServerPlayerBase[] afterMoveEntityHooks;
public boolean isMoveEntityModded;
private static final Map<String, String[]> allBaseBeforeMoveEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeMoveEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideMoveEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideMoveEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterMoveEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterMoveEntityInferiors = new Hashtable<String, String[]>(0);
public static void moveEntityWithHeading(IServerPlayerAPI target, float paramFloat1, float paramFloat2)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isMoveEntityWithHeadingModded)
serverPlayerAPI.moveEntityWithHeading(paramFloat1, paramFloat2);
else
target.localMoveEntityWithHeading(paramFloat1, paramFloat2);
}
private void moveEntityWithHeading(float paramFloat1, float paramFloat2)
{
if(beforeMoveEntityWithHeadingHooks != null)
for(int i = beforeMoveEntityWithHeadingHooks.length - 1; i >= 0 ; i--)
beforeMoveEntityWithHeadingHooks[i].beforeMoveEntityWithHeading(paramFloat1, paramFloat2);
if(overrideMoveEntityWithHeadingHooks != null)
overrideMoveEntityWithHeadingHooks[overrideMoveEntityWithHeadingHooks.length - 1].moveEntityWithHeading(paramFloat1, paramFloat2);
else
player.localMoveEntityWithHeading(paramFloat1, paramFloat2);
if(afterMoveEntityWithHeadingHooks != null)
for(int i = 0; i < afterMoveEntityWithHeadingHooks.length; i++)
afterMoveEntityWithHeadingHooks[i].afterMoveEntityWithHeading(paramFloat1, paramFloat2);
}
protected ServerPlayerBase GetOverwrittenMoveEntityWithHeading(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideMoveEntityWithHeadingHooks.length; i++)
if(overrideMoveEntityWithHeadingHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideMoveEntityWithHeadingHooks[i - 1];
return overWriter;
}
private final static List<String> beforeMoveEntityWithHeadingHookTypes = new LinkedList<String>();
private final static List<String> overrideMoveEntityWithHeadingHookTypes = new LinkedList<String>();
private final static List<String> afterMoveEntityWithHeadingHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeMoveEntityWithHeadingHooks;
private ServerPlayerBase[] overrideMoveEntityWithHeadingHooks;
private ServerPlayerBase[] afterMoveEntityWithHeadingHooks;
public boolean isMoveEntityWithHeadingModded;
private static final Map<String, String[]> allBaseBeforeMoveEntityWithHeadingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeMoveEntityWithHeadingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideMoveEntityWithHeadingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideMoveEntityWithHeadingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterMoveEntityWithHeadingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterMoveEntityWithHeadingInferiors = new Hashtable<String, String[]>(0);
public static void moveFlying(IServerPlayerAPI target, float paramFloat1, float paramFloat2, float paramFloat3)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isMoveFlyingModded)
serverPlayerAPI.moveFlying(paramFloat1, paramFloat2, paramFloat3);
else
target.localMoveFlying(paramFloat1, paramFloat2, paramFloat3);
}
private void moveFlying(float paramFloat1, float paramFloat2, float paramFloat3)
{
if(beforeMoveFlyingHooks != null)
for(int i = beforeMoveFlyingHooks.length - 1; i >= 0 ; i--)
beforeMoveFlyingHooks[i].beforeMoveFlying(paramFloat1, paramFloat2, paramFloat3);
if(overrideMoveFlyingHooks != null)
overrideMoveFlyingHooks[overrideMoveFlyingHooks.length - 1].moveFlying(paramFloat1, paramFloat2, paramFloat3);
else
player.localMoveFlying(paramFloat1, paramFloat2, paramFloat3);
if(afterMoveFlyingHooks != null)
for(int i = 0; i < afterMoveFlyingHooks.length; i++)
afterMoveFlyingHooks[i].afterMoveFlying(paramFloat1, paramFloat2, paramFloat3);
}
protected ServerPlayerBase GetOverwrittenMoveFlying(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideMoveFlyingHooks.length; i++)
if(overrideMoveFlyingHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideMoveFlyingHooks[i - 1];
return overWriter;
}
private final static List<String> beforeMoveFlyingHookTypes = new LinkedList<String>();
private final static List<String> overrideMoveFlyingHookTypes = new LinkedList<String>();
private final static List<String> afterMoveFlyingHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeMoveFlyingHooks;
private ServerPlayerBase[] overrideMoveFlyingHooks;
private ServerPlayerBase[] afterMoveFlyingHooks;
public boolean isMoveFlyingModded;
private static final Map<String, String[]> allBaseBeforeMoveFlyingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeMoveFlyingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideMoveFlyingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideMoveFlyingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterMoveFlyingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterMoveFlyingInferiors = new Hashtable<String, String[]>(0);
public static void onDeath(IServerPlayerAPI target, net.minecraft.util.DamageSource paramDamageSource)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isOnDeathModded)
serverPlayerAPI.onDeath(paramDamageSource);
else
target.localOnDeath(paramDamageSource);
}
private void onDeath(net.minecraft.util.DamageSource paramDamageSource)
{
if(beforeOnDeathHooks != null)
for(int i = beforeOnDeathHooks.length - 1; i >= 0 ; i--)
beforeOnDeathHooks[i].beforeOnDeath(paramDamageSource);
if(overrideOnDeathHooks != null)
overrideOnDeathHooks[overrideOnDeathHooks.length - 1].onDeath(paramDamageSource);
else
player.localOnDeath(paramDamageSource);
if(afterOnDeathHooks != null)
for(int i = 0; i < afterOnDeathHooks.length; i++)
afterOnDeathHooks[i].afterOnDeath(paramDamageSource);
}
protected ServerPlayerBase GetOverwrittenOnDeath(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideOnDeathHooks.length; i++)
if(overrideOnDeathHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideOnDeathHooks[i - 1];
return overWriter;
}
private final static List<String> beforeOnDeathHookTypes = new LinkedList<String>();
private final static List<String> overrideOnDeathHookTypes = new LinkedList<String>();
private final static List<String> afterOnDeathHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeOnDeathHooks;
private ServerPlayerBase[] overrideOnDeathHooks;
private ServerPlayerBase[] afterOnDeathHooks;
public boolean isOnDeathModded;
private static final Map<String, String[]> allBaseBeforeOnDeathSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeOnDeathInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnDeathSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnDeathInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnDeathSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnDeathInferiors = new Hashtable<String, String[]>(0);
public static void onLivingUpdate(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isOnLivingUpdateModded)
serverPlayerAPI.onLivingUpdate();
else
target.localOnLivingUpdate();
}
private void onLivingUpdate()
{
if(beforeOnLivingUpdateHooks != null)
for(int i = beforeOnLivingUpdateHooks.length - 1; i >= 0 ; i--)
beforeOnLivingUpdateHooks[i].beforeOnLivingUpdate();
if(overrideOnLivingUpdateHooks != null)
overrideOnLivingUpdateHooks[overrideOnLivingUpdateHooks.length - 1].onLivingUpdate();
else
player.localOnLivingUpdate();
if(afterOnLivingUpdateHooks != null)
for(int i = 0; i < afterOnLivingUpdateHooks.length; i++)
afterOnLivingUpdateHooks[i].afterOnLivingUpdate();
}
protected ServerPlayerBase GetOverwrittenOnLivingUpdate(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideOnLivingUpdateHooks.length; i++)
if(overrideOnLivingUpdateHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideOnLivingUpdateHooks[i - 1];
return overWriter;
}
private final static List<String> beforeOnLivingUpdateHookTypes = new LinkedList<String>();
private final static List<String> overrideOnLivingUpdateHookTypes = new LinkedList<String>();
private final static List<String> afterOnLivingUpdateHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeOnLivingUpdateHooks;
private ServerPlayerBase[] overrideOnLivingUpdateHooks;
private ServerPlayerBase[] afterOnLivingUpdateHooks;
public boolean isOnLivingUpdateModded;
private static final Map<String, String[]> allBaseBeforeOnLivingUpdateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeOnLivingUpdateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnLivingUpdateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnLivingUpdateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnLivingUpdateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnLivingUpdateInferiors = new Hashtable<String, String[]>(0);
public static void onKillEntity(IServerPlayerAPI target, net.minecraft.entity.EntityLivingBase paramEntityLivingBase)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isOnKillEntityModded)
serverPlayerAPI.onKillEntity(paramEntityLivingBase);
else
target.localOnKillEntity(paramEntityLivingBase);
}
private void onKillEntity(net.minecraft.entity.EntityLivingBase paramEntityLivingBase)
{
if(beforeOnKillEntityHooks != null)
for(int i = beforeOnKillEntityHooks.length - 1; i >= 0 ; i--)
beforeOnKillEntityHooks[i].beforeOnKillEntity(paramEntityLivingBase);
if(overrideOnKillEntityHooks != null)
overrideOnKillEntityHooks[overrideOnKillEntityHooks.length - 1].onKillEntity(paramEntityLivingBase);
else
player.localOnKillEntity(paramEntityLivingBase);
if(afterOnKillEntityHooks != null)
for(int i = 0; i < afterOnKillEntityHooks.length; i++)
afterOnKillEntityHooks[i].afterOnKillEntity(paramEntityLivingBase);
}
protected ServerPlayerBase GetOverwrittenOnKillEntity(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideOnKillEntityHooks.length; i++)
if(overrideOnKillEntityHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideOnKillEntityHooks[i - 1];
return overWriter;
}
private final static List<String> beforeOnKillEntityHookTypes = new LinkedList<String>();
private final static List<String> overrideOnKillEntityHookTypes = new LinkedList<String>();
private final static List<String> afterOnKillEntityHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeOnKillEntityHooks;
private ServerPlayerBase[] overrideOnKillEntityHooks;
private ServerPlayerBase[] afterOnKillEntityHooks;
public boolean isOnKillEntityModded;
private static final Map<String, String[]> allBaseBeforeOnKillEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeOnKillEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnKillEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnKillEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnKillEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnKillEntityInferiors = new Hashtable<String, String[]>(0);
public static void onStruckByLightning(IServerPlayerAPI target, net.minecraft.entity.effect.EntityLightningBolt paramEntityLightningBolt)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isOnStruckByLightningModded)
serverPlayerAPI.onStruckByLightning(paramEntityLightningBolt);
else
target.localOnStruckByLightning(paramEntityLightningBolt);
}
private void onStruckByLightning(net.minecraft.entity.effect.EntityLightningBolt paramEntityLightningBolt)
{
if(beforeOnStruckByLightningHooks != null)
for(int i = beforeOnStruckByLightningHooks.length - 1; i >= 0 ; i--)
beforeOnStruckByLightningHooks[i].beforeOnStruckByLightning(paramEntityLightningBolt);
if(overrideOnStruckByLightningHooks != null)
overrideOnStruckByLightningHooks[overrideOnStruckByLightningHooks.length - 1].onStruckByLightning(paramEntityLightningBolt);
else
player.localOnStruckByLightning(paramEntityLightningBolt);
if(afterOnStruckByLightningHooks != null)
for(int i = 0; i < afterOnStruckByLightningHooks.length; i++)
afterOnStruckByLightningHooks[i].afterOnStruckByLightning(paramEntityLightningBolt);
}
protected ServerPlayerBase GetOverwrittenOnStruckByLightning(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideOnStruckByLightningHooks.length; i++)
if(overrideOnStruckByLightningHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideOnStruckByLightningHooks[i - 1];
return overWriter;
}
private final static List<String> beforeOnStruckByLightningHookTypes = new LinkedList<String>();
private final static List<String> overrideOnStruckByLightningHookTypes = new LinkedList<String>();
private final static List<String> afterOnStruckByLightningHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeOnStruckByLightningHooks;
private ServerPlayerBase[] overrideOnStruckByLightningHooks;
private ServerPlayerBase[] afterOnStruckByLightningHooks;
public boolean isOnStruckByLightningModded;
private static final Map<String, String[]> allBaseBeforeOnStruckByLightningSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeOnStruckByLightningInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnStruckByLightningSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnStruckByLightningInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnStruckByLightningSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnStruckByLightningInferiors = new Hashtable<String, String[]>(0);
public static void onUpdate(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isOnUpdateModded)
serverPlayerAPI.onUpdate();
else
target.localOnUpdate();
}
private void onUpdate()
{
if(beforeOnUpdateHooks != null)
for(int i = beforeOnUpdateHooks.length - 1; i >= 0 ; i--)
beforeOnUpdateHooks[i].beforeOnUpdate();
if(overrideOnUpdateHooks != null)
overrideOnUpdateHooks[overrideOnUpdateHooks.length - 1].onUpdate();
else
player.localOnUpdate();
if(afterOnUpdateHooks != null)
for(int i = 0; i < afterOnUpdateHooks.length; i++)
afterOnUpdateHooks[i].afterOnUpdate();
}
protected ServerPlayerBase GetOverwrittenOnUpdate(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideOnUpdateHooks.length; i++)
if(overrideOnUpdateHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideOnUpdateHooks[i - 1];
return overWriter;
}
private final static List<String> beforeOnUpdateHookTypes = new LinkedList<String>();
private final static List<String> overrideOnUpdateHookTypes = new LinkedList<String>();
private final static List<String> afterOnUpdateHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeOnUpdateHooks;
private ServerPlayerBase[] overrideOnUpdateHooks;
private ServerPlayerBase[] afterOnUpdateHooks;
public boolean isOnUpdateModded;
private static final Map<String, String[]> allBaseBeforeOnUpdateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeOnUpdateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnUpdateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnUpdateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnUpdateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnUpdateInferiors = new Hashtable<String, String[]>(0);
public static void onUpdateEntity(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isOnUpdateEntityModded)
serverPlayerAPI.onUpdateEntity();
else
target.localOnUpdateEntity();
}
private void onUpdateEntity()
{
if(beforeOnUpdateEntityHooks != null)
for(int i = beforeOnUpdateEntityHooks.length - 1; i >= 0 ; i--)
beforeOnUpdateEntityHooks[i].beforeOnUpdateEntity();
if(overrideOnUpdateEntityHooks != null)
overrideOnUpdateEntityHooks[overrideOnUpdateEntityHooks.length - 1].onUpdateEntity();
else
player.localOnUpdateEntity();
if(afterOnUpdateEntityHooks != null)
for(int i = 0; i < afterOnUpdateEntityHooks.length; i++)
afterOnUpdateEntityHooks[i].afterOnUpdateEntity();
}
protected ServerPlayerBase GetOverwrittenOnUpdateEntity(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideOnUpdateEntityHooks.length; i++)
if(overrideOnUpdateEntityHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideOnUpdateEntityHooks[i - 1];
return overWriter;
}
private final static List<String> beforeOnUpdateEntityHookTypes = new LinkedList<String>();
private final static List<String> overrideOnUpdateEntityHookTypes = new LinkedList<String>();
private final static List<String> afterOnUpdateEntityHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeOnUpdateEntityHooks;
private ServerPlayerBase[] overrideOnUpdateEntityHooks;
private ServerPlayerBase[] afterOnUpdateEntityHooks;
public boolean isOnUpdateEntityModded;
private static final Map<String, String[]> allBaseBeforeOnUpdateEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeOnUpdateEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnUpdateEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideOnUpdateEntityInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnUpdateEntitySuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterOnUpdateEntityInferiors = new Hashtable<String, String[]>(0);
public static void readEntityFromNBT(IServerPlayerAPI target, net.minecraft.nbt.NBTTagCompound paramNBTTagCompound)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isReadEntityFromNBTModded)
serverPlayerAPI.readEntityFromNBT(paramNBTTagCompound);
else
target.localReadEntityFromNBT(paramNBTTagCompound);
}
private void readEntityFromNBT(net.minecraft.nbt.NBTTagCompound paramNBTTagCompound)
{
if(beforeReadEntityFromNBTHooks != null)
for(int i = beforeReadEntityFromNBTHooks.length - 1; i >= 0 ; i--)
beforeReadEntityFromNBTHooks[i].beforeReadEntityFromNBT(paramNBTTagCompound);
if(overrideReadEntityFromNBTHooks != null)
overrideReadEntityFromNBTHooks[overrideReadEntityFromNBTHooks.length - 1].readEntityFromNBT(paramNBTTagCompound);
else
player.localReadEntityFromNBT(paramNBTTagCompound);
if(afterReadEntityFromNBTHooks != null)
for(int i = 0; i < afterReadEntityFromNBTHooks.length; i++)
afterReadEntityFromNBTHooks[i].afterReadEntityFromNBT(paramNBTTagCompound);
}
protected ServerPlayerBase GetOverwrittenReadEntityFromNBT(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideReadEntityFromNBTHooks.length; i++)
if(overrideReadEntityFromNBTHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideReadEntityFromNBTHooks[i - 1];
return overWriter;
}
private final static List<String> beforeReadEntityFromNBTHookTypes = new LinkedList<String>();
private final static List<String> overrideReadEntityFromNBTHookTypes = new LinkedList<String>();
private final static List<String> afterReadEntityFromNBTHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeReadEntityFromNBTHooks;
private ServerPlayerBase[] overrideReadEntityFromNBTHooks;
private ServerPlayerBase[] afterReadEntityFromNBTHooks;
public boolean isReadEntityFromNBTModded;
private static final Map<String, String[]> allBaseBeforeReadEntityFromNBTSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeReadEntityFromNBTInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideReadEntityFromNBTSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideReadEntityFromNBTInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterReadEntityFromNBTSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterReadEntityFromNBTInferiors = new Hashtable<String, String[]>(0);
public static void setDead(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isSetDeadModded)
serverPlayerAPI.setDead();
else
target.localSetDead();
}
private void setDead()
{
if(beforeSetDeadHooks != null)
for(int i = beforeSetDeadHooks.length - 1; i >= 0 ; i--)
beforeSetDeadHooks[i].beforeSetDead();
if(overrideSetDeadHooks != null)
overrideSetDeadHooks[overrideSetDeadHooks.length - 1].setDead();
else
player.localSetDead();
if(afterSetDeadHooks != null)
for(int i = 0; i < afterSetDeadHooks.length; i++)
afterSetDeadHooks[i].afterSetDead();
}
protected ServerPlayerBase GetOverwrittenSetDead(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideSetDeadHooks.length; i++)
if(overrideSetDeadHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideSetDeadHooks[i - 1];
return overWriter;
}
private final static List<String> beforeSetDeadHookTypes = new LinkedList<String>();
private final static List<String> overrideSetDeadHookTypes = new LinkedList<String>();
private final static List<String> afterSetDeadHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeSetDeadHooks;
private ServerPlayerBase[] overrideSetDeadHooks;
private ServerPlayerBase[] afterSetDeadHooks;
public boolean isSetDeadModded;
private static final Map<String, String[]> allBaseBeforeSetDeadSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeSetDeadInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetDeadSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetDeadInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetDeadSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetDeadInferiors = new Hashtable<String, String[]>(0);
public static void setEntityActionState(IServerPlayerAPI target, float paramFloat1, float paramFloat2, boolean paramBoolean1, boolean paramBoolean2)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isSetEntityActionStateModded)
serverPlayerAPI.setEntityActionState(paramFloat1, paramFloat2, paramBoolean1, paramBoolean2);
else
target.localSetEntityActionState(paramFloat1, paramFloat2, paramBoolean1, paramBoolean2);
}
private void setEntityActionState(float paramFloat1, float paramFloat2, boolean paramBoolean1, boolean paramBoolean2)
{
if(beforeSetEntityActionStateHooks != null)
for(int i = beforeSetEntityActionStateHooks.length - 1; i >= 0 ; i--)
beforeSetEntityActionStateHooks[i].beforeSetEntityActionState(paramFloat1, paramFloat2, paramBoolean1, paramBoolean2);
if(overrideSetEntityActionStateHooks != null)
overrideSetEntityActionStateHooks[overrideSetEntityActionStateHooks.length - 1].setEntityActionState(paramFloat1, paramFloat2, paramBoolean1, paramBoolean2);
else
player.localSetEntityActionState(paramFloat1, paramFloat2, paramBoolean1, paramBoolean2);
if(afterSetEntityActionStateHooks != null)
for(int i = 0; i < afterSetEntityActionStateHooks.length; i++)
afterSetEntityActionStateHooks[i].afterSetEntityActionState(paramFloat1, paramFloat2, paramBoolean1, paramBoolean2);
}
protected ServerPlayerBase GetOverwrittenSetEntityActionState(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideSetEntityActionStateHooks.length; i++)
if(overrideSetEntityActionStateHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideSetEntityActionStateHooks[i - 1];
return overWriter;
}
private final static List<String> beforeSetEntityActionStateHookTypes = new LinkedList<String>();
private final static List<String> overrideSetEntityActionStateHookTypes = new LinkedList<String>();
private final static List<String> afterSetEntityActionStateHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeSetEntityActionStateHooks;
private ServerPlayerBase[] overrideSetEntityActionStateHooks;
private ServerPlayerBase[] afterSetEntityActionStateHooks;
public boolean isSetEntityActionStateModded;
private static final Map<String, String[]> allBaseBeforeSetEntityActionStateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeSetEntityActionStateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetEntityActionStateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetEntityActionStateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetEntityActionStateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetEntityActionStateInferiors = new Hashtable<String, String[]>(0);
public static void setPosition(IServerPlayerAPI target, double paramDouble1, double paramDouble2, double paramDouble3)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isSetPositionModded)
serverPlayerAPI.setPosition(paramDouble1, paramDouble2, paramDouble3);
else
target.localSetPosition(paramDouble1, paramDouble2, paramDouble3);
}
private void setPosition(double paramDouble1, double paramDouble2, double paramDouble3)
{
if(beforeSetPositionHooks != null)
for(int i = beforeSetPositionHooks.length - 1; i >= 0 ; i--)
beforeSetPositionHooks[i].beforeSetPosition(paramDouble1, paramDouble2, paramDouble3);
if(overrideSetPositionHooks != null)
overrideSetPositionHooks[overrideSetPositionHooks.length - 1].setPosition(paramDouble1, paramDouble2, paramDouble3);
else
player.localSetPosition(paramDouble1, paramDouble2, paramDouble3);
if(afterSetPositionHooks != null)
for(int i = 0; i < afterSetPositionHooks.length; i++)
afterSetPositionHooks[i].afterSetPosition(paramDouble1, paramDouble2, paramDouble3);
}
protected ServerPlayerBase GetOverwrittenSetPosition(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideSetPositionHooks.length; i++)
if(overrideSetPositionHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideSetPositionHooks[i - 1];
return overWriter;
}
private final static List<String> beforeSetPositionHookTypes = new LinkedList<String>();
private final static List<String> overrideSetPositionHookTypes = new LinkedList<String>();
private final static List<String> afterSetPositionHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeSetPositionHooks;
private ServerPlayerBase[] overrideSetPositionHooks;
private ServerPlayerBase[] afterSetPositionHooks;
public boolean isSetPositionModded;
private static final Map<String, String[]> allBaseBeforeSetPositionSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeSetPositionInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetPositionSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetPositionInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetPositionSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetPositionInferiors = new Hashtable<String, String[]>(0);
public static void setSneaking(IServerPlayerAPI target, boolean paramBoolean)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isSetSneakingModded)
serverPlayerAPI.setSneaking(paramBoolean);
else
target.localSetSneaking(paramBoolean);
}
private void setSneaking(boolean paramBoolean)
{
if(beforeSetSneakingHooks != null)
for(int i = beforeSetSneakingHooks.length - 1; i >= 0 ; i--)
beforeSetSneakingHooks[i].beforeSetSneaking(paramBoolean);
if(overrideSetSneakingHooks != null)
overrideSetSneakingHooks[overrideSetSneakingHooks.length - 1].setSneaking(paramBoolean);
else
player.localSetSneaking(paramBoolean);
if(afterSetSneakingHooks != null)
for(int i = 0; i < afterSetSneakingHooks.length; i++)
afterSetSneakingHooks[i].afterSetSneaking(paramBoolean);
}
protected ServerPlayerBase GetOverwrittenSetSneaking(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideSetSneakingHooks.length; i++)
if(overrideSetSneakingHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideSetSneakingHooks[i - 1];
return overWriter;
}
private final static List<String> beforeSetSneakingHookTypes = new LinkedList<String>();
private final static List<String> overrideSetSneakingHookTypes = new LinkedList<String>();
private final static List<String> afterSetSneakingHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeSetSneakingHooks;
private ServerPlayerBase[] overrideSetSneakingHooks;
private ServerPlayerBase[] afterSetSneakingHooks;
public boolean isSetSneakingModded;
private static final Map<String, String[]> allBaseBeforeSetSneakingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeSetSneakingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetSneakingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetSneakingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetSneakingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetSneakingInferiors = new Hashtable<String, String[]>(0);
public static void setSprinting(IServerPlayerAPI target, boolean paramBoolean)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isSetSprintingModded)
serverPlayerAPI.setSprinting(paramBoolean);
else
target.localSetSprinting(paramBoolean);
}
private void setSprinting(boolean paramBoolean)
{
if(beforeSetSprintingHooks != null)
for(int i = beforeSetSprintingHooks.length - 1; i >= 0 ; i--)
beforeSetSprintingHooks[i].beforeSetSprinting(paramBoolean);
if(overrideSetSprintingHooks != null)
overrideSetSprintingHooks[overrideSetSprintingHooks.length - 1].setSprinting(paramBoolean);
else
player.localSetSprinting(paramBoolean);
if(afterSetSprintingHooks != null)
for(int i = 0; i < afterSetSprintingHooks.length; i++)
afterSetSprintingHooks[i].afterSetSprinting(paramBoolean);
}
protected ServerPlayerBase GetOverwrittenSetSprinting(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideSetSprintingHooks.length; i++)
if(overrideSetSprintingHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideSetSprintingHooks[i - 1];
return overWriter;
}
private final static List<String> beforeSetSprintingHookTypes = new LinkedList<String>();
private final static List<String> overrideSetSprintingHookTypes = new LinkedList<String>();
private final static List<String> afterSetSprintingHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeSetSprintingHooks;
private ServerPlayerBase[] overrideSetSprintingHooks;
private ServerPlayerBase[] afterSetSprintingHooks;
public boolean isSetSprintingModded;
private static final Map<String, String[]> allBaseBeforeSetSprintingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeSetSprintingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetSprintingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSetSprintingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetSprintingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSetSprintingInferiors = new Hashtable<String, String[]>(0);
public static void swingItem(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isSwingItemModded)
serverPlayerAPI.swingItem();
else
target.localSwingItem();
}
private void swingItem()
{
if(beforeSwingItemHooks != null)
for(int i = beforeSwingItemHooks.length - 1; i >= 0 ; i--)
beforeSwingItemHooks[i].beforeSwingItem();
if(overrideSwingItemHooks != null)
overrideSwingItemHooks[overrideSwingItemHooks.length - 1].swingItem();
else
player.localSwingItem();
if(afterSwingItemHooks != null)
for(int i = 0; i < afterSwingItemHooks.length; i++)
afterSwingItemHooks[i].afterSwingItem();
}
protected ServerPlayerBase GetOverwrittenSwingItem(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideSwingItemHooks.length; i++)
if(overrideSwingItemHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideSwingItemHooks[i - 1];
return overWriter;
}
private final static List<String> beforeSwingItemHookTypes = new LinkedList<String>();
private final static List<String> overrideSwingItemHookTypes = new LinkedList<String>();
private final static List<String> afterSwingItemHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeSwingItemHooks;
private ServerPlayerBase[] overrideSwingItemHooks;
private ServerPlayerBase[] afterSwingItemHooks;
public boolean isSwingItemModded;
private static final Map<String, String[]> allBaseBeforeSwingItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeSwingItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSwingItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideSwingItemInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSwingItemSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterSwingItemInferiors = new Hashtable<String, String[]>(0);
public static void updateEntityActionState(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isUpdateEntityActionStateModded)
serverPlayerAPI.updateEntityActionState();
else
target.localUpdateEntityActionState();
}
private void updateEntityActionState()
{
if(beforeUpdateEntityActionStateHooks != null)
for(int i = beforeUpdateEntityActionStateHooks.length - 1; i >= 0 ; i--)
beforeUpdateEntityActionStateHooks[i].beforeUpdateEntityActionState();
if(overrideUpdateEntityActionStateHooks != null)
overrideUpdateEntityActionStateHooks[overrideUpdateEntityActionStateHooks.length - 1].updateEntityActionState();
else
player.localUpdateEntityActionState();
if(afterUpdateEntityActionStateHooks != null)
for(int i = 0; i < afterUpdateEntityActionStateHooks.length; i++)
afterUpdateEntityActionStateHooks[i].afterUpdateEntityActionState();
}
protected ServerPlayerBase GetOverwrittenUpdateEntityActionState(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideUpdateEntityActionStateHooks.length; i++)
if(overrideUpdateEntityActionStateHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideUpdateEntityActionStateHooks[i - 1];
return overWriter;
}
private final static List<String> beforeUpdateEntityActionStateHookTypes = new LinkedList<String>();
private final static List<String> overrideUpdateEntityActionStateHookTypes = new LinkedList<String>();
private final static List<String> afterUpdateEntityActionStateHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeUpdateEntityActionStateHooks;
private ServerPlayerBase[] overrideUpdateEntityActionStateHooks;
private ServerPlayerBase[] afterUpdateEntityActionStateHooks;
public boolean isUpdateEntityActionStateModded;
private static final Map<String, String[]> allBaseBeforeUpdateEntityActionStateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeUpdateEntityActionStateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideUpdateEntityActionStateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideUpdateEntityActionStateInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterUpdateEntityActionStateSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterUpdateEntityActionStateInferiors = new Hashtable<String, String[]>(0);
public static void updatePotionEffects(IServerPlayerAPI target)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isUpdatePotionEffectsModded)
serverPlayerAPI.updatePotionEffects();
else
target.localUpdatePotionEffects();
}
private void updatePotionEffects()
{
if(beforeUpdatePotionEffectsHooks != null)
for(int i = beforeUpdatePotionEffectsHooks.length - 1; i >= 0 ; i--)
beforeUpdatePotionEffectsHooks[i].beforeUpdatePotionEffects();
if(overrideUpdatePotionEffectsHooks != null)
overrideUpdatePotionEffectsHooks[overrideUpdatePotionEffectsHooks.length - 1].updatePotionEffects();
else
player.localUpdatePotionEffects();
if(afterUpdatePotionEffectsHooks != null)
for(int i = 0; i < afterUpdatePotionEffectsHooks.length; i++)
afterUpdatePotionEffectsHooks[i].afterUpdatePotionEffects();
}
protected ServerPlayerBase GetOverwrittenUpdatePotionEffects(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideUpdatePotionEffectsHooks.length; i++)
if(overrideUpdatePotionEffectsHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideUpdatePotionEffectsHooks[i - 1];
return overWriter;
}
private final static List<String> beforeUpdatePotionEffectsHookTypes = new LinkedList<String>();
private final static List<String> overrideUpdatePotionEffectsHookTypes = new LinkedList<String>();
private final static List<String> afterUpdatePotionEffectsHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeUpdatePotionEffectsHooks;
private ServerPlayerBase[] overrideUpdatePotionEffectsHooks;
private ServerPlayerBase[] afterUpdatePotionEffectsHooks;
public boolean isUpdatePotionEffectsModded;
private static final Map<String, String[]> allBaseBeforeUpdatePotionEffectsSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeUpdatePotionEffectsInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideUpdatePotionEffectsSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideUpdatePotionEffectsInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterUpdatePotionEffectsSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterUpdatePotionEffectsInferiors = new Hashtable<String, String[]>(0);
public static void writeEntityToNBT(IServerPlayerAPI target, net.minecraft.nbt.NBTTagCompound paramNBTTagCompound)
{
ServerPlayerAPI serverPlayerAPI = target.getServerPlayerAPI();
if(serverPlayerAPI != null && serverPlayerAPI.isWriteEntityToNBTModded)
serverPlayerAPI.writeEntityToNBT(paramNBTTagCompound);
else
target.localWriteEntityToNBT(paramNBTTagCompound);
}
private void writeEntityToNBT(net.minecraft.nbt.NBTTagCompound paramNBTTagCompound)
{
if(beforeWriteEntityToNBTHooks != null)
for(int i = beforeWriteEntityToNBTHooks.length - 1; i >= 0 ; i--)
beforeWriteEntityToNBTHooks[i].beforeWriteEntityToNBT(paramNBTTagCompound);
if(overrideWriteEntityToNBTHooks != null)
overrideWriteEntityToNBTHooks[overrideWriteEntityToNBTHooks.length - 1].writeEntityToNBT(paramNBTTagCompound);
else
player.localWriteEntityToNBT(paramNBTTagCompound);
if(afterWriteEntityToNBTHooks != null)
for(int i = 0; i < afterWriteEntityToNBTHooks.length; i++)
afterWriteEntityToNBTHooks[i].afterWriteEntityToNBT(paramNBTTagCompound);
}
protected ServerPlayerBase GetOverwrittenWriteEntityToNBT(ServerPlayerBase overWriter)
{
for(int i = 0; i < overrideWriteEntityToNBTHooks.length; i++)
if(overrideWriteEntityToNBTHooks[i] == overWriter)
if(i == 0)
return null;
else
return overrideWriteEntityToNBTHooks[i - 1];
return overWriter;
}
private final static List<String> beforeWriteEntityToNBTHookTypes = new LinkedList<String>();
private final static List<String> overrideWriteEntityToNBTHookTypes = new LinkedList<String>();
private final static List<String> afterWriteEntityToNBTHookTypes = new LinkedList<String>();
private ServerPlayerBase[] beforeWriteEntityToNBTHooks;
private ServerPlayerBase[] overrideWriteEntityToNBTHooks;
private ServerPlayerBase[] afterWriteEntityToNBTHooks;
public boolean isWriteEntityToNBTModded;
private static final Map<String, String[]> allBaseBeforeWriteEntityToNBTSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeWriteEntityToNBTInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideWriteEntityToNBTSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseOverrideWriteEntityToNBTInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterWriteEntityToNBTSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterWriteEntityToNBTInferiors = new Hashtable<String, String[]>(0);
protected final IServerPlayerAPI player;
private final static Set<String> keys = new HashSet<String>();
private final static Map<String, String> keysToVirtualIds = new HashMap<String, String>();
private final static Set<Class<?>> dynamicTypes = new HashSet<Class<?>>();
private final static Map<Class<?>, Map<String, Method>> virtualDynamicHookMethods = new HashMap<Class<?>, Map<String, Method>>();
private final static Map<Class<?>, Map<String, Method>> beforeDynamicHookMethods = new HashMap<Class<?>, Map<String, Method>>();
private final static Map<Class<?>, Map<String, Method>> overrideDynamicHookMethods = new HashMap<Class<?>, Map<String, Method>>();
private final static Map<Class<?>, Map<String, Method>> afterDynamicHookMethods = new HashMap<Class<?>, Map<String, Method>>();
private final static List<String> beforeLocalConstructingHookTypes = new LinkedList<String>();
private final static List<String> afterLocalConstructingHookTypes = new LinkedList<String>();
private static final Map<String, List<String>> beforeDynamicHookTypes = new Hashtable<String, List<String>>(0);
private static final Map<String, List<String>> overrideDynamicHookTypes = new Hashtable<String, List<String>>(0);
private static final Map<String, List<String>> afterDynamicHookTypes = new Hashtable<String, List<String>>(0);
private ServerPlayerBase[] beforeLocalConstructingHooks;
private ServerPlayerBase[] afterLocalConstructingHooks;
private final Map<ServerPlayerBase, String> baseObjectsToId = new Hashtable<ServerPlayerBase, String>();
private final Map<String, ServerPlayerBase> allBaseObjects = new Hashtable<String, ServerPlayerBase>();
private final Set<String> unmodifiableAllBaseIds = Collections.unmodifiableSet(allBaseObjects.keySet());
private static final Map<String, Constructor<?>> allBaseConstructors = new Hashtable<String, Constructor<?>>();
private static final Set<String> unmodifiableAllIds = Collections.unmodifiableSet(allBaseConstructors.keySet());
private static final Map<String, String[]> allBaseBeforeLocalConstructingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseBeforeLocalConstructingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterLocalConstructingSuperiors = new Hashtable<String, String[]>(0);
private static final Map<String, String[]> allBaseAfterLocalConstructingInferiors = new Hashtable<String, String[]>(0);
private static final Map<String, Map<String, String[]>> allBaseBeforeDynamicSuperiors = new Hashtable<String, Map<String, String[]>>(0);
private static final Map<String, Map<String, String[]>> allBaseBeforeDynamicInferiors = new Hashtable<String, Map<String, String[]>>(0);
private static final Map<String, Map<String, String[]>> allBaseOverrideDynamicSuperiors = new Hashtable<String, Map<String, String[]>>(0);
private static final Map<String, Map<String, String[]>> allBaseOverrideDynamicInferiors = new Hashtable<String, Map<String, String[]>>(0);
private static final Map<String, Map<String, String[]>> allBaseAfterDynamicSuperiors = new Hashtable<String, Map<String, String[]>>(0);
private static final Map<String, Map<String, String[]>> allBaseAfterDynamicInferiors = new Hashtable<String, Map<String, String[]>>(0);
private static boolean initialized = false;
}
| gpl-3.0 |
FlowsenAusMonotown/projectforge | projectforge-wicket/src/main/java/org/projectforge/web/gantt/GanttTreeTable.java | 1894 | /////////////////////////////////////////////////////////////////////////////
//
// Project ProjectForge Community Edition
// www.projectforge.org
//
// Copyright (C) 2001-2014 Kai Reinhard (k.reinhard@micromata.de)
//
// ProjectForge is dual-licensed.
//
// This community edition 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; version 3 of the License.
//
// This community edition 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.projectforge.web.gantt;
import org.projectforge.business.gantt.GanttTask;
import org.projectforge.web.tree.TreeTable;
/**
* The implementation of TreeTable for tasks. Used for browsing the tasks (tree view).
*/
public class GanttTreeTable extends TreeTable<GanttTreeTableNode>
{
private static final long serialVersionUID = -5169823286484221430L;
public GanttTreeTable(final GanttTask rootNode)
{
root = new GanttTreeTableNode(null, rootNode);
addDescendantNodes(root);
updateOpenStatus();
}
protected void addDescendantNodes(GanttTreeTableNode parent)
{
final GanttTask parentObj = parent.getGanttObject();
if (parentObj.getChildren() != null) {
for (final GanttTask childNode : parentObj.getChildren()) {
final GanttTreeTableNode child = new GanttTreeTableNode(parent, childNode);
addTreeTableNode(child);
addDescendantNodes(child);
}
}
}
}
| gpl-3.0 |
arksu/origin | client/src/com/a2client/network/game/serverpackets/ObjectState.java | 520 | package com.a2client.network.game.serverpackets;
import com.a2client.network.game.GamePacketHandler;
/**
* Created by arksu on 12.10.15.
*/
public class ObjectState extends GameServerPacket
{
static
{
GamePacketHandler.AddPacketType(0x1F, ObjectState.class);
}
private int _objectId;
private String _jsonState;
private byte[] _state;
@Override
public void readImpl()
{
_objectId = readD();
_jsonState = readS();
int len = readC();
_state = readB(len);
}
@Override
public void run()
{
}
}
| gpl-3.0 |
ScaniaTV/PhantomBot | source/tv/phantombot/event/twitch/host/TwitchHostEvent.java | 1671 | /*
* Copyright (C) 2016-2018 phantombot.tv
*
* 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 tv.phantombot.event.twitch.host;
import tv.phantombot.event.twitch.TwitchEvent;
public abstract class TwitchHostEvent extends TwitchEvent {
private final String hoster;
private final int users;
/*
* Abstract constructor.
*
* @param {String} hoster
*/
protected TwitchHostEvent(String hoster) {
this.hoster = hoster;
this.users = 0;
}
/*
* Abstract constructor.
*
* @param {String} hoster
* @param {int} users
*/
protected TwitchHostEvent(String hoster, int users) {
this.hoster = hoster;
this.users = users;
}
/*
* Method that gets the hosters name.
*
* @return {String} hoster
*/
public String getHoster() {
return this.hoster;
}
/*
* Method that gets the amount of users the user hosted for.
*
* @return {int} users
*/
public int getUsers() {
return this.users;
}
}
| gpl-3.0 |
StarTux/Custom | src/main/java/com/winthier/custom/item/ItemDescription.java | 3517 | package com.winthier.custom.item;
import com.winthier.custom.util.Msg;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* Utility class to format an item description in a unified way. Use
* this class to store item descriptions in a custom item. One
* version may be stored and reused.
*/
@Data
public final class ItemDescription {
private String displayName;
private String category;
private String description;
private String usage;
private final Map<String, String> stats = new LinkedHashMap<>();
private List<String> lore;
private static final int LINE_LENGTH = 28;
public ItemDescription() { }
public ItemDescription(ItemDescription orig) {
this.displayName = orig.displayName;
this.category = orig.category;
this.description = orig.description;
this.usage = orig.usage;
this.stats.putAll(orig.stats);
}
public List<String> getLore() {
if (lore == null) {
lore = new ArrayList<>();
if (category != null) {
lore.add(Msg.format("&9%s", category));
}
if (description != null) {
List<String> lines = Msg.wrap(description, LINE_LENGTH);
for (int i = 0; i < lines.size(); ++i) lines.set(i, ChatColor.RESET + lines.get(i));
lore.addAll(lines);
}
if (usage != null) {
lore.add("");
List<String> lines = Msg.wrap(ChatColor.GREEN + "USAGE" + ChatColor.RESET + " " + usage, LINE_LENGTH);
for (int i = 1; i < lines.size(); ++i) lines.set(i, ChatColor.RESET + lines.get(i));
lore.addAll(lines);
}
if (!stats.isEmpty()) {
lore.add("");
for (Map.Entry<String, String> entry: stats.entrySet()) {
lore.add(ChatColor.GREEN + entry.getKey() + ": " + ChatColor.RESET + entry.getValue());
}
}
}
return lore;
}
public void flushLore() {
lore = null;
}
public void load(ConfigurationSection config) {
displayName = config.getString("DisplayName");
category = config.getString("Category");
description = config.getString("Description");
usage = config.getString("Usage");
if (displayName != null) displayName = ChatColor.translateAlternateColorCodes('&', displayName);
if (category != null) category = ChatColor.translateAlternateColorCodes('&', category);
if (description != null) description = ChatColor.translateAlternateColorCodes('&', description);
if (usage != null) usage = ChatColor.translateAlternateColorCodes('&', usage);
lore = null;
}
public static ItemDescription of(ConfigurationSection config) {
ItemDescription instance = new ItemDescription();
instance.load(config);
return instance;
}
public void apply(ItemStack item) {
ItemMeta meta = item.getItemMeta();
if (displayName != null) meta.setDisplayName(ChatColor.RESET + displayName);
meta.setLore(getLore());
item.setItemMeta(meta);
}
public ItemDescription clone() {
return new ItemDescription(this);
}
}
| gpl-3.0 |
zhouchaochao/learning | common-test/src/test/java/Apple.java | 5532 |
/**
* Title: Apple
* Description: Apple
* Date: 2019/2/1
*
* @author <a href=mailto:zhouzhichao1024@gmail.com>chaochao</a>
*/
public class Apple {
private String s1;
private String s2;
private String s3;
private String s4;
private String s5;
private String s6;
private String s7;
private String s8;
private String s9;
private String s10;
private String s11;
private String s12;
private String s13;
private String s14;
private String s15;
private String s16;
private String s17;
private String s18;
private String s19;
private String s20;
private String s21;
private String s22;
private String s23;
private String s24;
private String s25;
private String s26;
private String s27;
private String s28;
private String s29;
private String s30;
private String s31;
private String s32;
public Apple() {
s1= "a1";
s2= "a2";
s3= "a3";
s4= "a4";
s5= "a5";
s6= "a6";
s7= "a7";
s8= "a8";
s9= "a9";
s10= "a10";
s11= "a11";
s12= "a12";
s13= "a13";
s14= "a14";
s15= "a15";
s16= "a16";
s17= "a17";
s18= "a18";
s19= "a19";
s20= "a20";
s21= "a21";
s22= "a22";
s23= "a23";
s24= "a24";
s25= "a25";
s26= "a26";
s27= "a27";
s28= "a28";
s29= "a29";
s30= "a30";
s31= "a31";
s32= "a32";
}
public String getS1() {
return s1;
}
public void setS1(String s1) {
this.s1 = s1;
}
public String getS2() {
return s2;
}
public void setS2(String s2) {
this.s2 = s2;
}
public String getS3() {
return s3;
}
public void setS3(String s3) {
this.s3 = s3;
}
public String getS4() {
return s4;
}
public void setS4(String s4) {
this.s4 = s4;
}
public String getS5() {
return s5;
}
public void setS5(String s5) {
this.s5 = s5;
}
public String getS6() {
return s6;
}
public void setS6(String s6) {
this.s6 = s6;
}
public String getS7() {
return s7;
}
public void setS7(String s7) {
this.s7 = s7;
}
public String getS8() {
return s8;
}
public void setS8(String s8) {
this.s8 = s8;
}
public String getS9() {
return s9;
}
public void setS9(String s9) {
this.s9 = s9;
}
public String getS10() {
return s10;
}
public void setS10(String s10) {
this.s10 = s10;
}
public String getS11() {
return s11;
}
public void setS11(String s11) {
this.s11 = s11;
}
public String getS12() {
return s12;
}
public void setS12(String s12) {
this.s12 = s12;
}
public String getS13() {
return s13;
}
public void setS13(String s13) {
this.s13 = s13;
}
public String getS14() {
return s14;
}
public void setS14(String s14) {
this.s14 = s14;
}
public String getS15() {
return s15;
}
public void setS15(String s15) {
this.s15 = s15;
}
public String getS16() {
return s16;
}
public void setS16(String s16) {
this.s16 = s16;
}
public String getS17() {
return s17;
}
public void setS17(String s17) {
this.s17 = s17;
}
public String getS18() {
return s18;
}
public void setS18(String s18) {
this.s18 = s18;
}
public String getS19() {
return s19;
}
public void setS19(String s19) {
this.s19 = s19;
}
public String getS20() {
return s20;
}
public void setS20(String s20) {
this.s20 = s20;
}
public String getS21() {
return s21;
}
public void setS21(String s21) {
this.s21 = s21;
}
public String getS22() {
return s22;
}
public void setS22(String s22) {
this.s22 = s22;
}
public String getS23() {
return s23;
}
public void setS23(String s23) {
this.s23 = s23;
}
public String getS24() {
return s24;
}
public void setS24(String s24) {
this.s24 = s24;
}
public String getS25() {
return s25;
}
public void setS25(String s25) {
this.s25 = s25;
}
public String getS26() {
return s26;
}
public void setS26(String s26) {
this.s26 = s26;
}
public String getS27() {
return s27;
}
public void setS27(String s27) {
this.s27 = s27;
}
public String getS28() {
return s28;
}
public void setS28(String s28) {
this.s28 = s28;
}
public String getS29() {
return s29;
}
public void setS29(String s29) {
this.s29 = s29;
}
public String getS30() {
return s30;
}
public void setS30(String s30) {
this.s30 = s30;
}
public String getS31() {
return s31;
}
public void setS31(String s31) {
this.s31 = s31;
}
public String getS32() {
return s32;
}
public void setS32(String s32) {
this.s32 = s32;
}
}
| gpl-3.0 |
wudiqishi123/test | src/test/java/leetcode/array/leetcode45.java | 1841 | package leetcode.array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Stack;
/**
* 链接:https://leetcode-cn.com/problems/jump-game-ii/
* 题目:跳跃游戏II
*
* 描述:
* 给定一个非负整数数组,你最初位于数组的第一个位置。
*
* 数组中的每个元素代表你在该位置可以跳跃的最大长度。
*
* 你的目标是使用最少的跳跃次数到达数组的最后一个位置。
* 假设你总是可以到达数组的最后一个位置。
*
* 举例:
*/
public class leetcode45 {
public static void main(String[] args) {
int [] nums={2,3,5,1,4};
int result=jump(nums);
System.out.println("result = "+result);
}
public static int jump(int[] nums) {
return test1(nums);
//return test2(nums);
}
// 贪心,每次跳的时候取 最大值,nums[i]+i
public static int test1(int [] nums){
int steps=0;
int maxPos=0;
int end =0;
for(int i=0;i<nums.length-1;i++){
if(maxPos<i+nums[i]){
maxPos=i+nums[i];
System.out.println(i);
}
if(i == end ){
end=maxPos;
steps++;
}
}
return steps;
}
// 倒序贪心,找到第1个能到达最后位置的下标,然后往前推
//
public static int test2(int [] nums){
int steps=0;
int position=nums.length-1;
while(position>0){
for(int i=0;i<nums.length-1;i++){
if(nums[i]+i>=position){
position=i;
steps++;
break;
}
}
}
return steps;
}
}
| gpl-3.0 |
TheRoss8/IT | Rilevatore/src/sample/Controller.java | 699 | package sample;
import javafx.fxml.FXML;
import javafx.scene.control.*;
public class Controller {
@FXML
private Button start;
@FXML
private Button stop;
@FXML
private Label seconds;
@FXML
private TextField text;
@FXML
private Slider slider;
private GPS gps;
public void startClicked() throws InterruptedException {
gps=new GPS(this.getTempo());
gps.start();
}
public void stopClicked(){
gps.stop();
}
private int getTempo(){
return (int)(slider.getValue());
}
public void update(){
text.setText(Integer.toString((int)slider.getValue()));
}
} | gpl-3.0 |
afnogueira/Cerberus | source/src/main/java/org/cerberus/servlet/testCase/importFile.java | 3949 | /*
* Cerberus Copyright (C) 2013 vertigo17
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This file is part of Cerberus.
*
* Cerberus 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.
*
* Cerberus 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 Cerberus. If not, see <http://www.gnu.org/licenses/>.
*/
package org.cerberus.servlet.testCase;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
/**
*
* @author ip100003
*/
@WebServlet(name = "importFile", urlPatterns = {"/importFile"})
public class importFile extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (ServletFileUpload.isMultipartContent(request)) {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
try {
List items = upload.parseRequest(request);
Iterator iterator = items.iterator();
File uploadedFile = null;
String test = "";
String testcase = "";
String step = "";
String load = "";
while (iterator.hasNext()) {
FileItem item = (FileItem) iterator.next();
if (!item.isFormField()) {
String fileName = item.getName();
String root = getServletContext().getRealPath("/");
File pathFile = new File(root + "/cerberusFiles");
if (!pathFile.exists()) {
//boolean status = pathFile.mkdirs();
pathFile.mkdirs();
}
uploadedFile = new File(pathFile + "/" + fileName);
System.out.println(uploadedFile.getAbsolutePath());
item.write(uploadedFile);
} else {
String name = item.getFieldName();
if (name.equals("Test")) {
test = item.getString();
} else if (name.equals("Testcase")) {
testcase = item.getString();
} else if (name.equals("Step")) {
step = item.getString();
} else if (name.equals("Load")) {
load = item.getString();
}
}
}
response.sendRedirect("ImportHTML.jsp?Test=" + test + "&Testcase=" + testcase + "&Step=" + step + "&Load=" + load + "&FilePath=" + uploadedFile.getAbsolutePath());
} catch (FileUploadException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| gpl-3.0 |
IsThisThePayneResidence/intellidots | src/main/java/ua/edu/hneu/ast/parsers/ECMAScriptListener.java | 39591 | // Generated from /mnt/hdd/Programming/Projects/Groovy/intellidots/src/main/antlr/ECMAScript.g4 by ANTLR 4.2.2
package ua.edu.hneu.ast.parsers;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.tree.ParseTreeListener;
/**
* This interface defines a complete listener for a parse tree produced by
* {@link ECMAScriptParser}.
*/
public interface ECMAScriptListener extends ParseTreeListener {
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PropertyExpressionAssignment}.
* @param ctx the parse tree
*/
void enterPropertyExpressionAssignment(@NotNull ECMAScriptParser.PropertyExpressionAssignmentContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PropertyExpressionAssignment}.
* @param ctx the parse tree
*/
void exitPropertyExpressionAssignment(@NotNull ECMAScriptParser.PropertyExpressionAssignmentContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#InExpression}.
* @param ctx the parse tree
*/
void enterInExpression(@NotNull ECMAScriptParser.InExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#InExpression}.
* @param ctx the parse tree
*/
void exitInExpression(@NotNull ECMAScriptParser.InExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#eos}.
* @param ctx the parse tree
*/
void enterEos(@NotNull ECMAScriptParser.EosContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#eos}.
* @param ctx the parse tree
*/
void exitEos(@NotNull ECMAScriptParser.EosContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#sourceElements}.
* @param ctx the parse tree
*/
void enterSourceElements(@NotNull ECMAScriptParser.SourceElementsContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#sourceElements}.
* @param ctx the parse tree
*/
void exitSourceElements(@NotNull ECMAScriptParser.SourceElementsContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#program}.
* @param ctx the parse tree
*/
void enterProgram(@NotNull ECMAScriptParser.ProgramContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#program}.
* @param ctx the parse tree
*/
void exitProgram(@NotNull ECMAScriptParser.ProgramContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#argumentList}.
* @param ctx the parse tree
*/
void enterArgumentList(@NotNull ECMAScriptParser.ArgumentListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#argumentList}.
* @param ctx the parse tree
*/
void exitArgumentList(@NotNull ECMAScriptParser.ArgumentListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ArgumentsExpression}.
* @param ctx the parse tree
*/
void enterArgumentsExpression(@NotNull ECMAScriptParser.ArgumentsExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ArgumentsExpression}.
* @param ctx the parse tree
*/
void exitArgumentsExpression(@NotNull ECMAScriptParser.ArgumentsExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#identifierName}.
* @param ctx the parse tree
*/
void enterIdentifierName(@NotNull ECMAScriptParser.IdentifierNameContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#identifierName}.
* @param ctx the parse tree
*/
void exitIdentifierName(@NotNull ECMAScriptParser.IdentifierNameContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#initialiser}.
* @param ctx the parse tree
*/
void enterInitialiser(@NotNull ECMAScriptParser.InitialiserContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#initialiser}.
* @param ctx the parse tree
*/
void exitInitialiser(@NotNull ECMAScriptParser.InitialiserContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#TypeofExpression}.
* @param ctx the parse tree
*/
void enterTypeofExpression(@NotNull ECMAScriptParser.TypeofExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#TypeofExpression}.
* @param ctx the parse tree
*/
void exitTypeofExpression(@NotNull ECMAScriptParser.TypeofExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#block}.
* @param ctx the parse tree
*/
void enterBlock(@NotNull ECMAScriptParser.BlockContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#block}.
* @param ctx the parse tree
*/
void exitBlock(@NotNull ECMAScriptParser.BlockContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#expressionStatement}.
* @param ctx the parse tree
*/
void enterExpressionStatement(@NotNull ECMAScriptParser.ExpressionStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#expressionStatement}.
* @param ctx the parse tree
*/
void exitExpressionStatement(@NotNull ECMAScriptParser.ExpressionStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#BitXOrExpression}.
* @param ctx the parse tree
*/
void enterBitXOrExpression(@NotNull ECMAScriptParser.BitXOrExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#BitXOrExpression}.
* @param ctx the parse tree
*/
void exitBitXOrExpression(@NotNull ECMAScriptParser.BitXOrExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#MultiplicativeExpression}.
* @param ctx the parse tree
*/
void enterMultiplicativeExpression(@NotNull ECMAScriptParser.MultiplicativeExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#MultiplicativeExpression}.
* @param ctx the parse tree
*/
void exitMultiplicativeExpression(@NotNull ECMAScriptParser.MultiplicativeExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#numericLiteral}.
* @param ctx the parse tree
*/
void enterNumericLiteral(@NotNull ECMAScriptParser.NumericLiteralContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#numericLiteral}.
* @param ctx the parse tree
*/
void exitNumericLiteral(@NotNull ECMAScriptParser.NumericLiteralContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ForInStatement}.
* @param ctx the parse tree
*/
void enterForInStatement(@NotNull ECMAScriptParser.ForInStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ForInStatement}.
* @param ctx the parse tree
*/
void exitForInStatement(@NotNull ECMAScriptParser.ForInStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#emptyStatement}.
* @param ctx the parse tree
*/
void enterEmptyStatement(@NotNull ECMAScriptParser.EmptyStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#emptyStatement}.
* @param ctx the parse tree
*/
void exitEmptyStatement(@NotNull ECMAScriptParser.EmptyStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#AdditiveExpression}.
* @param ctx the parse tree
*/
void enterAdditiveExpression(@NotNull ECMAScriptParser.AdditiveExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#AdditiveExpression}.
* @param ctx the parse tree
*/
void exitAdditiveExpression(@NotNull ECMAScriptParser.AdditiveExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#RelationalExpression}.
* @param ctx the parse tree
*/
void enterRelationalExpression(@NotNull ECMAScriptParser.RelationalExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#RelationalExpression}.
* @param ctx the parse tree
*/
void exitRelationalExpression(@NotNull ECMAScriptParser.RelationalExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#labelledStatement}.
* @param ctx the parse tree
*/
void enterLabelledStatement(@NotNull ECMAScriptParser.LabelledStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#labelledStatement}.
* @param ctx the parse tree
*/
void exitLabelledStatement(@NotNull ECMAScriptParser.LabelledStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#NewExpression}.
* @param ctx the parse tree
*/
void enterNewExpression(@NotNull ECMAScriptParser.NewExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#NewExpression}.
* @param ctx the parse tree
*/
void exitNewExpression(@NotNull ECMAScriptParser.NewExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#withStatement}.
* @param ctx the parse tree
*/
void enterWithStatement(@NotNull ECMAScriptParser.WithStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#withStatement}.
* @param ctx the parse tree
*/
void exitWithStatement(@NotNull ECMAScriptParser.WithStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#BitAndExpression}.
* @param ctx the parse tree
*/
void enterBitAndExpression(@NotNull ECMAScriptParser.BitAndExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#BitAndExpression}.
* @param ctx the parse tree
*/
void exitBitAndExpression(@NotNull ECMAScriptParser.BitAndExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#BitOrExpression}.
* @param ctx the parse tree
*/
void enterBitOrExpression(@NotNull ECMAScriptParser.BitOrExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#BitOrExpression}.
* @param ctx the parse tree
*/
void exitBitOrExpression(@NotNull ECMAScriptParser.BitOrExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#VoidExpression}.
* @param ctx the parse tree
*/
void enterVoidExpression(@NotNull ECMAScriptParser.VoidExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#VoidExpression}.
* @param ctx the parse tree
*/
void exitVoidExpression(@NotNull ECMAScriptParser.VoidExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#TernaryExpression}.
* @param ctx the parse tree
*/
void enterTernaryExpression(@NotNull ECMAScriptParser.TernaryExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#TernaryExpression}.
* @param ctx the parse tree
*/
void exitTernaryExpression(@NotNull ECMAScriptParser.TernaryExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#LogicalAndExpression}.
* @param ctx the parse tree
*/
void enterLogicalAndExpression(@NotNull ECMAScriptParser.LogicalAndExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#LogicalAndExpression}.
* @param ctx the parse tree
*/
void exitLogicalAndExpression(@NotNull ECMAScriptParser.LogicalAndExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#arrayLiteral}.
* @param ctx the parse tree
*/
void enterArrayLiteral(@NotNull ECMAScriptParser.ArrayLiteralContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#arrayLiteral}.
* @param ctx the parse tree
*/
void exitArrayLiteral(@NotNull ECMAScriptParser.ArrayLiteralContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#elision}.
* @param ctx the parse tree
*/
void enterElision(@NotNull ECMAScriptParser.ElisionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#elision}.
* @param ctx the parse tree
*/
void exitElision(@NotNull ECMAScriptParser.ElisionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#WhileStatement}.
* @param ctx the parse tree
*/
void enterWhileStatement(@NotNull ECMAScriptParser.WhileStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#WhileStatement}.
* @param ctx the parse tree
*/
void exitWhileStatement(@NotNull ECMAScriptParser.WhileStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#returnStatement}.
* @param ctx the parse tree
*/
void enterReturnStatement(@NotNull ECMAScriptParser.ReturnStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#returnStatement}.
* @param ctx the parse tree
*/
void exitReturnStatement(@NotNull ECMAScriptParser.ReturnStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PreDecreaseExpression}.
* @param ctx the parse tree
*/
void enterPreDecreaseExpression(@NotNull ECMAScriptParser.PreDecreaseExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PreDecreaseExpression}.
* @param ctx the parse tree
*/
void exitPreDecreaseExpression(@NotNull ECMAScriptParser.PreDecreaseExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#expressionSequence}.
* @param ctx the parse tree
*/
void enterExpressionSequence(@NotNull ECMAScriptParser.ExpressionSequenceContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#expressionSequence}.
* @param ctx the parse tree
*/
void exitExpressionSequence(@NotNull ECMAScriptParser.ExpressionSequenceContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#literal}.
* @param ctx the parse tree
*/
void enterLiteral(@NotNull ECMAScriptParser.LiteralContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#literal}.
* @param ctx the parse tree
*/
void exitLiteral(@NotNull ECMAScriptParser.LiteralContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#defaultClause}.
* @param ctx the parse tree
*/
void enterDefaultClause(@NotNull ECMAScriptParser.DefaultClauseContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#defaultClause}.
* @param ctx the parse tree
*/
void exitDefaultClause(@NotNull ECMAScriptParser.DefaultClauseContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PostDecreaseExpression}.
* @param ctx the parse tree
*/
void enterPostDecreaseExpression(@NotNull ECMAScriptParser.PostDecreaseExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PostDecreaseExpression}.
* @param ctx the parse tree
*/
void exitPostDecreaseExpression(@NotNull ECMAScriptParser.PostDecreaseExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#UnaryPlusExpression}.
* @param ctx the parse tree
*/
void enterUnaryPlusExpression(@NotNull ECMAScriptParser.UnaryPlusExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#UnaryPlusExpression}.
* @param ctx the parse tree
*/
void exitUnaryPlusExpression(@NotNull ECMAScriptParser.UnaryPlusExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ForStatement}.
* @param ctx the parse tree
*/
void enterForStatement(@NotNull ECMAScriptParser.ForStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ForStatement}.
* @param ctx the parse tree
*/
void exitForStatement(@NotNull ECMAScriptParser.ForStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#caseBlock}.
* @param ctx the parse tree
*/
void enterCaseBlock(@NotNull ECMAScriptParser.CaseBlockContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#caseBlock}.
* @param ctx the parse tree
*/
void exitCaseBlock(@NotNull ECMAScriptParser.CaseBlockContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#caseClauses}.
* @param ctx the parse tree
*/
void enterCaseClauses(@NotNull ECMAScriptParser.CaseClausesContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#caseClauses}.
* @param ctx the parse tree
*/
void exitCaseClauses(@NotNull ECMAScriptParser.CaseClausesContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ParenthesizedExpression}.
* @param ctx the parse tree
*/
void enterParenthesizedExpression(@NotNull ECMAScriptParser.ParenthesizedExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ParenthesizedExpression}.
* @param ctx the parse tree
*/
void exitParenthesizedExpression(@NotNull ECMAScriptParser.ParenthesizedExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PostIncrementExpression}.
* @param ctx the parse tree
*/
void enterPostIncrementExpression(@NotNull ECMAScriptParser.PostIncrementExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PostIncrementExpression}.
* @param ctx the parse tree
*/
void exitPostIncrementExpression(@NotNull ECMAScriptParser.PostIncrementExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#objectLiteral}.
* @param ctx the parse tree
*/
void enterObjectLiteral(@NotNull ECMAScriptParser.ObjectLiteralContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#objectLiteral}.
* @param ctx the parse tree
*/
void exitObjectLiteral(@NotNull ECMAScriptParser.ObjectLiteralContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#throwStatement}.
* @param ctx the parse tree
*/
void enterThrowStatement(@NotNull ECMAScriptParser.ThrowStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#throwStatement}.
* @param ctx the parse tree
*/
void exitThrowStatement(@NotNull ECMAScriptParser.ThrowStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#variableDeclaration}.
* @param ctx the parse tree
*/
void enterVariableDeclaration(@NotNull ECMAScriptParser.VariableDeclarationContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#variableDeclaration}.
* @param ctx the parse tree
*/
void exitVariableDeclaration(@NotNull ECMAScriptParser.VariableDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#IdentifierExpression}.
* @param ctx the parse tree
*/
void enterIdentifierExpression(@NotNull ECMAScriptParser.IdentifierExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#IdentifierExpression}.
* @param ctx the parse tree
*/
void exitIdentifierExpression(@NotNull ECMAScriptParser.IdentifierExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#propertyName}.
* @param ctx the parse tree
*/
void enterPropertyName(@NotNull ECMAScriptParser.PropertyNameContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#propertyName}.
* @param ctx the parse tree
*/
void exitPropertyName(@NotNull ECMAScriptParser.PropertyNameContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#caseClause}.
* @param ctx the parse tree
*/
void enterCaseClause(@NotNull ECMAScriptParser.CaseClauseContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#caseClause}.
* @param ctx the parse tree
*/
void exitCaseClause(@NotNull ECMAScriptParser.CaseClauseContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#variableDeclarationList}.
* @param ctx the parse tree
*/
void enterVariableDeclarationList(@NotNull ECMAScriptParser.VariableDeclarationListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#variableDeclarationList}.
* @param ctx the parse tree
*/
void exitVariableDeclarationList(@NotNull ECMAScriptParser.VariableDeclarationListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#setter}.
* @param ctx the parse tree
*/
void enterSetter(@NotNull ECMAScriptParser.SetterContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#setter}.
* @param ctx the parse tree
*/
void exitSetter(@NotNull ECMAScriptParser.SetterContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#functionDeclaration}.
* @param ctx the parse tree
*/
void enterFunctionDeclaration(@NotNull ECMAScriptParser.FunctionDeclarationContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#functionDeclaration}.
* @param ctx the parse tree
*/
void exitFunctionDeclaration(@NotNull ECMAScriptParser.FunctionDeclarationContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#getter}.
* @param ctx the parse tree
*/
void enterGetter(@NotNull ECMAScriptParser.GetterContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#getter}.
* @param ctx the parse tree
*/
void exitGetter(@NotNull ECMAScriptParser.GetterContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#assignmentOperator}.
* @param ctx the parse tree
*/
void enterAssignmentOperator(@NotNull ECMAScriptParser.AssignmentOperatorContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#assignmentOperator}.
* @param ctx the parse tree
*/
void exitAssignmentOperator(@NotNull ECMAScriptParser.AssignmentOperatorContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ThisExpression}.
* @param ctx the parse tree
*/
void enterThisExpression(@NotNull ECMAScriptParser.ThisExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ThisExpression}.
* @param ctx the parse tree
*/
void exitThisExpression(@NotNull ECMAScriptParser.ThisExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#futureReservedWord}.
* @param ctx the parse tree
*/
void enterFutureReservedWord(@NotNull ECMAScriptParser.FutureReservedWordContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#futureReservedWord}.
* @param ctx the parse tree
*/
void exitFutureReservedWord(@NotNull ECMAScriptParser.FutureReservedWordContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#statementList}.
* @param ctx the parse tree
*/
void enterStatementList(@NotNull ECMAScriptParser.StatementListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#statementList}.
* @param ctx the parse tree
*/
void exitStatementList(@NotNull ECMAScriptParser.StatementListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PropertyGetter}.
* @param ctx the parse tree
*/
void enterPropertyGetter(@NotNull ECMAScriptParser.PropertyGetterContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PropertyGetter}.
* @param ctx the parse tree
*/
void exitPropertyGetter(@NotNull ECMAScriptParser.PropertyGetterContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#EqualityExpression}.
* @param ctx the parse tree
*/
void enterEqualityExpression(@NotNull ECMAScriptParser.EqualityExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#EqualityExpression}.
* @param ctx the parse tree
*/
void exitEqualityExpression(@NotNull ECMAScriptParser.EqualityExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#keyword}.
* @param ctx the parse tree
*/
void enterKeyword(@NotNull ECMAScriptParser.KeywordContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#keyword}.
* @param ctx the parse tree
*/
void exitKeyword(@NotNull ECMAScriptParser.KeywordContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#elementList}.
* @param ctx the parse tree
*/
void enterElementList(@NotNull ECMAScriptParser.ElementListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#elementList}.
* @param ctx the parse tree
*/
void exitElementList(@NotNull ECMAScriptParser.ElementListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#BitShiftExpression}.
* @param ctx the parse tree
*/
void enterBitShiftExpression(@NotNull ECMAScriptParser.BitShiftExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#BitShiftExpression}.
* @param ctx the parse tree
*/
void exitBitShiftExpression(@NotNull ECMAScriptParser.BitShiftExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#BitNotExpression}.
* @param ctx the parse tree
*/
void enterBitNotExpression(@NotNull ECMAScriptParser.BitNotExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#BitNotExpression}.
* @param ctx the parse tree
*/
void exitBitNotExpression(@NotNull ECMAScriptParser.BitNotExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PropertySetter}.
* @param ctx the parse tree
*/
void enterPropertySetter(@NotNull ECMAScriptParser.PropertySetterContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PropertySetter}.
* @param ctx the parse tree
*/
void exitPropertySetter(@NotNull ECMAScriptParser.PropertySetterContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#LiteralExpression}.
* @param ctx the parse tree
*/
void enterLiteralExpression(@NotNull ECMAScriptParser.LiteralExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#LiteralExpression}.
* @param ctx the parse tree
*/
void exitLiteralExpression(@NotNull ECMAScriptParser.LiteralExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ArrayLiteralExpression}.
* @param ctx the parse tree
*/
void enterArrayLiteralExpression(@NotNull ECMAScriptParser.ArrayLiteralExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ArrayLiteralExpression}.
* @param ctx the parse tree
*/
void exitArrayLiteralExpression(@NotNull ECMAScriptParser.ArrayLiteralExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#MemberDotExpression}.
* @param ctx the parse tree
*/
void enterMemberDotExpression(@NotNull ECMAScriptParser.MemberDotExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#MemberDotExpression}.
* @param ctx the parse tree
*/
void exitMemberDotExpression(@NotNull ECMAScriptParser.MemberDotExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#MemberIndexExpression}.
* @param ctx the parse tree
*/
void enterMemberIndexExpression(@NotNull ECMAScriptParser.MemberIndexExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#MemberIndexExpression}.
* @param ctx the parse tree
*/
void exitMemberIndexExpression(@NotNull ECMAScriptParser.MemberIndexExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#formalParameterList}.
* @param ctx the parse tree
*/
void enterFormalParameterList(@NotNull ECMAScriptParser.FormalParameterListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#formalParameterList}.
* @param ctx the parse tree
*/
void exitFormalParameterList(@NotNull ECMAScriptParser.FormalParameterListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ForVarInStatement}.
* @param ctx the parse tree
*/
void enterForVarInStatement(@NotNull ECMAScriptParser.ForVarInStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ForVarInStatement}.
* @param ctx the parse tree
*/
void exitForVarInStatement(@NotNull ECMAScriptParser.ForVarInStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#propertySetParameterList}.
* @param ctx the parse tree
*/
void enterPropertySetParameterList(@NotNull ECMAScriptParser.PropertySetParameterListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#propertySetParameterList}.
* @param ctx the parse tree
*/
void exitPropertySetParameterList(@NotNull ECMAScriptParser.PropertySetParameterListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#AssignmentOperatorExpression}.
* @param ctx the parse tree
*/
void enterAssignmentOperatorExpression(@NotNull ECMAScriptParser.AssignmentOperatorExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#AssignmentOperatorExpression}.
* @param ctx the parse tree
*/
void exitAssignmentOperatorExpression(@NotNull ECMAScriptParser.AssignmentOperatorExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#tryStatement}.
* @param ctx the parse tree
*/
void enterTryStatement(@NotNull ECMAScriptParser.TryStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#tryStatement}.
* @param ctx the parse tree
*/
void exitTryStatement(@NotNull ECMAScriptParser.TryStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#debuggerStatement}.
* @param ctx the parse tree
*/
void enterDebuggerStatement(@NotNull ECMAScriptParser.DebuggerStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#debuggerStatement}.
* @param ctx the parse tree
*/
void exitDebuggerStatement(@NotNull ECMAScriptParser.DebuggerStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#DoStatement}.
* @param ctx the parse tree
*/
void enterDoStatement(@NotNull ECMAScriptParser.DoStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#DoStatement}.
* @param ctx the parse tree
*/
void exitDoStatement(@NotNull ECMAScriptParser.DoStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#PreIncrementExpression}.
* @param ctx the parse tree
*/
void enterPreIncrementExpression(@NotNull ECMAScriptParser.PreIncrementExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#PreIncrementExpression}.
* @param ctx the parse tree
*/
void exitPreIncrementExpression(@NotNull ECMAScriptParser.PreIncrementExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ObjectLiteralExpression}.
* @param ctx the parse tree
*/
void enterObjectLiteralExpression(@NotNull ECMAScriptParser.ObjectLiteralExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ObjectLiteralExpression}.
* @param ctx the parse tree
*/
void exitObjectLiteralExpression(@NotNull ECMAScriptParser.ObjectLiteralExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#LogicalOrExpression}.
* @param ctx the parse tree
*/
void enterLogicalOrExpression(@NotNull ECMAScriptParser.LogicalOrExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#LogicalOrExpression}.
* @param ctx the parse tree
*/
void exitLogicalOrExpression(@NotNull ECMAScriptParser.LogicalOrExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#NotExpression}.
* @param ctx the parse tree
*/
void enterNotExpression(@NotNull ECMAScriptParser.NotExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#NotExpression}.
* @param ctx the parse tree
*/
void exitNotExpression(@NotNull ECMAScriptParser.NotExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#switchStatement}.
* @param ctx the parse tree
*/
void enterSwitchStatement(@NotNull ECMAScriptParser.SwitchStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#switchStatement}.
* @param ctx the parse tree
*/
void exitSwitchStatement(@NotNull ECMAScriptParser.SwitchStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#variableStatement}.
* @param ctx the parse tree
*/
void enterVariableStatement(@NotNull ECMAScriptParser.VariableStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#variableStatement}.
* @param ctx the parse tree
*/
void exitVariableStatement(@NotNull ECMAScriptParser.VariableStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#FunctionExpression}.
* @param ctx the parse tree
*/
void enterFunctionExpression(@NotNull ECMAScriptParser.FunctionExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#FunctionExpression}.
* @param ctx the parse tree
*/
void exitFunctionExpression(@NotNull ECMAScriptParser.FunctionExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#UnaryMinusExpression}.
* @param ctx the parse tree
*/
void enterUnaryMinusExpression(@NotNull ECMAScriptParser.UnaryMinusExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#UnaryMinusExpression}.
* @param ctx the parse tree
*/
void exitUnaryMinusExpression(@NotNull ECMAScriptParser.UnaryMinusExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#AssignmentExpression}.
* @param ctx the parse tree
*/
void enterAssignmentExpression(@NotNull ECMAScriptParser.AssignmentExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#AssignmentExpression}.
* @param ctx the parse tree
*/
void exitAssignmentExpression(@NotNull ECMAScriptParser.AssignmentExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#InstanceofExpression}.
* @param ctx the parse tree
*/
void enterInstanceofExpression(@NotNull ECMAScriptParser.InstanceofExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#InstanceofExpression}.
* @param ctx the parse tree
*/
void exitInstanceofExpression(@NotNull ECMAScriptParser.InstanceofExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#statement}.
* @param ctx the parse tree
*/
void enterStatement(@NotNull ECMAScriptParser.StatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#statement}.
* @param ctx the parse tree
*/
void exitStatement(@NotNull ECMAScriptParser.StatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#DeleteExpression}.
* @param ctx the parse tree
*/
void enterDeleteExpression(@NotNull ECMAScriptParser.DeleteExpressionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#DeleteExpression}.
* @param ctx the parse tree
*/
void exitDeleteExpression(@NotNull ECMAScriptParser.DeleteExpressionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#propertyNameAndValueList}.
* @param ctx the parse tree
*/
void enterPropertyNameAndValueList(@NotNull ECMAScriptParser.PropertyNameAndValueListContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#propertyNameAndValueList}.
* @param ctx the parse tree
*/
void exitPropertyNameAndValueList(@NotNull ECMAScriptParser.PropertyNameAndValueListContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ForVarStatement}.
* @param ctx the parse tree
*/
void enterForVarStatement(@NotNull ECMAScriptParser.ForVarStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ForVarStatement}.
* @param ctx the parse tree
*/
void exitForVarStatement(@NotNull ECMAScriptParser.ForVarStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#sourceElement}.
* @param ctx the parse tree
*/
void enterSourceElement(@NotNull ECMAScriptParser.SourceElementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#sourceElement}.
* @param ctx the parse tree
*/
void exitSourceElement(@NotNull ECMAScriptParser.SourceElementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#breakStatement}.
* @param ctx the parse tree
*/
void enterBreakStatement(@NotNull ECMAScriptParser.BreakStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#breakStatement}.
* @param ctx the parse tree
*/
void exitBreakStatement(@NotNull ECMAScriptParser.BreakStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#ifStatement}.
* @param ctx the parse tree
*/
void enterIfStatement(@NotNull ECMAScriptParser.IfStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#ifStatement}.
* @param ctx the parse tree
*/
void exitIfStatement(@NotNull ECMAScriptParser.IfStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#reservedWord}.
* @param ctx the parse tree
*/
void enterReservedWord(@NotNull ECMAScriptParser.ReservedWordContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#reservedWord}.
* @param ctx the parse tree
*/
void exitReservedWord(@NotNull ECMAScriptParser.ReservedWordContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#finallyProduction}.
* @param ctx the parse tree
*/
void enterFinallyProduction(@NotNull ECMAScriptParser.FinallyProductionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#finallyProduction}.
* @param ctx the parse tree
*/
void exitFinallyProduction(@NotNull ECMAScriptParser.FinallyProductionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#catchProduction}.
* @param ctx the parse tree
*/
void enterCatchProduction(@NotNull ECMAScriptParser.CatchProductionContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#catchProduction}.
* @param ctx the parse tree
*/
void exitCatchProduction(@NotNull ECMAScriptParser.CatchProductionContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#continueStatement}.
* @param ctx the parse tree
*/
void enterContinueStatement(@NotNull ECMAScriptParser.ContinueStatementContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#continueStatement}.
* @param ctx the parse tree
*/
void exitContinueStatement(@NotNull ECMAScriptParser.ContinueStatementContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#arguments}.
* @param ctx the parse tree
*/
void enterArguments(@NotNull ECMAScriptParser.ArgumentsContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#arguments}.
* @param ctx the parse tree
*/
void exitArguments(@NotNull ECMAScriptParser.ArgumentsContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#functionBody}.
* @param ctx the parse tree
*/
void enterFunctionBody(@NotNull ECMAScriptParser.FunctionBodyContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#functionBody}.
* @param ctx the parse tree
*/
void exitFunctionBody(@NotNull ECMAScriptParser.FunctionBodyContext ctx);
/**
* Enter a parse tree produced by {@link ECMAScriptParser#eof}.
* @param ctx the parse tree
*/
void enterEof(@NotNull ECMAScriptParser.EofContext ctx);
/**
* Exit a parse tree produced by {@link ECMAScriptParser#eof}.
* @param ctx the parse tree
*/
void exitEof(@NotNull ECMAScriptParser.EofContext ctx);
} | gpl-3.0 |
hqnghi88/gamaClone | msi.gama.lang.gaml/src/msi/gama/lang/gaml/documentation/DocumentationNode.java | 3111 | /*********************************************************************************************
*
* 'DocumentationNode.java, in plugin msi.gama.lang.gaml, is part of the source code of the GAMA modeling and simulation
* platform. (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
*
*
**********************************************************************************************/
package msi.gama.lang.gaml.documentation;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
import msi.gama.common.interfaces.IGamlDescription;
import msi.gama.precompiler.GamlProperties;
public class DocumentationNode implements IGamlDescription {
public static byte[] compress(final String text) throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (final OutputStream out = new DeflaterOutputStream(baos, true);) {
out.write(text.getBytes("ISO-8859-1"));
}
return baos.toByteArray();
}
public static String decompress(final byte[] bytes) throws IOException {
final InputStream in = new InflaterInputStream(new ByteArrayInputStream(bytes));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] buffer = new byte[8192];
int len;
while ((len = in.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
return new String(baos.toByteArray(), "ISO-8859-1");
}
final byte[] title;
final byte[] doc;
// final byte[] plugin;
DocumentationNode(final IGamlDescription desc) throws IOException {
final String plugin = desc.getDefiningPlugin();
final String title = desc.getTitle();
String documentation = desc.getDocumentation();
if (plugin != null) {
documentation += "\n<p/><i> [defined in " + plugin + "] </i>";
}
doc = compress(documentation);
this.title = compress(title);
}
/**
* Method collectMetaInformation()
*
* @see msi.gama.common.interfaces.IGamlDescription#collectPlugins(java.util.Set)
*/
@Override
public void collectMetaInformation(final GamlProperties meta) {}
@Override
public String getDocumentation() {
try {
return decompress(doc);
} catch (final IOException e) {
e.printStackTrace();
return "Error";
}
}
@Override
public String getTitle() {
try {
return decompress(title);
} catch (final IOException e) {
e.printStackTrace();
return "Error";
}
}
@Override
public String getName() {
return "Online documentation";
}
@Override
public String getDefiningPlugin() {
return "";
}
@Override
public void setName(final String name) {
// Nothing
}
@Override
public String toString() {
return getTitle() + " - " + getDocumentation();
}
/**
* Method serialize()
*
* @see msi.gama.common.interfaces.IGamlable#serialize(boolean)
*/
@Override
public String serialize(final boolean includingBuiltIn) {
return toString();
}
} | gpl-3.0 |
goosesandbox/sdn_distributed | src/main/java/org/odl/api/SouthBound.java | 418 | package org.odl.api;
import org.odl.component.DeviceIdentifier;
import org.odl.component.NetworkDevice;
import org.odl.core.Path;
import java.util.List;
import java.util.Map;
public interface SouthBound extends DeviceIdentifier {
void addFlow(String destination, Path path);
Map<String, NetworkDevice> getAttachedDevices();
String deviceId();
Path findPath(String destinationDeviceId, Path path);
}
| gpl-3.0 |
seklum/NewHeart | app/src/main/java/com/beakon/newheart/activities/habits/list/model/HabitCardListCache.java | 11254 | /*
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker 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.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.beakon.newheart.activities.habits.list.model;
import android.support.annotation.*;
import com.beakon.newheart.*;
import com.beakon.newheart.commands.*;
import com.beakon.newheart.models.*;
import com.beakon.newheart.tasks.*;
import com.beakon.newheart.utils.*;
import java.util.*;
import javax.inject.*;
/**
* A HabitCardListCache fetches and keeps a cache of all the data necessary to
* render a HabitCardListView.
* <p>
* This is needed since performing database lookups during scrolling can make
* the ListView very slow. It also registers itself as an observer of the
* models, in order to update itself automatically.
* <p>
* Note that this class is singleton-scoped, therefore it is shared among all
* activities.
*/
@AppScope
public class HabitCardListCache implements CommandRunner.Listener
{
private int checkmarkCount;
private Task currentFetchTask;
@NonNull
private Listener listener;
@NonNull
private CacheData data;
@NonNull
private HabitList allHabits;
@NonNull
private HabitList filteredHabits;
private final TaskRunner taskRunner;
private final CommandRunner commandRunner;
@Inject
public HabitCardListCache(@NonNull HabitList allHabits,
@NonNull CommandRunner commandRunner,
@NonNull TaskRunner taskRunner)
{
this.allHabits = allHabits;
this.commandRunner = commandRunner;
this.filteredHabits = allHabits;
this.taskRunner = taskRunner;
this.listener = new Listener() {};
data = new CacheData();
}
public void cancelTasks()
{
if (currentFetchTask != null) currentFetchTask.cancel();
}
public int[] getCheckmarks(long habitId)
{
return data.checkmarks.get(habitId);
}
/**
* Returns the habits that occupies a certain position on the list.
*
* @param position the position of the habit
* @return the habit at given position
* @throws IndexOutOfBoundsException if position is not valid
*/
@NonNull
public Habit getHabitByPosition(int position)
{
return data.habits.get(position);
}
public int getHabitCount()
{
return data.habits.size();
}
public HabitList.Order getOrder()
{
return filteredHabits.getOrder();
}
public int getScore(long habitId)
{
return data.scores.get(habitId);
}
public void onAttached()
{
refreshAllHabits();
commandRunner.addListener(this);
}
@Override
public void onCommandExecuted(@NonNull Command command,
@Nullable Long refreshKey)
{
if (refreshKey == null) refreshAllHabits();
else refreshHabit(refreshKey);
}
public void onDetached()
{
commandRunner.removeListener(this);
}
public void refreshAllHabits()
{
if (currentFetchTask != null) currentFetchTask.cancel();
currentFetchTask = new RefreshTask();
taskRunner.execute(currentFetchTask);
}
public void refreshHabit(long id)
{
taskRunner.execute(new RefreshTask(id));
}
public void remove(@NonNull Long id)
{
Habit h = data.id_to_habit.get(id);
if (h == null) return;
int position = data.habits.indexOf(h);
data.habits.remove(position);
data.id_to_habit.remove(id);
data.checkmarks.remove(id);
data.scores.remove(id);
listener.onItemRemoved(position);
}
public void reorder(int from, int to)
{
Habit fromHabit = data.habits.get(from);
data.habits.remove(from);
data.habits.add(to, fromHabit);
listener.onItemMoved(from, to);
}
public void setCheckmarkCount(int checkmarkCount)
{
this.checkmarkCount = checkmarkCount;
}
public void setFilter(HabitMatcher matcher)
{
filteredHabits = allHabits.getFiltered(matcher);
}
public void setListener(@NonNull Listener listener)
{
this.listener = listener;
}
public void setOrder(HabitList.Order order)
{
allHabits.setOrder(order);
filteredHabits.setOrder(order);
refreshAllHabits();
}
/**
* Interface definition for a callback to be invoked when the data on the
* cache has been modified.
*/
public interface Listener
{
default void onItemChanged(int position) {}
default void onItemInserted(int position) {}
default void onItemMoved(int oldPosition, int newPosition) {}
default void onItemRemoved(int position) {}
default void onRefreshFinished() {}
}
private class CacheData
{
@NonNull
public HashMap<Long, Habit> id_to_habit;
@NonNull
public List<Habit> habits;
@NonNull
public HashMap<Long, int[]> checkmarks;
@NonNull
public HashMap<Long, Integer> scores;
/**
* Creates a new CacheData without any content.
*/
public CacheData()
{
id_to_habit = new HashMap<>();
habits = new LinkedList<>();
checkmarks = new HashMap<>();
scores = new HashMap<>();
}
public void copyCheckmarksFrom(@NonNull CacheData oldData)
{
int[] empty = new int[checkmarkCount];
for (Long id : id_to_habit.keySet())
{
if (oldData.checkmarks.containsKey(id))
checkmarks.put(id, oldData.checkmarks.get(id));
else checkmarks.put(id, empty);
}
}
public void copyScoresFrom(@NonNull CacheData oldData)
{
for (Long id : id_to_habit.keySet())
{
if (oldData.scores.containsKey(id))
scores.put(id, oldData.scores.get(id));
else scores.put(id, 0);
}
}
public void fetchHabits()
{
for (Habit h : filteredHabits)
{
habits.add(h);
id_to_habit.put(h.getId(), h);
}
}
}
private class RefreshTask implements Task
{
@NonNull
private CacheData newData;
@Nullable
private Long targetId;
private boolean isCancelled;
private TaskRunner runner;
public RefreshTask()
{
newData = new CacheData();
targetId = null;
isCancelled = false;
}
public RefreshTask(long targetId)
{
newData = new CacheData();
this.targetId = targetId;
}
@Override
public void cancel()
{
isCancelled = true;
}
@Override
public void doInBackground()
{
newData.fetchHabits();
newData.copyScoresFrom(data);
newData.copyCheckmarksFrom(data);
long day = DateUtils.millisecondsInOneDay;
long dateTo = DateUtils.getStartOfDay(DateUtils.getLocalTime());
long dateFrom = dateTo - (checkmarkCount - 1) * day;
runner.publishProgress(this, -1);
for (int position = 0; position < newData.habits.size(); position++)
{
if (isCancelled) return;
Habit habit = newData.habits.get(position);
Long id = habit.getId();
if (targetId != null && !targetId.equals(id)) continue;
newData.scores.put(id, habit.getScores().getTodayValue());
newData.checkmarks.put(id,
habit.getCheckmarks().getValues(dateFrom, dateTo));
runner.publishProgress(this, position);
}
}
@Override
public void onAttached(@NonNull TaskRunner runner)
{
this.runner = runner;
}
@Override
public void onPostExecute()
{
currentFetchTask = null;
listener.onRefreshFinished();
}
@Override
public void onProgressUpdate(int currentPosition)
{
if (currentPosition < 0) processRemovedHabits();
else processPosition(currentPosition);
}
private void performInsert(Habit habit, int position)
{
Long id = habit.getId();
data.habits.add(position, habit);
data.id_to_habit.put(id, habit);
data.scores.put(id, newData.scores.get(id));
data.checkmarks.put(id, newData.checkmarks.get(id));
listener.onItemInserted(position);
}
private void performMove(Habit habit, int fromPosition, int toPosition)
{
data.habits.remove(fromPosition);
data.habits.add(toPosition, habit);
listener.onItemMoved(fromPosition, toPosition);
}
private void performUpdate(Long id, int position)
{
Integer oldScore = data.scores.get(id);
int[] oldCheckmarks = data.checkmarks.get(id);
Integer newScore = newData.scores.get(id);
int[] newCheckmarks = newData.checkmarks.get(id);
boolean unchanged = true;
if (!oldScore.equals(newScore)) unchanged = false;
if (!Arrays.equals(oldCheckmarks, newCheckmarks)) unchanged = false;
if (unchanged) return;
data.scores.put(id, newScore);
data.checkmarks.put(id, newCheckmarks);
listener.onItemChanged(position);
}
private void processPosition(int currentPosition)
{
Habit habit = newData.habits.get(currentPosition);
Long id = habit.getId();
int prevPosition = data.habits.indexOf(habit);
if (prevPosition < 0) performInsert(habit, currentPosition);
else if (prevPosition == currentPosition)
performUpdate(id, currentPosition);
else performMove(habit, prevPosition, currentPosition);
}
private void processRemovedHabits()
{
Set<Long> before = data.id_to_habit.keySet();
Set<Long> after = newData.id_to_habit.keySet();
Set<Long> removed = new TreeSet<>(before);
removed.removeAll(after);
for (Long id : removed) remove(id);
}
}
}
| gpl-3.0 |
pantelis60/L2Scripts_Underground | gameserver/src/main/java/l2s/gameserver/model/base/RestartType.java | 254 | package l2s.gameserver.model.base;
/**
* @author VISTALL
* @date 13:00/27.04.2011
*/
public enum RestartType
{
TO_VILLAGE,
TO_CLANHALL,
TO_CASTLE,
TO_FORTRESS,
TO_FLAG,
FIXED,
AGATHION;
public static final RestartType[] VALUES = values();
}
| gpl-3.0 |
SuperMap-iDesktop/SuperMap-iDesktop-Cross | WorkflowView/src/main/java/com/supermap/desktop/WorkflowView/graphics/events/GraphRemovedListener.java | 242 | package com.supermap.desktop.WorkflowView.graphics.events;
import java.util.EventListener;
/**
* Created by highsad on 2017/5/27.
*/
public interface GraphRemovedListener extends EventListener {
void graphRemoved(GraphRemovedEvent e);
}
| gpl-3.0 |
632677663/Scorpio | scorpio/scorpio-exception/src/main/java/lyj/framework/exception/admin/AdminExceptionCode.java | 576 | package lyj.framework.exception.admin;
/**
*
* @ClassName: AdminExceptionCode
* @Description: admin模块的错误码
* @author lyj
* @date 2017年7月5日 下午2:39:00
*/
public class AdminExceptionCode {
//参数为空
public static final String PARAMETER_IS_NULL = "A00101";
//登录名为空
public static final String LOGIN_NAME_IS_NULL = "A00102";
//登录密码为空
public static final String LOGIN_PWD_IS_NULL = "A00103";
//账户或密码错误
public static final String LOGIN_FAIL = "A00104";
}
| gpl-3.0 |
nict-isp/ETL-flow-editor | backend/DynamicFlink/csv1POJO1446410876049.java | 499 | package DynamicFlink;
public class csv1POJO1446410876049{
String latitude;
public void setLatitude(String latitude) { this.latitude = latitude; }
public String getLatitude() { return this.latitude; }
String longitude;
public void setLongitude(String longitude) { this.longitude = longitude; }
public String getLongitude() { return this.longitude; }
String city_name;
public void setCity_name(String city_name) { this.city_name = city_name; }
public String getCity_name() { return this.city_name; }
} | gpl-3.0 |
KarnYong/BPaaS-modeling | platform extensions/diagram core/src/org/oryxeditor/server/diagram/StencilSetReference.java | 1551 | /*******************************************************************************
* Signavio Core Components
* Copyright (C) 2012 Signavio GmbH
*
* 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.oryxeditor.server.diagram;
/**
* Represents a reference to a stencilset
* <p>
* Includes a namespace and an optional URL
* @author philipp.maschke
*
*/
public class StencilSetReference {
String url;
String namespace;
public StencilSetReference(String namespace) {
this(namespace, null);
}
public StencilSetReference(String namespace, String url) {
this.namespace = namespace;
this.url = url;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
| gpl-3.0 |
wrmsr/cx3d | src/main/java/ini/cx3d/graphics/NavMouseState.java | 2648 | /*
Copyright (C) 2009 Frédéric Zubler, Rodney J. Douglas,
Dennis Göhlsdorf, Toby Weston, Andreas Hauri, Roman Bauer,
Sabina Pfister & Adrian M. Whatley.
This file is part of CX3D.
CX3D 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.
CX3D 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 CX3D. If not, see <http://www.gnu.org/licenses/>.
*/
package ini.cx3d.graphics;
import java.awt.Cursor;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
public class NavMouseState
extends MouseActionState
{
int lastX = 0, lastY = 0;
protected void setMouseSymbol()
{
view.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
public void leftPressed(MouseEvent arg0)
{
lastX = arg0.getX();
lastY = arg0.getY();
}
public void rightPressed(MouseEvent arg0)
{
lastX = arg0.getX();
lastY = arg0.getY();
}
public void leftDragged(MouseEvent arg0)
{
double xd = arg0.getX() - lastX;
double yd = arg0.getY() - lastY;
view.displacementy -= yd / view.getMagnification();
view.displacementx += xd / view.getMagnification();
view.repaint();
lastX = arg0.getX();
lastY = arg0.getY();
// System.out.println("view.displacementy = "+view.displacementy+"; view.displacementx = "+view.displacementx);
}
public void rightDragged(MouseEvent arg0)
{
double xd = arg0.getX() - lastX;
double yd = arg0.getY() - lastY;
view.rotateAroundZ(xd * 0.005);
view.rotateAroundX(yd * 0.005);
view.repaint();
lastX = arg0.getX();
lastY = arg0.getY();
// System.out.println("view.displacementy = "+view.displacementy+"; view.displacementx = "+view.displacementx);
}
public void mouseWheelMoved(MouseWheelEvent e)
{
int clicks = e.getWheelRotation();
if (clicks < 0) {
for (int i = 0; i < Math.abs(clicks); i++) {
view.increaseScalingFactor();
}
}
else {
for (int i = 0; i < Math.abs(clicks); i++) {
view.decreaseScalingFactor();
}
}
view.repaint();
}
}
| gpl-3.0 |
DevCrafters/MCLibrary | src/main/java/kr/rvs/mclibrary/bukkit/event/PlayerBlockWalkEvent.java | 735 | package kr.rvs.mclibrary.bukkit.event;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerMoveEvent;
/**
* Created by JunHyeong Lim on 2018-03-15
*/
public class PlayerBlockWalkEvent extends PlayerWalkEvent {
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() {
return handlers;
}
public PlayerBlockWalkEvent(Player player, Location from, Location to) {
super(player, from, to);
}
public PlayerBlockWalkEvent(PlayerMoveEvent event) {
super(event);
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}
| gpl-3.0 |
ConnorStroomberg/addis-core | src/main/java/org/drugis/trialverse/dataset/service/impl/HistoryServiceImpl.java | 10437 | package org.drugis.trialverse.dataset.service.impl;
import com.jayway.jsonpath.JsonPath;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.jena.datatypes.xsd.XSDDateTime;
import org.apache.jena.ext.com.google.common.collect.Lists;
import org.apache.jena.query.*;
import org.apache.jena.rdf.model.*;
import org.drugis.trialverse.dataset.exception.RevisionNotFoundException;
import org.drugis.trialverse.dataset.model.Merge;
import org.drugis.trialverse.dataset.model.VersionMapping;
import org.drugis.trialverse.dataset.model.VersionNode;
import org.drugis.trialverse.dataset.model.VersionNodeBuilder;
import org.drugis.trialverse.dataset.repository.DatasetReadRepository;
import org.drugis.trialverse.dataset.repository.VersionMappingRepository;
import org.drugis.trialverse.dataset.service.HistoryService;
import org.drugis.trialverse.graph.repository.GraphReadRepository;
import org.drugis.addis.security.Account;
import org.drugis.addis.security.ApiKey;
import org.drugis.addis.security.repository.AccountRepository;
import org.drugis.addis.security.repository.ApiKeyRepository;
import org.drugis.trialverse.util.JenaProperties;
import org.drugis.addis.util.WebConstants;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
/**
* Created by daan on 2-9-15.
*/
@Service
public class HistoryServiceImpl implements HistoryService {
@Inject
private ApiKeyRepository apiKeyRepository;
@Inject
private AccountRepository accountRepository;
@Inject
private VersionMappingRepository versionMappingRepository;
@Inject
private GraphReadRepository graphReadRepository;
@Inject
private DatasetReadRepository datasetReadRepository;
@Inject
private RestTemplate restTemplate;
@Override
public List<VersionNode> createHistory(URI trialverseDatasetUri) throws URISyntaxException, IOException, RevisionNotFoundException {
VersionMapping versionMapping = versionMappingRepository.getVersionMappingByDatasetUrl(trialverseDatasetUri);
Model historyModel = datasetReadRepository.getHistory(versionMapping.getVersionedDatasetUri());
ResIterator stmtIterator = historyModel.listSubjectsWithProperty(JenaProperties.typeProperty, JenaProperties.datasetVersionObject);
Map<String, Resource> versionMap = new HashMap<>();
Map<String, Boolean> referencedMap = new HashMap<>();
// create version map
populateVersionMaps(stmtIterator, versionMap, referencedMap);
// find head version
Resource headVersion = null;
for (String key : versionMap.keySet()) {
if (referencedMap.get(key) == null) {
headVersion = versionMap.get(key);
}
}
// sort the versions
List<VersionNode> sortedVersions = createSortedVersionList(versionMap, headVersion);
Set<RDFNode> seenRevisions = new HashSet<>();
for (VersionNode version : sortedVersions) {
StmtIterator graphRevisionBlankNodes = historyModel.listStatements(historyModel.getResource(version.getUri()), JenaProperties.graphRevisionProperty, (RDFNode) null);
while (graphRevisionBlankNodes.hasNext()) {
Resource graphRevisionBlankNode = graphRevisionBlankNodes.nextStatement().getObject().asResource();
StmtIterator revisionItr = historyModel.listStatements(graphRevisionBlankNode, JenaProperties.revisionProperty, (RDFNode) null);
Resource revisionSubject = revisionItr.next().getObject().asResource();
StmtIterator stmtIterator1 = historyModel.listStatements(revisionSubject, JenaProperties.mergedRevisionProperty, (RDFNode) null);
if (stmtIterator1.hasNext()) { // it's a merge revision
Statement mergedRevision = stmtIterator1.next();
if (!seenRevisions.contains(mergedRevision.getObject())) { // that hasn't been seen before
seenRevisions.add(mergedRevision.getObject());
StmtIterator datasetReference = historyModel.listStatements(mergedRevision.getResource(), JenaProperties.datasetProperty, (RDFNode) null);
RDFNode sourceDataset = datasetReference.next().getObject();
Merge merge = resolveMerge(mergedRevision.getObject().toString(), sourceDataset.toString());
version.setMerge(merge);
}
}
}
}
return sortedVersions;
}
private List<VersionNode> createSortedVersionList(Map<String, Resource> versionMap, Resource headVersion) {
List<VersionNode> sortedVersions = new ArrayList<>();
Resource current = headVersion;
for (int historyOrder = 0; historyOrder < versionMap.size(); ++historyOrder) {
sortedVersions.add(buildNewVersionNode(current, historyOrder));
Resource next = current.getPropertyResourceValue(JenaProperties.previousProperty);
current = next;
}
sortedVersions = Lists.reverse(sortedVersions);
return sortedVersions;
}
private VersionNode buildNewVersionNode(Resource current, int historyOrder) {
Statement title = current.getProperty(JenaProperties.TITLE_PROPERTY);
Resource creatorProp = current.getPropertyResourceValue(JenaProperties.creatorProperty);
String creator = creatorProp == null ? "unknown creator" : creatorProp.toString();
ApiKey apiKey = null;
Account account;
if (creator.startsWith(WebConstants.API_KEY_PREFIX)) {
apiKey = apiKeyRepository.get(Integer.valueOf(creator.substring(WebConstants.API_KEY_PREFIX.length())));
account = accountRepository.findAccountById(apiKey.getAccountId());
} else {
account = accountRepository.findAccountByEmail(creator.substring("mailto:".length()));
}
creator = account.getFirstName() + " " + account.getLastName();
Statement descriptionStatement = current.getProperty(JenaProperties.DESCRIPTION_PROPERTY);
Statement dateProp = current.getProperty(JenaProperties.DATE_PROPERTY);
return new VersionNodeBuilder()
.setUri(current.getURI())
.setVersionTitle(title == null ? "" : title.getObject().toString())
.setVersionDate(((XSDDateTime) dateProp.getObject().asLiteral().getValue()).asCalendar().getTime())
.setDescription(descriptionStatement == null ? null : descriptionStatement.getObject().toString())
.setHistoryOrder(historyOrder)
.setCreator(creator)
.setUserId(account.getId())
.setApplicationName(apiKey == null ? null : apiKey.getApplicationName())
.build();
}
private void populateVersionMaps(ResIterator stmtIterator, Map<String, Resource> versionMap, Map<String, Boolean> referencedMap) {
while (stmtIterator.hasNext()) {
Resource resource = stmtIterator.nextResource();
versionMap.put(resource.getURI(), resource);
Resource previous = resource.getPropertyResourceValue(JenaProperties.previousProperty);
if (previous != null) {
referencedMap.put(previous.getURI(), true);
}
}
}
private Merge resolveMerge(String revisionUri, String sourceDatasetUri) throws IOException, URISyntaxException, RevisionNotFoundException {
VersionMapping mapping = versionMappingRepository.getVersionMappingByVersionedURl(URI.create(sourceDatasetUri));
Model history = datasetReadRepository.getHistory(URI.create(sourceDatasetUri));
Pair<String, String> versionAndGraph = getVersionAndGraph(history, revisionUri);
String userUuid = DigestUtils.sha256Hex(mapping.getOwnerUuid());
String version = versionAndGraph.getLeft();
String graph = versionAndGraph.getRight();
String title = getStudyTitle(sourceDatasetUri, version, graph);
// find graph and version for the merge revision
return new Merge(revisionUri, mapping.getTrialverseDatasetUrl(), version, graph, title, userUuid);
}
private String getStudyTitle(String sourceDatasetUri, String version, String graph) throws IOException {
String template = IOUtils.toString(new ClassPathResource("getGraphTitle.sparql")
.getInputStream(), "UTF-8");
String query = template.replace("$graphUri", graph);
ResponseEntity<String> response = executeVersionedQuery(sourceDatasetUri, version, query);
return JsonPath.read(response.getBody(), "$.results.bindings[0].$title.$value");
}
private ResponseEntity<String> executeVersionedQuery(String sourceDatasetUri, String version, String query) {
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(sourceDatasetUri)
.path(WebConstants.QUERY_ENDPOINT)
.queryParam(WebConstants.QUERY_PARAM_QUERY, query)
.build();
HttpHeaders headers = new HttpHeaders();
headers.put(WebConstants.X_ACCEPT_EVENT_SOURCE_VERSION, Collections.singletonList(version));
headers.put(WebConstants.ACCEPT_HEADER, Collections.singletonList(WebConstants.APPLICATION_SPARQL_RESULTS_JSON));
return restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, new HttpEntity<>(headers), String.class);
}
private Pair<String, String> getVersionAndGraph(Model historyModel, String revisionUri) throws URISyntaxException,
RevisionNotFoundException, IOException {
String template = IOUtils.toString(new ClassPathResource("getGraphAndVersionByRevision.sparql")
.getInputStream(), "UTF-8");
template = template.replace("$revision", revisionUri);
Query query = QueryFactory.create(template);
QueryExecution queryExecution = QueryExecutionFactory.create(query, historyModel);
ResultSet resultSet = queryExecution.execSelect();
if (!resultSet.hasNext()) {
throw new RevisionNotFoundException("Unable to find version and graph for revision " + revisionUri);
}
QuerySolution solution = resultSet.nextSolution();
String version = solution.get(JenaProperties.VERSION).toString();
String graph = solution.get(JenaProperties.GRAPH).toString();
queryExecution.close();
return Pair.of(version, graph);
}
}
| gpl-3.0 |
idega/platform2 | src/com/idega/block/school/data/SchoolArea.java | 474 | package com.idega.block.school.data;
public interface SchoolArea extends com.idega.data.IDOEntity
{
public java.lang.String getName();
public java.lang.String getSchoolAreaCity();
public java.lang.String getSchoolAreaInfo();
public java.lang.String getSchoolAreaName();
public void initializeAttributes();
public void setSchoolAreaCity(java.lang.String p0);
public void setSchoolAreaInfo(java.lang.String p0);
public void setSchoolAreaName(java.lang.String p0);
}
| gpl-3.0 |
joey11111000111/EasyPlan | src/main/java/com/github/joey11111000111/EasyPlan/dao/ObjectIO.java | 6667 | package com.github.joey11111000111.EasyPlan.dao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.nio.file.Paths;
/**
* Implementation of the {@link iObjectIO} interface. Logging is included.
*/
public class ObjectIO implements iObjectIO {
/**
* The <a href="http://www.slf4j.org/">slf4j</a> logger object for this class.
*/
static final Logger LOGGER = LoggerFactory.getLogger(ObjectIO.class);
/**
* The string that represents the path to the save file.
*/
static final File SAVE_FILE;
/**
* Initializes the {@link #SAVE_PATH} in a platform independent way.
*/
static {
SAVE_FILE = Paths.get(System.getProperty("user.home"),
".EasyPlan",
"savedServices.xml")
.toFile();
}
/**
* {@inheritDoc}
*/
@Override
public void saveObject(Object object, Class<?> clazz) throws ObjectSaveFailureException {
LOGGER.trace("called saveObject");
if (!SAVE_FILE.exists()) {
LOGGER.debug("save file doesn't exist");
if (!SAVE_FILE.getParentFile().exists() && !SAVE_FILE.getParentFile().mkdirs())
throw new ObjectSaveFailureException("cannot create parent library");
try {
if (!SAVE_FILE.createNewFile())
throw new ObjectSaveFailureException("cannot explicitly create save file");
} catch (IOException ioe) {
throw new ObjectSaveFailureException("cannot explicitly create save file: " + ioe.getMessage());
}
LOGGER.debug("save file successfully created");
}
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(SAVE_FILE);
} catch (FileNotFoundException e) {
throw new ObjectSaveFailureException("save file cannot be created: " + e.getMessage());
}
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(object, outputStream);
LOGGER.debug("successfully saved object into save file");
} catch (JAXBException e) {
throw new ObjectSaveFailureException("Object cannot be saved: " + e.getMessage());
} finally {
try {
outputStream.close();
} catch (IOException e) {
LOGGER.warn("cannot close output stream");
}
}
}
/**
* {@inheritDoc}
*/
@Override
public <E> E readObject(Class<E> clazz) throws ObjectReadFailureException {
LOGGER.trace("called readObject");
InputStream inputStream = null;
try {
inputStream = new FileInputStream(SAVE_FILE);
} catch (FileNotFoundException e) {
throw new ObjectReadFailureException("save file is not found");
}
LOGGER.debug("save file found");
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
E loadedObject = (E)unmarshaller.unmarshal(inputStream);
LOGGER.debug("object successfully loaded from save file");
return loadedObject;
} catch (JAXBException jaxbe) {
throw new ObjectReadFailureException("Cannot read object: " + jaxbe.getMessage());
} finally {
try {
inputStream.close();
} catch (IOException ioe) {
LOGGER.warn("cannot close input stream");
}
}
}
/* @Override
public void saveObjects(Serializable[] objec) {
LOGGER.trace("called saveServices");
int size = objects.length;
// When there are no services, the reader will know that by not finding the save file
LOGGER.info("saving " + size + " bus services");
if (size == 0) {
File saveFile = new File(SAVE_PATH);
if (saveFile.exists())
if (!saveFile.delete())
LOGGER.error("couldn't delete save file");
return;
}
FileOutputStream fos;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(SAVE_PATH);
oos = new ObjectOutputStream(fos);
for (Serializable object : objects)
oos.writeObject(object);
}
catch (IOException ioe) {
LOGGER.error("I/O exception happened while saving the services", ioe);
} finally {
if (oos != null)
try {
oos.close();
} catch (IOException ioe) {
LOGGER.error("cannot close ObjectOutputStream", ioe);
}
}
}//saveObjects
@Override
public <E> List<E> readObjects(Class<E> clazz) throws ObjectReadFailureException {
LOGGER.trace("called readSavedServices");
List<E> readObjects = new ArrayList<>();
FileInputStream fis;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(SAVE_PATH);
ois = new ObjectInputStream(fis);
try {
while (true) {
try {
readObjects.add((E) ois.readObject());
} catch (ClassCastException | ClassNotFoundException e) {
throw new ObjectReadFailureException(e.getMessage());
}
}//while
} catch (EOFException eofe) {
LOGGER.debug("read " + readObjects.size() + " bus services from the save file");
}
} catch (FileNotFoundException fnfe) {
throw new ObjectReadFailureException("save file is not found");
} catch (IOException ioe) {
LOGGER.error("I/O exception happened while reading saves: ", ioe);
throw new ObjectReadFailureException(ioe.getMessage());
} finally {
if (ois != null)
try {
ois.close();
} catch (IOException ioe) {
LOGGER.error("I/O exception happened while trying to close the ObjectInputStream", ioe);
}
}
return readObjects;
}*/
}//class
| gpl-3.0 |
Leviathan143/betterbeginnings-MODIFIED | src/main/java/net/einsteinsci/betterbeginnings/items/ItemCharredMeat.java | 2938 | package net.einsteinsci.betterbeginnings.items;
import java.util.List;
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemCharredMeat extends ItemFood implements IBBName
{
public static final int META_MEAT = 0;
public static final int META_CHICKEN = 1;
public static final int META_MUTTON = 2;
public static final int META_RABBIT = 3;
public static final int META_FISH = 4;
public static final int META_UNKNOWN = 5;
public ItemCharredMeat()
{
super(5, 2.0f, true);
setHasSubtypes(true);
setMaxDamage(0);
setCreativeTab(ModMain.tabBetterBeginnings);
}
@Override
public String getUnlocalizedName(ItemStack stack)
{
if (stack == null)
{
return null;
}
return "item." + ModMain.MODID + "." + getSimpleUnlocalizedName(stack.getMetadata());
}
public static String getSimpleUnlocalizedName(int meta)
{
switch (meta)
{
case META_MEAT:
return "charred_meat";
case META_CHICKEN:
return "charred_chicken";
case META_MUTTON:
return "charred_mutton";
case META_RABBIT:
return "charred_rabbit";
case META_FISH:
return "charred_fish";
default:
return "charred_unknown";
}
}
public static int getDamageBasedOnMeat(ItemStack meatStack)
{
Item meat = meatStack.getItem();
if (meat == null)
{
return 5; // ???
}
if (meat == Items.BEEF || meat == Items.PORKCHOP ||
meat == Items.COOKED_BEEF || meat == Items.COOKED_PORKCHOP)
{
return 0;
}
if (meat == Items.CHICKEN || meat == Items.COOKED_CHICKEN)
{
return 1;
}
if (meat == Items.MUTTON || meat == Items.COOKED_MUTTON)
{
return 2;
}
if (meat == Items.RABBIT || meat == Items.COOKED_RABBIT)
{
return 3;
}
if (meat == Items.FISH || meat == Items.COOKED_FISH)
{
return 4;
}
return 0;
}
@Override
public void onFoodEaten(ItemStack stack, World world, EntityPlayer player)
{
super.onFoodEaten(stack, world, player);
RegisterAchievements.achievementGet(player, "charredMeat");
}
@Override
public String getName()
{
return "charred_meat";
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)
{
subItems.add(new ItemStack(itemIn, 1, 0));
subItems.add(new ItemStack(itemIn, 1, 1));
subItems.add(new ItemStack(itemIn, 1, 2));
subItems.add(new ItemStack(itemIn, 1, 3));
subItems.add(new ItemStack(itemIn, 1, 4));
subItems.add(new ItemStack(itemIn, 1, 5));
}
}
| gpl-3.0 |
meisamhe/GPLshared | Programming/JavaHTP6e_examples/ch09/fig09_09_11/CommissionEmployee2.java | 3898 | // Fig. 9.9: CommissionEmployee2.java
// CommissionEmployee2 class represents a commission employee.
public class CommissionEmployee2
{
protected String firstName;
protected String lastName;
protected String socialSecurityNumber;
protected double grossSales; // gross weekly sales
protected double commissionRate; // commission percentage
// five-argument constructor
public CommissionEmployee2( String first, String last, String ssn,
double sales, double rate )
{
// implicit call to Object constructor occurs here
firstName = first;
lastName = last;
socialSecurityNumber = ssn;
setGrossSales( sales ); // validate and store gross sales
setCommissionRate( rate ); // validate and store commission rate
} // end five-argument CommissionEmployee2 constructor
// set first name
public void setFirstName( String first )
{
firstName = first;
} // end method setFirstName
// return first name
public String getFirstName()
{
return firstName;
} // end method getFirstName
// set last name
public void setLastName( String last )
{
lastName = last;
} // end method setLastName
// return last name
public String getLastName()
{
return lastName;
} // end method getLastName
// set social security number
public void setSocialSecurityNumber( String ssn )
{
socialSecurityNumber = ssn; // should validate
} // end method setSocialSecurityNumber
// return social security number
public String getSocialSecurityNumber()
{
return socialSecurityNumber;
} // end method getSocialSecurityNumber
// set gross sales amount
public void setGrossSales( double sales )
{
grossSales = ( sales < 0.0 ) ? 0.0 : sales;
} // end method setGrossSales
// return gross sales amount
public double getGrossSales()
{
return grossSales;
} // end method getGrossSales
// set commission rate
public void setCommissionRate( double rate )
{
commissionRate = ( rate > 0.0 && rate < 1.0 ) ? rate : 0.0;
} // end method setCommissionRate
// return commission rate
public double getCommissionRate()
{
return commissionRate;
} // end method getCommissionRate
// calculate earnings
public double earnings()
{
return commissionRate * grossSales;
} // end method earnings
// return String representation of CommissionEmployee2 object
public String toString()
{
return String.format( "%s: %s %s\n%s: %s\n%s: %.2f\n%s: %.2f",
"commission employee", firstName, lastName,
"social security number", socialSecurityNumber,
"gross sales", grossSales,
"commission rate", commissionRate );
} // end method toString
} // end class CommissionEmployee2
/**************************************************************************
* (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/
| gpl-3.0 |
chichunchen/Java-Programming | Java in Winter/Data Structure in Java/List/First Last List/LinkQueueApp.java | 512 | class LinkQueueApp
{
public static void main(String[] args)
{
LinkQueue theQueue = new LinkQueue();
theQueue.insert(20); // insert items
theQueue.insert(40);
theQueue.displayQueue(); // display queue
theQueue.insert(60); // insert items
theQueue.insert(80);
theQueue.displayQueue(); // display queue
theQueue.remove(); // remove items
theQueue.remove();
theQueue.displayQueue(); // display queue
} // end main()
} | gpl-3.0 |
ScreboDevTeam/Screbo | src/de/beuth/sp/screbo/database/Cluster.java | 612 | package de.beuth.sp.screbo.database;
import java.io.Serializable;
/**
* POJO containing one or more postings which are grouped together.
* This object is serialized and deserialized when writing or reading to/from the database.
*
* @author volker.gronau
*
*/
@SuppressWarnings("serial")
public class Cluster implements Serializable, IDInterface {
protected String id;
protected IDList<Posting> postings = new IDList<>();
public IDList<Posting> getPostings() {
return postings;
}
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
}
| gpl-3.0 |
alesharik/GearsMod | src/api/java/com/alesharik/gearsmod/util/field/FieldNotFoundException.java | 911 | /*
* This file is part of GearsMod.
*
* GearsMod 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.
*
* GearsMod 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 GearsMod. If not, see <http://www.gnu.org/licenses/>.
*/
package com.alesharik.gearsmod.util.field;
public class FieldNotFoundException extends RuntimeException {
public FieldNotFoundException() {
super("Field not found!");
}
}
| gpl-3.0 |
autarchprinceps/MultiCastor | Vorgängerversionen/V2.0/Sourcecode/zisko/multicastor/program/view/ButtonTabComponent.java | 6346 | package zisko.multicastor.program.view;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.plaf.basic.BasicButtonUI;
import zisko.multicastor.program.controller.ViewController;
import zisko.multicastor.program.lang.LanguageManager;
/**
* Die Klasse ButtonTabComponent ist ein Panel das in den
* Tabs (Titeln) benutzt wird.
*
* Links steht dabei jeweils ein Icon
* in der Mitte der Titel und rechts ein Schliessueen Button.
*
* @version 2.0
*/
@SuppressWarnings("serial")
public class ButtonTabComponent extends JPanel{
private final DraggableTabbedPane pane;
private LanguageManager lang=LanguageManager.getInstance();
private ViewController vCtrl;
/**
* Der Konstruktor speichert die uebergeben Pane, und erzeugt direkt das neue
* Label mit Bild und Text
*
* Aussueerdem wird ein TabButton zum schliessueen hinzugefuegt.
*
* @param pPane Die TabPane zu der diese Komponente gehoert
* @param path Der Pfad zum Icon welches zum Tab geladen werden soll
*/
public ButtonTabComponent(final DraggableTabbedPane pPane, String path, ViewController pVCtrl){
// Set the Layout(that Label is left and Button right)
super(new FlowLayout(FlowLayout.LEFT,0,0));
// Set the Pane(remember it's final, we need to do this here)
this.pane = pPane;
setOpaque(false);
this.vCtrl = pVCtrl;
//Handle Errors
if(pane == null)
throw new NullPointerException("The parent TabbedPane is null");
// Set the Label with the Title of the right Compononent of the DraggableTabbedPane
JLabel label = new JLabel(new ImageIcon(getClass().getResource(path))){
public String getText(){
//This gets the index of this Component (or -1 if its not contained in a TabbedPane)
int i = pane.indexOfTabComponent(ButtonTabComponent.this);
if(i != -1)
return pane.getTitleAt(i);
return null;
}
};
label.setFont(MiscFont.getFont(0, 17));
add(label);
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
//Add the Button
JButton button = new TabButton();
add(button);
setBorder(BorderFactory.createEmptyBorder(2,0,0,0));
}
/**
* Die private Klasse TabButton.
* Sie ist dafuer verantwortlich einen Button zum schliessueen der Tabs zu erzeugen
* und enthaelt auch den ActionListener, der die Tabs dann wirklich schliessuet.
*/
private class TabButton extends JButton implements ActionListener {
public TabButton() {
int size = 17;
setPreferredSize(new Dimension(size, size));
setToolTipText(lang.getProperty("toolTip.closeThisTab"));
//Make the button looks the same for all Laf's
setUI(new BasicButtonUI());
//Make it transparent
setContentAreaFilled(false);
//No need to be focusable
setFocusable(false);
setBorder(BorderFactory.createEtchedBorder());
setBorderPainted(false);
//Making nice rollover effect
//we use the same listener for all buttons
addMouseListener(buttonMouseListener);
setRolloverEnabled(true);
//Close the proper tab by clicking the button
addActionListener(this);
}
/**
* actionPerformed, kuemmert sich darum den Tab zu schliessueen
* wenn der Button geschlossen wird
*
* @param ActionEvent e, wird nicht benutzt
*/
public void actionPerformed(ActionEvent e) {
int i = pane.indexOfTabComponent(ButtonTabComponent.this);
if (i != -1) {
pane.closeTab(pane.getTitleAt(i));
pane.remove(i);
vCtrl.autoSave();
}
}
/**
* we don't want to update UI for this button
*/
public void updateUI() {
}
/**
* paint the cross
*
* @param g Standart fuer painComponent Methoden von AWT
*/
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
//shift the image for pressed buttons
if (getModel().isPressed()) {
g2.translate(1, 1);
}
g2.setStroke(new BasicStroke(2));
g2.setColor(Color.BLACK);
if (getModel().isRollover()) {
g2.setColor(Color.MAGENTA);
}
int delta = 6;
g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
g2.dispose();
}
}
private final static MouseListener buttonMouseListener = new MouseAdapter() {
/**
* Funktion welche dafuer sorgt den Rahmen
* fuer den "Hover-Effekt" zu zeichnen
*
* @param e, das MouseEvent ueber welches
* der entsprechende Button ausgewaehlt werden kann
*/
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(true);
}
}
/**
* Funktion welche dafuer sorgt den Rahmen
* fuer den "Hover-Effekt" wieder zu entfernen
*
* @param e, das MouseEvent ueber welches
* der entsprechende Button ausgewaehlt werden kann
*/
public void mouseExited(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setBorderPainted(false);
}
}
};
}
| gpl-3.0 |
wemanity/Acceptance-Tests-with-JBehave | jbehave-with-dbunit/dbunit-facilitation/src/main/java/poc/jbehave/testing/config/DbUnitFacilitationConfig.java | 352 | /**
*
*/
package poc.jbehave.testing.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* Configuration Spring pour DbUnit Facilitation.
*
* @author Xavier Pigeon
*/
@Configuration
@ComponentScan("poc.jbehave.testing")
public class DbUnitFacilitationConfig {} | gpl-3.0 |
triguero/Keel3.0 | src/keel/Algorithms/UnsupervisedLearning/AssociationRules/IntervalRuleLearning/MOPNAR/Gene.java | 11747 | /***********************************************************************
This file is part of KEEL-software, the Data Mining tool for regression,
classification, clustering, pattern mining and so on.
Copyright (C) 2004-2010
F. Herrera (herrera@decsai.ugr.es)
L. Sánchez (luciano@uniovi.es)
J. Alcalá-Fdez (jalcala@decsai.ugr.es)
S. García (sglopez@ujaen.es)
A. Fernández (alberto.fernandez@ujaen.es)
J. Luengo (julianlm@decsai.ugr.es)
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 keel.Algorithms.UnsupervisedLearning.AssociationRules.IntervalRuleLearning.MOPNAR;
/**
* <p>
* @author Written by Diana Martín (dmartin@ceis.cujae.edu.cu)
* @version 1.1
* @since JDK1.6
* </p>
*/
import org.core.Randomize;
public class Gene {
/**
* <p>
* It is used for representing and handling a Gene throughout the evolutionary learning
* </p>
*/
public static final int NOT_INVOLVED = -1;
public static final int ANTECEDENT = 0;
public static final int CONSEQUENT = 1;
private int attr;
private int ac;
private boolean pn;
private double lb;
private double ub;
private double min_attr;
private double max_attr;
private int type;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
/**
* <p>
* It creates a new gene
* </p>
*/
public Gene() {
}
/**
* <p>
* It allows to clone correctly a gene
* </p>
* @return A copy of the gene
*/
public Gene copy() {
Gene gene = new Gene();
gene.attr = this.attr;
gene.ac = this.ac;
gene.pn = this.pn;
gene.lb = this.lb;
gene.ub = this.ub;
gene.type = this.type;
gene.min_attr = this.min_attr;
gene.max_attr = this.max_attr;
return gene;
}
/**
* <p>
* It does inversions for each part of a gene which were specifically designed for this algorithm
* </p>
* @param type The domain type of gene
* @param min_attr The minimum domain value depending on the type of gene
* @param max_attr The maximum domain value depending on the type of gene
*/
public void invert(int type, double min_attr, double max_attr) {
switch (this.ac) {
case Gene.NOT_INVOLVED:
this.ac = Gene.ANTECEDENT;
break;
case Gene.ANTECEDENT:
this.ac = Gene.CONSEQUENT;
break;
case Gene.CONSEQUENT:
this.ac = Gene.NOT_INVOLVED;
}
this.pn = !this.pn;
if ( type != myDataset.NOMINAL ) {
if ( type == myDataset.REAL ) {
this.lb = Randomize.RandClosed() * (this.lb - min_attr) + min_attr;
this.ub = Randomize.RandClosed() * (max_attr - this.ub) + this.ub;
}
else {
this.lb = Randomize.RandintClosed((int)min_attr, (int)this.lb);
this.ub = Randomize.RandintClosed((int)this.ub, (int)max_attr);
}
}
else {
if (this.lb == max_attr) this.lb = this.ub = min_attr;
else {
this.lb++;
this.ub++;
}
}
}
/**
* <p>
* It returns whether a gene is involved in the chromosome being considered.
* In case it is involved, returns if it acts as antecedent or consequent
* </p>
* @return A constant value indicating the "role" played by the gene
*/
public int getActAs() {
return this.ac;
}
/**
* <p>
* It sets whether a gene is involved in the chromosome being considered.
* In case it is involved, the user must specify if it acts as antecedent or consequent
* </p>
* @param ac The constant value indicating the "role" played by the gene
*/
public void setActAs(int ac) {
this.ac = ac;
}
/**
* <p>
* It returns if a gene treats a positive or negative interval
* </p>
* @return A value indicating whether the interval must be considered as positive
*/
public boolean getIsPositiveInterval() {
return this.pn;
}
/**
* <p>
* It sets if a gene treats positive or negative interval
* </p>
* @param pn The value indicating whether the interval must be considered as positive
*/
public void setIsPositiveInterval(boolean pn) {
this.pn = pn;
}
/**
* <p>
* It returns the lower bound of the interval stored in a gene
* </p>
* @return A value indicating the lower bound of the interval
*/
public double getLowerBound() {
return this.lb;
}
/**
* <p>
* It sets the lower bound of the interval stored in a gene
* </p>
* @param lb The value indicating the lower bound of the interval
*/
public void setLowerBound(double lb) {
this.lb = lb;
}
/**
* <p>
* It returns the upper bound of the interval stored in a gene
* </p>
* @return A value indicating the upper bound of the interval
*/
public double getUpperBound() {
return this.ub;
}
/**
* <p>
* It sets the upper bound of the interval stored in a gene
* </p>
* @param lb The value indicating the upper bound of the interval
*/
public void setUpperBound(double ub) {
this.ub = ub;
}
/**
* <p>
* It indicates whether some other gene is "equal to" this one
* </p>
* @param obj The reference object with which to compare
* @return True if this gene is the same as the argument; False otherwise
*/
public boolean equals(Gene g) {
double lb_posit, ub_posit;
if (g.attr == this.attr) {
if (g.ac == this.ac) {
if (g.pn == this.pn) {
if (Math.abs(g.lb - this.lb) <= 0.00001) {
if (Math.abs(g.ub - this.ub) <= 0.00001) return true;
}
}
else {
if (!g.pn){
if(g.lb == this.min_attr){
lb_posit = g.ub;
ub_posit = this.max_attr;
if (type == myDataset.REAL) lb_posit+= 0.0001;
else lb_posit += 1;
if (Math.abs(lb_posit - this.lb) <= 0.00001) {
if (Math.abs(ub_posit - this.ub) <= 0.00001) return true;
}
}
if(g.ub == this.max_attr){
lb_posit = this.min_attr;
ub_posit = g.lb;
if(type == myDataset.REAL) ub_posit -= 0.0001;
else ub_posit -= 1;
if (Math.abs(lb_posit - this.lb) <= 0.00001) {
if (Math.abs(ub_posit - this.ub) <= 0.00001) return true;
}
}
}
else {
if(!this.pn){
if(this.lb == this.min_attr){
lb_posit = this.ub;
ub_posit = this.max_attr;
if (type == myDataset.REAL) lb_posit+= 0.0001;
else lb_posit += 1;
if (Math.abs(lb_posit - g.lb) <= 0.00001) {
if (Math.abs(ub_posit - g.ub) <= 0.00001) return true;
}
}
if(this.ub == this.max_attr){
lb_posit =this.min_attr;
ub_posit = this.lb;
if(type == myDataset.REAL) ub_posit -= 0.0001;
else ub_posit -= 1;
if (Math.abs(lb_posit - g.lb) <= 0.00001) {
if (Math.abs(ub_posit - g.ub) <= 0.00001) return true;
}
}
}
}
}
}
}
return false;
}
/**
* <p>
* It returns a string representation of a gene
* </p>
* @return A string representation of the gene
*/
public String toString() {
return "Attr: " + attr + "AC: " + ac + "; PN: " + pn + "; LB: " + lb + "; UB: " + ub;
}
public int getAttr() {
return this.attr;
}
public void setAttr(int var) {
this.attr = var;
}
public int randAct () {
return (Randomize.RandintClosed(Gene.NOT_INVOLVED, Gene.CONSEQUENT));
}
public void tuneInterval (myDataset dataset, int[] covered) {
int i, r, nData;
double min, max, delta;
double[] example;
nData = dataset.getnTrans();
if(this.pn){
min = this.ub;
max = this.lb;
for (i=0; i < nData; i++) {
if (covered[i] > 0) {
example = dataset.getExample(i);
if (example[this.attr] < min) min = example[this.attr];
if (example[this.attr] > max) max = example[this.attr];
}
}
this.ub = max;
this.lb = min;
}
else//negative interval
{
if(dataset.getAttributeType(this.attr)== myDataset.REAL) delta = 0.0001;
else delta = 1.0;
min = dataset.getMax(this.attr) + delta;
max = dataset.getMin(this.attr) - delta;
for (r=0; r < nData; r++) {
if (covered[r] > 0) {
example = dataset.getExample(r);
if ( (example[this.attr] < min) && (example[this.attr] > this.ub) ) min = example[this.attr];
if ( (example[this.attr] > max) && (example[this.attr] < this.lb) ) max = example[this.attr];
}
}
this.lb = max + delta;
this.ub = min - delta;
}
}
public boolean isCover (int var, double value) {
boolean covered;
if (this.attr != var) return (false);
covered = true;
if (this.pn) {
if ((value < this.lb) || (value > this.ub)) covered = false;
}
else {
if ((value >= this.lb) && (value <= this.ub)) covered = false;
}
return (covered);
}
public boolean isSubGen (Gene g) {
double lb_posit, ub_posit;
if (this.attr != g.attr) return (false);
if (this.ac != g.ac) return (false);
if ((this.pn) && (g.pn)){
if (Math.abs(g.lb - this.lb) > 0.00001) return (false);
if (Math.abs(g.ub - this.ub) > 0.00001) return (false);
}
else if ((!this.pn) && (!g.pn)){//negative interval
if (Math.abs(g.lb - this.lb) > 0.00001) return (false);
if (Math.abs(g.ub - this.ub) > 0.00001) return (false);
}
else {
if(!g.pn){ // g negative interval
if(g.lb == this.min_attr){
lb_posit = g.ub;
ub_posit = this.max_attr;
if (type == myDataset.REAL) lb_posit+= 0.0001;
else lb_posit += 1;
if (Math.abs(lb_posit - this.lb) > 0.00001) return (false);
if (Math.abs(ub_posit - this.ub) > 0.00001) return (false);
}
if(g.ub == this.max_attr){
lb_posit = this.min_attr;
ub_posit = g.lb;
if(type == myDataset.REAL) ub_posit -= 0.0001;
else ub_posit -= 1;
if (Math.abs(lb_posit - this.lb) > 0.00001) return (false);
if (Math.abs(ub_posit - this.ub) > 0.00001) return (false);
}
}
else { // this negative interval
if(!this.pn){
if(this.lb == this.min_attr){
lb_posit = this.ub;
ub_posit = this.max_attr;
if(type == myDataset.REAL) lb_posit+= 0.0001;
else lb_posit += 1;
if (Math.abs(lb_posit - g.lb) > 0.00001) return (false);
if (Math.abs(ub_posit - this.ub) > 0.00001) return (false);
}
if(this.ub == this.max_attr){
lb_posit = this.min_attr;
ub_posit = this.lb;
if(type == myDataset.REAL) ub_posit -= 0.0001;
else ub_posit -= 1;
if (Math.abs(lb_posit - g.lb) > 0.00001) return (false);
if (Math.abs(ub_posit - this.ub) > 0.00001) return (false);
}
}
}
}
return (true);
}
public double getMax_attr() {
return max_attr;
}
public void setMax_attr(double max_attr) {
this.max_attr = max_attr;
}
public double getMin_attr() {
return min_attr;
}
public void setMin_attr(double min_attr) {
this.min_attr = min_attr;
}
}
| gpl-3.0 |
robward-scisys/sldeditor | modules/import/export-sld/src/main/java/com/sldeditor/exportdata/esri/keys/symbols/PictureLineSymbolKeys.java | 1616 | /*
* SLD Editor - The Open Source Java SLD Editor
*
* Copyright (C) 2016, SCISYS UK Limited
*
* 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 com.sldeditor.exportdata.esri.keys.symbols;
/**
* The Class PictureLineSymbolKeys, contains all the keys used within
* the intermediate json file to represent an Esri MXD picture line symbols that the
* SLD Editor can understand.
*
* @author Robert Ward (SCISYS)
*/
public class PictureLineSymbolKeys {
public static final String PICTURE_LINE_SYMBOL = "PictureLineSymbol";
public static final String IS_ROTATED = "isRotated";
public static final String SWAP_FORE_GROUND_BACK_GROUND_COLOUR = "swapForeGroundBackGroundColour";
public static final String X_SCALE = "xScale";
public static final String Y_SCALE = "yScale";
public static final String PICTURE = "picture";
public static final String BACKGROUND_COLOUR = "backgroundColour";
public static final String BITMAP_TRANSPARENCY_COLOUR = "bitmapTransparencyColour";
}
| gpl-3.0 |
Edaenge/Chord_P2P_Simulation | ChordSimulation/src/Chord/Tasks/FixFingersTask.java | 1995 | /*
* Copyright (C) 2015 Simon Edänge <ediz_cracked@hotmail.com>
* Bachelor Computer Science Degree Project
* Blekinge Institute of Technology Sweden <http://www.bth.se/>
*
* 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 Chord.Tasks;
import Chord.ChordNode;
import Chord.FingerTable.Finger;
import Chord.FingerTable.FingerTable;
/**
* This class is used as a background worker, and called every time t.
*
* It corrects the finger entries in the local nodes finger table.
*
* @author Simon Edänge
*/
public class FixFingersTask implements Runnable
{
private final ChordNode mLocal;
private int mFixFingerIndex;
public FixFingersTask(ChordNode self)
{
mLocal = self;
mFixFingerIndex = 0;
}
@Override
public void run()
{
if(mLocal != null)
FixFingers();
}
private void FixFingers()
{
FingerTable fingerTable = mLocal.GetFingerTable();
if( mFixFingerIndex >= fingerTable.GetSize() )
mFixFingerIndex = 0;
ChordNode n;
Finger f = fingerTable.Get(mFixFingerIndex++);
if(f == null)
return;
n = mLocal.findSuccessor(f.start);
if(n != null && n != mLocal)
{
f.node = n;
fingerTable.AddSuccessorToList(n);
}
}
}
| gpl-3.0 |
pvenne/jgoose | src/com/gremwell/jnetbridge/Port.java | 1939 | package com.gremwell.jnetbridge;
import org.jnetpcap.nio.JBuffer;
import org.jnetpcap.packet.JPacket;
/**
* This class represents an abstract port.
*
* Subclasses are expected to do the necessary to obtain received packets
* and to pass it to ingress() method, which will pass them to the listener.
*
* Subclasses have to override send() method and make necessary arrangements
* to send given packet.
*
* Subclasses are expected to increment corresponding counters to
* provide information about port activity.
*
* @author Alexandre Bezroutchko
* @author Gremwell bvba
*/
public abstract class Port {
protected final String name;
protected PortListener listener = null;
// counters
protected int received = 0;
protected int sent = 0;
Port(String name) {
this.name = name;
}
/**
* Set a <code>PortListener</code> the port has to pass ingress packets to.
*
* @param listener
*/
public void setListener(PortListener listener) {
this.listener = listener;
}
/**
* The clients have to invoke this method to release resources allocated
* for this port, if any.
*/
public abstract void close();
@Override
public String toString() {
return "name=" + name;
}
public String getName() {
return name;
}
/**
* @return A string containing current packet and error counters.
*/
public String getStat() {
return "received=" + received + ", sent=" + sent;
}
/**
* This method is invoked by subclasses, asynchronously.
*
*/
void ingress(JPacket packet) {
if (listener != null) {
listener.ingress(this, packet);
}
}
/**
* Invoked by the clients. The subclasses of <code>Port</code> have
* to send the packet immediately or enqueue it.
*
*/
public abstract void send(JBuffer packet);
}
| gpl-3.0 |
mckunkel/CLASEtaPrimeAnalysis | EtaPrimeAnalysis/src/main/java/services/MainServiceImpl.java | 8777 | /* +__^_________,_________,_____,________^-.-------------------,
* | ||||||||| `--------' | | O
* `+-------------USMC----------^----------|___________________|
* `\_,---------,---------,--------------'
* / X MK X /'| /'
* / X MK X / `\ /'
* / X MK X /`-------'
* / X MK X /
* / X MK X /
* (________( @author m.c.kunkel
* `------'
*/
package services;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import domain.Analysis;
import domain.Coordinate;
import domain.Cuts;
import domain.DataPoint;
import domain.TreeVector;
import domain.utils.GlobalConstants;
public class MainServiceImpl implements MainService {
private List<String> reactionList = null;
private List<String> skimService = null;
private DataPoint dataPoint = null;
private List<Coordinate> invariantMassList = null;
private List<Coordinate> missingMassList = null;
private boolean calQ;
private boolean calW;
private boolean calP;
private Map<Coordinate, Integer> neededHists = null;
private List<String> genList = null;
private List<String> recList = null;
private List<Cuts> cutList = null;
private TreeVector treeVector = null;
public MainServiceImpl() {
this.reactionList = new ArrayList<>();
this.skimService = new ArrayList<>();
this.dataPoint = new DataPoint();
this.invariantMassList = new ArrayList<>();
this.missingMassList = new ArrayList<>();
this.calQ = false;
this.calW = false;
this.calP = false;
this.neededHists = new HashMap<>();
this.genList = new ArrayList<>();
this.recList = new ArrayList<>();
this.cutList = new ArrayList<>();
this.treeVector = new TreeVector("T");
}
private void createTreeBranches(String dataType) {
List<String> tmpList = new ArrayList<>();
for (Coordinate aCoordinate : invariantMassList) {
String branchName = "";
if (this.neededHists.get(aCoordinate) > 1) {
for (int i = 0; i < this.neededHists.get(aCoordinate); i++) {
branchName = dataType + "M" + GlobalConstants.coordinateToString(aCoordinate)
+ Integer.toString(i + 1);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
} else {
branchName = dataType + "M" + GlobalConstants.coordinateToString(aCoordinate);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
}
for (Coordinate aCoordinate : missingMassList) {
String branchName = "";
if (this.neededHists.get(aCoordinate) > 1) {
for (int i = 0; i < this.neededHists.get(aCoordinate); i++) {
branchName = dataType + "Mx" + GlobalConstants.coordinateToString(aCoordinate)
+ Integer.toString(i + 1);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
} else {
branchName = dataType + "Mx" + GlobalConstants.coordinateToString(aCoordinate);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
}
if (calQ) {
String branchName = "";
int occurrences = Collections.frequency(reactionList, "e-");
// System.out.println(occurrences + " the number of possible
// calculations for Q2");
for (int i = 0; i < occurrences; i++) {
branchName = dataType + "QSq" + Integer.toString(i + 1);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
}
if (calW) {
String branchName = "";
int occurrences = Collections.frequency(reactionList, "e-");
// System.out.println(occurrences + " the number of possible
// calculations for Q2");
for (int i = 0; i < occurrences; i++) {
branchName = dataType + "W" + Integer.toString(i + 1);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
}
if (calP) {
String[] pList = { "Ptot", "Px", "Py", "Pz" };
for (String string : reactionList) {
String branchName = "";
int occurrences = Collections.frequency(reactionList, string);
if (occurrences > 1) {
for (int i = 0; i < occurrences; i++) {
for (String string2 : pList) {
branchName = dataType + GlobalConstants.coordinateToString(string) + "_" + string2
+ Integer.toString(i + 1);
// System.out.println(branchName);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
}
} else {
for (String string2 : pList) {
branchName = dataType + GlobalConstants.coordinateToString(string) + "_" + string2;
// System.out.println(branchName);
treeVector.addBranch(branchName, "", "");
tmpList.add(branchName);
}
}
}
}
if (dataType.equals("gen")) {
this.genList.addAll(tmpList);
} else {
this.recList.addAll(tmpList);
}
//
// for (String str : treeVector.getListOfBranches()) {
// System.out.println(str + " is a branch that you set " + dataType);
// }
}
private void makeBranches() {
Map<Coordinate, Integer> aCoordMap = new HashMap<>();
for (Coordinate aCoordinate : getMissingMassList()) {
int occurrences = 0;
for (String string : aCoordinate) {
occurrences = occurrences + Collections.frequency(reactionList, string);
}
int histsNeeded = occurrences - aCoordinate.getStrSize() + 1;
if (!aCoordMap.containsKey(aCoordinate)) {
aCoordMap.put(aCoordinate, histsNeeded);
}
}
for (Coordinate aCoordinate : getInvariantList()) {
int occurrences = 0;
for (String string : aCoordinate) {
occurrences = occurrences + Collections.frequency(reactionList, string);
}
int histsNeeded = occurrences - aCoordinate.getStrSize() + 1;
if (!aCoordMap.containsKey(aCoordinate)) {
aCoordMap.put(aCoordinate, histsNeeded);
}
}
setHists(aCoordMap, skimService);
}
private void setHists(Map<Coordinate, Integer> aMap, List<String> skimService) {
this.neededHists = aMap;
for (String dataType : skimService) {
createTreeBranches(dataType);
}
}
public List<String> getGenList() {
return this.genList;
}
public List<String> getRecList() {
return this.recList;
}
public void setReaction(String... strings) {
for (String string : strings) {
this.reactionList.add(string);
}
}
public void addMCService() {
this.skimService.add("gen");
}
public void addReconService() {
this.skimService.add("rec");
}
public List<String> getSkimService() {
return this.skimService;
}
public List<String> getReactionList() {
return this.reactionList;
}
public void addCut(double mean, double sigmaRange, String... strings) {
Coordinate aCoordinate = new Coordinate(strings);
Cuts cuts = new Cuts(aCoordinate, mean, sigmaRange);
this.cutList.add(cuts);
}
public void addCut(double mean, double sigma, double sigmaRange, String... strings) {
Coordinate aCoordinate = new Coordinate(strings);
Cuts cuts = new Cuts(aCoordinate, mean, sigma, sigmaRange);
this.cutList.add(cuts);
}
public void addCut(double mean, int side, String... strings) {
Coordinate aCoordinate = new Coordinate(strings);
Cuts cuts = new Cuts(aCoordinate, mean, side);
this.cutList.add(cuts);
}
public List<Cuts> getcutList() {
return this.cutList;
}
public List<Coordinate> getInvariantList() {
return this.invariantMassList;
}
public List<Coordinate> getMissingMassList() {
return this.missingMassList;
}
public void addToInvariantList(String... strings) {
Coordinate aCoordinate = new Coordinate(strings);
this.invariantMassList.add(aCoordinate);
}
public void addToIMissingMassList(String... strings) {
Coordinate aCoordinate = new Coordinate(strings);
this.missingMassList.add(aCoordinate);
}
public void calQ() {
this.calQ = true;
}
public void calW() {
this.calW = true;
}
public void calP() {
this.calP = true;
}
public boolean isQ() {
return this.calQ;
}
public boolean isW() {
return this.calW;
}
public boolean isP() {
return this.calP;
}
public TreeVector getTree() {
return this.treeVector;
}
public void addDataPoint(DataPoint dataPoint) {
this.dataPoint = this.dataPoint.addDataPoint(dataPoint);
}
public void assembleDataPoint() {
getTree().addToTree(this.dataPoint);
this.dataPoint = new DataPoint();
}
public void runService(String[] array) {
makeBranches();
for (String str : treeVector.getListOfBranches()) {
System.out.println(str + " is a branch that is made");
}
// AnalysisPlotsWithGamma analysisPlots = new AnalysisPlotsWithGamma();
// AnalysisPlotsEpEmGam analysisPlots = new AnalysisPlotsEpEmGam();
Analysis analysis = new Analysis(array);
analysis.run();
DataToJSON dataToJSON = new DataToJSON();
dataToJSON.init();
// AnalysisPlots analysisPlots = new AnalysisPlots();
// analysisPlots.run();
System.exit(1);
}
}
| gpl-3.0 |
Mapleroid/cm-server | server-5.11.0.src/com/cloudera/cmf/service/config/ConfigChange.java | 2076 | package com.cloudera.cmf.service.config;
import com.cloudera.cmf.model.DbConfig;
import com.cloudera.cmf.model.DbConfigContainer;
import com.cloudera.cmf.model.DbHost;
import com.cloudera.cmf.model.DbRole;
import com.cloudera.cmf.model.DbRoleConfigGroup;
import com.cloudera.cmf.model.DbService;
import com.cloudera.cmf.model.Enums.ConfigScope;
import com.cloudera.cmf.service.EntityChange;
public class ConfigChange extends EntityChange<DbConfig>
{
private DbHost host;
private DbService service;
private DbRoleConfigGroup group;
private DbRole role;
private DbConfigContainer container;
private String oldValue;
private String newValue;
private ParamSpec<?> ps;
private Enums.ConfigScope configScope;
public ConfigChange(ParamSpec<?> ps, DbConfig oldConfig, DbConfig newConfig)
{
super(oldConfig, newConfig);
DbConfig notNullConfig = oldConfig != null ? oldConfig : newConfig;
this.host = notNullConfig.getHost();
this.service = notNullConfig.getService();
this.group = notNullConfig.getRoleConfigGroup();
this.role = notNullConfig.getRole();
this.container = notNullConfig.getConfigContainer();
this.configScope = notNullConfig.getConfigScope();
this.ps = ps;
this.oldValue = (oldConfig == null ? null : oldConfig.getValueCoercingNull());
this.newValue = (newConfig == null ? null : newConfig.getValueCoercingNull());
}
public String getOldValue() {
return this.oldValue;
}
public String getNewValue() {
return this.newValue;
}
public Enums.ConfigScope getConfigScope() {
return this.configScope;
}
public DbService getService() {
return this.service;
}
public DbRole getRole() {
return this.role;
}
public DbConfigContainer getConfigContainer() {
return this.container;
}
public DbRoleConfigGroup getRoleConfigGroup() {
return this.group;
}
public DbHost getHost() {
return this.host;
}
public ParamSpec<?> getParamSpec() {
return this.ps;
}
} | gpl-3.0 |
hohohahi/Bottle_CloudServer | src/main/java/com/shishuo/cms/tag/ConfigTag.java | 1251 | /*
* Copyright © 2013 Changsha Shishuo Network Technology Co., Ltd. All rights reserved.
* 长沙市师说网络科技有限公司 版权所有
* http://www.shishuo.com
*/
package com.shishuo.cms.tag;
import static freemarker.template.ObjectWrapper.BEANS_WRAPPER;
import java.io.IOException;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shishuo.cms.plugin.TagPlugin;
import com.shishuo.cms.service.ConfigService;
import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
/**
* @author Administrator file标签
*/
@Service
public class ConfigTag extends TagPlugin {
@Autowired
private ConfigService configService;
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
// 获取页面的参数
String key = params.get("key").toString();
String value = configService.getStringByKey(key);
env.setVariable("tag_value", BEANS_WRAPPER.wrap(value));
body.render(env.getOut());
}
}
| gpl-3.0 |
albere/bereal.mc.generic | client/ClientProxy.java | 336 | package bereal.mc.generic.client;
import net.minecraftforge.client.MinecraftForgeClient;
import bereal.mc.generic.CommonProxy;
public class ClientProxy extends CommonProxy {
@Override
public void registerRenderers() {
// This is for rendering entities and so forth later on
}
}
| gpl-3.0 |
QuattroX/pixel-dungeon | src/com/dit599/customPD/ui/HealthBar.java | 1537 | /*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* 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 com.dit599.customPD.ui;
import com.watabou.noosa.ColorBlock;
import com.watabou.noosa.ui.Component;
public class HealthBar extends Component {
private static final int COLOR_BG = 0xFFCC0000;
private static final int COLOR_LVL = 0xFF00EE00;
private static final int HEIGHT = 2;
private ColorBlock hpBg;
private ColorBlock hpLvl;
private float level;
@Override
protected void createChildren() {
hpBg = new ColorBlock( 1, 1, COLOR_BG );
add( hpBg );
hpLvl = new ColorBlock( 1, 1, COLOR_LVL );
add( hpLvl );
height = HEIGHT;
}
@Override
protected void layout() {
hpBg.x = hpLvl.x = x;
hpBg.y = hpLvl.y = y;
hpBg.size( width, HEIGHT );
hpLvl.size( width * level, HEIGHT );
height = HEIGHT;
}
public void level( float value ) {
level = value;
layout();
}
}
| gpl-3.0 |
peterhuerlimann/bluej-java-learning | Kapitel05/Kritzeln/Stift.java | 4770 | import java.awt.Color;
import java.util.Random;
/**
* Mithilfe eines Stift-Objekt kann in ein Canvas-Leinwand gezeichnet werden.
* Der Stift verfügt über eine Position, Richtung, Farbe und einen Aufgesetzt/Abgehoben-Zustand.
* Der Stift kann über die Canvas bewegt werden. Wenn der Stift aufgesetzt ist , zeichnet er
* beim Bewegen eine Linie in die Leinwand. (Ist der Stift abgehoben, zeichnet er keine Linie.)
*
* @author Michael Kölling und David J. Barnes
* @version 31.07.2011
*/
public class Stift
{
// Konstanten für die zufaelligesGekritzel-Methode
private static final int GEKRITZEL_GROESSE = 40;
private static final int GEKRITZEL_ZAEHLER = 30;
private int xPosition;
private int yPosition;
private int rotation;
private Color farbe;
private boolean stiftAufgesetzt;
private Canvas canvas;
private Random zufallsgenerator;
/**
* Erzeuge einen neuen Stift mit seiner eigenen Canvas. Der Stift erzeugt sich eine neue Canvas,
* in die er zeichnen kann, und startet in einem definierten Zustand (Position: Mitte der Leinwand,
* Richtung: rechts, Farbe: schwarz, Stift: aufgesetzt).
*/
public Stift()
{
this (280, 220, new Canvas("Meine Canvas", 560, 440));
}
/**
* Erzeuge einen neuen Stift für eine gegebene Canvas. Die Richtung ist anfänglich 0 (nach rechts),
* die Farbe ist schwarz und der Stift ist aufgesetzt.
*
* @param xPos die anfängliche horizontale Koordinate des Stiftes
* @param yPos die anfängliche vertikale Koordinate des Stiftes
* @param zeichenCanvas die Canvas, in die gezeichnet werden soll
*/
public Stift(int xPos, int yPos, Canvas zeichenCanvas)
{
xPosition = xPos;
yPosition = yPos;
rotation = 0;
stiftAufgesetzt = true;
farbe = Color.BLACK;
canvas = zeichenCanvas;
zufallsgenerator = new Random();
}
/**
* Bewege den Stift für die angegebene Distanz in die aktuelle Richtung. Wenn,
* der Stift aufgesetzt ist, lasse eine Linie zurück.
*
* @param distanz Die Distanz um die der Stift von der aktuellen Position aus nach vorne bewegt werden soll.
*/
public void bewegen(int distanz)
{
double winkel = Math.toRadians(rotation);
int neuX = (int) Math.round(xPosition + Math.cos(winkel) * distanz);
int neuY = (int) Math.round(yPosition + Math.sin(winkel) * distanz);
bewegenNach(neuX, neuY);
}
/**
* Bewege den Stift zu der angegebenen Position. Wenn,
* der Stift aufgesetzt ist, lasse eine Linie zurück.
*
* @param x Die x-Koordinate, zu der der Stift bewegt werden soll.
* @param y Die y-Koordinate, zu der der Stift bewegt werden soll.
*/
public void bewegenNach(int x, int y)
{
if (stiftAufgesetzt) {
canvas.setForegroundColor(farbe);
canvas.drawLine(xPosition, yPosition, x, y);
}
xPosition = x;
yPosition = y;
}
/**
* Drehe den Stift ausgehend von der aktuellen Drehung um den gewünschten Betrag
* (angegeben in Winkelgrad) im Uhrzeigersinn.
*
* @param winkelgrad der Winkel, um den gedreht werden soll. (360 ergibt einen vollen Kreis.)
*/
public void drehen(int winkelgrad)
{
rotation = rotation + winkelgrad;
}
/**
* Drehe den Stift in die gewünschte Richtung. 0 bedeutet rechts, 90 unten, 180 links, 270 oben.
*
* @param winkel der Winkel, zu dem der Stift gedreht werden soll.
*/
public void drehenZu(int winkel)
{
rotation = winkel;
}
/**
* Lege die Zeichenfarbe fest.
*
* @param neueFarbe die Farbe, die für nachfolgende Zeichenoperationen verwendet werden soll.
*/
public void setzeFarbe(Color neueFarbe)
{
farbe = neueFarbe;
}
/**
* Hebe den Stift ab. Nachfolgende Bewegungen werden keine Linie auf dem Canvas hinterlassen.
*/
public void stiftAbheben()
{
stiftAufgesetzt = false;
}
/**
* Setze den Stift auf. Nachfolgende Bewegungen werden eine Linie auf dem Canvas hinterlassen.
*/
public void stiftAufsetzen()
{
stiftAufgesetzt = true;
}
/**
* Kritzel in der aktuellen Farbe auf den Canvas. Größe und Komplexität des produzierten
* Gekritzels wird durch die Konstanten GEKRITZEL_GROESSE und GEKRITZEL_ZAEHLER bestimmt.
*/
public void zufaelligesGekritzel()
{
for (int i=0; i<GEKRITZEL_ZAEHLER; i++) {
bewegen(zufallsgenerator.nextInt(GEKRITZEL_GROESSE));
drehen(160 + zufallsgenerator.nextInt(40));
}
}
}
| gpl-3.0 |
panksy2k/JavaInterviewCoding | src/com/pankaj/designpatterns/factory/Website.java | 324 | package com.pankaj.designpatterns.factory;
import java.util.ArrayList;
import java.util.List;
public abstract class Website {
protected List<Page> pages = new ArrayList<>();
public List<Page> getPages() {
return pages;
}
public Website() {
this.createWebsite();
}
public abstract void createWebsite();
}
| gpl-3.0 |
GrandViewTech/bookSystem | src/main/java/com/v2tech/services/ResourceUnderReviewService.java | 1531 | package com.v2tech.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.v2tech.base.V2GenericException;
import com.v2tech.domain.ResourceUnderReview;
import com.v2tech.repository.ResourceUnderReviewRepository;
@Service
public class ResourceUnderReviewService {
@Autowired
ResourceUnderReviewRepository resourceUnderReviewRepository;
public ResourceUnderReview saveOrUpdate(ResourceUnderReview resource){
if(resource.getResourceName() == null){
throw new V2GenericException("Review without Resurce Name");
}
ResourceUnderReview resourceUnderReview = resourceUnderReviewRepository.getResourceUnderReviewByResourceName(resource.getResourceName());
if(resourceUnderReview == null){
return resourceUnderReviewRepository.save(resource);
}
else{
resourceUnderReview.setCriteria(resource.getCriteria());
resourceUnderReview.setResourceTitle(resource.getResourceTitle());
resourceUnderReview.setAverageRatingForResource(resource.getAverageRatingForResource());
resourceUnderReview.setLinkURLToResource(resource.getLinkURLToResource());
resourceUnderReview.setNumberOfTimesDiscussed(resource.getNumberOfTimesDiscussed());
resourceUnderReview.setNumberOfTimesFavourited(resource.getNumberOfTimesFavourited());
resourceUnderReview.setNumberOfTimesReviewed(resource.getNumberOfTimesReviewed());
return resourceUnderReviewRepository.save(resourceUnderReview);
}
}
}
| gpl-3.0 |
frank240889/MusicalLibraryOrganizer | app/src/main/java/mx/dev/franco/automusictagfixer/fixer/TrackLoader.java | 1216 | package mx.dev.franco.automusictagfixer.fixer;
import android.os.AsyncTask;
import java.util.List;
import mx.dev.franco.automusictagfixer.interfaces.InfoTrackLoader;
import mx.dev.franco.automusictagfixer.persistence.room.Track;
import mx.dev.franco.automusictagfixer.persistence.room.TrackRoomDatabase;
public class TrackLoader extends AsyncTask<Integer, Void, List<Track>> {
private InfoTrackLoader<List<Track>> mDataLoader;
private TrackRoomDatabase mTrackRoomDatabase;
public TrackLoader(InfoTrackLoader<List<Track>> dataLoader, TrackRoomDatabase trackRoomDatabase){
mDataLoader = dataLoader;
mTrackRoomDatabase = trackRoomDatabase;
}
@Override
protected List<Track> doInBackground(Integer... integers) {
return mTrackRoomDatabase.trackDao().getSelectedTrack(integers[0]);
}
@Override
protected void onPostExecute(List<Track> list){
if(mDataLoader != null)
mDataLoader.onTrackDataLoaded(list);
mDataLoader = null;
mTrackRoomDatabase = null;
}
@Override
public void onCancelled(List<Track> list){
super.onCancelled();
mDataLoader = null;
mTrackRoomDatabase = null;
}
} | gpl-3.0 |
trackplus/Genji | src/main/java/com/aurel/track/persist/TWorkItemPeer.java | 84464 | /**
* Genji Scrum Tool and Issue Tracker
* Copyright (C) 2015 Steinbeis GmbH & Co. KG Task Management Solutions
* <a href="http://www.trackplus.com">Genji Scrum Tool</a>
*
* 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/>.
*/
/* $Id:$ */
package com.aurel.track.persist;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import com.aurel.track.util.IntegerStringBean;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Criteria.Criterion;
import org.apache.torque.util.Transaction;
import com.aurel.track.admin.customize.category.filter.execute.loadItems.criteria.CriteriaUtil;
import com.aurel.track.admin.customize.category.filter.execute.loadItems.criteria.MeetingCriteria;
import com.aurel.track.admin.customize.category.filter.execute.loadItems.criteria.ResponsibleCriteria;
import com.aurel.track.admin.customize.category.filter.execute.loadItems.criteria.TreeFilterCriteria;
import com.aurel.track.admin.customize.category.filter.tree.design.FilterUpperTO;
import com.aurel.track.admin.customize.category.filter.tree.design.RACIBean;
import com.aurel.track.admin.customize.treeConfig.field.FieldBL;
import com.aurel.track.beans.TListTypeBean;
import com.aurel.track.beans.TPersonBean;
import com.aurel.track.beans.TStateBean;
import com.aurel.track.beans.TWorkItemBean;
import com.aurel.track.cluster.ClusterMarkChangesBL;
import com.aurel.track.dao.WorkItemDAO;
import com.aurel.track.dao.torque.SimpleCriteria;
import com.aurel.track.errors.ErrorData;
import com.aurel.track.exchange.excel.ExcelImportNotUniqueIdentifiersException;
import com.aurel.track.fieldType.constants.BooleanFields;
import com.aurel.track.fieldType.constants.SystemFields;
import com.aurel.track.fieldType.runtime.bl.AttributeValueBL;
import com.aurel.track.item.ItemBL;
import com.aurel.track.item.ItemLoaderException;
import com.aurel.track.item.ItemPersisterException;
import com.aurel.track.item.workflow.execute.WorkflowContext;
import com.aurel.track.lucene.index.LuceneIndexer;
import com.aurel.track.tql.TqlBL;
import com.aurel.track.util.DateTimeUtils;
import com.aurel.track.util.EqualUtils;
import com.aurel.track.util.GeneralUtils;
import com.workingdogs.village.DataSetException;
import com.workingdogs.village.Record;
import com.workingdogs.village.Value;
/**
*
* This class is the persistence layer proxy for the core objects in the
* Genji system, the issues.
*
*/
public class TWorkItemPeer extends com.aurel.track.persist.BaseTWorkItemPeer
implements WorkItemDAO {
private static final long serialVersionUID = 3300436877834074233L;
private static final Logger LOGGER = LogManager.getLogger(TWorkItemPeer.class);
private static final String failedWith = " failed with ";
private static Class[] dependentPeerClasses = {
TActualEstimatedBudgetPeer.class,
TAttachmentPeer.class,
TBaseLinePeer.class,
TBudgetPeer.class,
TCostPeer.class,
TIssueAttributeValuePeer.class,
TNotifyPeer.class,
TStateChangePeer.class,
TTrailPeer.class,
TComputedValuesPeer.class,
TAttributeValuePeer.class,
TWorkItemLinkPeer.class,
TWorkItemLinkPeer.class,
TWorkItemLockPeer.class,
THistoryTransactionPeer.class,
TSummaryMailPeer.class,
TMSProjectTaskPeer.class,
TPersonBasketPeer.class,
TLastVisitedItemPeer.class,
TReadIssuePeer.class,
TAttachmentVersionPeer.class,
TItemTransitionPeer.class,
//use the superclass doDelete() method!!!
BaseTWorkItemPeer.class
};
private static String[] fields = {
TActualEstimatedBudgetPeer.WORKITEMKEY,
TAttachmentPeer.WORKITEM,
TBaseLinePeer.WORKITEMKEY,
TBudgetPeer.WORKITEMKEY,
TCostPeer.WORKITEM,
TIssueAttributeValuePeer.ISSUE,
TNotifyPeer.WORKITEM,
TStateChangePeer.WORKITEMKEY,
TTrailPeer.WORKITEMKEY,
TComputedValuesPeer.WORKITEMKEY,
TAttributeValuePeer.WORKITEM,
TWorkItemLinkPeer.LINKPRED,
TWorkItemLinkPeer.LINKSUCC,
TWorkItemLockPeer.WORKITEM,
THistoryTransactionPeer.WORKITEM,
TSummaryMailPeer.WORKITEM,
TMSProjectTaskPeer.WORKITEM,
TPersonBasketPeer.WORKITEM,
TLastVisitedItemPeer.WORKITEM,
TReadIssuePeer.WORKITEM,
TAttachmentVersionPeer.WORKITEM,
TItemTransitionPeer.WORKITEM,
BaseTWorkItemPeer.WORKITEMKEY
};
/**
* delete workItems with the given criteria and delete all dependent database entries
* Called by reflection
* @param crit
*/
public static void doDelete(Criteria crit) {
try {
// retrieve all the items first
List<TWorkItem> list = doSelect(crit);
if (list == null || list.isEmpty()) {
return;
}
List<Integer> itemIDs = new ArrayList<Integer>(list.size());
for (TWorkItem tWorkItem : list) {
itemIDs.add(tWorkItem.getObjectID());
}
removeParents(itemIDs);
List<Integer> itemPickerFields = FieldBL.getCustomPickerFieldIDs(SystemFields.INTEGER_ISSUENO);
for (TWorkItem workItem : list) {
Integer workItemID = workItem.getObjectID();
if (itemPickerFields!=null && !itemPickerFields.isEmpty()) {
for (Integer fieldID : itemPickerFields) {
//Remove the occurrences of items in item pickers
AttributeValueBL.deleteBySystemOption(fieldID, workItemID, SystemFields.INTEGER_ISSUENO);
}
}
ReflectionHelper.delete(dependentPeerClasses, fields, workItemID);
}
} catch (TorqueException e) {
LOGGER.error("Cascade deleteing the field configs failed with " + e.getMessage());
}
}
/**
* Set the superior workItem to null for the child workItems of a deleted parent node
* @param objectID
*/
private static void removeParents(List<Integer> itemIDs) {
List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(itemIDs);
if (workItemIDChunksList==null) {
return;
}
Iterator<int[]> iterator = workItemIDChunksList.iterator();
int i = 0;
while (iterator.hasNext()) {
i++;
int[] workItemIDChunk = (int[])iterator.next();
Criteria selectCriteria = new Criteria();
selectCriteria.addIn(SUPERIORWORKITEM, workItemIDChunk);
Criteria updateCriteria = new Criteria();
updateCriteria.add(SUPERIORWORKITEM, (Object)null, Criteria.ISNULL);
try {
doUpdate(selectCriteria, updateCriteria);
} catch (TorqueException e) {
LOGGER.error("Removing the deleted superior workItem from childen to be deleted at loop " + i + failedWith + e.getMessage());
}
}
}
/************************************************************************
*************************Bean methods***********************************
************************************************************************/
/**
* Loads a priorityBean by primary key
* @param objectID
* @return
*/
@Override
public TWorkItemBean loadByPrimaryKey(Integer objectID) throws ItemLoaderException {
TWorkItem tWorkItem = null;
try {
tWorkItem = retrieveByPK(objectID);
} catch(Exception e) {
LOGGER.info("Loading the workItem by primary key " + objectID + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
throw new ItemLoaderException("Loading the workItem by " + objectID + " failed", e);
}
if (tWorkItem!=null){
return tWorkItem.getBean();
}
return null;
}
@Override
public TWorkItemBean loadByProjectSpecificID(Integer projectID,Integer idNumber) throws ItemLoaderException{
Criteria crit = new Criteria();
crit.add(PROJECTKEY,projectID);
crit.add(IDNUMBER,idNumber);
try {
List<TWorkItem> torqueList = doSelect(crit);
if(torqueList!=null && !torqueList.isEmpty()){
return torqueList.get(0).getBean();
}
} catch (TorqueException e) {
LOGGER.error("loadByProjectSpecificID failed with " + e.getMessage());
}
return null;
}
/**
* Gets the list of workItems which should appear in the reminder email
* @param personID
* @param remindMeAsOriginator
* @param remindMeAsManager
* @param remindMeAsResponsible
* @param dateLimit
* @return
*/
@Override
public List<TWorkItemBean> loadReminderWorkItems(Integer personID, String remindMeAsOriginator, String remindMeAsManager, String remindMeAsResponsible, Date dateLimit) {
// now build the criteria
Criteria crit = new Criteria();
Criterion raciCriterion = null;
boolean first = true;
if (remindMeAsOriginator!=null && BooleanFields.TRUE_VALUE.equals(remindMeAsOriginator)) {
LOGGER.debug("Adding originator");
raciCriterion = crit.getNewCriterion(ORIGINATOR, personID, Criteria.EQUAL);
first = false;
}
if (remindMeAsManager!=null && BooleanFields.TRUE_VALUE.equals(remindMeAsManager)) {
if (first) {
LOGGER.debug("Adding manager");
raciCriterion = crit.getNewCriterion(OWNER, personID, Criteria.EQUAL);
first = false;
} else {
LOGGER.debug("ORing manager");
if (raciCriterion!=null) { // just to disable compiler warning
raciCriterion = raciCriterion.or(crit.getNewCriterion(OWNER, personID, Criteria.EQUAL));
}
}
}
if (remindMeAsResponsible!=null && BooleanFields.TRUE_VALUE.equals(remindMeAsResponsible)) {
if (first) {
LOGGER.debug("adding responsible");
raciCriterion = crit.getNewCriterion(RESPONSIBLE, personID, Criteria.EQUAL);
} else {
LOGGER.debug("ORing responsible");
if (raciCriterion!=null) { // just to disable compiler warning
raciCriterion = raciCriterion.or(crit.getNewCriterion(RESPONSIBLE, personID, Criteria.EQUAL));
}
}
}
if (raciCriterion!=null) {
crit.add(raciCriterion);
} else {
crit.add(RESPONSIBLE, personID, Criteria.EQUAL);
}
Criterion endDatesCriterion = crit.getNewCriterion(ENDDATE, dateLimit, Criteria.LESS_EQUAL);
endDatesCriterion.or(crit.getNewCriterion(TOPDOWNENDDATE, dateLimit, Criteria.LESS_EQUAL));
crit.add(endDatesCriterion);
CriteriaUtil.addStateFlagUnclosedCriteria(crit);
CriteriaUtil.addArchivedDeletedFilter(crit);
CriteriaUtil.addActiveProjectCriteria(crit);
//crit.add(TWorkItemPeer.ENDDATE, dateLimit, Criteria.LESS_EQUAL);
crit.addDescendingOrderByColumn(ENDDATE);
crit.addDescendingOrderByColumn(TOPDOWNENDDATE);
LOGGER.debug(crit.toString());
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Getting the reminder workItems failed with " + e.getMessage());
return null;
}
}
/**
* Gets the number of entries in TWORKITEM.
* @return number of table entries in TWORKITEM
*/
@Override
public int count() {
String COUNT = "count(" + WORKITEMKEY + ")";
Criteria crit = new Criteria(); // use empty Criteria to get all entries
crit.addSelectColumn(COUNT); // SELECT count(WORKITEMKEY);
try {
return ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asInt();
} catch (TorqueException e) {
LOGGER.error("Counting the workItems failed with " + e.getMessage());
} catch (DataSetException e) {
LOGGER.error("Counting the workItems failed with " + e.getMessage());
}
return 0;
// get the one and only returned record. Get the first value in this record.
// Record values index always starts at 1.
}
/**
* Gets a workItem by secondary key values
* @param identifierFieldValues
* @return
*/
@Override
public TWorkItemBean loadBySecondaryKeys(Map<Integer, Object> identifierFieldValues) throws ExcelImportNotUniqueIdentifiersException {
List<TWorkItem> workItems = null;
Criteria crit = new Criteria();
try {
Object projectID = identifierFieldValues.get(SystemFields.INTEGER_PROJECT);
if (projectID!=null) {
crit.add(PROJECTKEY, projectID);
}
Object releaseScheduled = identifierFieldValues.get(SystemFields.INTEGER_RELEASESCHEDULED);
if (releaseScheduled!=null) {
crit.add(RELSCHEDULEDKEY, releaseScheduled);
}
Object releaseNoticed = identifierFieldValues.get(SystemFields.INTEGER_RELEASENOTICED);
if (releaseNoticed!=null) {
crit.add(RELNOTICEDKEY, releaseNoticed);
}
Object managerID = identifierFieldValues.get(SystemFields.INTEGER_MANAGER);
if (managerID!=null) {
crit.add(OWNER, managerID);
}
Object responsibleID = identifierFieldValues.get(SystemFields.INTEGER_RESPONSIBLE);
if (responsibleID!=null) {
crit.add(RESPONSIBLE, responsibleID);
}
Object originatorID = identifierFieldValues.get(SystemFields.INTEGER_ORIGINATOR);
if (originatorID!=null) {
crit.add(ORIGINATOR, originatorID);
}
Object changedByID = identifierFieldValues.get(SystemFields.INTEGER_CHANGEDBY);
if (changedByID!=null) {
crit.add(CHANGEDBY, changedByID);
}
Object issueTypeID = identifierFieldValues.get(SystemFields.INTEGER_ISSUETYPE);
if (issueTypeID!=null) {
crit.add(CATEGORYKEY, issueTypeID);
}
Object stateID = identifierFieldValues.get(SystemFields.INTEGER_STATE);
if (stateID!=null) {
crit.add(STATE, stateID);
}
Object priorityID = identifierFieldValues.get(SystemFields.INTEGER_PRIORITY);
if (priorityID!=null) {
crit.add(PRIORITYKEY, priorityID);
}
Object severityID = identifierFieldValues.get(SystemFields.INTEGER_SEVERITY);
if (severityID!=null) {
crit.add(SEVERITYKEY, severityID);
}
Object synopsis = identifierFieldValues.get(SystemFields.INTEGER_SYNOPSIS);
if (synopsis!=null && !"".equals(synopsis)) {
crit.add(PACKAGESYNOPSYS, synopsis);
}
Object createDate = identifierFieldValues.get(SystemFields.INTEGER_CREATEDATE);
if (createDate!=null) {
crit.add(CREATED, createDate);
}
Object startDate = identifierFieldValues.get(SystemFields.INTEGER_STARTDATE);
if (startDate!=null) {
crit.add(STARTDATE, startDate);
}
Object endDate = identifierFieldValues.get(SystemFields.INTEGER_ENDDATE);
if (endDate!=null) {
crit.add(ENDDATE, endDate);
}
Object issueNo = identifierFieldValues.get(SystemFields.INTEGER_ISSUENO);
if (issueNo!=null) {
crit.add(WORKITEMKEY, issueNo);
}
Object build = identifierFieldValues.get(SystemFields.INTEGER_BUILD);
if (build!=null && !"".equals(build)) {
crit.add(BUILD, build);
}
Object submitterEmail = identifierFieldValues.get(SystemFields.INTEGER_SUBMITTEREMAIL);
if (submitterEmail!=null && !"".equals(submitterEmail)) {
crit.add(SUBMITTEREMAIL, submitterEmail);
}
Object superiorWorkItem = identifierFieldValues.get(SystemFields.INTEGER_SUPERIORWORKITEM);
if (superiorWorkItem!=null) {
crit.add(SUPERIORWORKITEM, superiorWorkItem);
}
//ReportBeanLoader.addArchivedDeletedFilter(crit);
workItems = doSelect(crit);
} catch (Exception e) {
LOGGER.error("Getting the workItems by secondary keys failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
if (workItems==null || workItems.isEmpty()) {
return null;
} else {
if (!workItems.isEmpty()) {
LOGGER.debug("More than one workItems found for the secondary keys");
throw new ExcelImportNotUniqueIdentifiersException(workItems.size() + "workItems found");
}
}
return workItems.get(0).getBean();
}
/**
* Gets the list of all workItems
* @return
*/
@Override
public List<TWorkItemBean> loadAll() {
Criteria crit = new Criteria();
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (Exception e) {
LOGGER.error("Getting all workItems failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
return new LinkedList<TWorkItemBean>();
}
}
/**
* Gets the list of all issues with parent.
* @return
*/
@Override
public List<TWorkItemBean> loadAllWithParent() {
Criteria crit = new Criteria();
crit.add(SUPERIORWORKITEM, (Object)null, Criteria.ISNOTNULL);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (Exception e) {
LOGGER.error("Getting all workItems with parent failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
return new LinkedList<TWorkItemBean>();
}
}
@Override
public List<TWorkItemBean> getChildren(Integer key){
Criteria crit = new Criteria();
crit.add(BaseTWorkItemPeer.SUPERIORWORKITEM, key, Criteria.EQUAL);
crit.addAscendingOrderByColumn(BaseTWorkItemPeer.WORKITEMKEY);
CriteriaUtil.addArchivedDeletedFilter(crit);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading the children by key " + key + failedWith + e);
return null;
}
}
/**
* Gets the children of a issue array
* @param workItemIDs
* @param notClosed whether to get only the unclosed child issues, or all child issues
* @param archived
* @param deleted
* @param itemTypesList
* @return
*/
@Override
public List<TWorkItemBean> getChildren(int[] workItemIDs,
boolean notClosed, Integer archived, Integer deleted, List<Integer> itemTypesList) {
List<TWorkItemBean> workItemList = new ArrayList<TWorkItemBean>();
if (workItemIDs==null || workItemIDs.length==0) {
return workItemList;
}
Criteria criteria;
List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemIDs);
if (workItemIDChunksList==null) {
return workItemList;
}
Iterator<int[]> iterator = workItemIDChunksList.iterator();
int i = 0;
while (iterator.hasNext()) {
i++;
int[] workItemIDChunk = iterator.next();
criteria = new Criteria();
criteria.addIn(SUPERIORWORKITEM, workItemIDChunk);
if (notClosed) {
CriteriaUtil.addStateFlagUnclosedCriteria(criteria);
}
if (itemTypesList!=null && !itemTypesList.isEmpty()) {
criteria.addIn(CATEGORYKEY, itemTypesList);
}
CriteriaUtil.addArchivedCriteria(criteria, archived, deleted);
try {
workItemList.addAll(convertTorqueListToBeanList(doSelect(criteria)));
} catch(Exception e) {
LOGGER.error("Loading the workItemBeans by children and the chunk number " +
i + " of length " + workItemIDChunk.length + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
}
return workItemList;
}
/**
* Gets the last workItem created by a person
* @param personID
* @return
*/
@Override
public TWorkItemBean loadLastCreated(Integer personID) {
Date createdDate = null;
String max = "max(" + CREATED + ")";
Criteria criteria = new Criteria();
criteria.add(ORIGINATOR, personID);
criteria.addSelectColumn(max);
List<Record> records = null;
try {
records = doSelectVillageRecords(criteria);
if (records!=null && !records.isEmpty()) {
Record record = records.get(0);
if (record!=null) {
createdDate = record.getValue(1).asDate();
}
}
} catch (Exception e) {
LOGGER.error("Getting the creation date of the last workItem created by person " + personID + " failed with: " + e);
}
List<TWorkItem> workItemList = null;
if (createdDate!=null) {
createdDate=DateTimeUtils.clearDateSeconds(createdDate);
criteria.clear();
criteria.add(ORIGINATOR, personID);
criteria.add(CREATED, createdDate, Criteria.GREATER_EQUAL);
criteria.addDescendingOrderByColumn(WORKITEMKEY);
try {
workItemList = doSelect(criteria);
} catch (TorqueException e) {
LOGGER.error("Getting the last workItem created by person " + personID + " failed with: " + e);
}
}
if (workItemList!=null && !workItemList.isEmpty()) {
return ((TWorkItem)workItemList.get(0)).getBean();
}
//}
return null;
}
/**
* Gets the last workItem created by a person for a project and issueType
* When for the project-issueType is not found, get the last by project
* @param personID
* @param projectID
* @param issueTypeID
* @return
*/
@Override
public TWorkItemBean loadLastCreatedByProjectIssueType(Integer personID, Integer projectID, Integer issueTypeID) {
List<TWorkItem> workItemList = null;
Criteria criteria = new Criteria();
criteria.add(PROJECTKEY, projectID);
criteria.add(ORIGINATOR, personID);
criteria.add(CATEGORYKEY, issueTypeID);
criteria.addDescendingOrderByColumn(CREATED);
criteria.setLimit(1);
try {
workItemList = doSelect(criteria);
} catch (TorqueException e) {
LOGGER.error("Getting the creation date of the last workItem by person " + personID + " project " +
projectID + " failed with: " + e);
}
if (workItemList!=null && !workItemList.isEmpty()) {
return ((TWorkItem)workItemList.get(0)).getBean();
}
criteria.clear();
criteria.add(PROJECTKEY, projectID);
criteria.add(ORIGINATOR, personID);
criteria.addDescendingOrderByColumn(CREATED);
criteria.setLimit(1);
try {
workItemList = doSelect(criteria);
} catch (TorqueException e) {
LOGGER.error("Getting the creation date of the last workItem by person " + personID + " project " +
projectID + " failed with: " + e);
}
if (workItemList!=null && !workItemList.isEmpty()) {
return ((TWorkItem)workItemList.get(0)).getBean();
}
return null;
}
/**
* Loads a WorkItemBean list by workItemKeys
* @param workItemKeys
* @return
*/
@Override
public List<TWorkItemBean> loadByWorkItemKeys(int[] workItemKeys) {
return loadByWorkItemKeys(workItemKeys,(Date)null,(Date)null);
}
@Override
public List<TWorkItemBean> loadByWorkItemKeys(int[] workItemKeys,Date startDate,Date endDate){
List<TWorkItemBean> workItemList = new ArrayList<TWorkItemBean>();
if (workItemKeys==null || workItemKeys.length==0) {
return workItemList;
}
Criteria criteria;
List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemKeys);
if (workItemIDChunksList==null) {
return workItemList;
}
Iterator<int[]> iterator = workItemIDChunksList.iterator();
int i = 0;
while (iterator.hasNext()) {
i++;
int[] workItemIDChunk = (int[])iterator.next();
criteria = new Criteria();
criteria.addIn(WORKITEMKEY, workItemIDChunk);
addDateCriteria(criteria,startDate,endDate);
try {
workItemList.addAll(convertTorqueListToBeanList(doSelect(criteria)));
} catch(Exception e) {
LOGGER.error("Loading the workItemBeans by workItemKeys and the chunk number " +
i + " of length " + workItemIDChunk.length + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
}
return workItemList;
}
/**
* Loads a list with {@link TWorkItemBean}s as specified by the object identifiers in parameter.
* @param workItemKeys - the array of object identifiers for the <code>TWorkItemBean</code>s to be retrieved.
* @param archived
* @param deleted
* @return A list with {@link TWorkItemBean}s.
*/
@Override
public List<TWorkItemBean> loadByWorkItemKeys(int[] workItemKeys, Integer archived, Integer deleted) {
List<TWorkItemBean> workItemList = new ArrayList<TWorkItemBean>();
if (workItemKeys==null || workItemKeys.length==0) {
return workItemList;
}
Criteria criteria;
List<int[]> workItemIDChunksList = GeneralUtils.getListOfChunks(workItemKeys);
if (workItemIDChunksList==null) {
return workItemList;
}
Iterator<int[]> iterator = workItemIDChunksList.iterator();
int i = 0;
while (iterator.hasNext()) {
i++;
int[] workItemIDChunk = (int[])iterator.next();
criteria = new Criteria();
criteria.addIn(WORKITEMKEY, workItemIDChunk);
CriteriaUtil.addArchivedCriteria(criteria, archived, deleted);
try {
workItemList.addAll(convertTorqueListToBeanList(doSelect(criteria)));
} catch(Exception e) {
LOGGER.error("Loading the workItemBeans by workItemKeys and the chunk number " +
i + " of length " + workItemIDChunk.length + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
}
return workItemList;
}
/**
* Loads a list with {@link TWorkItemBean}s as specified by synopsis list in parameter.
* @param workItemKeys - synopsisList
* <p/>
* @return A list with {@link TWorkItemBean}s.
*/
@Override
public List<TWorkItemBean> loadBySynopsisList(List<String> synopsisList) {
List<TWorkItemBean> workItemList = new ArrayList<TWorkItemBean>();
if (synopsisList==null || synopsisList.isEmpty()) {
return workItemList;
}
Criteria criteria;
List<List<String>> workItemSynopsisChunksList = GeneralUtils.getListOfStringChunks(synopsisList);
if (workItemSynopsisChunksList==null) {
return workItemList;
}
Iterator<List<String>> iterator = workItemSynopsisChunksList.iterator();
int i = 0;
while (iterator.hasNext()) {
i++;
List<String> workItemSynopsisChunk = iterator.next();
criteria = new Criteria();
criteria.addIn(PACKAGESYNOPSYS, workItemSynopsisChunk);
try {
workItemList.addAll(convertTorqueListToBeanList(doSelect(criteria)));
} catch(Exception e) {
LOGGER.error("Loading the workItemBeans by synopsis list and the chunk number " +
i + " of length " + workItemSynopsisChunk.size() + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
}
return workItemList;
}
/**
* Loads a list with {@link TWorkItemBean}s as specified by the uuids in parameter.
* @param uuids - the list of object uuids for the TWorkItemBeans to be retrieved.
* <p/>
* @return A list with {@link TWorkItemBean}s.
*/
@Override
public List<TWorkItemBean> loadByUuids(List<String> uuids) {
List<TWorkItemBean> workItemList = new ArrayList<TWorkItemBean>();
if (uuids==null || uuids.isEmpty()) {
return workItemList;
}
Criteria criteria;
List<List<String>> workItemIDChunksList = GeneralUtils.getListOfStringChunks(uuids);
if (workItemIDChunksList==null) {
return workItemList;
}
Iterator<List<String>> iterator = workItemIDChunksList.iterator();
int i = 0;
while (iterator.hasNext()) {
i++;
List<String> workItemIDChunk = iterator.next();
criteria = new Criteria();
criteria.addIn(TPUUID, workItemIDChunk);
try {
workItemList.addAll(convertTorqueListToBeanList(doSelect(criteria)));
} catch(Exception e) {
LOGGER.error("Loading the workItemBeans by uuids and the chunk number " +
i + " of length " + workItemIDChunk.size() + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
}
return workItemList;
}
/**
* Loads workItems for import which has associated msProjectTaskBean objects
* and are of type task, include also the closed and deleted, archived tasks
* @param entityID
* @param entityType
*/
@Override
public List<TWorkItemBean> loadMsProjectTasksForImport(Integer entityID, int entityType) {
Criteria crit = new Criteria();
crit.addJoin(WORKITEMKEY, BaseTMSProjectTaskPeer.WORKITEM);
crit.addJoin(CATEGORYKEY, BaseTListTypePeer.PKEY);
crit.add(BaseTListTypePeer.TYPEFLAG, TListTypeBean.TYPEFLAGS.TASK);
switch (entityType) {
case SystemFields.RELEASESCHEDULED:
crit.add(RELSCHEDULEDKEY, entityID);
break;
case SystemFields.PROJECT:
crit.add(PROJECTKEY, entityID);
break;
default:
return null;
}
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch(Exception e) {
LOGGER.error("Loading WorkItems with task by entityID " + entityID + " entityType " + entityType + failedWith + e.getMessage());
return null;
}
}
/**
* Loads workItems for export which has associated msProjectTaskBean objects and are of type task
* exclude the archived and deleted tasks and depending on "closed" also the closed tasks
* @param entityID
* @param entityType
* @param notClosed
* @return
*/
@Override
public List<TWorkItemBean> loadMsProjectTasksForExport(Integer entityID, int entityType, boolean notClosed) {
Criteria crit = new Criteria();
//left join because the new task workItems doesn't have TMSProjectTask pair yet
crit.addJoin(WORKITEMKEY, BaseTMSProjectTaskPeer.WORKITEM, Criteria.LEFT_JOIN);
crit.addJoin(CATEGORYKEY, BaseTListTypePeer.PKEY);
crit.add(BaseTListTypePeer.TYPEFLAG, TListTypeBean.TYPEFLAGS.TASK);
CriteriaUtil.addArchivedDeletedFilter(crit);
if (notClosed) {
CriteriaUtil.addStateFlagUnclosedCriteria(crit);
}
crit.addAscendingOrderByColumn(BaseTMSProjectTaskPeer.OUTLINENUMBER);
//the new ones doesn't have outline number, they are ordered by creation date
crit.addAscendingOrderByColumn(CREATED);
switch (entityType) {
case SystemFields.RELEASESCHEDULED:
crit.add(RELSCHEDULEDKEY, entityID);
break;
case SystemFields.PROJECT:
crit.add(PROJECTKEY, entityID);
break;
default:
return null;
}
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch(Exception e) {
LOGGER.error("Loading WorkItems with task by entityID " + entityID + " entityType " + entityType + failedWith + e.getMessage());
return null;
}
}
/**
* Loads all indexable workItems and sets the projectID fields
* @return
*/
@Override
public List<TWorkItemBean> loadIndexable() {
//For example workItems from closed projects, closed workItems
List<TWorkItemBean> workItemBeans = loadAll();
return workItemBeans;
}
/**
* Gets the maximal objectID
*/
@Override
public Integer getMaxObjectID() {
String max = "max(" + WORKITEMKEY + ")";
Criteria crit = new Criteria();
crit.addSelectColumn(max);
try {
return ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asIntegerObj();
} catch (Exception e) {
LOGGER.error("Getting the maximal workItemID failed with " + e.getMessage());
}
return null;
}
/**
* Gets the next chunk
* @param actualValue
* @param chunkInterval
* @return
*/
@Override
public List<TWorkItemBean> getNextChunk(Integer actualValue, Integer chunkInterval) {
SimpleCriteria crit = new SimpleCriteria();
int toValue = actualValue.intValue() + chunkInterval.intValue();
crit.addIsBetween(WORKITEMKEY, actualValue.intValue(), toValue);
crit.addAscendingOrderByColumn(LASTEDIT);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Getting the workitems from " + actualValue + " to " + toValue + failedWith + e.getMessage());
return null;
}
}
/**
* Load the workItems by a systemListID depending on a systemListType
* @param systemListType
* @param systemListID
* @return
*/
@Override
public int[] loadBySystemList(int systemListType, Integer systemListID) {
Criteria crit = new Criteria();
switch (systemListType) {
case SystemFields.PROJECT:
crit.add(PROJECTKEY, systemListID);
break;
case SystemFields.RELEASE:
Criterion relNoticed = crit.getNewCriterion(RELNOTICEDKEY, systemListID, Criteria.EQUAL);
Criterion relScheduled= crit.getNewCriterion(RELSCHEDULEDKEY, systemListID, Criteria.EQUAL);
crit.add(relNoticed.or(relScheduled));
break;
case SystemFields.ISSUETYPE:
crit.add(CATEGORYKEY, systemListID);
break;
case SystemFields.STATE:
crit.add(STATE, systemListID);
break;
case SystemFields.PRIORITY:
crit.add(PRIORITYKEY, systemListID);
break;
case SystemFields.SEVERITY:
crit.add(SEVERITYKEY, systemListID);
break;
default:
return null;
}
crit.addSelectColumn(WORKITEMKEY);
List<Record> torqueList = null;
try {
torqueList = doSelectVillageRecords(crit);
} catch (TorqueException e) {
LOGGER.error("Loading workItemIDs by systemListType " + systemListType +
" and systemListID " + systemListID + failedWith + e);
}
int[] workItemIDs = null;
if (torqueList!=null) {
workItemIDs = new int[torqueList.size()];
for (int i = 0; i < torqueList.size(); i++) {
Record record = (Record)torqueList.get(i);
try {
workItemIDs[i] = record.getValue(1).asInt();
} catch (DataSetException e) {
LOGGER.error("Getting the workItemIDs by systemListType " + systemListType +
" and systemListID " + systemListID + failedWith + e);
}
}
}
return workItemIDs;
}
/**
* Get all the issue from an project, include the closed/archived/deleted issues.
*/
@Override
public List<TWorkItemBean> loadAllByProject(Integer projectID, Integer archived, Integer deleted) {
Criteria crit = new Criteria();
crit.add(PROJECTKEY, projectID);
crit.addAscendingOrderByColumn(WORKITEMKEY);
CriteriaUtil.addArchivedCriteria(crit, archived, deleted);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading all workItems by project " + projectID + failedWith + e.getMessage());
return null;
}
}
Object mutex = new Object();
/**
* Saves a workItemBean in the TWorkItem table and creates/updates a lucene Document for it.
* Be sure that the TWorkItem.save() is not called directly from other program code,
* because then no lucene indexing takes place!!!
* @param workItemBean
*/
@Override
public Integer save(TWorkItemBean workItemBean) throws ItemPersisterException {
boolean isNew = false;
Integer objectID = null;
Integer idNumber = null;
try {
isNew = workItemBean.getObjectID()==null || workItemBean.getObjectID().intValue()==-1;
TWorkItem tWorkItem = BaseTWorkItem.createTWorkItem(workItemBean);
if (isNew) {
synchronized (mutex) {
Integer projectID = tWorkItem.getProjectID();
Integer nextWBS = getNextWbsOnLevel(tWorkItem.getSuperiorworkitem(), projectID);
tWorkItem.setWBSOnLevel(nextWBS);
idNumber = calculateIDNumber(projectID, tWorkItem);
}
} else {
tWorkItem.save();
}
objectID = tWorkItem.getObjectID();
LOGGER.debug("WorkItem with ID " + objectID + " saved ");
} catch (Exception e) {
LOGGER.error("Saving the workItem " + workItemBean.getObjectID() +
" with synopsis " + workItemBean.getSynopsis() + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
throw new ItemPersisterException("Saving the workItem " + workItemBean.getObjectID() +
" with synopsis " + workItemBean.getSynopsis() + " failed", e);
}
try {
//objectID null means that the save doesn't succeeded
if (objectID!=null) {
if (isNew) {
workItemBean.setObjectID(objectID);
workItemBean.setIDNumber(idNumber);
}
LuceneIndexer.addToWorkItemIndex(workItemBean, !isNew);
//possible lucene update in other cluster nodes
ClusterMarkChangesBL.markDirtyWorkitemInCluster(objectID, ClusterMarkChangesBL.getChangeTypeByAddOrUpdateIndex(isNew));
}
} catch (Exception e) {
LOGGER.error("Saving the workitem in lucene index failed with " + e.getMessage());
}
return objectID;
}
/**
* Calculates the project specific IDNumber
* If tWorkItem is specified then it is saved after setting the calculated IDNumber
* Otherwise only returns the IDNumber
* @param projectID
* @param tWorkItem
* @return
*/
private static synchronized Integer calculateIDNumber(Integer projectID, TWorkItem tWorkItem) {
Integer nextItemID = null;
if (projectID!=null) {
Connection connection = null;
try {
connection = Transaction.begin(DATABASE_NAME);
} catch (TorqueException e) {
LOGGER.error("Getting the connection for failed with " + e.getMessage());
return null;
}
if (connection!=null) {
try {
TProject tProject = null;
try {
tProject = TProjectPeer.retrieveByPK(projectID, connection);
} catch(Exception e) {
LOGGER.error("Loading of a project by primary key " + projectID + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
if (tProject!=null) {
nextItemID = tProject.getNextItemID();
if (nextItemID==null) {
nextItemID = getNextItemID(projectID);
}
if (tWorkItem!=null) {
tWorkItem.setIDNumber(nextItemID);
tWorkItem.save(connection);
}
tProject.setNextItemID(nextItemID.intValue()+1);
TProjectPeer.doUpdate(tProject, connection);
Transaction.commit(connection);
}
connection = null;
} catch (Exception e) {
LOGGER.error("Setting the project specific itemID failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
} finally {
if (connection!=null) {
Transaction.safeRollback(connection);
}
}
}
}
return nextItemID;
}
/**
* Saves a workItemBean in the TWorkItem table without lucene update.
* @param workItemBean
*/
@Override
public Integer saveSimple(TWorkItemBean workItemBean) throws ItemPersisterException {
Integer objectID = null;
try {
TWorkItem tWorkItem = BaseTWorkItem.createTWorkItem(workItemBean);
tWorkItem.save();
objectID = tWorkItem.getObjectID();
LOGGER.debug("WorkItem with ID " + objectID + " saved ");
} catch (Exception e) {
LOGGER.error("Saving the workItem " + workItemBean.getObjectID() +
" with synopsis " + workItemBean.getSynopsis() + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
throw new ItemPersisterException("Saving the workItem " + workItemBean.getObjectID() +
" with synopsis " + workItemBean.getSynopsis() + " failed", e);
}
return objectID;
}
/**
* Whether the item has open children besides exceptChildrenIDs
* @param objectID
* @return
*/
@Override
public List<TWorkItemBean> getOpenChildren(Integer objectID, List<Integer> exceptChildrenIDs) {
Criteria crit = new Criteria();
crit.add(SUPERIORWORKITEM, objectID);
crit.addJoin(STATE, TStatePeer.PKEY);
crit.add(TStatePeer.STATEFLAG, TStateBean.STATEFLAGS.CLOSED, Criteria.NOT_EQUAL);
if (exceptChildrenIDs!=null && !exceptChildrenIDs.isEmpty()) {
crit.addNotIn(WORKITEMKEY, exceptChildrenIDs);
}
CriteriaUtil.addArchivedDeletedFilter(crit);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Getting the open children failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
return null;
}
}
/**
* Is any workItem from the array still open?
* @param workItemIDs
* @return
*/
@Override
public boolean isAnyWorkItemOpen(int[] workItemIDs) {
if (workItemIDs==null || workItemIDs.length==0) {
return false;
}
Criteria crit = new Criteria();
crit.addIn(WORKITEMKEY, workItemIDs);
crit.addJoin(STATE, BaseTStatePeer.PKEY);
crit.add(BaseTStatePeer.STATEFLAG, TStateBean.STATEFLAGS.CLOSED, Criteria.NOT_EQUAL);
CriteriaUtil.addArchivedDeletedFilter(crit);
List<TWorkItem> list = null;
try {
list = doSelect(crit);
} catch (TorqueException e) {
LOGGER.error("Getting the open children failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
return list!=null && !list.isEmpty();
}
/**
* Returns a deep copy of the workItemBean
* @param workItemBean
* @return
*/
@Override
public TWorkItemBean copyDeep(TWorkItemBean workItemBean) {
TWorkItem tWorkItemOriginal = null;
try {
tWorkItemOriginal = BaseTWorkItem.createTWorkItem(workItemBean);
} catch (TorqueException e1) {
LOGGER.error("Getting the torque object from bean failed with " + e1.getMessage());
}
TWorkItem tWorkItemCopy = null;
if (tWorkItemOriginal!=null) {
try {
tWorkItemCopy = tWorkItemOriginal.copy(true);
} catch (TorqueException e2) {
LOGGER.error("Deep copy failed with " + e2.getMessage());
}
}
if (tWorkItemCopy!=null) {
return tWorkItemCopy.getBean();
} else {
return null;
}
}
/**
* Get a list of workItemBeans according to a prepared critera
* @param criteria
* @return
*/
public static List<TWorkItemBean> getWorkItemBeansByCriteria(Criteria criteria) {
try {
return convertTorqueListToBeanList(doSelect(criteria));
} catch (TorqueException e) {
LOGGER.error("Loading the workItems by criteria " + criteria.toString() + failedWith + e.getMessage());
return null;
}
}
/*********************************************************
* Manager-, Responsible-, My- and Custom Reports methods *
*********************************************************/
public static void addDateCriteria(Criteria crit, Date startDate, Date endDate){
if (startDate==null && endDate==null) {
return;
}
if (startDate!=null && endDate!=null) {
// criteria for start date
Criteria.Criterion cStartDateMin = crit.getNewCriterion(STARTDATE , startDate, Criteria.GREATER_EQUAL);
Criteria.Criterion cStartDateMax = crit.getNewCriterion(STARTDATE , endDate, Criteria.LESS_EQUAL);
Criteria.Criterion cStartDateAnd = cStartDateMin.and(cStartDateMax);
// criteria for topdown start date
Criteria.Criterion cTopDownStartDateMin = crit.getNewCriterion(TOPDOWNSTARTDATE, startDate, Criteria.GREATER_EQUAL);
Criteria.Criterion cTopDownStartDateMax = crit.getNewCriterion(TOPDOWNSTARTDATE, endDate, Criteria.LESS_EQUAL);
Criteria.Criterion cTopDownStartDateAnd = cTopDownStartDateMin.and(cTopDownStartDateMax);
// criteria for end date
Criteria.Criterion cEndDateMin = crit.getNewCriterion(ENDDATE, startDate, Criteria.GREATER_EQUAL);
Criteria.Criterion cEndDateMax = crit.getNewCriterion(ENDDATE, endDate, Criteria.LESS_EQUAL);
Criteria.Criterion cEndDateAnd = cEndDateMin.and(cEndDateMax);
// criteria for topDown end date
Criteria.Criterion cTopDownEndDateMin = crit.getNewCriterion(TOPDOWNENDDATE, startDate, Criteria.GREATER_EQUAL);
Criteria.Criterion cTopDownEndDateMax = crit.getNewCriterion(TOPDOWNENDDATE, endDate, Criteria.LESS_EQUAL);
Criteria.Criterion cTopDownEndDateAnd = cTopDownEndDateMin.and(cTopDownEndDateMax);
// or criteria for start and end date
Criteria.Criterion cDateOr = cStartDateAnd.or(cEndDateAnd).or(cTopDownStartDateAnd).or(cTopDownEndDateAnd);
crit.add(cDateOr);
} else {
if (startDate!=null) {
// criteria for start date
Criteria.Criterion cStartDateMin = crit.getNewCriterion(STARTDATE , startDate, Criteria.GREATER_EQUAL);
// criteria for TopDown start date
Criteria.Criterion cTopDownStartDateMin = crit.getNewCriterion(TOPDOWNSTARTDATE , startDate, Criteria.GREATER_EQUAL);
// criteria for end date
Criteria.Criterion cEndDateMin = crit.getNewCriterion(ENDDATE, startDate, Criteria.GREATER_EQUAL);
// criteria for TopDown end date
Criteria.Criterion cTopDownEndDateMin = crit.getNewCriterion(TOPDOWNENDDATE, startDate, Criteria.GREATER_EQUAL);
// or criteria for start and end date
Criteria.Criterion cDateOr = cStartDateMin.or(cEndDateMin).or(cTopDownStartDateMin).or(cTopDownEndDateMin);
crit.add(cDateOr);
}
if (endDate!=null) {
// criteria for start date
Criteria.Criterion cStartDateMax = crit.getNewCriterion(STARTDATE , endDate, Criteria.LESS_EQUAL);
// criteria for TopDownstart date
Criteria.Criterion cTopDownStartDateMax = crit.getNewCriterion(TOPDOWNSTARTDATE , endDate, Criteria.LESS_EQUAL);
// criteria for end date
Criteria.Criterion cEndDateMax = crit.getNewCriterion(ENDDATE , endDate, Criteria.LESS_EQUAL);
// criteria for TopDown end date
Criteria.Criterion cTopDownEndDateMax = crit.getNewCriterion(TOPDOWNENDDATE , endDate, Criteria.LESS_EQUAL);
// or criteria for start and end date
Criteria.Criterion cDateOr = cStartDateMax.or(cEndDateMax).or(cTopDownStartDateMax).or(cTopDownEndDateMax);
crit.add(cDateOr);
}
}
}
/**
* Count the number of items in InBasket
* @param personID
* @return
*/
@Override
public Integer countResponsibleWorkItems(Integer personID) {
Criteria crit = ResponsibleCriteria.prepareResponsibleCriteria(personID);
String COUNT = "count(" + WORKITEMKEY + ")";
crit.addSelectColumn(COUNT);
try {
return ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asInt();
} catch (TorqueException e) {
LOGGER.error("Counting the workItems failed with " + e.getMessage());
} catch (DataSetException e) {
LOGGER.error("Counting the workItems failed with " + e.getMessage());
}
return 0;
}
/**
* Get the workItemBeans the person is responsible for
* If project is not null then just for that project
* @param personID
* @param project
* @param entityFlag the meaning of the project: can be project, release, subproject etc.
* @return
*/
@Override
public List<TWorkItemBean> loadResponsibleWorkItems(Integer personID) {
Criteria crit = ResponsibleCriteria.prepareResponsibleCriteria(personID);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading the responsible workItems for person " + personID + failedWith + e.getMessage());
return new ArrayList<TWorkItemBean>();
}
}
/**
* Get meetings workItemBeans the person
* is manager or responsible or owner for
* If project is not null then just for that project/release
* @param personID
* @param project
* @param entityFlag the meaning of the project: can be project, release, subproject etc.
* @return
*/
@Override
public List<TWorkItemBean> loadOrigManRespMeetings(Integer personID, Integer[] projectIDs, Integer[] releaseIDs) {
Criteria crit = MeetingCriteria.prepareOrigManRespMeetingsCriteria(personID, projectIDs, releaseIDs);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading the my workItems for person " + personID + failedWith + e.getMessage());
return new ArrayList<TWorkItemBean>();
}
}
/**
* Get meetings workItemBeans the person
* is consulted or informed for
* If project is not null then just for that project/release
* @param personID
* @param project
* @param entityFlag the meaning of the project: can be project, release, subproject etc.
* @return
*/
@Override
public List<TWorkItemBean> loadConsInfMeetings(Integer personID, Integer[] projectIDs, Integer[] releaseIDs) {
Criteria crit = MeetingCriteria.prepareConsInfMeetingsCriteria(personID, projectIDs, releaseIDs);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading the my workItems for person " + personID + failedWith + e.getMessage());
return new ArrayList<TWorkItemBean>();
}
}
/**
* Get the workItemBeans filtered by the FilterSelectsTO
* @param filterSelectsTO
* @return
*/
@Override
public Set<Integer> loadParentsInContext(Integer[] projectIDs, Integer itemTypeID) {
Set<Integer> parentIDSet = new HashSet<Integer>();
Criteria crit = new Criteria();
String parent = "PARENT";
String child = "CHILD";
crit.addAlias(parent, TWorkItemPeer.TABLE_NAME);
crit.addAlias(child, TWorkItemPeer.TABLE_NAME);
crit.addJoin(parent + ".WORKITEMKEY", child + ".SUPERIORWORKITEM");
if (projectIDs != null && projectIDs.length != 0) {
crit.addIn(parent + ".PROJECTKEY", projectIDs);
}
if (itemTypeID!=null) {
crit.add(parent + ".CATEGORYKEY", itemTypeID);
}
crit.addSelectColumn(parent + ".WORKITEMKEY");
crit.setDistinct();
List<Record> records = null;
try {
records = doSelectVillageRecords(crit);
} catch (TorqueException e) {
LOGGER.error("Loading the context items with parent failed with " + e.getMessage());
return parentIDSet;
}
try {
if (records!=null && !records.isEmpty()) {
for (Record record : records) {
Integer workItemID = record.getValue(1).asIntegerObj();
parentIDSet.add(workItemID);
}
}
} catch (Exception e) {
LOGGER.error("Getting the parent itemID failed with " + e.getMessage());
}
return parentIDSet;
}
/**
* Count the number of filter items
* @param filterUpperTO
* @param raciBean
* @param personID
* @return
*/
@Override
public Integer countTreeFilterItems(FilterUpperTO filterUpperTO, RACIBean raciBean, Integer personID) {
Integer[] selectedProjects = filterUpperTO.getSelectedProjects();
if (selectedProjects==null || selectedProjects.length==0) {
//at least one selected project needed
return 0;
}
Criteria crit = TreeFilterCriteria.prepareTreeFilterCriteria(filterUpperTO, raciBean, personID);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(crit.toString());
}
String COUNT = "count(" + WORKITEMKEY + ")";
crit.addSelectColumn(COUNT);
try {
return ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asInt();
} catch (TorqueException e) {
LOGGER.error("Counting the workItems failed with " + e.getMessage());
} catch (DataSetException e) {
LOGGER.error("Counting the workItems failed with " + e.getMessage());
}
return 0;
}
@Override
public List<TWorkItemBean> loadTreeFilterItems(FilterUpperTO filterUpperTO, RACIBean raciBean, Integer personID, Date startDate,Date endDate) {
Integer[] selectedProjects = filterUpperTO.getSelectedProjects();
if (selectedProjects==null || selectedProjects.length==0) {
//at least one selected project needed
return new ArrayList<TWorkItemBean>();
}
Criteria crit = TreeFilterCriteria.prepareTreeFilterCriteria(filterUpperTO, raciBean, personID);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(crit.toString());
}
addDateCriteria(crit,startDate,endDate);
try {
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading the custom report workItems failed with " + e.getMessage());
return new ArrayList<TWorkItemBean>();
}
}
/**
* Gets the itemIDs filtered by filterSelectsTO and raciBean which are parents
* @param filterSelectsTO
* @param raciBean
* @param personID
* @param startDate
* @param enddDate
* @return
*/
@Override
public Set<Integer> loadTreeFilterParentIDs(FilterUpperTO filterSelectsTO, RACIBean raciBean, Integer personID, Date startDate, Date endDate) {
Integer[] selectedProjects = filterSelectsTO.getSelectedProjects();
if (selectedProjects==null || selectedProjects.length==0) {
//at least one selected project needed
return new HashSet<Integer>();
}
Criteria crit = TreeFilterCriteria.prepareTreeFilterCriteria(filterSelectsTO, raciBean, personID);
addDateCriteria(crit,startDate,endDate);
return getParentItems(crit);
}
/**
* Gets the itemIDs of those items which have children
* @param crit
* @return
*/
private static Set<Integer> getParentItems(Criteria crit) {
Set<Integer> parentIDSet = new HashSet<Integer>();
String parent = TWorkItemPeer.TABLE_NAME;//"PARENT";
String child = "CHILD";
crit.addAlias(parent, TWorkItemPeer.TABLE_NAME);
crit.addAlias(child, TWorkItemPeer.TABLE_NAME);
crit.addJoin(parent + ".WORKITEMKEY", child + ".SUPERIORWORKITEM");
crit.addSelectColumn(parent + ".WORKITEMKEY");
//crit.setDistinct();
List<Record> records = null;
try {
records = doSelectVillageRecords(crit);
} catch (TorqueException e) {
LOGGER.error("Loading the context items with parent failed with " + e.getMessage());
return parentIDSet;
}
try {
if (records!=null && !records.isEmpty()) {
for (Record record : records) {
Integer workItemID = record.getValue(1).asIntegerObj();
parentIDSet.add(workItemID);
}
}
} catch (Exception e) {
LOGGER.error("Getting the parent itemID failed with " + e.getMessage());
}
return parentIDSet;
}
/**
* Loads the items filtered by a TQL expression
* @param filterString
* @param personBean
* @param locale
* @param errors
* @param startDate
* @param endDate
* @return
*/
@Override
public List<TWorkItemBean> loadTQLFilterItems(String filterString, TPersonBean personBean, Locale locale, List<ErrorData> errors, Date startDate, Date endDate) {
Criteria tqlCriteria = TqlBL.createCriteria(filterString, personBean, locale, errors);
addDateCriteria(tqlCriteria,startDate, endDate);
try {
return convertTorqueListToBeanList(doSelect(tqlCriteria));
} catch (TorqueException e) {
LOGGER.error("Loading the TQL workItems failed with " + e.getMessage());
return new ArrayList<TWorkItemBean>();
}
}
/**
* Loads the itemIDs filtered by a TQL expression which are parents
* @param filterString
* @param personBean
* @param locale
* @param errors
* @return
*/
@Override
public Set<Integer> loadTQLFilterParentIDs(String filterString, TPersonBean personBean, Locale locale, List<ErrorData> errors) {
Criteria tqlCriteria = TqlBL.createCriteria(filterString, personBean, locale, errors);
return getParentItems(tqlCriteria);
}
/**
/**
* Load projectsIDs where the user has
* originator/manager/responsible role for at least one workItem
* @param meAndMySubstituted
* @param meAndMySubstitutedAndGroups
* @return
*/
@Override
public Set<Integer> loadOrigManRespProjects(List<Integer> meAndMySubstituted, List<Integer> meAndMySubstitutedAndGroups) {
Criteria criteria = new Criteria();
Criterion originator = criteria.getNewCriterion(TWorkItemPeer.ORIGINATOR, meAndMySubstituted, Criteria.IN);
Criterion manager = criteria.getNewCriterion(TWorkItemPeer.OWNER, meAndMySubstituted, Criteria.IN);
Criterion responsible = criteria.getNewCriterion(TWorkItemPeer.RESPONSIBLE, meAndMySubstitutedAndGroups, Criteria.IN);
criteria.add(originator.or(manager).or(responsible));
return getProjectIDs(criteria, "originator/manager/responsible");
}
/**
* Load projectsIDs where the user has consultant/informant
* role for at least one workItem
* @param meAndMySubstitutedAndGroups
* @return
*/
@Override
public Set<Integer> loadConsultantInformantProjects(List<Integer> meAndMySubstitutedAndGroups) {
Criteria criteria = new Criteria();
criteria.addJoin(TWorkItemPeer.WORKITEMKEY, TNotifyPeer.WORKITEM);
criteria.addIn(TNotifyPeer.PERSONKEY, meAndMySubstitutedAndGroups);
//criteria.addIn(TNotifyPeer.RACIROLE, new String[] {RaciRole.CONSULTANT, RaciRole.INFORMANT});
return getProjectIDs(criteria, "consultant/informant");
}
/**
* Load the not closed projects where the user has on behalf of
* role for at least one workItem
* @param meAndMySubstitutedAndGroups
* @return
*/
@Override
public Set<Integer> loadOnBehalfOfProjects(List<Integer> meAndMySubstitutedAndGroups, List<Integer> onBehalfPickerFieldIDs) {
Criteria criteria = new Criteria();
criteria.addJoin(TWorkItemPeer.WORKITEMKEY, TAttributeValuePeer.WORKITEM);
criteria.addIn(TAttributeValuePeer.FIELDKEY, onBehalfPickerFieldIDs);
criteria.addIn(TAttributeValuePeer.SYSTEMOPTIONID, meAndMySubstitutedAndGroups);
return getProjectIDs(criteria, "on behalf of");
}
/**
* Gets the projectIDs from resultset
* @param criteria
* @param raciRoles
* @return
*/
private static Set<Integer> getProjectIDs(Criteria criteria, String raciRoles) {
Set<Integer> projectIDs = new HashSet<Integer>();
try {
criteria.addSelectColumn(PROJECTKEY);
criteria.setDistinct();
List<Record> projectIDRecords = doSelectVillageRecords(criteria);
if (projectIDRecords!=null) {
for (Record record : projectIDRecords) {
try {
Value value = record.getValue(1);
if (value!=null) {
Integer projectID = value.asIntegerObj();
if (projectID!=null) {
projectIDs.add(projectID);
}
}
} catch (DataSetException e) {
LOGGER.error("Getting the projectID failed with " + e.getMessage());
}
}
}
} catch (TorqueException e) {
LOGGER.error("Loading of " + raciRoles +" projects failed with " + e.getMessage());
}
return projectIDs;
}
/**
* Convert the torque object list into bean list
* @param torqueList
* @return
*/
public static List<TWorkItemBean> convertTorqueListToBeanList(List<TWorkItem> torqueList) {
List<TWorkItemBean> beanList = new ArrayList<TWorkItemBean>();
if (torqueList!=null){
Iterator<TWorkItem> itrTorqueList = torqueList.iterator();
while (itrTorqueList.hasNext()){
beanList.add(itrTorqueList.next().getBean());
}
}
return beanList;
}
/**
* sets the wbs for the entire project
* @param projectID
*/
@Override
public void setWbs(Integer projectID) {
Criteria crit = new Criteria();
crit.add(PROJECTKEY, projectID);
//in the case that the wbs got corrupted but still a wbs existed before try to preserve the order
crit.addAscendingOrderByColumn(WBSONLEVEL);
//if wbs does not exist then fall back to workItemKey as wbs
crit.addAscendingOrderByColumn(WORKITEMKEY);
List<TWorkItem> workItems = null;
try {
workItems = doSelect(crit);
} catch (TorqueException e) {
LOGGER.error("Loading the workItems by project " + projectID + failedWith + e.getMessage());
}
Map<Integer, List<Integer>> childerenIDsForParentIDsMap = new HashMap<Integer, List<Integer>>();
Map<Integer, TWorkItem> workItemsMap = new HashMap<Integer, TWorkItem>();
List<Integer> rootItems = new ArrayList<Integer>();
if (workItems != null) {
for (TWorkItem workItem : workItems) {
Integer workItemID = workItem.getObjectID();
workItemsMap.put(workItemID, workItem);
Integer parentID = workItem.getSuperiorworkitem();
if (parentID==null) {
rootItems.add(workItemID);
} else {
List<Integer> children = childerenIDsForParentIDsMap.get(parentID);
if (children==null) {
children = new LinkedList<Integer>();
childerenIDsForParentIDsMap.put(parentID, children);
}
children.add(workItemID);
}
}
}
setWbsOnLevel(workItemsMap, rootItems);
for (Integer parentIDs : childerenIDsForParentIDsMap.keySet()) {
List<Integer> childrenIDs = childerenIDsForParentIDsMap.get(parentIDs);
setWbsOnLevel(workItemsMap, childrenIDs);
}
}
/**
* Sets the wbs on a level
* @param workItemsMap
* @param workItemsOnSameLevel
*/
private static void setWbsOnLevel(Map<Integer, TWorkItem> workItemsMap, List<Integer> workItemsOnSameLevel) {
if (workItemsOnSameLevel!=null) {
for (int i = 0; i < workItemsOnSameLevel.size(); i++) {
Integer workItemID = workItemsOnSameLevel.get(i);
TWorkItem workItem = workItemsMap.get(workItemID);
if (workItem!=null) {
int wbs = i+1;
//save only if differs: avoid the expensive save operations if the value is already set
if (workItem.getWBSOnLevel()==null || workItem.getWBSOnLevel().intValue()!=wbs) {
workItem.setWBSOnLevel(wbs);
try {
workItem.save();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Set the WBS " + wbs + " for workItem " + workItemID);
}
} catch (Exception e) {
LOGGER.error("Setting the WBS " + wbs + failedWith + e.getMessage());
}
}
}
}
}
}
/**
* Sets the wbs on the affected workItems after a drag and drop operation
* @param draggedWorkItemID
* @param droppedToWorkItemID
* @param before
*/
@Override
public synchronized void dropNearWorkItem(Integer draggedWorkItemID, Integer droppedToWorkItemID, boolean before) {
TWorkItemBean workItemBeanDragged = null;
try {
workItemBeanDragged = loadByPrimaryKey(draggedWorkItemID);
} catch (ItemLoaderException e1) {
LOGGER.warn("The fromWorkItemID " + draggedWorkItemID + " does not exist");
return;
}
TWorkItemBean workItemBeanDroppedTo = null;
try {
workItemBeanDroppedTo = loadByPrimaryKey(droppedToWorkItemID);
} catch (ItemLoaderException e1) {
LOGGER.warn("The toWorkItemID " + droppedToWorkItemID + " does not exist");
return;
}
Integer projectID = workItemBeanDragged.getProjectID();
if (projectID==null) {
LOGGER.warn("No project found for " + draggedWorkItemID + " does not exist");
return;
}
if (workItemBeanDragged.getWBSOnLevel()==null || workItemBeanDroppedTo.getWBSOnLevel()==null) {
setWbs(projectID);
try {
//load them again this time with wbs numbers set
workItemBeanDragged = loadByPrimaryKey(draggedWorkItemID);
workItemBeanDroppedTo = loadByPrimaryKey(droppedToWorkItemID);
} catch (ItemLoaderException e) {
}
}
if (!projectID.equals(workItemBeanDroppedTo.getProjectID())) {
LOGGER.debug("The drop target is not from the same project: abort drop");
return;
}
Integer parentOfDraggedWorkItem = workItemBeanDragged.getSuperiorworkitem();
Integer parentOfDroppedToWorkItem = workItemBeanDroppedTo.getSuperiorworkitem();
Integer draggedSortOrder = workItemBeanDragged.getWBSOnLevel();
Integer droppedToSortOrder = workItemBeanDroppedTo.getWBSOnLevel();
if (draggedSortOrder==null || droppedToSortOrder==null) {
LOGGER.warn("The draggedSortOrder " + draggedSortOrder + " droppedToSortOrder " + droppedToSortOrder);
return;
}
String sqlStmt = null;
String droppedCriteria = "";
String draggedCriteria = "";
Integer workItemSortOrder;
boolean parentsNull = parentOfDraggedWorkItem==null && parentOfDroppedToWorkItem==null;
boolean parentsNotNull = parentOfDraggedWorkItem!=null && parentOfDroppedToWorkItem!=null;
if (parentsNull || (parentsNotNull && parentOfDraggedWorkItem != null &&
parentOfDraggedWorkItem.equals(parentOfDroppedToWorkItem))) {
if (draggedSortOrder.equals(droppedToSortOrder)) {
//on the same level the same sortorder, not a real move, do nothing
LOGGER.debug("The draggedSortOrder " + draggedSortOrder + " equals droppedToSortOrder " + droppedToSortOrder);
return;
}
String parentCriteria = "";
//same level: both parent null or same parent
if (parentsNotNull) {
parentCriteria = " AND SUPERIORWORKITEM = " + parentOfDraggedWorkItem;
} else {
parentCriteria = " AND SUPERIORWORKITEM IS NULL ";
}
int inc = 0;
if (draggedSortOrder>droppedToSortOrder) {
inc = 1;
if (before) {
droppedCriteria = " AND WBSONLEVEL >= " + droppedToSortOrder;
draggedCriteria = " AND WBSONLEVEL < " + draggedSortOrder;
workItemSortOrder = droppedToSortOrder;
} else {
droppedCriteria = " AND WBSONLEVEL > " + droppedToSortOrder;
draggedCriteria = " AND WBSONLEVEL < " + draggedSortOrder;
workItemSortOrder = droppedToSortOrder+1;
}
} else {
inc = -1;
if (before) {
droppedCriteria = " AND WBSONLEVEL < " + droppedToSortOrder;
draggedCriteria = " AND WBSONLEVEL > " + draggedSortOrder;
workItemSortOrder = droppedToSortOrder-1;
} else {
droppedCriteria = " AND WBSONLEVEL <= " + droppedToSortOrder;
draggedCriteria = " AND WBSONLEVEL > " + draggedSortOrder;
workItemSortOrder = droppedToSortOrder;
}
}
sqlStmt = "UPDATE TWORKITEM SET WBSONLEVEL = WBSONLEVEL " +
" + " + inc + " WHERE " + " PROJECTKEY = " + projectID +
parentCriteria + draggedCriteria + droppedCriteria;
executeStatemant(sqlStmt);
} else {
if (EqualUtils.equal(draggedWorkItemID, parentOfDroppedToWorkItem)) {
LOGGER.warn("The WBS change would cause the issue " + draggedWorkItemID + " to became parent of itself");
//avoid same parentID as issueID
return;
}
if (ItemBL.isAscendant(draggedWorkItemID, parentOfDroppedToWorkItem)) {
LOGGER.warn("The chosen parent " + parentOfDroppedToWorkItem + " is already a descendant of the " + draggedWorkItemID);
return;
}
//different levels
//1. remove the dragged item from the original position and shift the following items up
shiftBranch(draggedSortOrder, parentOfDraggedWorkItem, projectID, false);
//2. shift down the actual items in the new place to make space for the dragged item to the new position
String parentCriteriaOfDroppedItem = "";
if (parentOfDroppedToWorkItem!=null) {
parentCriteriaOfDroppedItem = " AND SUPERIORWORKITEM = " + parentOfDroppedToWorkItem;
} else {
parentCriteriaOfDroppedItem = " AND SUPERIORWORKITEM IS NULL ";
}
if (before) {
droppedCriteria = " AND WBSONLEVEL >= " + droppedToSortOrder;
workItemSortOrder = droppedToSortOrder;
} else {
droppedCriteria = " AND WBSONLEVEL > " + droppedToSortOrder;
workItemSortOrder = droppedToSortOrder+1;
}
sqlStmt = "UPDATE TWORKITEM SET WBSONLEVEL = WBSONLEVEL" +
"+1 " + " WHERE " + " PROJECTKEY = " + projectID +
parentCriteriaOfDroppedItem + droppedCriteria;
executeStatemant(sqlStmt);
workItemBeanDragged.setSuperiorworkitem(parentOfDroppedToWorkItem);
}
workItemBeanDragged.setWBSOnLevel(workItemSortOrder);
try {
saveSimple(workItemBeanDragged);
} catch (ItemPersisterException e) {
LOGGER.error("Saving the new droppedToSortOrder " + droppedToSortOrder +
" for workItemID " + draggedWorkItemID + failedWith + e.getMessage(), e);
}
}
/**
* The parent was changed: recalculate the WBS both the old parent and the new parent can be null
* @param workItemBean
* @param workItemBeanOriginal
* @param contextInformation
*/
@Override
public void parentChanged(TWorkItemBean workItemBean, TWorkItemBean workItemBeanOriginal,
Map<String, Object> contextInformation) {
if (workItemBeanOriginal==null) {
//new item
return;
}
Integer oldParent = workItemBeanOriginal.getSuperiorworkitem();
Integer newParent = workItemBean.getSuperiorworkitem();
if ((oldParent==null && newParent==null) || (oldParent!=null && newParent!=null && oldParent.equals(newParent))) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("no parent change: wbs not affected");
}
return;
}
Integer projectID = workItemBean.getProjectID();
if (projectID==null) {
LOGGER.warn("No project found for workItem" + workItemBean.getObjectID());
return;
}
//old parent workItem and project
TWorkItemBean oldParentWorkItemBean = null;
boolean sameProjectAsOldParent = false;
if (oldParent!=null) {
try {
oldParentWorkItemBean = loadByPrimaryKey(oldParent);
Integer oldParentProjectID = oldParentWorkItemBean.getProjectID();
if (oldParentProjectID==null) {
LOGGER.warn("No project found for oldParent " + oldParent);
return;
} else {
sameProjectAsOldParent = projectID.equals(oldParentProjectID);
}
} catch (ItemLoaderException e1) {
LOGGER.warn("The oldParent workItem " + oldParent + " does not exist");
return;
}
} else {
//previously it has no parent: the projects are considered the same
sameProjectAsOldParent = true;
}
//new parent workItem and project
TWorkItemBean newParentWorkItemBean = null;
boolean sameProjectAsNewParent = false;
if (newParent!=null) {
try {
newParentWorkItemBean = loadByPrimaryKey(newParent);
Integer newParentProjectID = newParentWorkItemBean.getProjectID();
if (newParentProjectID==null) {
LOGGER.warn("No project found for newParent " + newParent);
return;
} else {
sameProjectAsNewParent = projectID.equals(newParentProjectID);
}
} catch (ItemLoaderException e1) {
LOGGER.warn("The newParent workItem " + newParent + " does not exist");
return;
}
} else {
//the parent is removed: the projects are considered the same
sameProjectAsNewParent = true;
}
boolean outdent = false;
if (contextInformation!=null && contextInformation.get(TWorkItemBean.OUTDENT)!=null &&
((Boolean)contextInformation.get(TWorkItemBean.OUTDENT)).booleanValue()) {
outdent = true;
}
Integer originalWBS = workItemBean.getWBSOnLevel();
if (originalWBS==null) {
//renumber if null and get the WBS number again
setWbs(projectID);
try {
//load them again this time with wbs numbers set
workItemBean = loadByPrimaryKey(workItemBean.getObjectID());
originalWBS = workItemBean.getWBSOnLevel();
} catch (ItemLoaderException e) {
}
}
//1. remove the item from the original parent's childen and shift the following items up
if (sameProjectAsOldParent && !outdent) {
//if there were no previous wbs or the project of the workItem differs form the
//oldParent's project then there is no need to change anything in the old branch
//move the issue's next siblings up one level if it is no outdent
//(by outdent the issue's next siblings will be children of the issue)
shiftBranch(originalWBS, oldParent, projectID, false);
}
//2. add the item as last child of the new parent
if (sameProjectAsNewParent) {
//if the new parent differs from the workItem's parent then no change in wbs
Integer newWBS;
if (outdent && (contextInformation != null) && (oldParentWorkItemBean != null)) {
List<Integer> filteredNextSiblingIDs = (List<Integer>)contextInformation.get(TWorkItemBean.NEXT_SIBLINGS);
//by outdent the oldParent becomes the new previous sibling: make space for the outdented item,
//by shifting down the siblings of newParent (previous grandparent) after the oldParent
Integer oldParentWBS = oldParentWorkItemBean.getWBSOnLevel();
if (oldParentWBS==null) {
newWBS = Integer.valueOf(1);
} else {
newWBS = Integer.valueOf(oldParentWBS.intValue()+1);
}
//shift down the children of the newParent beginning with
//oldParentWBS exclusive to make place for the outdented issue
shiftBranch(oldParentWBS, newParent, projectID, true);
//get the next available WBS after the outdented issue's original children
Integer nextWbsOnOudentedChildren = getNextWbsOnLevel(workItemBean.getObjectID(), projectID);
//gather the all siblings (not just the next ones according to wbs) of the outdented issue,
//because it is not guaranteed that at the moment of the outline the sortOrder is by wbs
//(can be that in the ReportBeans there is a next sibling which has a lower wbs nummer as the outlined one still according
//to the selected ReportBeans sortorder it is a next sibling, consequently it will become a child of outlined issue)
Criteria criteria = new Criteria();
criteria.add(SUPERIORWORKITEM, oldParent);
criteria.add(WORKITEMKEY, workItemBean.getObjectID(), Criteria.NOT_EQUAL);
//criteria.add(WBSONLEVEL, originalWBS, Criteria.GREATER_THAN);
criteria.add(PROJECTKEY, projectID);
//in the case that the wbs got corrupted but still a wbs existed before try to preserve the order
criteria.addAscendingOrderByColumn(WBSONLEVEL);
//if wbs does not exist then fall back to workItemKey as wbs
criteria.addAscendingOrderByColumn(WORKITEMKEY);
List<TWorkItemBean> allSiblingWorkItemBeans = null;
try {
allSiblingWorkItemBeans = convertTorqueListToBeanList(doSelect(criteria));
} catch (TorqueException e) {
LOGGER.warn("Getting the next siblings of the outdented issue " + workItemBean.getObjectID() + failedWith + e.getMessage(), e );
}
List<String> idChunks = GeneralUtils.getCommaSepararedIDChunksInParenthesis(filteredNextSiblingIDs);
//set all next siblings as children of the outdented workItem (see MS Project)
//actualize the WBS for old next present siblings (future children of the outdented issue).
//No common update is possible because the WBS of the next present siblings might contain gaps
Map<Integer, TWorkItemBean> siblingWorkItemsMap =
GeneralUtils.createMapFromList(allSiblingWorkItemBeans);
for (int i = 0; i < filteredNextSiblingIDs.size(); i++) {
//the order from the ReportBeans should be preserved, insependently of current wbs
//(consquently the relative wbs order between the siblings might change)
TWorkItemBean nextSiblingworkItemBean = siblingWorkItemsMap.get(filteredNextSiblingIDs.get(i));
if (nextSiblingworkItemBean!=null && nextSiblingworkItemBean.getWBSOnLevel()!=(nextWbsOnOudentedChildren+i)) {
nextSiblingworkItemBean.setWBSOnLevel(nextWbsOnOudentedChildren+i);
try {
saveSimple(nextSiblingworkItemBean);
} catch (ItemPersisterException e) {
LOGGER.warn("Saving the outdented present workitem " + nextSiblingworkItemBean.getObjectID() + failedWith + e.getMessage());
}
}
}
//renumber those next siblings which were not re-parented (those not present in the ReportBeans)
//to fill up the gaps leaved by the re-parented present next siblings
//no common update is possible because of gaps
int i=0;
if (allSiblingWorkItemBeans != null) {
for (Iterator<TWorkItemBean> iterator = allSiblingWorkItemBeans.iterator(); iterator.hasNext();) {
TWorkItemBean nextSiblingworkItemBean = iterator.next();
if (!filteredNextSiblingIDs.contains(nextSiblingworkItemBean.getObjectID())) {
i++;
if (nextSiblingworkItemBean.getWBSOnLevel()!=i) {
nextSiblingworkItemBean.setWBSOnLevel(i);
try {
saveSimple(nextSiblingworkItemBean);
} catch (ItemPersisterException e) {
LOGGER.warn("Saving the outdented not present workItem " + nextSiblingworkItemBean.getObjectID() + failedWith + e.getMessage());
}
}
}
}
}
String parentCriteria = " AND SUPERIORWORKITEM = " + oldParent;
String subprojectCriteria = " PROJECTKEY = " + projectID;
//set all present next siblings as children of the outdented workItem (see MS Project).
for (Iterator<String> iterator = idChunks.iterator(); iterator.hasNext();) {
String idChunk = iterator.next();
String sqlStmt = "UPDATE TWORKITEM SET SUPERIORWORKITEM = " +
workItemBean.getObjectID() + " WHERE " + subprojectCriteria +
parentCriteria + " AND WORKITEMKEY IN " + idChunk;
executeStatemant(sqlStmt);
}
} else {
newWBS = getNextWbsOnLevel(newParent, projectID);
}
//shift the entire branch down and set the outdented workitem as first child of his previous parent
if (EqualUtils.notEqual(workItemBean.getWBSOnLevel(), newWBS)) {
workItemBean.setWBSOnLevel(newWBS);
}
}
}
/**
* The project was changed: recalculate the WBS
* @param workItemBean
* @param workItemBeanOriginal
*/
@Override
public void projectChanged(TWorkItemBean workItemBean, TWorkItemBean workItemBeanOriginal) {
if (workItemBeanOriginal==null) {
//new item
return;
}
Integer oldProjectID = workItemBeanOriginal.getProjectID();
Integer newProjectID = workItemBean.getProjectID();
if (oldProjectID==null || newProjectID==null) {
LOGGER.warn("Old project " + oldProjectID + " new project " + newProjectID);
return;
}
//same project -> no wbs change
if (oldProjectID.equals(newProjectID)) {
LOGGER.debug("No project changed ");
return;
}
TWorkItemBean parentWorkItemBean = null;
Integer parentID = workItemBean.getSuperiorworkitem();
Integer parentProjectID = null;
if (parentID!=null) {
try {
parentWorkItemBean = loadByPrimaryKey(parentID);
} catch (ItemLoaderException e) {
LOGGER.warn("The parent workItem " + parentID + " does not exist");
}
if (parentWorkItemBean!=null) {
parentProjectID = parentWorkItemBean.getProjectID();
}
}
Integer originalWBS = workItemBean.getWBSOnLevel();
if (originalWBS==null) {
//renumber if null and get the WBS number again
setWbs(oldProjectID);
try {
//load them again this time with wbs numbers set
workItemBean = loadByPrimaryKey(workItemBean.getObjectID());
originalWBS = workItemBean.getWBSOnLevel();
} catch (ItemLoaderException e) {
}
}
//1. remove the item from the original parent's childen and shift the following items up
//if the item has no parent or the item's parent project and the item's old project is the same
if (parentProjectID==null || parentProjectID.equals(oldProjectID)) {
//if there were no previous wbs or the project of the workItem differs form the
//oldParent's project then there is no need to change anything in the old branch
//String commaSeparatedSubprojects = getCommaSepararedSubprojectIDs(oldProjectID, new HashSet<Integer>());
shiftBranch(originalWBS, parentID, oldProjectID, false);
} else {
LOGGER.debug("The originalSortOrder was null. There is no need to shift the children of the old parent ");
}
//2. add the item as last child of the new (parent project)
if (parentProjectID==null || parentProjectID.equals(newProjectID)) {
//if the new project differs from the workItem's parent then no change in wbs
Integer newWbs = getNextWbsOnLevel(parentID, newProjectID);
if (EqualUtils.notEqual(workItemBean.getWBSOnLevel(), newWbs)) {
workItemBean.setWBSOnLevel(newWbs);
}
}
Integer idNumber = calculateIDNumber(newProjectID, null);
if (idNumber!=null) {
workItemBean.setIDNumber(idNumber);
}
}
/**
* Gets the root items or children of a parent from a project
* The archived/deleted items are also included
* @param parentID
* @param projectID
* @return
*/
private static Integer getNextWbsOnLevel(Integer parentID, Integer projectID){
Criteria crit = new Criteria();
if (parentID==null) {
crit.add(SUPERIORWORKITEM, (Integer)null, Criteria.ISNULL);
} else {
crit.add(SUPERIORWORKITEM, parentID, Criteria.EQUAL);
}
crit.add(PROJECTKEY, projectID);
String max = "max(" + WBSONLEVEL + ")";
crit.addSelectColumn(max);
Integer maxWBSOnLevel = null;
try {
maxWBSOnLevel = ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asIntegerObj();
} catch (Exception e) {
LOGGER.error("Getting the maximal wbs for parent " + parentID + " projectID " + projectID + failedWith + e.getMessage());
}
if (maxWBSOnLevel==null) {
return Integer.valueOf(1);
} else {
return Integer.valueOf(maxWBSOnLevel.intValue()+1);
}
}
private static void shiftBranch(Integer originalWBS, Integer parentID, Integer projectID, boolean increase) {
String oldParentCriteria = "";
if (parentID!=null) {
oldParentCriteria = " AND SUPERIORWORKITEM = " + parentID;
} else {
oldParentCriteria = " AND SUPERIORWORKITEM IS NULL ";
}
String increaseCriteria;
if (increase) {
increaseCriteria = "+1 ";
} else {
increaseCriteria = "-1 ";
}
String shiftOldParentsChildren = " AND WBSONLEVEL > " + originalWBS;
String projectCriteria = " PROJECTKEY = " + projectID;
String sqlStmt = "UPDATE TWORKITEM SET WBSONLEVEL = WBSONLEVEL " +
increaseCriteria + " WHERE " + projectCriteria +
oldParentCriteria + shiftOldParentsChildren;
executeStatemant(sqlStmt);
}
private static void executeStatemant(String sqlStmt) {
Connection db = null;
try {
db = Torque.getConnection(DATABASE_NAME);
// it's the same name for all tables here, so we don't care
Statement stmt;
stmt = db.createStatement();
stmt.executeUpdate(sqlStmt);
} catch (TorqueException e) {
LOGGER.debug(ExceptionUtils.getStackTrace(e));
} catch (SQLException e) {
LOGGER.debug(ExceptionUtils.getStackTrace(e));
} finally {
Torque.closeConnection(db);
}
}
/**
* Gets the root items or children of a parent from a project
* The archived/deleted items are also included
* @param parentID
* @param projectID
* @return
*/
private static Integer getNextItemID(Integer projectID){
Criteria crit = new Criteria();
crit.add(PROJECTKEY, projectID);
String max = "max(" + IDNUMBER + ")";
crit.addSelectColumn(max);
Integer maxIDNumber = null;
try {
List<Record> records = doSelectVillageRecords(crit);
if (records!=null && !records.isEmpty()) {
maxIDNumber = records.get(0).getValue(1).asIntegerObj();
}
} catch (Exception e) {
LOGGER.error("Getting the maximal IDNumber for projectID " + projectID + failedWith + e.getMessage());
}
if (maxIDNumber==null) {
return Integer.valueOf(1);
} else {
return Integer.valueOf(maxIDNumber.intValue()+1);
}
}
/**
* Gets the items from the context in a certain status which were not modified after lastModified
* @param workflowContext
* @param statusID
* @param lastModified
* @return
*/
@Override
public List<TWorkItemBean> getInStatusUnmodifiedAfter(WorkflowContext workflowContext, Integer statusID, Date lastModified) {
Criteria crit = new Criteria();
CriteriaUtil.addActiveInactiveProjectCriteria(crit);
CriteriaUtil.addArchivedDeletedFilter(crit);
CriteriaUtil.addAccessLevelPublicFilter(crit);
addWorkflowContextCriteria(crit, workflowContext);
crit.add(STATE, statusID);
crit.add(LASTEDIT, lastModified, Criteria.LESS_EQUAL);
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Criteria " + crit);
}
return convertTorqueListToBeanList(doSelect(crit));
} catch (TorqueException e) {
LOGGER.error("Loading the items in status " + statusID + " not modifed after " + lastModified + failedWith + e.getMessage());
return new ArrayList<TWorkItemBean>();
}
}
/**
* Gets the itemIDs from the context in a certain status without a status change after lastModified
* @param workflowContext
* @param statusID
* @param lastModified
* @return
*/
@Override
public List<Integer> getInStatusNoStatusChangeAfter(WorkflowContext workflowContext, Integer statusID, Date lastModified) {
List<Integer> itemIDs = null;
Criteria crit = new Criteria();
String maxLastEdit = "MAX(" + THistoryTransactionPeer.LASTEDIT + ")";
CriteriaUtil.addActiveInactiveProjectCriteria(crit);
CriteriaUtil.addArchivedDeletedFilter(crit);
CriteriaUtil.addAccessLevelPublicFilter(crit);
addWorkflowContextCriteria(crit, workflowContext);
crit.add(STATE, statusID);
crit.addJoin(WORKITEMKEY, THistoryTransactionPeer.WORKITEM);
crit.addJoin(THistoryTransactionPeer.OBJECTID, TFieldChangePeer.HISTORYTRANSACTION);
crit.add(TFieldChangePeer.FIELDKEY, SystemFields.INTEGER_STATE);
crit.addSelectColumn(THistoryTransactionPeer.WORKITEM);
crit.addGroupByColumn(THistoryTransactionPeer.WORKITEM);
Criterion criterion = crit.getNewCriterion(maxLastEdit, lastModified, Criteria.LESS_EQUAL);
crit.addHaving(criterion);
List<Record> records = new LinkedList<Record>();
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Criteria " + crit);
}
records = doSelectVillageRecords(crit);
} catch(Exception e) {
LOGGER.error("Groupping the workitems by date of the last modified status before " + lastModified + failedWith + e.getMessage());
}
try {
if (records!=null && !records.isEmpty()) {
itemIDs = new ArrayList<Integer>(records.size());
for (Record record : records) {
Integer itemID = record.getValue(1).asIntegerObj();
itemIDs.add(itemID);
}
}
} catch (Exception e) {
LOGGER.error("Loading the items in status " + statusID + " not modifed after " + lastModified + failedWith + e.getMessage());
}
return itemIDs;
}
public List<IntegerStringBean> getPath(Integer objectID) throws ItemLoaderException{
List<IntegerStringBean> result=new ArrayList<IntegerStringBean>();
Integer workItemID=objectID;
while(workItemID!=null){
TWorkItem tWorkItem = getInternalWorkItem(workItemID);
result.add(0,new IntegerStringBean(tWorkItem.getSynopsis(), tWorkItem.getObjectID()));
workItemID = tWorkItem.getSuperiorworkitem();
}
return result;
}
private TWorkItem getInternalWorkItem(Integer objectID) throws ItemLoaderException {
TWorkItem tWorkItem = null;
try {
tWorkItem = retrieveByPK(objectID);
} catch(Exception e) {
LOGGER.info("Loading the workItem by primary key " + objectID + failedWith + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
throw new ItemLoaderException("Loading the workItem by " + objectID + " failed", e);
}
if(tWorkItem==null){
throw new ItemLoaderException("No item found for workItem ID " + objectID);
}
return tWorkItem;
}
/**
* Filter the items by context
* @param crit
* @param workflowContext
* @return
*/
private static Criteria addWorkflowContextCriteria(Criteria crit, WorkflowContext workflowContext) {
Integer itemTypeID = workflowContext.getItemTypeID();
Integer projectTypeID = workflowContext.getProjectTypeID();
Integer projectID = workflowContext.getProjectID();
if (itemTypeID!=null) {
crit.add(CATEGORYKEY, itemTypeID);
}
if (projectTypeID!=null) {
crit.addJoin(PROJECTKEY, TProjectPeer.PKEY);
crit.add(TProjectPeer.PROJECTTYPE, projectTypeID);
} else {
if (projectID!=null) {
crit.add(PROJECTKEY, projectID);
}
}
return crit;
}
}
| gpl-3.0 |
Telsis/jOCP | src/com/telsis/jocp/messages/DeliverTo.java | 14629 | /*
* Telsis Limited jOCP library
*
* Copyright (C) Telsis Ltd. 2010-2013.
*
* This Program is free software: you can copy, redistribute 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.
*
* If you modify this Program you must mark it as changed by you and give a relevant date.
*
* This Program is published 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
* receive a copy of the GNU General Public License along with this program. If not,
* see <http//www.gnu.org/licenses/>.
*
* In making commercial use of this Program you indemnify Telsis Limited and all of its related
* Companies for any contractual assumptions of liability that may be imposed on Telsis Limited
* or any of its related Companies.
*
*/
package com.telsis.jocp.messages;
import java.nio.ByteBuffer;
import java.util.Arrays;
import com.telsis.jocp.CallMessageException;
import com.telsis.jocp.OCPException;
import com.telsis.jocp.LegacyOCPMessageTypes;
import com.telsis.jocp.OCPTelno;
/**
* Send this message to instruct a call-handling platform to outdial using the
* specified number and connect an existing caller to the outdialled party. The
* expected reply to this message is {@link DeliverToResult Deliver To Result}.
* <p/>
* This message has the following parameters:
* <table>
* <tr>
* <th>Field Name</th>
* <th>Size</th>
* <th>Description</th>
* </tr>
* <tr>
* <td>destLegID</td>
* <td>2</td>
* <td>Leg ID on call handling unit to act upon</td>
* </tr>
* <tr>
* <td>origLegID</td>
* <td>2</td>
* <td>SCP's Leg ID for the new party</td>
* </tr>
* <tr>
* <td>spare</td>
* <td>1</td>
* <td><i>For word alignment</i></td>
* </tr>
* <tr>
* <td>zipNumber</td>
* <td>1</td>
* <td>The index into the zip table on the SCP for this result</td>
* </tr>
* <tr>
* <td>cliMode</td>
* <td>2</td>
* <td>0 if no CLI to be supplied<br/>
* 1 if unit to use A party's CLI<br/>
* 2 if CLI specified</td>
* </tr>
* <tr>
* <td>timeout</td>
* <td>2</td>
* <td>Time to wait for answer</td>
* </tr>
* <tr>
* <td>spare</td>
* <td>1</td>
* <td><i>For word alignment</i></td>
* </tr>
* <tr>
* <td>outdialNoTypePlan</td>
* <td>1</td>
* <td>Q931 Type in high nibble and Plan in low nibble for outdialled number</td>
* </tr>
* <tr>
* <td>outdialNo</td>
* <td>18</td>
* <td>2 byte length followed by 32 packed digits</td>
* </tr>
* <tr>
* <td>cliPresScreen</td>
* <td>1</td>
* <td>Q931 CLI Presentation and Screening indicators (only meaningful if
* CLIMode is 2)</td>
* </tr>
* <tr>
* <td>cliTypePlan</td>
* <td>1</td>
* <td>Q931 Type in high nibble and Plan in low nibble for CLI (only meaningful
* if CLIMode is 2)</td>
* </tr>
* <tr>
* <td>cliNo</td>
* <td>18</td>
* <td>2 byte length followed by 32 packed digits (only meaningful if CLIMode is
* 2)</td>
* </tr>
* </table>
*
* @see DeliverToResult
* @author Telsis
*/
public class DeliverTo extends CallControlMessage {
/** The message type. */
public static final LegacyOCPMessageTypes TYPE = LegacyOCPMessageTypes.DELIVER_TO;
/** The expected length of the message. */
private static final int EXPECTED_LENGTH = 50;
/** The length of the outdialNo field. */
private static final int OUTDIAL_NO_LENGTH = 18;
/** The length of the CLI field. */
private static final int CLI_LENGTH = 18;
/** Set cliMode to this to indicate that no CLI is to be supplied. */
public static final short CLI_MODE_USE_NONE = 0;
/** Set cliMode to this to indicate to use the A party's CLI. */
public static final short CLI_MODE_USE_A_PARTY = 1;
/** Set cliMode to this to indicate to use the specified CLI. */
public static final short CLI_MODE_USE_SPECIFIED = 2;
/** The Leg ID on call handling unit to act upon. */
private short destLegID;
/** The SCP's Leg ID for the new party. */
private short origLegID;
/** The index into the zip table on the SCP for this result. */
private byte zipNumber;
/** The CLI mode. */
private short cliMode;
/** The Time to wait for answer. */
private short timeout;
/** The outdial type and plan. */
private byte outdialNoTypePlan;
/** The outdial number. */
private byte[] outdialNo = new byte[OUTDIAL_NO_LENGTH];
/** The CLI Presentation and Screening indicators. */
private byte cliPresScreen;
/** The CLI type and plan. */
private byte cliTypePlan;
/** The CLI. */
private byte[] cliNo = new byte[CLI_LENGTH];
/**
* Decode the buffer into a DeliverTo message.
*
* @param buffer
* the message to decode
* @param minLength
* the minimum length of the message
* @param maxLength
* the maximum length of the message
* @param decode
* true if the payload should be decoded; false to skip decoding
* the payload. For use by subclasses that need to decode fields
* in a different order
* @throws OCPException
* if the buffer could not be decoded
*/
protected DeliverTo(final ByteBuffer buffer, final int minLength,
final int maxLength, final boolean decode) throws OCPException {
super(buffer);
super.advance(buffer);
if (buffer.limit() < minLength
|| buffer.limit() > maxLength) {
throw new CallMessageException(
getDestTID(),
getOrigTID(),
this.getCommandCode(),
CallCommandUnsupported.REASON_LENGTH_UNSUPPORTED,
(short) buffer.limit());
}
if (!decode) {
return;
}
destLegID = buffer.getShort();
origLegID = buffer.getShort();
buffer.get(); // for word alignment
zipNumber = buffer.get();
cliMode = buffer.getShort();
timeout = buffer.getShort();
buffer.get(); // for word alignment
outdialNoTypePlan = buffer.get();
buffer.get(outdialNo);
cliPresScreen = buffer.get();
cliTypePlan = buffer.get();
buffer.get(cliNo);
}
/**
* Decode the buffer into a Deliver To message.
*
* @param buffer
* the message to decode
* @throws OCPException
* if the buffer could not be decoded
*/
public DeliverTo(final ByteBuffer buffer) throws OCPException {
this(buffer, EXPECTED_LENGTH, EXPECTED_LENGTH, true);
}
/**
* Calls {@link CallControlMessage#CallControlMessage(short)} directly with
* the specified message type. For use by subclasses.
*
* @param commandCode
* the command code
*/
protected DeliverTo(final short commandCode) {
super(commandCode);
}
/**
* Instantiates a new Deliver To message.
*/
public DeliverTo() {
this(TYPE.getCommandCode());
}
/**
* Encode the header and payload into the buffer. This modifies the buffer
* in-place and sets the buffer's position to the end of the payload.
*
* @param buffer
* The buffer to insert the message into
* @param encode
* true if the payload should be encoded; false to skip encoding
* the payload. For use by subclasses that need to encode fields
* in a different order
*/
// CSOFF: DesignForExtension
protected void encode(final ByteBuffer buffer, final boolean encode) {
// CSON: DesignForExtension
super.encode(buffer);
if (!encode) {
return;
}
buffer.putShort(destLegID);
buffer.putShort(origLegID);
buffer.put((byte) 0); // for word alignment
buffer.put(zipNumber);
buffer.putShort(cliMode);
buffer.putShort(timeout);
buffer.put((byte) 0); // for word alignment
buffer.put(outdialNoTypePlan);
buffer.put(outdialNo);
buffer.put(cliPresScreen);
buffer.put(cliTypePlan);
buffer.put(cliNo);
}
@Override // CSIGNORE: DesignForExtension
protected void encode(final ByteBuffer buffer) {
encode(buffer, true);
}
/**
* Gets the dest leg ID.
*
* @return the dest leg ID
*/
public final short getDestLegID() {
return destLegID;
}
/**
* Sets the dest leg ID.
*
* @param newdestLegID
* the new dest leg ID
*/
public final void setDestLegID(final short newdestLegID) {
this.destLegID = newdestLegID;
}
/**
* Gets the orig leg ID.
*
* @return the orig leg ID
*/
public final short getOrigLegID() {
return origLegID;
}
/**
* Sets the orig leg ID.
*
* @param neworigLegID
* the new orig leg ID
*/
public final void setOrigLegID(final short neworigLegID) {
this.origLegID = neworigLegID;
}
/**
* Gets the zip number.
*
* @return the zip number
*/
public final byte getZipNumber() {
return zipNumber;
}
/**
* Sets the zip number.
*
* @param newzipNumber
* the new zip number
*/
public final void setZipNumber(final byte newzipNumber) {
this.zipNumber = newzipNumber;
}
/**
* Gets the CLI mode.
*
* @return the CLI mode
*/
public final short getCliMode() {
return cliMode;
}
/**
* Sets the CLI mode.
*
* @param newcliMode
* the new CLI mode
*/
public final void setCliMode(final short newcliMode) {
this.cliMode = newcliMode;
}
/**
* Gets the timeout.
*
* @return the timeout
*/
public final short getTimeout() {
return timeout;
}
/**
* Sets the timeout.
*
* @param newtimeout
* the new timeout
*/
public final void setTimeout(final short newtimeout) {
this.timeout = newtimeout;
}
/**
* Gets the outdial type and plan.
*
* @return the outdial type and plan
*/
public final byte getOutdialNoTypePlan() {
return outdialNoTypePlan;
}
/**
* Sets the outdial type and plan.
*
* @param newoutdialNoTypePlan
* the new outdial type and plan
*/
public final void setOutdialNoTypePlan(final byte newoutdialNoTypePlan) {
this.outdialNoTypePlan = newoutdialNoTypePlan;
}
/**
* Gets the outdial digits.
*
* @return the outdial digits
*/
public final byte[] getOutdialNo() {
return Arrays.copyOf(outdialNo, outdialNo.length);
}
/**
* Sets the outdial digits.
*
* @param newoutdialNo
* the new outdial digits
*/
public final void setOutdialNo(final byte[] newoutdialNo) {
this.outdialNo = Arrays.copyOf(newoutdialNo, newoutdialNo.length);
}
/**
* Gets the CLI digits, type and plan.
*
* @return the CLI digits, type and plan
*/
public final OCPTelno getOutdialTelno() {
return new OCPTelno(this.outdialNoTypePlan, this.outdialNo);
}
/**
* Sets the CLI digits, type and plan.
*
* @param newOutdial the new CLI digits, type and plan
*/
public final void setOutdialTelno(final OCPTelno newOutdial) {
this.outdialNoTypePlan = newOutdial.getTypePlan();
this.outdialNo = newOutdial.getTelno();
}
/**
* Gets the CLI Presentation and Screening indicators.
*
* @return the CLI Presentation and Screening indicators
*/
public final byte getCliPresScreen() {
return cliPresScreen;
}
/**
* Sets the CLI Presentation and Screening indicators.
*
* @param newcliPresScreen
* the new CLI Presentation and Screening indicators
*/
public final void setCliPresScreen(final byte newcliPresScreen) {
this.cliPresScreen = newcliPresScreen;
}
/**
* Gets the CLI type and plan.
*
* @return the CLI type and plan
*/
public final byte getCliTypePlan() {
return cliTypePlan;
}
/**
* Sets the CLI type and plan.
*
* @param newcliTypePlan
* the new CLI type and plan
*/
public final void setCliTypePlan(final byte newcliTypePlan) {
this.cliTypePlan = newcliTypePlan;
}
/**
* Gets the CLI digits.
*
* @return the CLI digits
*/
public final byte[] getCliNo() {
return Arrays.copyOf(cliNo, cliNo.length);
}
/**
* Sets the CLI digits.
*
* @param newcliNo
* the new CLI digits
*/
public final void setCliNo(final byte[] newcliNo) {
this.cliNo = Arrays.copyOf(newcliNo, newcliNo.length);
}
/**
* Gets the CLI digits, type and plan.
*
* @return the CLI digits, type and plan
*/
public final OCPTelno getCLITelno() {
return new OCPTelno(this.cliTypePlan, this.cliNo);
}
/**
* Sets the CLI digits, type and plan.
*
* @param newCLI the new CLI digits, type and plan
*/
public final void setCLITelno(final OCPTelno newCLI) {
this.cliTypePlan = newCLI.getTypePlan();
this.cliNo = newCLI.getTelno();
}
@Override // CSIGNORE: DesignForExtension
public String toString() {
return "Deliver To";
}
}
| gpl-3.0 |
Qmunity/BluePower | src/main/java/com/bluepowermod/container/ContainerItemDetector.java | 4045 | /*
* This file is part of Blue Power. Blue Power 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. Blue Power 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 Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package com.bluepowermod.container;
import com.bluepowermod.ClientProxy;
import com.bluepowermod.client.gui.BPContainerType;
import com.bluepowermod.client.gui.GuiContainerBase;
import com.bluepowermod.tile.tier1.TileAlloyFurnace;
import com.bluepowermod.tile.tier1.TileItemDetector;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* @author MineMaarten
*/
public class ContainerItemDetector extends Container {
public int mode = -1;
public int fuzzySetting = -1;
private final IInventory itemDetector;
public ContainerItemDetector(int windowId, PlayerInventory invPlayer, IInventory inventory) {
super(BPContainerType.ITEM_DETECTOR, windowId);
this.itemDetector = inventory;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
addSlot(new Slot(itemDetector, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
bindPlayerInventory(invPlayer);
}
public ContainerItemDetector( int id, PlayerInventory player ) {
this( id, player, new Inventory( TileItemDetector.SLOTS ));
}
protected void bindPlayerInventory(PlayerInventory invPlayer) {
// Render inventory
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlot(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
// Render hotbar
for (int j = 0; j < 9; j++) {
addSlot(new Slot(invPlayer, j, 8 + j * 18, 142));
}
}
@Override
public boolean stillValid(PlayerEntity player) {
return itemDetector.stillValid(player);
}
@Override
public ItemStack quickMoveStack(PlayerEntity player, int par2) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = (Slot) slots.get(par2);
if (slot != null && slot.hasItem()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.copy();
if (par2 < 9) {
if (!moveItemStackTo(itemstack1, 9, 45, true))
return ItemStack.EMPTY;
} else if (!moveItemStackTo(itemstack1, 0, 9, false)) {
return ItemStack.EMPTY;
}
if (itemstack1.getCount() == 0) {
slot.set(ItemStack.EMPTY);
} else {
slot.setChanged();
}
if (itemstack1.getCount() != itemstack.getCount()) {
slot.onQuickCraft(itemstack, itemstack1);
} else {
return ItemStack.EMPTY;
}
}
return itemstack;
}
@Override
@OnlyIn(Dist.CLIENT)
public void setData(int id, int value) {
super.setData(id, value);
if (id == 0) {
mode = value;
((GuiContainerBase) ClientProxy.getOpenedGui()).redraw();
} else if (id == 1) {
fuzzySetting = value;
((GuiContainerBase) ClientProxy.getOpenedGui()).redraw();
}
}
}
| gpl-3.0 |
RyanPrintup/Star-Sector | src/main/java/com/ryanprintup/starsector/packets/StartCraftingInContainerPacket.java | 677 | package com.ryanprintup.starsector.packets;
import com.ryanprintup.starsector.BasePacket;
import com.ryanprintup.starsector.net.BufferStream;
public class StartCraftingInContainerPacket implements BasePacket
{
private long entityId; // sVLQ
public StartCraftingInContainerPacket()
{
}
public StartCraftingInContainerPacket(long entityId)
{
this.entityId = entityId;
}
@Override
public void read(BufferStream stream)
{
entityId = stream.readSVLQ();
}
@Override
public void write(BufferStream stream)
{
}
@Override
public byte getId()
{
return 37;
}
public long getEntityId()
{
return entityId;
}
} | gpl-3.0 |
JThink/SkyEye | skyeye-data/skyeye-data-jpa/src/main/java/com/jthink/skyeye/data/jpa/dto/NameInfoDto.java | 825 | package com.jthink.skyeye.data.jpa.dto;
/**
* JThink@JThink
*
* @author JThink
* @version 0.0.1
* @desc name info dto
* @date 2016-11-17 09:17:19
*/
public class NameInfoDto {
private String name;
private String type;
private String app;
public NameInfoDto() {
}
public NameInfoDto(String name, String type, String app) {
this.name = name;
this.type = type;
this.app = app;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
}
| gpl-3.0 |