blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
410
content_id
stringlengths
40
40
detected_licenses
listlengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
132 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
28 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
352
50ccdd48691a17c63a2e4ff9c5a7721b487db895
f24169e7a8f3f1b32b85c118e651c70e1a1470ad
/engine/src/main/java/com/android/zxb/engine/view/ChooseOnePopupWindow.java
00b9671a86f073a22b9a7ebfb16256fc14b58452
[]
no_license
0xE4s0n/ruanjianbei
a2e691d461a10931c46125f8d98130246dd5aabc
08300395148acfb2075f7f7ad93875e5968ed05f
refs/heads/master
2020-09-11T05:52:56.848181
2019-12-29T06:56:21
2019-12-29T06:56:21
221,961,327
0
0
null
null
null
null
UTF-8
Java
false
false
3,478
java
package com.android.zxb.engine.view; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.android.zxb.engine.R; import com.android.zxb.engine.base.ui.view.BasePopupWindow; /** * 必须单选弹出框 * created by zhaoxiangbin on 2019/3/27 16:03 * 460837364@qq.com */ public class ChooseOnePopupWindow extends BasePopupWindow { private Context mContext; private String[] mDatas; private String mTitleValue; private int selected = 0; private TextView mTitleView; private RecyclerView mListView; private OneAdapter mAdapter; public ChooseOnePopupWindow(Activity context, String[] data, String title, int choosed) { super(context); this.mContext = context; this.mDatas = data; this.mTitleValue = title; this.selected = choosed; initView(); initPopWindow(); } public void setOnItemClickListener(OnItemClickListener ck) { this.mOnItemClickListener = ck; } private OnItemClickListener mOnItemClickListener; public interface OnItemClickListener { void onItemClick(int position); } @Override public void getLayoutView() { view = inflater.inflate(R.layout.pop_choose_one_layout, null); } @Override public void initView() { mTitleView = view.findViewById(R.id.pop_title); mListView = view.findViewById(R.id.choose_one_list); mListView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); initData(); } private void initData() { mTitleView.setText(mTitleValue); mAdapter = new OneAdapter(); mListView.setAdapter(mAdapter); } class OneAdapter extends RecyclerView.Adapter<OneAdapter.ViewHolder> { public OneAdapter() { } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(mContext).inflate(R.layout.item_choose_one, parent, false); return new OneAdapter.ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { holder.itemTxv.setText(mDatas[position]); if (selected == position) { holder.itemSelectImg.setImageResource(R.drawable.btn_bk_gongkai_s); } else { holder.itemSelectImg.setImageResource(R.drawable.btn_bk_gongkai_n); } holder.itemTxv.setOnClickListener(v -> { if (selected != position) { selected = position; mOnItemClickListener.onItemClick(selected); } dismiss(); }); } @Override public int getItemCount() { return mDatas.length; } class ViewHolder extends RecyclerView.ViewHolder { TextView itemTxv; ImageView itemSelectImg; public ViewHolder(View view) { super(view); itemTxv = view.findViewById(R.id.item_title); itemSelectImg = view.findViewById(R.id.item_select); } } } }
[ "1181499949@qq.com" ]
1181499949@qq.com
64d9d87c8023e31dc2206c50a790dd367c3075d7
962aa5e0d13dca4fc530868209cf2a08eaa46897
/MIS/src/main/Foraccess.java
f709367ef645f195c0fbefcb5ff12e5f22e00d0e
[]
no_license
LeoEatle/MIS_java
ca6e111beae43f1aa94ca70d766ff0bae2587f93
c97f2886575327360dbf7f4d46574469dfb76b01
refs/heads/master
2016-09-05T10:50:58.961510
2015-09-20T02:00:10
2015-09-20T02:00:10
42,796,692
0
0
null
null
null
null
UTF-8
Java
false
false
483
java
package main; import java.sql.DriverManager; import com.mysql.jdbc.Connection; public class Foraccess { static java.sql.Connection conn; public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); String url = "jdbc:Access:///c:/a/db.mdb"; conn = DriverManager.getConnection(url, "", ""); } catch (Exception e) { e.printStackTrace(); } } }
[ "liuyitao811@hotmail.com" ]
liuyitao811@hotmail.com
1033a0a1a1f378c3c31beb54923dcf6b2b623f72
fe62b66b1f1d36b5c25204468740bd7168acaf7d
/StubsTutorial/test/com/vodafone/test/BasicCalculatorStub.java
37245707b352694687a7ffef961bc3a010afa362
[]
no_license
mahwishriazjamil/TDDQA
0ffc0d2405a4ec98cf4b74b3024eab4b2c36d9a7
55fcd8a25eb06ed5173cce7e0f2c9dcf0b3edb39
refs/heads/master
2020-04-11T12:29:22.941361
2018-12-14T12:34:50
2018-12-14T12:34:50
161,782,222
0
0
null
null
null
null
UTF-8
Java
false
false
349
java
package com.vodafone.test; import com.company.BasicCalculatorService; public class BasicCalculatorStub implements BasicCalculatorService { public BasicCalculatorStub(){ } @Override public double fibonacciAdd(double x, double y) { return 9999; } @Override public double fibonacciSubtract(double x, double y) { return -9999; } }
[ "mahwish.riazjamil@vodafone.com" ]
mahwish.riazjamil@vodafone.com
7bb67bd6390c41a3b2fdfd1c549e590f2f9514b8
0c62103df45d9021a12e9b12982a83392c393c24
/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSSchedulerNode.java
3927b00f68efcc10ef439d0c72247c13cae2452b
[ "LicenseRef-scancode-unknown", "CC-PDDC", "LGPL-2.1-only", "GCC-exception-3.1", "GPL-2.0-only", "EPL-1.0", "Classpath-exception-2.0", "BSD-3-Clause", "Apache-2.0", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-other-permissive", "CDDL-1.0", "MIT", "CC-BY-2.5", "CC-BY-3.0", ...
permissive
maobaolong/hadoop
f934d4dc0ba45162230adf90819699071ca1171d
f378621546df760aef8d2560b6e9469260bdd4bf
refs/heads/trunk
2021-06-15T11:16:40.192051
2017-05-01T06:32:20
2017-05-01T06:32:20
89,907,623
0
1
Apache-2.0
2020-02-09T09:16:47
2017-05-01T08:05:13
Java
UTF-8
Java
false
false
15,728
java
/** * 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.hadoop.yarn.server.resourcemanager.scheduler.fair; import org.apache.hadoop.yarn.api.records.*; import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode; import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.ArrayList; import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * Test scheduler node, especially preemption reservations. */ public class TestFSSchedulerNode { private final ArrayList<RMContainer> containers = new ArrayList<>(); private RMNode createNode() { RMNode node = mock(RMNode.class); when(node.getTotalCapability()).thenReturn(Resource.newInstance(8192, 8)); when(node.getHostName()).thenReturn("host.domain.com"); return node; } private void createDefaultContainer() { createContainer(Resource.newInstance(1024, 1), null); } private RMContainer createContainer( Resource request, ApplicationAttemptId appAttemptId) { RMContainer container = mock(RMContainer.class); Container containerInner = mock(Container.class); ContainerId id = mock(ContainerId.class); when(id.getContainerId()).thenReturn((long)containers.size()); when(containerInner.getResource()). thenReturn(Resources.clone(request)); when(containerInner.getId()).thenReturn(id); when(containerInner.getExecutionType()). thenReturn(ExecutionType.GUARANTEED); when(container.getApplicationAttemptId()).thenReturn(appAttemptId); when(container.getContainerId()).thenReturn(id); when(container.getContainer()).thenReturn(containerInner); when(container.getExecutionType()).thenReturn(ExecutionType.GUARANTEED); when(container.getAllocatedResource()). thenReturn(Resources.clone(request)); containers.add(container); return container; } private void saturateCluster(FSSchedulerNode schedulerNode) { while (!Resources.isNone(schedulerNode.getUnallocatedResource())) { createDefaultContainer(); schedulerNode.allocateContainer(containers.get(containers.size() - 1)); schedulerNode.containerStarted(containers.get(containers.size() - 1). getContainerId()); } } private FSAppAttempt createStarvingApp(FSSchedulerNode schedulerNode, Resource request) { FSAppAttempt starvingApp = mock(FSAppAttempt.class); ApplicationAttemptId appAttemptId = mock(ApplicationAttemptId.class); when(starvingApp.getApplicationAttemptId()).thenReturn(appAttemptId); when(starvingApp.assignContainer(schedulerNode)).thenAnswer( new Answer<Resource>() { @Override public Resource answer(InvocationOnMock invocationOnMock) throws Throwable { Resource response = Resource.newInstance(0, 0); while (!Resources.isNone(request) && !Resources.isNone(schedulerNode.getUnallocatedResource())) { RMContainer container = createContainer(request, appAttemptId); schedulerNode.allocateContainer(container); Resources.addTo(response, container.getAllocatedResource()); Resources.subtractFrom(request, container.getAllocatedResource()); } return response; } }); when(starvingApp.isStarved()).thenAnswer( new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable { return !Resources.isNone(request); } } ); when(starvingApp.getPendingDemand()).thenReturn(request); return starvingApp; } private void finalValidation(FSSchedulerNode schedulerNode) { assertEquals("Everything should have been released", Resources.none(), schedulerNode.getAllocatedResource()); assertTrue("No containers should be reserved for preemption", schedulerNode.containersForPreemption.isEmpty()); assertTrue("No resources should be reserved for preemptors", schedulerNode.resourcesPreemptedForApp.isEmpty()); assertEquals( "No amount of resource should be reserved for preemptees", Resources.none(), schedulerNode.getTotalReserved()); } private void allocateContainers(FSSchedulerNode schedulerNode) { FairScheduler.assignPreemptedContainers(schedulerNode); } /** * Allocate and release a single container. */ @Test public void testSimpleAllocation() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); createDefaultContainer(); assertEquals("Nothing should have been allocated, yet", Resources.none(), schedulerNode.getAllocatedResource()); schedulerNode.allocateContainer(containers.get(0)); assertEquals("Container should be allocated", containers.get(0).getContainer().getResource(), schedulerNode.getAllocatedResource()); schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); assertEquals("Everything should have been released", Resources.none(), schedulerNode.getAllocatedResource()); // Check that we are error prone schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); finalValidation(schedulerNode); } /** * Allocate and release three containers with launch. */ @Test public void testMultipleAllocations() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); createDefaultContainer(); createDefaultContainer(); createDefaultContainer(); assertEquals("Nothing should have been allocated, yet", Resources.none(), schedulerNode.getAllocatedResource()); schedulerNode.allocateContainer(containers.get(0)); schedulerNode.containerStarted(containers.get(0).getContainerId()); schedulerNode.allocateContainer(containers.get(1)); schedulerNode.containerStarted(containers.get(1).getContainerId()); schedulerNode.allocateContainer(containers.get(2)); assertEquals("Container should be allocated", Resources.multiply(containers.get(0).getContainer().getResource(), 3.0), schedulerNode.getAllocatedResource()); schedulerNode.releaseContainer(containers.get(1).getContainerId(), true); schedulerNode.releaseContainer(containers.get(2).getContainerId(), true); schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); finalValidation(schedulerNode); } /** * Allocate and release a single container. */ @Test public void testSimplePreemption() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); // Launch containers and saturate the cluster saturateCluster(schedulerNode); assertEquals("Container should be allocated", Resources.multiply(containers.get(0).getContainer().getResource(), containers.size()), schedulerNode.getAllocatedResource()); // Request preemption FSAppAttempt starvingApp = createStarvingApp(schedulerNode, Resource.newInstance(1024, 1)); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(0)), starvingApp); assertEquals( "No resource amount should be reserved for preemptees", containers.get(0).getAllocatedResource(), schedulerNode.getTotalReserved()); // Preemption occurs release one container schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); allocateContainers(schedulerNode); assertEquals("Container should be allocated", schedulerNode.getTotalResource(), schedulerNode.getAllocatedResource()); // Release all remaining containers for (int i = 1; i < containers.size(); ++i) { schedulerNode.releaseContainer(containers.get(i).getContainerId(), true); } finalValidation(schedulerNode); } /** * Allocate and release three containers requested by two apps. */ @Test public void testComplexPreemption() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); // Launch containers and saturate the cluster saturateCluster(schedulerNode); assertEquals("Container should be allocated", Resources.multiply(containers.get(0).getContainer().getResource(), containers.size()), schedulerNode.getAllocatedResource()); // Preempt a container FSAppAttempt starvingApp1 = createStarvingApp(schedulerNode, Resource.newInstance(2048, 2)); FSAppAttempt starvingApp2 = createStarvingApp(schedulerNode, Resource.newInstance(1024, 1)); // Preemption thread kicks in schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(0)), starvingApp1); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(1)), starvingApp1); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(2)), starvingApp2); // Preemption happens schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); schedulerNode.releaseContainer(containers.get(2).getContainerId(), true); schedulerNode.releaseContainer(containers.get(1).getContainerId(), true); allocateContainers(schedulerNode); assertEquals("Container should be allocated", schedulerNode.getTotalResource(), schedulerNode.getAllocatedResource()); // Release all containers for (int i = 3; i < containers.size(); ++i) { schedulerNode.releaseContainer(containers.get(i).getContainerId(), true); } finalValidation(schedulerNode); } /** * Allocate and release three containers requested by two apps in two rounds. */ @Test public void testMultiplePreemptionEvents() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); // Launch containers and saturate the cluster saturateCluster(schedulerNode); assertEquals("Container should be allocated", Resources.multiply(containers.get(0).getContainer().getResource(), containers.size()), schedulerNode.getAllocatedResource()); // Preempt a container FSAppAttempt starvingApp1 = createStarvingApp(schedulerNode, Resource.newInstance(2048, 2)); FSAppAttempt starvingApp2 = createStarvingApp(schedulerNode, Resource.newInstance(1024, 1)); // Preemption thread kicks in schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(0)), starvingApp1); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(1)), starvingApp1); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(2)), starvingApp2); // Preemption happens schedulerNode.releaseContainer(containers.get(1).getContainerId(), true); allocateContainers(schedulerNode); schedulerNode.releaseContainer(containers.get(2).getContainerId(), true); schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); allocateContainers(schedulerNode); assertEquals("Container should be allocated", schedulerNode.getTotalResource(), schedulerNode.getAllocatedResource()); // Release all containers for (int i = 3; i < containers.size(); ++i) { schedulerNode.releaseContainer(containers.get(i).getContainerId(), true); } finalValidation(schedulerNode); } /** * Allocate and release a single container and delete the app in between. */ @Test public void testPreemptionToCompletedApp() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); // Launch containers and saturate the cluster saturateCluster(schedulerNode); assertEquals("Container should be allocated", Resources.multiply(containers.get(0).getContainer().getResource(), containers.size()), schedulerNode.getAllocatedResource()); // Preempt a container FSAppAttempt starvingApp = createStarvingApp(schedulerNode, Resource.newInstance(1024, 1)); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(0)), starvingApp); schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); // Stop the application then try to satisfy the reservation // and observe that there are still free resources not allocated to // the deleted app when(starvingApp.isStopped()).thenReturn(true); allocateContainers(schedulerNode); assertNotEquals("Container should be allocated", schedulerNode.getTotalResource(), schedulerNode.getAllocatedResource()); // Release all containers for (int i = 1; i < containers.size(); ++i) { schedulerNode.releaseContainer(containers.get(i).getContainerId(), true); } finalValidation(schedulerNode); } /** * Preempt a bigger container than the preemption request. */ @Test public void testPartialReservedPreemption() { RMNode node = createNode(); FSSchedulerNode schedulerNode = new FSSchedulerNode(node, false); // Launch containers and saturate the cluster saturateCluster(schedulerNode); assertEquals("Container should be allocated", Resources.multiply(containers.get(0).getContainer().getResource(), containers.size()), schedulerNode.getAllocatedResource()); // Preempt a container Resource originalStarvingAppDemand = Resource.newInstance(512, 1); FSAppAttempt starvingApp = createStarvingApp(schedulerNode, originalStarvingAppDemand); schedulerNode.addContainersForPreemption( Collections.singletonList(containers.get(0)), starvingApp); // Preemption occurs schedulerNode.releaseContainer(containers.get(0).getContainerId(), true); // Container partially reassigned allocateContainers(schedulerNode); assertEquals("Container should be allocated", Resources.subtract(schedulerNode.getTotalResource(), Resource.newInstance(512, 0)), schedulerNode.getAllocatedResource()); // Cleanup simulating node update schedulerNode.getPreemptionList(); // Release all containers for (int i = 1; i < containers.size(); ++i) { schedulerNode.releaseContainer(containers.get(i).getContainerId(), true); } finalValidation(schedulerNode); } }
[ "kasha@apache.org" ]
kasha@apache.org
83918fd925e7fc11772f0054d20b3eb01edd5d98
552fdb092d8e29076474abb271c2e407f928a49c
/ad-core/src/main/java/com/palmtech/ad/dao/StPushAppDao.java
8e68f674d8e3ad7fbc172b3deedd2b9082c287e5
[]
no_license
caomingjian2012/example-core
2ed8d8149c617923c2ba9f44083feefc39cdc180
ebb248eb03ae567f6e4aad5b9064300e8acf6304
refs/heads/master
2021-01-10T12:58:17.838148
2015-11-15T15:54:13
2015-11-15T15:54:13
46,224,409
0
0
null
null
null
null
UTF-8
Java
false
false
368
java
package com.palmtech.ad.dao; import cn.org.rapid_framework.page.Page; import com.common.plugins.myframework.DaoInterface; import com.palmtech.ad.entity.st.StPushApp; import com.palmtech.ad.entity.st.StPushAppQuery; public interface StPushAppDao extends DaoInterface<StPushApp,java.lang.String> { Page<StPushApp> findPage(StPushAppQuery query); }
[ "94391992@qq.com" ]
94391992@qq.com
30034d93ae948b8fce6526168186c8f070dd2381
7a8e18ad7ad1cdc6b3a91ca4ff5d402d0d20be17
/CFT/elasticsearch/c1d44780675a9ff43e87a44f62969a0214928988/TransportAction.java/anc_TransportAction.java
08de1dfc072749945af49c4f0adef084f34099b1
[]
no_license
mandelbrotset/Test
ec5d5ad5b29d28240f6d21073b41ca60070404b1
2a119c9a6077dce184d2edb872489f3f2c5d872e
refs/heads/master
2021-01-21T04:46:42.441186
2016-06-30T15:10:39
2016-06-30T15:10:39
50,836,379
0
0
null
null
null
null
UTF-8
Java
false
false
8,406
java
/* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch 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.elasticsearch.action.support; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskManager; import org.elasticsearch.threadpool.ThreadPool; import java.util.concurrent.atomic.AtomicInteger; import static org.elasticsearch.action.support.PlainActionFuture.newFuture; /** * */ public abstract class TransportAction<Request extends ActionRequest<Request>, Response extends ActionResponse> extends AbstractComponent { protected final ThreadPool threadPool; protected final String actionName; private final ActionFilter[] filters; protected final ParseFieldMatcher parseFieldMatcher; protected final IndexNameExpressionResolver indexNameExpressionResolver; protected final TaskManager taskManager; protected TransportAction(Settings settings, String actionName, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, TaskManager taskManager) { super(settings); this.threadPool = threadPool; this.actionName = actionName; this.filters = actionFilters.filters(); this.parseFieldMatcher = new ParseFieldMatcher(settings); this.indexNameExpressionResolver = indexNameExpressionResolver; this.taskManager = taskManager; } public final ActionFuture<Response> execute(Request request) { PlainActionFuture<Response> future = newFuture(); execute(request, future); return future; } public final Task execute(Request request, ActionListener<Response> listener) { Task task = taskManager.register("transport", actionName, request); if (task == null) { execute(null, request, listener); } else { execute(task, request, new ActionListener<Response>() { @Override public void onResponse(Response response) { taskManager.unregister(task); listener.onResponse(response); } @Override public void onFailure(Throwable e) { taskManager.unregister(task); listener.onFailure(e); } }); } return task; } private final void execute(Task task, Request request, ActionListener<Response> listener) { ActionRequestValidationException validationException = request.validate(); if (validationException != null) { listener.onFailure(validationException); return; } if (filters.length == 0) { try { doExecute(task, request, listener); } catch(Throwable t) { logger.trace("Error during transport action execution.", t); listener.onFailure(t); } } else { RequestFilterChain requestFilterChain = new RequestFilterChain<>(this, logger); requestFilterChain.proceed(task, actionName, request, listener); } } protected void doExecute(Task task, Request request, ActionListener<Response> listener) { doExecute(request, listener); } protected abstract void doExecute(Request request, ActionListener<Response> listener); private static class RequestFilterChain<Request extends ActionRequest<Request>, Response extends ActionResponse> implements ActionFilterChain { private final TransportAction<Request, Response> action; private final AtomicInteger index = new AtomicInteger(); private final ESLogger logger; private RequestFilterChain(TransportAction<Request, Response> action, ESLogger logger) { this.action = action; this.logger = logger; } @Override @SuppressWarnings("unchecked") public void proceed(Task task, String actionName, ActionRequest request, ActionListener listener) { int i = index.getAndIncrement(); try { if (i < this.action.filters.length) { this.action.filters[i].apply(task, actionName, request, listener, this); } else if (i == this.action.filters.length) { this.action.doExecute(task, (Request) request, new FilteredActionListener<Response>(actionName, listener, new ResponseFilterChain(this.action.filters, logger))); } else { listener.onFailure(new IllegalStateException("proceed was called too many times")); } } catch(Throwable t) { logger.trace("Error during transport action execution.", t); listener.onFailure(t); } } @Override public void proceed(String action, ActionResponse response, ActionListener listener) { assert false : "request filter chain should never be called on the response side"; } } private static class ResponseFilterChain implements ActionFilterChain { private final ActionFilter[] filters; private final AtomicInteger index; private final ESLogger logger; private ResponseFilterChain(ActionFilter[] filters, ESLogger logger) { this.filters = filters; this.index = new AtomicInteger(filters.length); this.logger = logger; } @Override public void proceed(Task task, String action, ActionRequest request, ActionListener listener) { assert false : "response filter chain should never be called on the request side"; } @Override @SuppressWarnings("unchecked") public void proceed(String action, ActionResponse response, ActionListener listener) { int i = index.decrementAndGet(); try { if (i >= 0) { filters[i].apply(action, response, listener, this); } else if (i == -1) { listener.onResponse(response); } else { listener.onFailure(new IllegalStateException("proceed was called too many times")); } } catch (Throwable t) { logger.trace("Error during transport action execution.", t); listener.onFailure(t); } } } private static class FilteredActionListener<Response extends ActionResponse> implements ActionListener<Response> { private final String actionName; private final ActionListener listener; private final ResponseFilterChain chain; private FilteredActionListener(String actionName, ActionListener listener, ResponseFilterChain chain) { this.actionName = actionName; this.listener = listener; this.chain = chain; } @Override public void onResponse(Response response) { chain.proceed(actionName, response, listener); } @Override public void onFailure(Throwable e) { listener.onFailure(e); } } }
[ "isak.eriksson@mail.com" ]
isak.eriksson@mail.com
2da40e98004c894a0488b0c6b29a7f7ac0b64d58
4f13f9c4bca764f504a778b26da0fadd2ac3cf38
/src/test/java/RestApi.java
74ea9cdf65b5c9ebcd20181a50d54f3ca0886c8f
[]
no_license
MakmoKGZ/apiWeek2Project
7771cb824a47b693f67e9987180e95ba90871bab
8123135b3f77eda1a5a8f7f5db6ad55f1bcaed56
refs/heads/master
2022-12-23T07:28:58.710300
2020-10-02T22:23:51
2020-10-02T22:23:51
300,746,879
0
1
null
2020-10-02T22:29:25
2020-10-02T22:10:04
Java
UTF-8
Java
false
false
335
java
import java.net.http.HttpResponse; public class RestApi { HttpResponse<String> httpResponse = Unirest.get(“<some_url>/<endpoint>?param1=value1&param2=value2”) .header("header1", header1) .header("header2", header2); .asString(); System.out.println( httpResponse.getHeaders().get("Content-Type")); }
[ "workmakmo@gmail.com" ]
workmakmo@gmail.com
73914a375ab4b66d66bd0536714f4df3ec17cf76
45bcb90c060c335bc18877c6154a158f67967148
/pvmanager/datasource-graphene/src/main/java/org/diirt/datasource/graphene/ScatterGraph2DFunction.java
f6275fe424eb91b6d8afb433c8584cb2ca2eac02
[ "MIT" ]
permissive
gcarcassi/diirt
fee958d4606fe1c619ab28dde2d39bfdb68ccb5f
f2a7caa176f3f76f24c7cfa844029168e9634bb2
refs/heads/master
2020-04-05T22:58:09.892003
2017-06-02T15:23:44
2017-06-02T15:23:44
50,449,601
0
0
null
2016-01-26T18:27:46
2016-01-26T18:27:45
null
UTF-8
Java
false
false
3,338
java
/** * Copyright (C) 2010-14 diirt developers. See COPYRIGHT.TXT * All rights reserved. Use is subject to license terms. See LICENSE.TXT */ package org.diirt.datasource.graphene; import java.awt.image.BufferedImage; import java.util.List; import org.diirt.graphene.Point2DDataset; import org.diirt.graphene.ScatterGraph2DRenderer; import org.diirt.graphene.ScatterGraph2DRendererUpdate; import org.diirt.datasource.QueueCollector; import org.diirt.datasource.ReadFunction; import org.diirt.vtype.VImage; import org.diirt.vtype.VTable; import org.diirt.vtype.ValueUtil; import static org.diirt.datasource.graphene.ArgumentExpressions.*; /** * @author shroffk * */ public class ScatterGraph2DFunction implements ReadFunction<Graph2DResult> { private ReadFunction<? extends VTable> tableData; private ReadFunctionArgument<String> xColumnName; private ReadFunctionArgument<String> yColumnName; private ReadFunctionArgument<String> tooltipColumnName; private ScatterGraph2DRenderer renderer = new ScatterGraph2DRenderer(300, 200); private VImage previousImage; private final QueueCollector<ScatterGraph2DRendererUpdate> rendererUpdateQueue = new QueueCollector<>( 100); public ScatterGraph2DFunction(ReadFunction<?> tableData, ReadFunction<?> xColumnName, ReadFunction<?> yColumnName, ReadFunction<?> tooltipColumnName) { this.tableData = new CheckedReadFunction<>(tableData, "Data", VTable.class); this.xColumnName = stringArgument(xColumnName, "X Column"); this.yColumnName = stringArgument(yColumnName, "Y Column"); this.tooltipColumnName = stringArgument(tooltipColumnName, "Tooltip Column"); } public QueueCollector<ScatterGraph2DRendererUpdate> getRendererUpdateQueue() { return rendererUpdateQueue; } @Override public Graph2DResult readValue() { VTable vTable = tableData.readValue(); xColumnName.readNext(); yColumnName.readNext(); tooltipColumnName.readNext(); // Table and columns must be available if (vTable == null || xColumnName.isMissing() || yColumnName.isMissing()) { return null; } // Prepare new dataset Point2DDataset dataset = DatasetConversions.point2DDatasetFromVTable(vTable, xColumnName.getValue(), yColumnName.getValue()); List<ScatterGraph2DRendererUpdate> updates = rendererUpdateQueue .readValue(); for (ScatterGraph2DRendererUpdate scatterGraph2DRendererUpdate : updates) { renderer.update(scatterGraph2DRendererUpdate); } if (renderer.getImageHeight() == 0 && renderer.getImageWidth() == 0) { return null; } BufferedImage image = new BufferedImage(renderer.getImageWidth(), renderer.getImageHeight(), BufferedImage.TYPE_3BYTE_BGR); renderer.draw(image.createGraphics(), dataset); previousImage = ValueUtil.toVImage(image); return new Graph2DResult(vTable, previousImage, new GraphDataRange(renderer.getXPlotRange(), renderer.getXPlotRange(), renderer.getXAggregatedRange()), new GraphDataRange( renderer.getYPlotRange(), renderer.getYPlotRange(), renderer.getYAggregatedRange()), -1); } }
[ "gabriele.carcassi@gmail.com" ]
gabriele.carcassi@gmail.com
b7011c0f91f87d96bcc756c050579d5d0fdcfe75
95e944448000c08dd3d6915abb468767c9f29d3c
/sources/com/p280ss/android/ugc/aweme/newfollow/p1424vh/UpLoadRecoverItemViewHolder_ViewBinding.java
d18428062eee7fb0bcc5aa5bee1e6f81dc010179
[]
no_license
xrealm/tiktok-src
261b1faaf7b39d64bb7cb4106dc1a35963bd6868
90f305b5f981d39cfb313d75ab231326c9fca597
refs/heads/master
2022-11-12T06:43:07.401661
2020-07-04T20:21:12
2020-07-04T20:21:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,134
java
package com.p280ss.android.ugc.aweme.newfollow.p1424vh; import android.view.View; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import butterknife.Unbinder; import butterknife.internal.Utils; import com.p280ss.android.ugc.aweme.base.p308ui.RemoteImageView; import com.zhiliaoapp.musically.df_live_zego_link.R; /* renamed from: com.ss.android.ugc.aweme.newfollow.vh.UpLoadRecoverItemViewHolder_ViewBinding */ public class UpLoadRecoverItemViewHolder_ViewBinding implements Unbinder { /* renamed from: a */ private UpLoadRecoverItemViewHolder f89378a; public void unbind() { UpLoadRecoverItemViewHolder upLoadRecoverItemViewHolder = this.f89378a; if (upLoadRecoverItemViewHolder != null) { this.f89378a = null; upLoadRecoverItemViewHolder.mCoverImage = null; upLoadRecoverItemViewHolder.mTextView = null; upLoadRecoverItemViewHolder.mProgressBar = null; upLoadRecoverItemViewHolder.mIvClose = null; upLoadRecoverItemViewHolder.mIvRefresh = null; return; } throw new IllegalStateException("Bindings already cleared."); } public UpLoadRecoverItemViewHolder_ViewBinding(UpLoadRecoverItemViewHolder upLoadRecoverItemViewHolder, View view) { this.f89378a = upLoadRecoverItemViewHolder; upLoadRecoverItemViewHolder.mCoverImage = (RemoteImageView) Utils.findRequiredViewAsType(view, R.id.a4j, "field 'mCoverImage'", RemoteImageView.class); upLoadRecoverItemViewHolder.mTextView = (TextView) Utils.findRequiredViewAsType(view, R.id.e8a, "field 'mTextView'", TextView.class); upLoadRecoverItemViewHolder.mProgressBar = (ProgressBar) Utils.findRequiredViewAsType(view, R.id.e8c, "field 'mProgressBar'", ProgressBar.class); upLoadRecoverItemViewHolder.mIvClose = (ImageView) Utils.findRequiredViewAsType(view, R.id.b7g, "field 'mIvClose'", ImageView.class); upLoadRecoverItemViewHolder.mIvRefresh = (ImageView) Utils.findRequiredViewAsType(view, R.id.bbg, "field 'mIvRefresh'", ImageView.class); } }
[ "65450641+Xyzdesk@users.noreply.github.com" ]
65450641+Xyzdesk@users.noreply.github.com
b8a80034452f9be561b8e7e6efeefe3dc75d7515
ff316044df4c523d284f19d5d2bfb546dd43da18
/src/main/java/com/jikexueyuan/demo/springmvc/lesson6/controller/ProductController.java
8e38e1b94433423ec35a94e36af5cf618c3f9e64
[]
no_license
missionagain/FinalExam3
0500321be748fe161b6b9facef617738d9172155
d51bdee67aa30e089155d46be2a5daaac2f3973f
refs/heads/master
2020-06-30T15:02:57.136075
2016-11-21T13:07:27
2016-11-21T13:07:27
74,364,242
0
0
null
null
null
null
UTF-8
Java
false
false
1,408
java
package com.jikexueyuan.demo.springmvc.lesson6.controller; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.jikexueyuan.demo.springmvc.lesson6.dao.ProductDao; import com.jikexueyuan.demo.springmvc.lesson6.entity.Product; import com.jikexueyuan.demo.springmvc.lesson6.entity.User; @Controller public class ProductController { @Resource ProductDao pdtDao; @RequestMapping(value="/editsave") public String saveProduct(@ModelAttribute Product pdt,Model model){ pdtDao.Save(pdt); model.addAttribute("pdt", pdt); List<Product> pdtList=new ArrayList<Product>(); pdtList=pdtDao.searchAll(); model.addAttribute("pdtList", pdtList); User user=new User(); user.setUserName("LEO"); user.setUserType(0); model.addAttribute("user", user); return "index"; } @RequestMapping(value="/show/{id}") public String showProduct(@PathVariable("id")int id,Model model){ Product pdt2=pdtDao.search(id); model.addAttribute("product",pdt2); return "show"; } @RequestMapping(value="/account") public String showAccount(){ return"redirect:/account.html"; } }
[ "weihang0253@163.com" ]
weihang0253@163.com
8b3aee449f3b965b9d5d42a3b2f57a143d4514c0
d45a868d611564fd4c0bab2086ac123c8a9f4946
/src/main/java/com/wishlist/gateway/proxy/filters/PreFilter.java
1c999e72398bd1409b40533e23d0500894d6d5d3
[]
no_license
mailtosunil/wishlist-gateway
9bda1e115c593352646f9af67c69347745659b1a
873180fd482deb635b735118a6e4eaf36ab6cd12
refs/heads/master
2020-04-14T05:27:43.921215
2019-01-02T08:41:30
2019-01-02T08:41:30
163,661,301
0
0
null
null
null
null
UTF-8
Java
false
false
793
java
package com.wishlist.gateway.proxy.filters; import javax.servlet.http.HttpServletRequest; import com.netflix.zuul.ZuulFilter; import com.netflix.zuul.context.RequestContext; import com.netflix.zuul.exception.ZuulException; public class PreFilter extends ZuulFilter { public PreFilter() { } @Override public boolean shouldFilter() { return true; } @Override public Object run() throws ZuulException { RequestContext context = RequestContext.getCurrentContext(); HttpServletRequest request = context.getRequest(); System.out.println( "Request method: " + request.getMethod() + " Request URL: " + request.getRequestURL().toString()); return null; } @Override public String filterType() { return "pre"; } @Override public int filterOrder() { return 1; } }
[ "mailtosunilbehera@gmail.com" ]
mailtosunilbehera@gmail.com
65c4e5383872dce99d14434e278fd5a0a7d20368
d9b077b5e3d6dab3c2ca0c07fe80894985b250af
/core/src/test/java/net/fortress/eventlistener/chain/factory/DefaultContractEventDetailsFactoryTest.java
0fd83bc67342835a6a44853458eede7c70ad95d9
[]
no_license
bydolson/fortress-event-listener
db5fc3254bab0eb410a8744783bccaf77a0e6d01
f4ae34e53e83d01b9aa71c970cf4580c3cda83c8
refs/heads/main
2023-02-01T06:48:36.611589
2020-12-17T08:05:47
2020-12-17T08:05:47
319,055,535
0
0
null
null
null
null
UTF-8
Java
false
false
8,273
java
/* * 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 net.fortress.eventlistener.chain.factory; import net.fortress.eventlistener.chain.converter.EventParameterConverter; import net.fortress.eventlistener.chain.settings.Node; import net.fortress.eventlistener.chain.util.Web3jUtil; import net.fortress.eventlistener.dto.event.ContractEventDetails; import net.fortress.eventlistener.dto.event.ContractEventStatus; import net.fortress.eventlistener.dto.event.filter.ContractEventFilter; import net.fortress.eventlistener.dto.event.filter.ContractEventSpecification; import net.fortress.eventlistener.dto.event.filter.ParameterDefinition; import net.fortress.eventlistener.dto.event.filter.ParameterType; import net.fortress.eventlistener.dto.event.parameter.EventParameter; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.web3j.abi.datatypes.Type; import org.web3j.crypto.Keys; import org.web3j.protocol.core.methods.response.EthBlock; import java.math.BigInteger; import java.util.Arrays; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class DefaultContractEventDetailsFactoryTest { //Values: 123, 0x00a329c0648769a73afac7f9381e08fb43dbea72, -42 private static final String LOG_DATA = "0x000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd6"; //Values: 456 private static final String INDEXED_PARAM = "0x00000000000000000000000000000000000000000000000000000000000001c8"; private static final String CONTRACT_ADDRESS = "0x7a55a28856d43bba3c6a7e36f2cee9a82923e99b"; private static final String EVENT_NAME = "DummyEvent"; private static final String ADDRESS = "0x2250683dbe4e0b90395c3c5d7def87784a2b916c"; private static final BigInteger LOG_INDEX = BigInteger.TEN; private static final String TX_HASH = "0x1fb4a22baf926bd643d796e1332b73452b4eeb1dc6e8be787d4bf54dcccf4485"; private static final BigInteger BLOCK_NUMBER = BigInteger.valueOf(12345); private static final String BLOCK_HASH = "0xf6c7c0822df1bce82b8edf55ab93f2e69ea80ef714801789fae3b3a08f761047"; private static final String NETWORK_NAME = "ThisIsANetworkName"; private DefaultContractEventDetailsFactory underTest; private EventParameterConverter mockParameterCoverter; private org.web3j.protocol.core.methods.response.Log mockLog; private static ContractEventSpecification eventSpec; private ContractEventFilter filter; static { eventSpec = new ContractEventSpecification(); eventSpec.setEventName(EVENT_NAME); eventSpec.setIndexedParameterDefinitions( Arrays.asList(new ParameterDefinition(0, ParameterType.build("UINT256")))); eventSpec.setNonIndexedParameterDefinitions(Arrays.asList( new ParameterDefinition(1, ParameterType.build("UINT256")), new ParameterDefinition(2, ParameterType.build("ADDRESS")), new ParameterDefinition(3, ParameterType.build("INT256")))); } @Before public void init() { mockParameterCoverter = mock(EventParameterConverter.class); mockLog = mock(org.web3j.protocol.core.methods.response.Log.class); when(mockLog.getData()).thenReturn(LOG_DATA); when(mockLog.getTopics()).thenReturn(Arrays.asList(null, INDEXED_PARAM)); when(mockLog.getAddress()).thenReturn(ADDRESS); when(mockLog.getLogIndex()).thenReturn(LOG_INDEX); when(mockLog.getTransactionHash()).thenReturn(TX_HASH); when(mockLog.getBlockNumber()).thenReturn(BLOCK_NUMBER); when(mockLog.getBlockHash()).thenReturn(BLOCK_HASH); filter = new ContractEventFilter(); filter.setContractAddress(CONTRACT_ADDRESS); filter.setEventSpecification(eventSpec); } @Test public void testValuesCorrect() { DefaultContractEventDetailsFactory underTest = createFactory(BigInteger.TEN); final ContractEventDetails eventDetails = underTest.createEventDetails(filter, mockLog); assertEquals(eventDetails.getName(), eventSpec.getEventName()); assertEquals(filter.getId(), eventDetails.getFilterId()); assertEquals(Keys.toChecksumAddress(ADDRESS), eventDetails.getAddress()); assertEquals(LOG_INDEX, eventDetails.getLogIndex()); assertEquals(TX_HASH, eventDetails.getTransactionHash()); assertEquals(BLOCK_NUMBER, eventDetails.getBlockNumber()); assertEquals(BLOCK_HASH, eventDetails.getBlockHash()); assertEquals(Web3jUtil.getSignature(eventSpec), eventDetails.getEventSpecificationSignature()); assertEquals(ContractEventStatus.UNCONFIRMED, eventDetails.getStatus()); assertEquals(NETWORK_NAME,eventDetails.getNetworkName()); } @Test public void testStatusWhenLogRemoved() { when(mockLog.isRemoved()).thenReturn(true); DefaultContractEventDetailsFactory underTest = createFactory(BigInteger.TEN); final ContractEventDetails eventDetails = underTest.createEventDetails(filter, mockLog); assertEquals(ContractEventStatus.INVALIDATED, eventDetails.getStatus()); } @Test public void testStatusWhenZeroConfirmationsConfigured() { DefaultContractEventDetailsFactory underTest = createFactory(BigInteger.ZERO); final ContractEventDetails eventDetails = underTest.createEventDetails(filter, mockLog); assertEquals(ContractEventStatus.CONFIRMED, eventDetails.getStatus()); } @Test public void testIndexedParametersAreCorrect() { final DefaultContractEventDetailsFactory underTest = createFactory(BigInteger.TEN); final EventParameter mockParam1 = mock(EventParameter.class); final ArgumentCaptor<Type> argumentCaptor = ArgumentCaptor.forClass(Type.class); when(mockParameterCoverter.convert(argumentCaptor.capture())).thenReturn(mockParam1); final ContractEventDetails eventDetails = underTest.createEventDetails(filter, mockLog); assertEquals(Arrays.asList(mockParam1), eventDetails.getIndexedParameters()); assertEquals(BigInteger.valueOf(456), argumentCaptor.getAllValues().get(3).getValue()); } @Test public void testNonIndexedParametersAreCorrect() { final DefaultContractEventDetailsFactory underTest = createFactory(BigInteger.TEN); final EventParameter mockParam1 = mock(EventParameter.class); final ArgumentCaptor<Type> argumentCaptor = ArgumentCaptor.forClass(Type.class); when(mockParameterCoverter.convert(argumentCaptor.capture())).thenReturn(mockParam1); final ContractEventDetails eventDetails = underTest.createEventDetails(filter, mockLog); assertEquals(Arrays.asList(mockParam1, mockParam1, mockParam1), eventDetails.getNonIndexedParameters()); assertEquals(BigInteger.valueOf(123), argumentCaptor.getAllValues().get(0).getValue()); assertEquals("0x00a329c0648769a73afac7f9381e08fb43dbea72", argumentCaptor.getAllValues().get(1).toString()); assertEquals(BigInteger.valueOf(-42), argumentCaptor.getAllValues().get(2).getValue()); } private DefaultContractEventDetailsFactory createFactory(BigInteger confirmations) { Node node = new Node(); node.setBlocksToWaitForConfirmation(confirmations); node.setBlocksToWaitForMissingTx(BigInteger.valueOf(100)); node.setBlocksToWaitBeforeInvalidating(BigInteger.valueOf(5)); return new DefaultContractEventDetailsFactory(mockParameterCoverter, node, NETWORK_NAME); } }
[ "canercak@gmail.com" ]
canercak@gmail.com
e81c70491609cd00fa968eb794a5029e3db1516e
a3a7d359877d69c2f0c0800cbefd70abff738ce1
/src/obligatoriodda/dominio/Observer.java
a0951e43ebb4860a2f61415f0b7466e989aa975c
[]
no_license
Tiaghovski/Obg-DDA
a47129aebb041fb2922ee027cc13bbe0a28375bd
31eeed863dfe492c0de584069309b9088d28681f
refs/heads/master
2022-12-31T03:20:42.250029
2020-10-17T02:56:30
2020-10-17T02:56:30
304,784,622
0
0
null
null
null
null
UTF-8
Java
false
false
333
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package obligatoriodda.dominio; /** * * @author alumno */ public interface Observer { void Update(Observable o, Object evento); }
[ "tiagosilva_93@hotmail.es" ]
tiagosilva_93@hotmail.es
a3c8268012161f48f8b0e96c973d292f3b5c9237
e598b7af2153958ccc3162063d071f0f697efbe8
/app/src/main/java/io/andronicus/todomvp/tasks/TasksFilterType.java
a5a83aad17fc9a61ac42482282c5874cbb43297e
[ "Apache-2.0" ]
permissive
andronicus-kim/TodoMVP
141a7921aa737eab363c790e38f157edb6d5735f
05c1e7c102addda3a74c5c0b249e4a8f777fe549
refs/heads/master
2020-03-13T13:56:27.322219
2018-05-02T14:20:44
2018-05-02T14:20:44
131,148,393
0
0
null
2018-04-26T12:11:13
2018-04-26T11:53:25
Java
UTF-8
Java
false
false
669
java
/* * Copyright (C) 2018 Andronicus * * 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 io.andronicus.todomvp.tasks; public enum TasksFilterType { }
[ "androkim.kim7@gmail.com" ]
androkim.kim7@gmail.com
328805ba8761c4a4f46e5ddd31a13ca40be7826c
53e1a48014eed3f5c07ada1e09836d5c54f13857
/yhzh/project/hxpt/Model/src/com/yhzh/biz/impl/DataObjectBizImpl.java
742f352d0f137dea4143173f3ea3d9cb4f7fae17
[]
no_license
yunhuazhihuii/yhzh
64f64758a97a4a721b142f3c6ed8ecbf83979f66
215fd8c956c02a3392d6a8b9d98ad87dafc94afb
refs/heads/master
2020-03-10T01:18:39.036057
2019-04-04T03:12:29
2019-04-04T03:12:29
129,106,198
1
0
null
null
null
null
UTF-8
Java
false
false
5,537
java
package com.yhzh.biz.impl; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import javax.annotation.Resource; import com.yhzh.biz.DataObjectBiz; import com.yhzh.dao.DataObjectDao; import com.yhzh.pojo.S0000002; import com.yhzh.pojo.S1120000; import net.sf.json.JSONObject; public class DataObjectBizImpl implements DataObjectBiz { @Resource DataObjectDao dataObjectDao; @Override public String CreateDataObject(String DataObjectString) { StringBuffer sb = new StringBuffer(); try { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式 String date = df.format(new Date()); // 将字符串转换成json对象 JSONObject jsonObject1 = new JSONObject().fromObject(DataObjectString); S1120000 s1120000 = new S1120000(); s1120000.setF1(jsonObject1.getString("ServerCode")); String F2 = dataObjectDao.AutoGetCode("08");// 查询数据对象编码 s1120000.setF2(F2); s1120000.setF3(jsonObject1.getString("DataObjectName")); s1120000.setF4(jsonObject1.getString("DataObjectDesc")); s1120000.setF5(date); s1120000.setF6("1"); // 更新到s1120000表中 dataObjectDao.insertS1120000(s1120000); // 更新到s0000002表中 S0000002 s0000002 = new S0000002(); s0000002.setF1(jsonObject1.getString("ServerCode"));// 服务编码 s0000002.setF2(F2);// 节点编码 s0000002.setF3(jsonObject1.getString("DataObjectName"));// 节点名称 s0000002.setF4("1120000");// 对象类别 s0000002.setF5("1");// 对象状态 s0000002.setF6(jsonObject1.getString("ParentId"));// 父节点 dataObjectDao.insertS0000002(s0000002); sb.append("{isSuccess:1,"); sb.append("resultMessage:").append("'CreateDataObject success!'").append("}"); } catch (Exception e) { // TODO Auto-generated catch block sb.append("{isSuccess:0,"); sb.append("resultMessage:").append("'CreateDataObject error!'").append(","); sb.append("failMessage:").append('"' + e.toString() + '"').append("}"); e.printStackTrace(); } JSONObject jsonObject = new JSONObject().fromObject(sb.toString()); return jsonObject.toString(); } @Override public String findS1120000ByDataObjectCode(String DataObjectCode) { StringBuffer sb = new StringBuffer(); try { List<Map<String, Object>> findS1120000ByDataObjectCode = dataObjectDao .findS1120000ByDataObjectCode(DataObjectCode); List<Object> list = new ArrayList<Object>(); for (Map<String, Object> map : findS1120000ByDataObjectCode) { String F1 = (String) map.get("F1"); String F2 = (String) map.get("F2"); String F3 = (String) map.get("F3"); String F4 = (String) map.get("F4"); Date F5 = (Date) map.get("F5"); String F6 = (String) map.get("F6"); String string = "{'F1':'" + F1 + "','F2':'" + F2 + "','F3':'" + F3 + "','F4':'" + F4 + "','F5':'" + F5 + "','F6':'" + F6 + "'}"; JSONObject jsonObject = new JSONObject().fromObject(string); list.add(jsonObject); } sb.append("{isSuccess:1,"); sb.append("resultMessage:").append(list).append("}"); } catch (Exception e) { sb.append("{isSuccess:0,"); sb.append("resultMessage:").append("'findS1000000ByServerCode error!'").append(","); sb.append("failMessage:").append('"' + e.toString() + '"').append("}"); e.printStackTrace(); } JSONObject jsonObject = new JSONObject().fromObject(sb.toString()); return jsonObject.toString(); } @Override public String UpdateDataObject(String DataObjectString) { StringBuffer sb = new StringBuffer(); JSONObject jsonObject1 = new JSONObject().fromObject(DataObjectString); try { // 更新S1120000表 S1120000 s1120000 = new S1120000(); s1120000.setF1(jsonObject1.getString("F1")); s1120000.setF2(jsonObject1.getString("F2")); s1120000.setF3(jsonObject1.getString("F3")); s1120000.setF4(jsonObject1.getString("F4")); s1120000.setF5(jsonObject1.getString("F5")); s1120000.setF6(jsonObject1.getString("F6")); dataObjectDao.UpdateDataObject(s1120000); // 更新S0000002表 S0000002 s0000002 = new S0000002(); s0000002.setF2((String) jsonObject1.get("F2"));// 设置编码 s0000002.setF3((String) jsonObject1.get("F3"));// 设置名称 dataObjectDao.updateS0000002(s0000002); sb.append("{isSuccess:1,"); sb.append("resultMessage:").append("'UpdateDataObject success!'").append("}"); } catch (Exception e) { sb.append("{isSuccess:0,"); sb.append("resultMessage:").append("'UpdateDataObject error!'").append(","); sb.append("failMessage:").append('"' + e.toString() + '"').append("}"); e.printStackTrace(); } JSONObject jsonObject = new JSONObject().fromObject(sb.toString()); return jsonObject.toString(); } @Override public String DeleteDataObject(String DataObjectCode) { StringBuffer sb = new StringBuffer(); try { // 先删除子节点 dataObjectDao.deleteS0000002ByCodeSub(DataObjectCode); dataObjectDao.DeleteDataObject(DataObjectCode); dataObjectDao.deleteS0000002ByCode(DataObjectCode); sb.append("{isSuccess:1,"); sb.append("resultMessage:").append("'DeleteDataObject success!'").append("}"); } catch (Exception e) { sb.append("{isSuccess:0,"); sb.append("resultMessage:").append("'DeleteDataObject error!'").append(","); sb.append("failMessage:").append('"' + e.toString() + '"').append("}"); e.printStackTrace(); } JSONObject jsonObject = new JSONObject().fromObject(sb.toString()); return jsonObject.toString(); } }
[ "rookiedream@126.com" ]
rookiedream@126.com
5c3c28328a224f873fc7797f0b5323154e554974
6482753b5eb6357e7fe70e3057195e91682db323
/com/google/common/primitives/Primitives.java
78b5a7e1e631625e868c74fad416541b04a8470c
[]
no_license
TheShermanTanker/Server-1.16.3
45cf9996afa4cd4d8963f8fd0588ae4ee9dca93c
48cc08cb94c3094ebddb6ccfb4ea25538492bebf
refs/heads/master
2022-12-19T02:20:01.786819
2020-09-18T21:29:40
2020-09-18T21:29:40
296,730,962
0
1
null
null
null
null
UTF-8
Java
false
false
2,654
java
package com.google.common.primitives; import java.util.Collections; import java.util.HashMap; import com.google.common.base.Preconditions; import java.util.Set; import java.util.Map; import com.google.common.annotations.GwtIncompatible; @GwtIncompatible public final class Primitives { private static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_TYPE; private static final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE_TYPE; private Primitives() { } private static void add(final Map<Class<?>, Class<?>> forward, final Map<Class<?>, Class<?>> backward, final Class<?> key, final Class<?> value) { forward.put(key, value); backward.put(value, key); } public static Set<Class<?>> allPrimitiveTypes() { return (Set<Class<?>>)Primitives.PRIMITIVE_TO_WRAPPER_TYPE.keySet(); } public static Set<Class<?>> allWrapperTypes() { return (Set<Class<?>>)Primitives.WRAPPER_TO_PRIMITIVE_TYPE.keySet(); } public static boolean isWrapperType(final Class<?> type) { return Primitives.WRAPPER_TO_PRIMITIVE_TYPE.containsKey(Preconditions.<Class<?>>checkNotNull(type)); } public static <T> Class<T> wrap(final Class<T> type) { Preconditions.<Class<T>>checkNotNull(type); final Class<T> wrapped = (Class<T>)Primitives.PRIMITIVE_TO_WRAPPER_TYPE.get(type); return (wrapped == null) ? type : wrapped; } public static <T> Class<T> unwrap(final Class<T> type) { Preconditions.<Class<T>>checkNotNull(type); final Class<T> unwrapped = (Class<T>)Primitives.WRAPPER_TO_PRIMITIVE_TYPE.get(type); return (unwrapped == null) ? type : unwrapped; } static { final Map<Class<?>, Class<?>> primToWrap = (Map<Class<?>, Class<?>>)new HashMap(16); final Map<Class<?>, Class<?>> wrapToPrim = (Map<Class<?>, Class<?>>)new HashMap(16); add(primToWrap, wrapToPrim, Boolean.TYPE, Boolean.class); add(primToWrap, wrapToPrim, Byte.TYPE, Byte.class); add(primToWrap, wrapToPrim, Character.TYPE, Character.class); add(primToWrap, wrapToPrim, Double.TYPE, Double.class); add(primToWrap, wrapToPrim, Float.TYPE, Float.class); add(primToWrap, wrapToPrim, Integer.TYPE, Integer.class); add(primToWrap, wrapToPrim, Long.TYPE, Long.class); add(primToWrap, wrapToPrim, Short.TYPE, Short.class); add(primToWrap, wrapToPrim, Void.TYPE, Void.class); PRIMITIVE_TO_WRAPPER_TYPE = Collections.unmodifiableMap((Map)primToWrap); WRAPPER_TO_PRIMITIVE_TYPE = Collections.unmodifiableMap((Map)wrapToPrim); } }
[ "tanksherman27@gmail.com" ]
tanksherman27@gmail.com
628d58ffa8436d7198b3c9fbd9ee8dbc594b747b
30262e2c47316143de877ea797702cbe98b6eca3
/chess-demo/src/main/java/com/len/chessdemo/elements/Tile.java
ac3c225c99052d11cacae4828d9715508ffc32ee
[]
no_license
lennemo09/chess-engine-spring
5bb7f1e00292eb671ffcaad434f04ac6fb65e004
36e015d65a81a943fab80a803ca6883d1693cc7d
refs/heads/main
2023-03-13T09:40:45.462402
2021-03-04T08:05:10
2021-03-04T08:05:10
344,359,516
0
0
null
null
null
null
UTF-8
Java
false
false
522
java
package com.len.chessdemo.elements; import com.len.chessdemo.utils.Position; public class Tile { private Piece piece; private Position pos; public Tile(Position pos, Piece piece) { this.setPiece(piece); this.setPos(pos); } public Piece getPiece() { return piece; } public void setPiece(Piece piece) { this.piece = piece; } public Position getPos() { return pos; } public void setPos(Position pos) { this.pos = pos; } }
[ "leluong@deloitte.com.au" ]
leluong@deloitte.com.au
864abccdcb53e4b2fff6c58ca51385beb224541f
18e42a09d7f5dacc1bbeeae4c22284c60cc88b1f
/xstream/src/test/com/thoughtworks/acceptance/ConcurrentTypesTest.java
0d6d16246fe57213b571a2faa77ac32d0d678ee7
[ "BSD-3-Clause" ]
permissive
x-stream/xstream
ab7f586f1d682902bbf96f3be2b953df98ff32c3
289ae780001c31d7d5d75e0d58608c13f44549a2
refs/heads/master
2023-08-30T19:33:58.497180
2023-04-22T16:03:39
2023-04-22T16:03:39
32,219,624
818
270
NOASSERTION
2023-05-02T23:36:09
2015-03-14T15:57:12
Java
UTF-8
Java
false
false
5,549
java
/* * Copyright (C) 2012, 2015, 2017, 2018, 2021, 2022 XStream Committers. * All rights reserved. * * The software in this package is published under the terms of the BSD * style license a copy of which has been included with this distribution in * the LICENSE.txt file. * * Created on 17. July 2018 by Joerg Schaible, renamed from Concurrent15TypesTest */ package com.thoughtworks.acceptance; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import com.thoughtworks.acceptance.objects.Original; import com.thoughtworks.acceptance.objects.Replaced; import com.thoughtworks.xstream.converters.collections.MapConverter; public class ConcurrentTypesTest extends AbstractAcceptanceTest { public void testConcurrentHashMap() { final ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>(); map.put("walnes", "joe"); final String xml = xstream.toXML(map); final String expected = "" + "<concurrent-hash-map>\n" + " <entry>\n" + " <string>walnes</string>\n" + " <string>joe</string>\n" + " </entry>\n" + "</concurrent-hash-map>"; assertEquals(xml, expected); final ConcurrentHashMap<String, String> out = xstream.fromXML(xml); assertEquals("{walnes=joe}", out.toString()); } public static class DerivedConcurrentHashMap extends ConcurrentHashMap<Object, Object> { private static final long serialVersionUID = 1L; } public void testDerivedConcurrentHashMap() { xstream.alias("derived-map", DerivedConcurrentHashMap.class); xstream.registerConverter(new MapConverter(xstream.getMapper(), DerivedConcurrentHashMap.class)); final Map<Object, Object> map = new DerivedConcurrentHashMap(); map.put("test", "JUnit"); final String xml = "" + "<derived-map>\n" + " <entry>\n" + " <string>test</string>\n" + " <string>JUnit</string>\n" + " </entry>\n" + "</derived-map>"; assertBothWays(map, xml); } public void testAtomicBoolean() { final AtomicBoolean atomicBoolean = new AtomicBoolean(); assertBothWays(atomicBoolean, "<atomic-boolean>" + atomicBoolean + "</atomic-boolean>"); } public void testAtomicBooleanWithOldFormat() { assertEquals(new AtomicBoolean(true).toString(), xstream.fromXML("" // + "<java.util.concurrent.atomic.AtomicBoolean>\n" // + " <value>1</value>\n" // + "</java.util.concurrent.atomic.AtomicBoolean>").toString()); } public void testAtomicInteger() { final AtomicInteger atomicInteger = new AtomicInteger(42); assertBothWays(atomicInteger, "<atomic-int>" + atomicInteger + "</atomic-int>"); } public void testAtomicIntegerWithOldFormat() { assertEquals(new AtomicInteger(42).toString(), xstream.fromXML("" // + "<java.util.concurrent.atomic.AtomicInteger>\n" // + " <value>42</value>\n" // + "</java.util.concurrent.atomic.AtomicInteger>").toString()); } public void testAtomicLong() { final AtomicLong atomicLong = new AtomicLong(42); assertBothWays(atomicLong, "<atomic-long>" + atomicLong + "</atomic-long>"); } public void testAtomicLongWithOldFormat() { assertEquals(new AtomicInteger(42).toString(), xstream.fromXML("" // + "<java.util.concurrent.atomic.AtomicLong>\n" // + " <value>42</value>\n" // + "</java.util.concurrent.atomic.AtomicLong>").toString()); } public void testAtomicReference() { final AtomicReference<String> atomicRef = new AtomicReference<>("test"); assertBothWays(atomicRef, ("" // + "<atomic-reference>\n" // + " <value class='string'>test</value>\n" // + "</atomic-reference>").replace('\'', '"')); } @SuppressWarnings("unchecked") public void testAtomicReferenceWithOldFormat() { assertEquals(new AtomicReference<String>("test").get(), ((AtomicReference<String>)xstream.fromXML("" // + "<java.util.concurrent.atomic.AtomicReference>\n" // + " <value class='string'>test</value>\n" // + "</java.util.concurrent.atomic.AtomicReference>")).get()); } public void testAtomicReferenceWithAlias() { xstream.aliasField("junit", AtomicReference.class, "value"); final AtomicReference<String> atomicRef = new AtomicReference<>("test"); assertBothWays(atomicRef, ("" // + "<atomic-reference>\n" // + " <junit class='string'>test</junit>\n" // + "</atomic-reference>").replace('\'', '"')); } public void testAtomicReferenceWithReplaced() { xstream.alias("original", Original.class); xstream.alias("replaced", Replaced.class); final AtomicReference<Original> atomicRef = new AtomicReference<>(new Original("test")); assertBothWays(atomicRef, ("" // + "<atomic-reference>\n" // + " <value class='original' resolves-to='replaced'>\n" + " <replacedValue>TEST</replacedValue>\n" + " </value>\n" // + "</atomic-reference>").replace('\'', '"')); } }
[ "joerg.schaible@gmx.de" ]
joerg.schaible@gmx.de
711c387d252a7454873676228b57d301ded5b2c7
171d3f42ea5a5bd582d7d67593fbb2e093ae3fb2
/app/src/main/java/com/example/antonsskafferiapplication/OrderData.java
ae825c0a5aafbe08a1b15930419d2452cd1fae93
[]
no_license
antons-skafferi/application
086302771a15e65c713d1008abc9d6cb2ba64115
52ceaf437a9fccbf0ceb70a7de19625be7528dbe
refs/heads/master
2020-04-23T16:50:56.452415
2019-03-19T08:27:49
2019-03-19T08:27:49
171,312,106
0
0
null
2019-02-18T20:40:20
2019-02-18T15:52:30
null
UTF-8
Java
false
false
898
java
package com.example.antonsskafferiapplication; import android.util.Pair; import java.util.ArrayList; public class OrderData { /*Is used in kitchenActivity to load complete orders from the database*/ private String tableNumber; private String note; private ArrayList<OrderDetails> orders; public OrderData(String t){ orders = new ArrayList<>(); tableNumber = t; } public void addOrder(String orderName, String amount, String dateTime, String orderId){ OrderDetails orderDet = new OrderDetails(orderName, amount, dateTime, orderId); orders.add(orderDet); } public void setNote(String n){ note = n; } public String getNotes(){ return note; } public String getTableNumber(){ return tableNumber; } public ArrayList<OrderDetails> getItems(){ return orders; } }
[ "eliasaxel.fredin@gmail.com" ]
eliasaxel.fredin@gmail.com
11aaa8936d54eca37596c252a18debf47e01ed17
91bd01ee4348d016cbc4a45b661ffda10007379d
/Comp-Graf/lib/gluegen-java-src/com/jogamp/common/util/IntegerStack.java
233b321909b67c56a3401a54b6029f2ba87203e9
[]
no_license
Paesdb/Comp-Graf
cac930256d5ecdfcad7b4c25207e28f4e5f07f19
4c7e12fa212f3839d059445b0fddb7216ec84240
refs/heads/master
2021-01-18T15:34:52.194599
2017-03-16T19:55:46
2017-03-16T19:55:46
84,346,162
1
1
null
null
null
null
UTF-8
Java
false
false
6,674
java
/** * Copyright 2012 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ package com.jogamp.common.util; import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; import java.nio.IntBuffer; /** * Simple primitive-type stack. * <p> * Implemented operations: * <ul> * <li>FILO - First In, Last Out</li> * </ul> * </p> */ public class /*name*/IntegerStack/*name*/ implements PrimitiveStack { private int position; private int[] buffer; private int growSize; /** * @param initialSize initial size, must be &gt; zero * @param growSize grow size if {@link #position()} is reached, maybe <code>0</code> * in which case an {@link IndexOutOfBoundsException} is thrown. */ public /*name*/IntegerStack/*name*/(final int initialSize, final int growSize) { this.position = 0; this.growSize = growSize; this.buffer = new int[initialSize]; } @Override public final int capacity() { return buffer.length; } @Override public final int position() { return position; } @Override public final void position(final int newPosition) throws IndexOutOfBoundsException { if( 0 > position || position >= buffer.length ) { throw new IndexOutOfBoundsException("Invalid new position "+newPosition+", "+this.toString()); } position = newPosition; } @Override public final int remaining() { return buffer.length - position; } @Override public final int getGrowSize() { return growSize; } @Override public final void setGrowSize(final int newGrowSize) { growSize = newGrowSize; } @Override public final String toString() { return "IntegerStack[0..(pos "+position+").."+buffer.length+", remaining "+remaining()+"]"; } public final int[] buffer() { return buffer; } private final void growIfNecessary(final int length) throws IndexOutOfBoundsException { if( position + length > buffer.length ) { if( 0 >= growSize ) { throw new IndexOutOfBoundsException("Out of fixed stack size: "+this); } final int[] newBuffer = new int[buffer.length + growSize]; System.arraycopy(buffer, 0, newBuffer, 0, position); buffer = newBuffer; } } /** * FILO put operation * * @param src source buffer * @param srcOffset offset of src * @param length number of float elements to put from <code>src</code> on-top this stack * @return the src float[] * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size or offset+length exceeds src. */ public final int[] putOnTop(final int[] src, final int srcOffset, final int length) throws IndexOutOfBoundsException { growIfNecessary(length); System.arraycopy(src, srcOffset, buffer, position, length); position += length; return src; } /** * FILO put operation * * @param src source buffer, it's position is incremented by <code>length</code> * @param length number of float elements to put from <code>src</code> on-top this stack * @return the src FloatBuffer * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size * @throws BufferUnderflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ public final IntBuffer putOnTop(final IntBuffer src, final int length) throws IndexOutOfBoundsException, BufferUnderflowException { growIfNecessary(length); src.get(buffer, position, length); position += length; return src; } /** * FILO get operation * * @param dest destination buffer * @param destOffset offset of dest * @param length number of float elements to get from-top this stack to <code>dest</code>. * @return the dest float[] * @throws IndexOutOfBoundsException if stack or <code>dest</code> has less elements than <code>length</code>. */ public final int[] getFromTop(final int[] dest, final int destOffset, final int length) throws IndexOutOfBoundsException { System.arraycopy(buffer, position-length, dest, destOffset, length); position -= length; return dest; } /** * FILO get operation * * @param dest destination buffer, it's position is incremented by <code>length</code>. * @param length number of float elements to get from-top this stack to <code>dest</code>. * @return the dest FloatBuffer * @throws IndexOutOfBoundsException if stack has less elements than length * @throws BufferOverflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ public final IntBuffer getFromTop(final IntBuffer dest, final int length) throws IndexOutOfBoundsException, BufferOverflowException { dest.put(buffer, position-length, length); position -= length; return dest; } }
[ "jeanortiz14@gmail.com" ]
jeanortiz14@gmail.com
35a081963ee4aa32bfb4447ea8b6ef5d3d51cf9b
9127f9dcf78802d3838fb75b70b7f5a06970a5db
/Java/Labs/Labs_OOP/Lab 6/src/src/ru/mirea/lab6/_1/Blackmirror.java
313219c2d83cd0cdcc87779e356ff2df19c5fa97
[]
no_license
Destinyr4zr/4sem
1d725e49222495876f8688073bb5410106c27cec
897cb97b6b446c7b131f5527a617db5f29887ec5
refs/heads/master
2021-04-20T14:01:50.403566
2020-03-24T13:19:04
2020-03-24T13:19:04
249,689,974
0
0
null
null
null
null
UTF-8
Java
false
false
179
java
package src.ru.mirea.lab6._1; public class Blackmirror { public static void main(String[] args){ Game message = new Game(); message.setVisible(true); } }
[ "pristine.kirill@gmail.com" ]
pristine.kirill@gmail.com
2ce70d95a5717116c9741a3113dbc456466caf2a
9e17f7ee73285dba2deb0a8c321973e28f33ae3a
/STACK_2018/src/ds/stack/Stack.java
64d4efa24af0fb0e89f4408f17b136606d1b0eb6
[]
no_license
anariky1/DataStrucure
fe12326f4f56ce977425a65061ce4abf4ebc18da
3160fa17b4f470bd99ca9242ee80ce39782b5a20
refs/heads/master
2020-03-28T21:43:23.292153
2018-09-17T19:29:25
2018-09-17T19:29:25
149,176,850
0
0
null
null
null
null
UTF-8
Java
false
false
892
java
package ds.stack; public class Stack { private int maxsize; //size the stack private long[] stackArray; //container storing list of items private int top; //represent the index position of last item public Stack(int maxsize){ this.maxsize=maxsize; this.stackArray=new long[maxsize]; this.top=-1; } public void push(long j){ if(isFull()){ System.out.println(" the stack is already full"); }else{ top++; stackArray[top]=j; } } public long pop(){ if(isEmpty()){ System.out.println("the stack is already empty"); return -1; }else{ int old_top=top; top--; return stackArray[old_top]; //we are not removing , we are shifting the top index to the below one. } } public long peak(){ return stackArray[top]; } public boolean isEmpty(){ return(top==-1); } public boolean isFull(){ return (maxsize-1==top); } }
[ "ananthgithub@gmail.com" ]
ananthgithub@gmail.com
3e85691ffccd5fa74dbb4b18bcf234c3ec1dbf92
3841f7991232e02c850b7e2ff6e02712e9128b17
/小浪底泥沙三维/EV_Xld/jni/src/JAVA/EV_Spatial3DDatasetWrapper/src/com/earthview/world/spatial3d/dataset/ModelCacheUtility.java
ce542c4b68ad673114f0f5d4d0d93ee522925c30
[]
no_license
15831944/BeijingEVProjects
62bf734f1cb0a8be6fed42cf6b207f9dbdf99e71
3b5fa4c4889557008529958fc7cb51927259f66e
refs/heads/master
2021-07-22T14:12:15.106616
2017-10-15T11:33:06
2017-10-15T11:33:06
null
0
0
null
null
null
null
UTF-8
Java
false
false
25,023
java
package com.earthview.world.spatial3d.dataset; import global.*; import com.earthview.world.base.*; import com.earthview.world.util.*; import com.earthview.world.core.*; public class ModelCacheUtility extends com.earthview.world.core.AllocatedObject { static { GlobalClassFactoryMap.put("EarthView::World::Spatial3D::Dataset::CModelCacheUtility", new ModelCacheUtilityClassFactory()); } public ModelCacheUtility() { super(CreatedWhenConstruct.CWC_NotToCreate); Create("CModelCacheUtility", null); } native private static boolean clearDataset_EVString_EVString_ev_bool(String datasourceName, String datasetName, boolean bTemplDataset); /** * 清除数据集缓存 * @param datasourceName 数据源名 * @param datasetName 数据集名 */ public static boolean clearDataset(String datasourceName, String datasetName, boolean bTemplDataset) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; boolean bTemplDatasetParamValue = bTemplDataset; boolean returnValue = clearDataset_EVString_EVString_ev_bool(datasourceNameParamValue, datasetNameParamValue, bTemplDatasetParamValue); return returnValue; } native private static boolean writeDatasetModel_EVString_EVString_EVString_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(String datasourceName, String datasetName, String octCode, long pMeshFeature, long thumbTextures, long origTextures, long cubeTextures, long materials, long progs, long gpus, long skeletons, long animation); /** * 缓存实体数据集模型 * @param */ public static boolean writeDatasetModel(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial.geodataset.Ifeature pMeshFeature, com.earthview.world.spatial3d.dataset.FeatureVector thumbTextures, com.earthview.world.spatial3d.dataset.FeatureVector origTextures, com.earthview.world.spatial3d.dataset.FeatureVector cubeTextures, com.earthview.world.spatial3d.dataset.FeatureVector materials, com.earthview.world.spatial3d.dataset.FeatureVector progs, com.earthview.world.spatial3d.dataset.FeatureVector gpus, com.earthview.world.spatial3d.dataset.FeatureVector skeletons, com.earthview.world.spatial3d.dataset.FeatureVector animation) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long pMeshFeatureParamValue = (pMeshFeature == null ? 0L : pMeshFeature.nativeObject.pointer); long thumbTexturesParamValue = thumbTextures.nativeObject.pointer; long origTexturesParamValue = origTextures.nativeObject.pointer; long cubeTexturesParamValue = cubeTextures.nativeObject.pointer; long materialsParamValue = materials.nativeObject.pointer; long progsParamValue = progs.nativeObject.pointer; long gpusParamValue = gpus.nativeObject.pointer; long skeletonsParamValue = skeletons.nativeObject.pointer; long animationParamValue = animation.nativeObject.pointer; boolean returnValue = writeDatasetModel_EVString_EVString_EVString_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, pMeshFeatureParamValue, thumbTexturesParamValue, origTexturesParamValue, cubeTexturesParamValue, materialsParamValue, progsParamValue, gpusParamValue, skeletonsParamValue, animationParamValue); return returnValue; } native private static boolean writeTemplDBModel_EVString_EVString_EVString_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(String datasourceName, String datasetName, String octCode, long pMeshFeature, long thumbTextures, long origTextures, long cubeTextures, long materials, long progs, long gpus, long skeletons, long animation); /** * 缓存实体模型库数据集模型 * @param */ public static boolean writeTemplDBModel(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial.geodataset.Ifeature pMeshFeature, com.earthview.world.spatial3d.dataset.FeatureVector thumbTextures, com.earthview.world.spatial3d.dataset.FeatureVector origTextures, com.earthview.world.spatial3d.dataset.FeatureVector cubeTextures, com.earthview.world.spatial3d.dataset.FeatureVector materials, com.earthview.world.spatial3d.dataset.FeatureVector progs, com.earthview.world.spatial3d.dataset.FeatureVector gpus, com.earthview.world.spatial3d.dataset.FeatureVector skeletons, com.earthview.world.spatial3d.dataset.FeatureVector animation) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long pMeshFeatureParamValue = (pMeshFeature == null ? 0L : pMeshFeature.nativeObject.pointer); long thumbTexturesParamValue = thumbTextures.nativeObject.pointer; long origTexturesParamValue = origTextures.nativeObject.pointer; long cubeTexturesParamValue = cubeTextures.nativeObject.pointer; long materialsParamValue = materials.nativeObject.pointer; long progsParamValue = progs.nativeObject.pointer; long gpusParamValue = gpus.nativeObject.pointer; long skeletonsParamValue = skeletons.nativeObject.pointer; long animationParamValue = animation.nativeObject.pointer; boolean returnValue = writeTemplDBModel_EVString_EVString_EVString_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, pMeshFeatureParamValue, thumbTexturesParamValue, origTexturesParamValue, cubeTexturesParamValue, materialsParamValue, progsParamValue, gpusParamValue, skeletonsParamValue, animationParamValue); return returnValue; } native private static boolean writeTemplEntity_EVString_EVString_EVString_IFeature(String datasourceName, String datasetName, String code, long pMeshFeature); /** * 缓存模型库模型 * @param */ public static boolean writeTemplEntity(String datasourceName, String datasetName, String code, com.earthview.world.spatial.geodataset.Ifeature pMeshFeature) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String codeParamValue = code; long pMeshFeatureParamValue = (pMeshFeature == null ? 0L : pMeshFeature.nativeObject.pointer); boolean returnValue = writeTemplEntity_EVString_EVString_EVString_IFeature(datasourceNameParamValue, datasetNameParamValue, codeParamValue, pMeshFeatureParamValue); return returnValue; } native private static boolean deleteDatasetModel_EVString_EVString_EVString_ev_uint32(String datasourceName, String datasetName, String octCode, long id); /** * 删除实体数据集模型 * @param */ public static boolean deleteDatasetModel(String datasourceName, String datasetName, String octCode, long id) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long idParamValue = id; boolean returnValue = deleteDatasetModel_EVString_EVString_EVString_ev_uint32(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, idParamValue); return returnValue; } native private static boolean deleteTemplDBModel_EVString_EVString_EVString_ev_uint32(String datasourceName, String datasetName, String octCode, long id); /** * 删除实体模型库数据集模型 * @param */ public static boolean deleteTemplDBModel(String datasourceName, String datasetName, String octCode, long id) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long idParamValue = id; boolean returnValue = deleteTemplDBModel_EVString_EVString_EVString_ev_uint32(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, idParamValue); return returnValue; } native private static boolean deleteTemplEntity_EVString_EVString_ev_uint32(String datasourceName, String datasetName, long id); /** * 删除模型库模型 * @param */ public static boolean deleteTemplEntity(String datasourceName, String datasetName, long id) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; long idParamValue = id; boolean returnValue = deleteTemplEntity_EVString_EVString_ev_uint32(datasourceNameParamValue, datasetNameParamValue, idParamValue); return returnValue; } native private static boolean updateDatasetEntityInfo_EVString_EVString_EVString_IFeature(String datasourceName, String datasetName, String octCode, long pMeshFeature); /** * 更新实体数据集场景信息 * @param */ public static boolean updateDatasetEntityInfo(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial.geodataset.Ifeature pMeshFeature) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long pMeshFeatureParamValue = (pMeshFeature == null ? 0L : pMeshFeature.nativeObject.pointer); boolean returnValue = updateDatasetEntityInfo_EVString_EVString_EVString_IFeature(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, pMeshFeatureParamValue); return returnValue; } native private static boolean updateTemplDatasetEntityInfo_EVString_EVString_EVString_IFeature(String datasourceName, String datasetName, String octCode, long pMeshFeature); /** * 更新模板数据集场景信息 * @param */ public static boolean updateTemplDatasetEntityInfo(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial.geodataset.Ifeature pMeshFeature) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long pMeshFeatureParamValue = (pMeshFeature == null ? 0L : pMeshFeature.nativeObject.pointer); boolean returnValue = updateTemplDatasetEntityInfo_EVString_EVString_EVString_IFeature(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, pMeshFeatureParamValue); return returnValue; } native private static boolean updateTemplDBInfo_EVString_EVString_IFeature(String datasourceName, String datasetName, long pMeshFeature); /** * 更新模板库基础信息 * @param */ public static boolean updateTemplDBInfo(String datasourceName, String datasetName, com.earthview.world.spatial.geodataset.Ifeature pMeshFeature) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; long pMeshFeatureParamValue = (pMeshFeature == null ? 0L : pMeshFeature.nativeObject.pointer); boolean returnValue = updateTemplDBInfo_EVString_EVString_IFeature(datasourceNameParamValue, datasetNameParamValue, pMeshFeatureParamValue); return returnValue; } native private static boolean readDatasetModel_CEntityDataset_EVString_ev_uint32_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(long pDataset, String octCode, long id, long pMeshFeature, long thumbTextures, long origTextures, long cubeTextures, long materials, long progs, long gpus, long skeletons, long animation); /** * 读取实体数据集模型 * @param */ public static boolean readDatasetModel(com.earthview.world.spatial3d.dataset.EntityDataset pDataset, String octCode, long id, NativeObjectPointer<com.earthview.world.spatial.geodataset.Ifeature> pMeshFeature, com.earthview.world.spatial3d.dataset.FeatureVector thumbTextures, com.earthview.world.spatial3d.dataset.FeatureVector origTextures, com.earthview.world.spatial3d.dataset.FeatureVector cubeTextures, com.earthview.world.spatial3d.dataset.FeatureVector materials, com.earthview.world.spatial3d.dataset.FeatureVector progs, com.earthview.world.spatial3d.dataset.FeatureVector gpus, com.earthview.world.spatial3d.dataset.FeatureVector skeletons, com.earthview.world.spatial3d.dataset.FeatureVector animation) { long pDatasetParamValue = (pDataset == null ? 0L : pDataset.nativeObject.pointer); String octCodeParamValue = octCode; long idParamValue = id; long pMeshFeatureParamValue = pMeshFeature.nativeObject.pointer; long thumbTexturesParamValue = thumbTextures.nativeObject.pointer; long origTexturesParamValue = origTextures.nativeObject.pointer; long cubeTexturesParamValue = cubeTextures.nativeObject.pointer; long materialsParamValue = materials.nativeObject.pointer; long progsParamValue = progs.nativeObject.pointer; long gpusParamValue = gpus.nativeObject.pointer; long skeletonsParamValue = skeletons.nativeObject.pointer; long animationParamValue = animation.nativeObject.pointer; boolean returnValue = readDatasetModel_CEntityDataset_EVString_ev_uint32_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(pDatasetParamValue, octCodeParamValue, idParamValue, pMeshFeatureParamValue, thumbTexturesParamValue, origTexturesParamValue, cubeTexturesParamValue, materialsParamValue, progsParamValue, gpusParamValue, skeletonsParamValue, animationParamValue); return returnValue; } native private static boolean readTemplDBModel_CMeshTemplateDataset_EVString_EVString_EVString_ev_uint32_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(long pDataset, String datasourceName, String datasetName, String octCode, long id, long pMeshFeature, long thumbTextures, long origTextures, long cubeTextures, long materials, long progs, long gpus, long skeletons, long animatio); /** * 读取实体模型库数据集模型 * @param */ public static boolean readTemplDBModel(com.earthview.world.spatial3d.dataset.MeshTemplateDataset pDataset, String datasourceName, String datasetName, String octCode, long id, NativeObjectPointer<com.earthview.world.spatial.geodataset.Ifeature> pMeshFeature, com.earthview.world.spatial3d.dataset.FeatureVector thumbTextures, com.earthview.world.spatial3d.dataset.FeatureVector origTextures, com.earthview.world.spatial3d.dataset.FeatureVector cubeTextures, com.earthview.world.spatial3d.dataset.FeatureVector materials, com.earthview.world.spatial3d.dataset.FeatureVector progs, com.earthview.world.spatial3d.dataset.FeatureVector gpus, com.earthview.world.spatial3d.dataset.FeatureVector skeletons, com.earthview.world.spatial3d.dataset.FeatureVector animatio) { long pDatasetParamValue = (pDataset == null ? 0L : pDataset.nativeObject.pointer); String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long idParamValue = id; long pMeshFeatureParamValue = pMeshFeature.nativeObject.pointer; long thumbTexturesParamValue = thumbTextures.nativeObject.pointer; long origTexturesParamValue = origTextures.nativeObject.pointer; long cubeTexturesParamValue = cubeTextures.nativeObject.pointer; long materialsParamValue = materials.nativeObject.pointer; long progsParamValue = progs.nativeObject.pointer; long gpusParamValue = gpus.nativeObject.pointer; long skeletonsParamValue = skeletons.nativeObject.pointer; long animatioParamValue = animatio.nativeObject.pointer; boolean returnValue = readTemplDBModel_CMeshTemplateDataset_EVString_EVString_EVString_ev_uint32_IFeature_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector_FeatureVector(pDatasetParamValue, datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, idParamValue, pMeshFeatureParamValue, thumbTexturesParamValue, origTexturesParamValue, cubeTexturesParamValue, materialsParamValue, progsParamValue, gpusParamValue, skeletonsParamValue, animatioParamValue); return returnValue; } native private static long readTemplEntity_CEntityDataset_ev_uint32_EVString(long pDataset, long id, String code); /** * 读取模型库模型 * @param */ public static com.earthview.world.spatial.geodataset.Ifeature readTemplEntity(com.earthview.world.spatial3d.dataset.EntityDataset pDataset, long id, String code) { long pDatasetParamValue = (pDataset == null ? 0L : pDataset.nativeObject.pointer); long idParamValue = id; String codeParamValue = code; long returnValue = readTemplEntity_CEntityDataset_ev_uint32_EVString(pDatasetParamValue, idParamValue, codeParamValue); if(returnValue == 0L) { return null; } com.earthview.world.spatial.geodataset.Ifeature __returnValue = new com.earthview.world.spatial.geodataset.Ifeature(CreatedWhenConstruct.CWC_NotToCreate, "IFeature"); __returnValue.setDelegate(true); InstancePointer __instancePointer = new InstancePointer(returnValue); __returnValue.setInstancePointer(__instancePointer); IClassFactory __returnValueClassFactory = GlobalClassFactoryMap.get(__returnValue.getCppInstanceTypeName()); if (__returnValueClassFactory != null) { __returnValue.setDelegate(true); __returnValue = (com.earthview.world.spatial.geodataset.Ifeature)__returnValueClassFactory.create(); __returnValue.setDelegate(true); __returnValue.bindNativeObject(__instancePointer, "IFeature"); } return __returnValue; } native private static boolean readDatasetModelOrigTexture_EVString_EVString_EVString_FeatureVector_TextureStreamVector(String datasourceName, String datasetName, String octCode, long origFeatureVec, long imgTextures); /** * 读取实体数据集模型的大纹理 * @param */ public static boolean readDatasetModelOrigTexture(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial3d.dataset.FeatureVector origFeatureVec, com.earthview.world.spatial3d.dataset.TextureStreamVector imgTextures) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long origFeatureVecParamValue = origFeatureVec.nativeObject.pointer; long imgTexturesParamValue = imgTextures.nativeObject.pointer; boolean returnValue = readDatasetModelOrigTexture_EVString_EVString_EVString_FeatureVector_TextureStreamVector(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, origFeatureVecParamValue, imgTexturesParamValue); return returnValue; } native private static boolean readTemplDatasetOrigTexture_EVString_EVString_EVString_FeatureVector_TextureStreamVector(String datasourceName, String datasetName, String octCode, long origFeatureVec, long texStreams); /** * 读取实体模型库数据集模型的大纹理 * @param */ public static boolean readTemplDatasetOrigTexture(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial3d.dataset.FeatureVector origFeatureVec, com.earthview.world.spatial3d.dataset.TextureStreamVector texStreams) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long origFeatureVecParamValue = origFeatureVec.nativeObject.pointer; long texStreamsParamValue = texStreams.nativeObject.pointer; boolean returnValue = readTemplDatasetOrigTexture_EVString_EVString_EVString_FeatureVector_TextureStreamVector(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, origFeatureVecParamValue, texStreamsParamValue); return returnValue; } native private static long readMeshTemplID_EVString_EVString_ev_uint32(String datasourceName, String datasetName, long meshInstID); public static long readMeshTemplID(String datasourceName, String datasetName, long meshInstID) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; long meshInstIDParamValue = meshInstID; long returnValue = readMeshTemplID_EVString_EVString_ev_uint32(datasourceNameParamValue, datasetNameParamValue, meshInstIDParamValue); return returnValue; } native private static boolean readDatasetAniDataStream_EVString_EVString_EVString_ev_uint32_MemoryDataStreamPtr(String datasourceName, String datasetName, String octCode, long meshID, long stream); /** * 读本地模型数据集anifeature * @param */ public static boolean readDatasetAniDataStream(String datasourceName, String datasetName, String octCode, long meshID, com.earthview.world.core.MemoryDataStreamPtr stream) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long meshIDParamValue = meshID; long streamParamValue = stream.nativeObject.pointer; boolean returnValue = readDatasetAniDataStream_EVString_EVString_EVString_ev_uint32_MemoryDataStreamPtr(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, meshIDParamValue, streamParamValue); return returnValue; } native private static boolean readTemplAniDataStream_EVString_EVString_ev_uint32_MemoryDataStreamPtr(String datasourceName, String datasetName, long meshID, long stream); /** * 读取模型库的anifeature * @param */ public static boolean readTemplAniDataStream(String datasourceName, String datasetName, long meshID, com.earthview.world.core.MemoryDataStreamPtr stream) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; long meshIDParamValue = meshID; long streamParamValue = stream.nativeObject.pointer; boolean returnValue = readTemplAniDataStream_EVString_EVString_ev_uint32_MemoryDataStreamPtr(datasourceNameParamValue, datasetNameParamValue, meshIDParamValue, streamParamValue); return returnValue; } native private static boolean writeDatasetModelOrigTexture_EVString_EVString_EVString_FeatureVector(String datasourceName, String datasetName, String octCode, long origFeatureVec); /** * 缓存实体数据集大纹理 * @param */ public static boolean writeDatasetModelOrigTexture(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial3d.dataset.FeatureVector origFeatureVec) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long origFeatureVecParamValue = origFeatureVec.nativeObject.pointer; boolean returnValue = writeDatasetModelOrigTexture_EVString_EVString_EVString_FeatureVector(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, origFeatureVecParamValue); return returnValue; } native private static boolean writeTemplDatasetOrigTexture_EVString_EVString_EVString_FeatureVector(String datasourceName, String datasetName, String octCode, long origFeatureVec); /** * 缓存实体模型库数据集大纹理 * @param */ public static boolean writeTemplDatasetOrigTexture(String datasourceName, String datasetName, String octCode, com.earthview.world.spatial3d.dataset.FeatureVector origFeatureVec) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; String octCodeParamValue = octCode; long origFeatureVecParamValue = origFeatureVec.nativeObject.pointer; boolean returnValue = writeTemplDatasetOrigTexture_EVString_EVString_EVString_FeatureVector(datasourceNameParamValue, datasetNameParamValue, octCodeParamValue, origFeatureVecParamValue); return returnValue; } native private static void updateAltitudeMode_EVString_EVString_EVDatasetType_EVAltitudeMode_ev_real64(String datasourceName, String datasetName, int type, int altitudeMode, double altitudeValue); /** * 修改缓存中的高度模式 * @param */ public static void updateAltitudeMode(String datasourceName, String datasetName, com.earthview.world.spatial.geodataset.EVDatasetType type, com.earthview.world.spatial.utility.EVAltitudeMode altitudeMode, double altitudeValue) { String datasourceNameParamValue = datasourceName; String datasetNameParamValue = datasetName; int typeParamValue = type.getValue(); int altitudeModeParamValue = altitudeMode.getValue(); double altitudeValueParamValue = altitudeValue; updateAltitudeMode_EVString_EVString_EVDatasetType_EVAltitudeMode_ev_real64(datasourceNameParamValue, datasetNameParamValue, typeParamValue, altitudeModeParamValue, altitudeValueParamValue); } public ModelCacheUtility(CreatedWhenConstruct cwc) { super(CreatedWhenConstruct.CWC_NotToCreate); } public ModelCacheUtility(CreatedWhenConstruct cwc, String classNameStr) { super(CreatedWhenConstruct.CWC_NotToCreate, classNameStr); } public static ModelCacheUtility fromBaseObject(BaseObject baseObj) { if (baseObj == null || InstancePointer.ZERO.equals(baseObj.nativeObject)) { return null; } ModelCacheUtility obj = null; if(baseObj instanceof ModelCacheUtility) { obj = (ModelCacheUtility)baseObj; } else { obj = new ModelCacheUtility(CreatedWhenConstruct.CWC_NotToCreate); obj.bindNativeObject(baseObj.nativeObject, "CModelCacheUtility"); obj.increaseCast(); } return obj; } }
[ "yanguanqi@aliyun.com" ]
yanguanqi@aliyun.com
2db30b4ca6f5b68e637c9631b59f983e1971de90
ca4b516a4be70d1074d78bade6531ecabd611e0b
/hbase191208/hbase-mr/src/main/java/com/muye/hbase/reducer/InsertDataReducer.java
900f793ca986c8a8a8c911aa2d486c4320b77b2d
[]
no_license
dancheng0/HBASE
9eb9e159edf652e18bd5ca3e4211eacb12c151c6
fa9eae53b294ef65fa01963ccbe4e269e1db1e93
refs/heads/master
2020-11-24T23:22:10.027016
2019-12-19T09:26:09
2019-12-19T09:26:09
228,384,457
0
0
null
null
null
null
UTF-8
Java
false
false
748
java
package com.muye.hbase.reducer; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.mapreduce.TableReducer; import org.apache.hadoop.io.NullWritable; import java.io.IOException; /** * @author : gwh * @date : 2019-12-17 10:24 **/ public class InsertDataReducer extends TableReducer<ImmutableBytesWritable,Put,NullWritable> { @Override protected void reduce(ImmutableBytesWritable key, Iterable<Put> values, Context context) throws IOException, InterruptedException { //运行reducer,增加数据 for (Put put : values) { if(!put.isEmpty()){ context.write(NullWritable.get(),put); } } } }
[ "1595864175@qq.com" ]
1595864175@qq.com
e7e0f56f72c5ced8f8058dc36d63cb2df50acb0f
17d23e4467c3a17ec5164236a5ecd8b28c540eb5
/src/insoft/handler/GetWatch.java
d03433205bb674e15c37c3dcc58dcb2897994950
[]
no_license
DongminK/NGFClient
877f659f6b31313d6af3c973de93696c3e7ae9ec
fa3f2a0b242fdc7793f10c22998dcbdf69b2d878
refs/heads/master
2020-03-19T12:52:38.134778
2018-06-08T00:45:11
2018-06-08T00:45:11
136,546,651
0
0
null
null
null
null
UTF-8
Java
false
false
905
java
package insoft.handler; import insoft.client.IHandler; import insoft.client.Util; import insoft.openmanager.message.Message; import java.util.Vector; public class GetWatch implements IHandler { @Override public String getName() { // TODO Auto-generated method stub return "GET_WATCH"; } @Override public Message requestMessage() { // TODO Auto-generated method stub Message msg = new Message(getName()); Message filter = new Message(""); filter.setInteger("type", 0); filter.setString("attr_name", "owner_id"); Vector<String> vValues = new Vector<String>(); vValues.add(Util.readCommand("CONFIG_ID")); filter.setVector("values", vValues); Vector<Message> vFilters = new Vector<Message>(); vFilters.add(filter); msg.setVector("filters", vFilters); return msg; } @Override public void setPrevMessage(Message msg) { // TODO Auto-generated method stub } }
[ "kdm0228@gmail.com" ]
kdm0228@gmail.com
5bd0781b8eb3cad85d9e195f3104b8815714f8b8
d2cb1f4f186238ed3075c2748552e9325763a1cb
/methods_all/nonstatic_methods/java_awt_event_ComponentEvent_wait_long_int.java
6e1d5a042c83758e1a8115550a4a284bb559049f
[]
no_license
Adabot1/data
9e5c64021261bf181b51b4141aab2e2877b9054a
352b77eaebd8efdb4d343b642c71cdbfec35054e
refs/heads/master
2020-05-16T14:22:19.491115
2019-05-25T04:35:00
2019-05-25T04:35:00
183,001,929
4
0
null
null
null
null
UTF-8
Java
false
false
197
java
class java_awt_event_ComponentEvent_wait_long_int{ public static void function() {java.awt.event.ComponentEvent obj = new java.awt.event.ComponentEvent();obj.wait(3452663207410873447,1000401425);}}
[ "peter2008.ok@163.com" ]
peter2008.ok@163.com
1950781369806112fe71935adb528affcaa81cb6
8957537f636c91c29ca7ba21ece7b96fc04feb11
/lesson2/Account HW/abstractAccount.java
6d1f23b9500e694c4e248c13c5db534abb986706
[]
no_license
Ziyilan/Mobile-Proto-16
a5c2d4366634a7c25b8788ce9577ac405417d346
7ca2bc65907d1f85155cd3e7e7f43b16f18011e6
refs/heads/master
2021-01-22T01:38:42.936470
2016-10-31T00:42:45
2016-10-31T00:42:45
67,151,413
0
0
null
2021-01-05T00:51:44
2016-09-01T17:17:03
Java
UTF-8
Java
false
false
554
java
public abstract class abstractAccount { protected MoneySaver owner; protected long amount; public abstractAccount(long amount, MoneySaver owner){ this.amount = amount; this.owner = owner; } public void deposit(long depositAmount){ } public abstract long getAmount(); public abstract void setAmount(long amount); public abstract MoneySaver getOwner(); public abstract String toString(); public static void main(String[] args){ abstractAccount aa = new abstractAccount(10, new MoneySaver("Jason", 3)); } }
[ "ziyi.lan@students.olin.edu" ]
ziyi.lan@students.olin.edu
7330567e060ecc3a02421706768922614a43806a
61ad4132cbf8a6576a95ad388382488cffa333b8
/app/src/main/java/com/example/covidapps/model/preferencesData/UserModel.java
88005354d599c136447b70ae140214eb0b8c1a96
[]
no_license
ghozay19/ListCovidMVVM
1c013dfa1776f15f125afd5e31c51fb38c91524a
bdb426685924335e92ac8efd10a97332a91ab499
refs/heads/master
2023-01-10T01:00:04.895240
2020-11-08T16:30:58
2020-11-08T16:30:58
311,105,956
0
0
null
null
null
null
UTF-8
Java
false
false
692
java
package com.example.covidapps.model.preferencesData; import android.os.Parcel; import android.os.Parcelable; public class UserModel { String username; String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "UserModel{" + "username='" + username + '\'' + ", password='" + password + '\'' + '}'; } }
[ "ghozymustofa28@gmail.com" ]
ghozymustofa28@gmail.com
4ba9ee4b40a791b121e0f788d0a5a09b78abb935
88d031ad952813de055b5b7dfc9653acf045425d
/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/QueryMapperUnitTests.java
cf304a4b70fe8e3219eb6ec1bc0575058acbd28c
[]
no_license
whirlwind-match/spring-data-mongodb
4efa5de37a32f0a7ecae719cc5e2e47d76c5511d
ba9abd1dd06d9c25d47d1edb8350c308ad91ec9f
refs/heads/master
2021-01-18T10:41:21.887142
2012-06-20T10:23:32
2012-06-20T10:24:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,138
java
/* * Copyright (c) 2011 by the original author(s). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.data.mongodb.core.convert; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.data.mongodb.core.query.Criteria.*; import static org.springframework.data.mongodb.core.query.Query.*; import java.math.BigInteger; import java.util.Arrays; import org.bson.types.ObjectId; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.MongoDbFactory; import org.springframework.data.mongodb.core.Person; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; import org.springframework.data.mongodb.core.query.BasicQuery; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import com.mongodb.BasicDBList; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import com.mongodb.QueryBuilder; /** * Unit tests for {@link QueryMapper}. * * @author Oliver Gierke */ @RunWith(MockitoJUnitRunner.class) @SuppressWarnings("unused") public class QueryMapperUnitTests { QueryMapper mapper; MongoMappingContext context; @Mock MongoDbFactory factory; @Before public void setUp() { context = new MongoMappingContext(); MappingMongoConverter converter = new MappingMongoConverter(factory, context); converter.afterPropertiesSet(); mapper = new QueryMapper(converter); } @Test public void translatesIdPropertyIntoIdKey() { DBObject query = new BasicDBObject("foo", "value"); MongoPersistentEntity<?> entity = context.getPersistentEntity(Sample.class); DBObject result = mapper.getMappedObject(query, entity); assertThat(result.get("_id"), is(notNullValue())); assertThat(result.get("foo"), is(nullValue())); } @Test public void convertsStringIntoObjectId() { DBObject query = new BasicDBObject("_id", new ObjectId().toString()); DBObject result = mapper.getMappedObject(query, null); assertThat(result.get("_id"), is(instanceOf(ObjectId.class))); } @Test public void handlesBigIntegerIdsCorrectly() { DBObject dbObject = new BasicDBObject("id", new BigInteger("1")); DBObject result = mapper.getMappedObject(dbObject, null); assertThat(result.get("_id"), is((Object) "1")); } @Test public void handlesObjectIdCapableBigIntegerIdsCorrectly() { ObjectId id = new ObjectId(); DBObject dbObject = new BasicDBObject("id", new BigInteger(id.toString(), 16)); DBObject result = mapper.getMappedObject(dbObject, null); assertThat(result.get("_id"), is((Object) id)); } /** * @see DATAMONGO-278 */ @Test public void translates$NeCorrectly() { Criteria criteria = where("foo").ne(new ObjectId().toString()); DBObject result = mapper.getMappedObject(criteria.getCriteriaObject(), context.getPersistentEntity(Sample.class)); Object object = result.get("_id"); assertThat(object, is(instanceOf(DBObject.class))); DBObject dbObject = (DBObject) object; assertThat(dbObject.get("$ne"), is(instanceOf(ObjectId.class))); } /** * @see DATAMONGO-326 */ @Test public void handlesEnumsCorrectly() { Query query = query(where("foo").is(Enum.INSTANCE)); DBObject result = mapper.getMappedObject(query.getQueryObject(), null); Object object = result.get("foo"); assertThat(object, is(instanceOf(String.class))); } @Test public void handlesEnumsInNotEqualCorrectly() { Query query = query(where("foo").ne(Enum.INSTANCE)); DBObject result = mapper.getMappedObject(query.getQueryObject(), null); Object object = result.get("foo"); assertThat(object, is(instanceOf(DBObject.class))); Object ne = ((DBObject) object).get("$ne"); assertThat(ne, is(instanceOf(String.class))); assertThat(ne.toString(), is(Enum.INSTANCE.name())); } @Test public void handlesEnumsIn$InCorrectly() { Query query = query(where("foo").in(Enum.INSTANCE)); DBObject result = mapper.getMappedObject(query.getQueryObject(), null); Object object = result.get("foo"); assertThat(object, is(instanceOf(DBObject.class))); Object in = ((DBObject) object).get("$in"); assertThat(in, is(instanceOf(BasicDBList.class))); BasicDBList list = (BasicDBList) in; assertThat(list.size(), is(1)); assertThat(list.get(0), is(instanceOf(String.class))); assertThat(list.get(0).toString(), is(Enum.INSTANCE.name())); } /** * @see DATAMONGO-373 */ @Test public void handlesNativelyBuiltQueryCorrectly() { DBObject query = new QueryBuilder().or(new BasicDBObject("foo", "bar")).get(); mapper.getMappedObject(query, null); } /** * @see DATAMONGO-369 */ @Test public void handlesAllPropertiesIfDBObject() { DBObject query = new BasicDBObject(); query.put("foo", new BasicDBObject("$in", Arrays.asList(1, 2))); query.put("bar", new Person()); DBObject result = mapper.getMappedObject(query, null); assertThat(result.get("bar"), is(notNullValue())); } /** * @see DATAMONGO-429 */ @Test public void transformsArraysCorrectly() { Query query = new BasicQuery("{ 'tags' : { '$all' : [ 'green', 'orange']}}"); DBObject result = mapper.getMappedObject(query.getQueryObject(), null); assertThat(result, is(query.getQueryObject())); } class Sample { @Id private String foo; } class BigIntegerId { @Id private BigInteger id; } enum Enum { INSTANCE; } }
[ "info@olivergierke.de" ]
info@olivergierke.de
ce69645f7ba87c3fcb8ea5d09510f68f1de3bae7
10a831a439f8ea5584e0f01708f198efc2dcc182
/src/main/java/qa/qcri/rahar/config/WebAppConfig.java
016ed24af8b51a00a58e7cd21753a918ab66c908
[]
no_license
amanagrawal9/spring-hibernate-base-app
7c08219c15d016098cfd4eaa226049d193ae4f01
4d1a67b7e12945d2db3cbd95ba74934e552e2a9e
refs/heads/master
2020-12-02T07:34:53.242745
2016-08-31T07:06:12
2016-08-31T07:06:12
67,012,499
0
0
null
null
null
null
UTF-8
Java
false
false
3,045
java
package qa.qcri.rahar.config; import javax.persistence.EntityManagerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.io.ClassPathResource; import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; @Configuration @EnableWebMvc @ComponentScan("qa.qcri.rahar") @PropertySource("classpath:application.properties") @EnableScheduling public class WebAppConfig extends WebMvcConfigurerAdapter { @Autowired EntityManagerFactory entityManagerFactory; /* To load properties files */ @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); ClassPathResource locations[] = { new ClassPathResource("/application.properties")}; ppc.setLocations(locations); return ppc; } @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable(); } @Bean public OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor() { OpenEntityManagerInViewInterceptor oemiv = new OpenEntityManagerInViewInterceptor(); oemiv.setEntityManagerFactory(entityManagerFactory); return oemiv; } @Bean public ViewResolver viewResolver() { InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); viewResolver.setViewClass(JstlView.class); viewResolver.setPrefix("/WEB-INF/views/"); viewResolver.setSuffix(".html"); return viewResolver; } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/*.html").addResourceLocations("/WEB-INF/pages/"); } @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("forward:/index.html"); } /* @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("index"); }*/ }
[ "aman.agrawal9@gmail.com" ]
aman.agrawal9@gmail.com
050202e64fb84d89c62c0b05f5be7c1e2754eaf1
9c7ea25a118e94970809a7b879c9f8db2964a40f
/target/generated-sources/xjc/im_03_00_38_local/ObjectFactory.java
1d2b7e9df7903d3b750a8f1887a8c6b7fe17891b
[]
no_license
vramku/onebusaway-tcip-api-v40
c29d6133654fcf17fe4b85f060f91ec358e6446b
cc3792c1176b033e0a505eb597bc733ff16a16fd
refs/heads/master
2020-12-26T04:48:19.209063
2016-05-19T20:54:17
2016-05-19T20:54:17
37,859,287
0
0
null
2015-06-22T14:15:47
2015-06-22T14:15:46
null
UTF-8
Java
false
false
22,497
java
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2015.06.24 at 02:32:24 PM EDT // package im_03_00_38_local; import javax.xml.bind.annotation.XmlRegistry; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the im_03_00_38_local package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory { /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: im_03_00_38_local * */ public ObjectFactory() { } /** * Create an instance of {@link AirlineTravelInformation } * */ public AirlineTravelInformation createAirlineTravelInformation() { return new AirlineTravelInformation(); } /** * Create an instance of {@link AssetDescription } * */ public AssetDescription createAssetDescription() { return new AssetDescription(); } /** * Create an instance of {@link AvailableForHandOff } * */ public AvailableForHandOff createAvailableForHandOff() { return new AvailableForHandOff(); } /** * Create an instance of {@link Basics } * */ public Basics createBasics() { return new Basics(); } /** * Create an instance of {@link BcastCycle } * */ public BcastCycle createBcastCycle() { return new BcastCycle(); } /** * Create an instance of {@link CargoDocs } * */ public CargoDocs createCargoDocs() { return new CargoDocs(); } /** * Create an instance of {@link CargoUnits } * */ public CargoUnits createCargoUnits() { return new CargoUnits(); } /** * Create an instance of {@link CargoVehicle } * */ public CargoVehicle createCargoVehicle() { return new CargoVehicle(); } /** * Create an instance of {@link CautionsForResponders } * */ public CautionsForResponders createCautionsForResponders() { return new CautionsForResponders(); } /** * Create an instance of {@link CenterPlans } * */ public CenterPlans createCenterPlans() { return new CenterPlans(); } /** * Create an instance of {@link CenterType } * */ public CenterType createCenterType() { return new CenterType(); } /** * Create an instance of {@link ChangeCenterProperties } * */ public ChangeCenterProperties createChangeCenterProperties() { return new ChangeCenterProperties(); } /** * Create an instance of {@link ClearOrRepairPlan } * */ public ClearOrRepairPlan createClearOrRepairPlan() { return new ClearOrRepairPlan(); } /** * Create an instance of {@link CloseIncidentEvent } * */ public CloseIncidentEvent createCloseIncidentEvent() { return new CloseIncidentEvent(); } /** * Create an instance of {@link ComplexCost } * */ public ComplexCost createComplexCost() { return new ComplexCost(); } /** * Create an instance of {@link Description } * */ public Description createDescription() { return new Description(); } /** * Create an instance of {@link DifferentialGPSCorrections } * */ public DifferentialGPSCorrections createDifferentialGPSCorrections() { return new DifferentialGPSCorrections(); } /** * Create an instance of {@link DisableCenterOnLine } * */ public DisableCenterOnLine createDisableCenterOnLine() { return new DisableCenterOnLine(); } /** * Create an instance of {@link Distribution } * */ public Distribution createDistribution() { return new Distribution(); } /** * Create an instance of {@link EstablishCenterOnLine } * */ public EstablishCenterOnLine createEstablishCenterOnLine() { return new EstablishCenterOnLine(); } /** * Create an instance of {@link EstablishCenterProperties } * */ public EstablishCenterProperties createEstablishCenterProperties() { return new EstablishCenterProperties(); } /** * Create an instance of {@link EvacuationData } * */ public EvacuationData createEvacuationData() { return new EvacuationData(); } /** * Create an instance of {@link Evacuation } * */ public Evacuation createEvacuation() { return new Evacuation(); } /** * Create an instance of {@link EventInformation } * */ public EventInformation createEventInformation() { return new EventInformation(); } /** * Create an instance of {@link Facilities } * */ public Facilities createFacilities() { return new Facilities(); } /** * Create an instance of {@link FileTransfer } * */ public FileTransfer createFileTransfer() { return new FileTransfer(); } /** * Create an instance of {@link FullPositionVector } * */ public FullPositionVector createFullPositionVector() { return new FullPositionVector(); } /** * Create an instance of {@link GrantHandOff } * */ public GrantHandOff createGrantHandOff() { return new GrantHandOff(); } /** * Create an instance of {@link Header } * */ public Header createHeader() { return new Header(); } /** * Create an instance of {@link IDXWrapper } * */ public IDXWrapper createIDXWrapper() { return new IDXWrapper(); } /** * Create an instance of {@link ImmediateSiteEvacuation } * */ public ImmediateSiteEvacuation createImmediateSiteEvacuation() { return new ImmediateSiteEvacuation(); } /** * Create an instance of {@link Impact } * */ public Impact createImpact() { return new Impact(); } /** * Create an instance of {@link IMWrapper } * */ public IMWrapper createIMWrapper() { return new IMWrapper(); } /** * Create an instance of {@link IncidentDescription } * */ public IncidentDescription createIncidentDescription() { return new IncidentDescription(); } /** * Create an instance of {@link IncidentInformation } * */ public IncidentInformation createIncidentInformation() { return new IncidentInformation(); } /** * Create an instance of {@link InformationRequest } * */ public InformationRequest createInformationRequest() { return new InformationRequest(); } /** * Create an instance of {@link InformationRequestType } * */ public InformationRequestType createInformationRequestType() { return new InformationRequestType(); } /** * Create an instance of {@link InfrastructureReport } * */ public InfrastructureReport createInfrastructureReport() { return new InfrastructureReport(); } /** * Create an instance of {@link InjuryData } * */ public InjuryData createInjuryData() { return new InjuryData(); } /** * Create an instance of {@link IssueStamp } * */ public IssueStamp createIssueStamp() { return new IssueStamp(); } /** * Create an instance of {@link LinkDataSet } * */ public LinkDataSet createLinkDataSet() { return new LinkDataSet(); } /** * Create an instance of {@link LinkTrafficInformation } * */ public LinkTrafficInformation createLinkTrafficInformation() { return new LinkTrafficInformation(); } /** * Create an instance of {@link GeoLocation } * */ public GeoLocation createGeoLocation() { return new GeoLocation(); } /** * Create an instance of {@link ManageCommandStructure } * */ public ManageCommandStructure createManageCommandStructure() { return new ManageCommandStructure(); } /** * Create an instance of {@link ManeuverInstruction } * */ public ManeuverInstruction createManeuverInstruction() { return new ManeuverInstruction(); } /** * Create an instance of {@link MaterialRelease } * */ public MaterialRelease createMaterialRelease() { return new MaterialRelease(); } /** * Create an instance of {@link MaydayDataSet } * */ public MaydayDataSet createMaydayDataSet() { return new MaydayDataSet(); } /** * Create an instance of {@link MergeIncidentEvent } * */ public MergeIncidentEvent createMergeIncidentEvent() { return new MergeIncidentEvent(); } /** * Create an instance of {@link NeedEMS } * */ public NeedEMS createNeedEMS() { return new NeedEMS(); } /** * Create an instance of {@link NeedFireSuppression } * */ public NeedFireSuppression createNeedFireSuppression() { return new NeedFireSuppression(); } /** * Create an instance of {@link NeedLawEnforcement } * */ public NeedLawEnforcement createNeedLawEnforcement() { return new NeedLawEnforcement(); } /** * Create an instance of {@link NeedOtherServices } * */ public NeedOtherServices createNeedOtherServices() { return new NeedOtherServices(); } /** * Create an instance of {@link NeedRescueServices } * */ public NeedRescueServices createNeedRescueServices() { return new NeedRescueServices(); } /** * Create an instance of {@link NetworkConditions } * */ public NetworkConditions createNetworkConditions() { return new NetworkConditions(); } /** * Create an instance of {@link NewIncidentEvent } * */ public NewIncidentEvent createNewIncidentEvent() { return new NewIncidentEvent(); } /** * Create an instance of {@link OrganizationPosition } * */ public OrganizationPosition createOrganizationPosition() { return new OrganizationPosition(); } /** * Create an instance of {@link ParkingInstructions } * */ public ParkingInstructions createParkingInstructions() { return new ParkingInstructions(); } /** * Create an instance of {@link ParkingLotInformation } * */ public ParkingLotInformation createParkingLotInformation() { return new ParkingLotInformation(); } /** * Create an instance of {@link PedigreeList } * */ public PedigreeList createPedigreeList() { return new PedigreeList(); } /** * Create an instance of {@link PersonInformation } * */ public PersonInformation createPersonInformation() { return new PersonInformation(); } /** * Create an instance of {@link PhysicalAssetStatus } * */ public PhysicalAssetStatus createPhysicalAssetStatus() { return new PhysicalAssetStatus(); } /** * Create an instance of {@link PlacardsLabelsSignage } * */ public PlacardsLabelsSignage createPlacardsLabelsSignage() { return new PlacardsLabelsSignage(); } /** * Create an instance of {@link PollForHandOff } * */ public PollForHandOff createPollForHandOff() { return new PollForHandOff(); } /** * Create an instance of {@link PositionFix } * */ public PositionFix createPositionFix() { return new PositionFix(); } /** * Create an instance of {@link PreemptionUserData } * */ public PreemptionUserData createPreemptionUserData() { return new PreemptionUserData(); } /** * Create an instance of {@link PublicIncidentDescription } * */ public PublicIncidentDescription createPublicIncidentDescription() { return new PublicIncidentDescription(); } /** * Create an instance of {@link RequestForExternalInformation } * */ public RequestForExternalInformation createRequestForExternalInformation() { return new RequestForExternalInformation(); } /** * Create an instance of {@link RequestHandOff } * */ public RequestHandOff createRequestHandOff() { return new RequestHandOff(); } /** * Create an instance of {@link RequestImmediateAssistance } * */ public RequestImmediateAssistance createRequestImmediateAssistance() { return new RequestImmediateAssistance(); } /** * Create an instance of {@link RequestInformation } * */ public RequestInformation createRequestInformation() { return new RequestInformation(); } /** * Create an instance of {@link RequestNetworkConditions } * */ public RequestNetworkConditions createRequestNetworkConditions() { return new RequestNetworkConditions(); } /** * Create an instance of {@link RequestPhysicalAsset } * */ public RequestPhysicalAsset createRequestPhysicalAsset() { return new RequestPhysicalAsset(); } /** * Create an instance of {@link RequestPhysicalAssetStatus } * */ public RequestPhysicalAssetStatus createRequestPhysicalAssetStatus() { return new RequestPhysicalAssetStatus(); } /** * Create an instance of {@link RequestPreemptionUserData } * */ public RequestPreemptionUserData createRequestPreemptionUserData() { return new RequestPreemptionUserData(); } /** * Create an instance of {@link RequestRouteAdvice } * */ public RequestRouteAdvice createRequestRouteAdvice() { return new RequestRouteAdvice(); } /** * Create an instance of {@link RequestStatus } * */ public RequestStatus createRequestStatus() { return new RequestStatus(); } /** * Create an instance of {@link RequestTrafficControlPlan } * */ public RequestTrafficControlPlan createRequestTrafficControlPlan() { return new RequestTrafficControlPlan(); } /** * Create an instance of {@link RequestWorkZoneData } * */ public RequestWorkZoneData createRequestWorkZoneData() { return new RequestWorkZoneData(); } /** * Create an instance of {@link ResourceAssignment } * */ public ResourceAssignment createResourceAssignment() { return new ResourceAssignment(); } /** * Create an instance of {@link ResponseGroup } * */ public ResponseGroup createResponseGroup() { return new ResponseGroup(); } /** * Create an instance of {@link Response } * */ public Response createResponse() { return new Response(); } /** * Create an instance of {@link RouteAdvice } * */ public RouteAdvice createRouteAdvice() { return new RouteAdvice(); } /** * Create an instance of {@link Route } * */ public Route createRoute() { return new Route(); } /** * Create an instance of {@link RouteRequest } * */ public RouteRequest createRouteRequest() { return new RouteRequest(); } /** * Create an instance of {@link RouteSet } * */ public RouteSet createRouteSet() { return new RouteSet(); } /** * Create an instance of {@link RouteStatus } * */ public RouteStatus createRouteStatus() { return new RouteStatus(); } /** * Create an instance of {@link SceneStaging } * */ public SceneStaging createSceneStaging() { return new SceneStaging(); } /** * Create an instance of {@link Segment } * */ public Segment createSegment() { return new Segment(); } /** * Create an instance of {@link ServerStatus } * */ public ServerStatus createServerStatus() { return new ServerStatus(); } /** * Create an instance of {@link Severity } * */ public Severity createSeverity() { return new Severity(); } /** * Create an instance of {@link ShippingEntry } * */ public ShippingEntry createShippingEntry() { return new ShippingEntry(); } /** * Create an instance of {@link SplitIncidentEvent } * */ public SplitIncidentEvent createSplitIncidentEvent() { return new SplitIncidentEvent(); } /** * Create an instance of {@link StagingArea } * */ public StagingArea createStagingArea() { return new StagingArea(); } /** * Create an instance of {@link StatusBlock } * */ public StatusBlock createStatusBlock() { return new StatusBlock(); } /** * Create an instance of {@link SubRoute } * */ public SubRoute createSubRoute() { return new SubRoute(); } /** * Create an instance of {@link TimeMarks } * */ public TimeMarks createTimeMarks() { return new TimeMarks(); } /** * Create an instance of {@link TrackInvolvedPerson } * */ public TrackInvolvedPerson createTrackInvolvedPerson() { return new TrackInvolvedPerson(); } /** * Create an instance of {@link TrackInvolvedVehicle } * */ public TrackInvolvedVehicle createTrackInvolvedVehicle() { return new TrackInvolvedVehicle(); } /** * Create an instance of {@link TrackResponsePersonnel } * */ public TrackResponsePersonnel createTrackResponsePersonnel() { return new TrackResponsePersonnel(); } /** * Create an instance of {@link TrackSpecialCircumstances } * */ public TrackSpecialCircumstances createTrackSpecialCircumstances() { return new TrackSpecialCircumstances(); } /** * Create an instance of {@link TrafficControlPlan } * */ public TrafficControlPlan createTrafficControlPlan() { return new TrafficControlPlan(); } /** * Create an instance of {@link TranmissionPoint } * */ public TranmissionPoint createTranmissionPoint() { return new TranmissionPoint(); } /** * Create an instance of {@link TransitEventSource } * */ public TransitEventSource createTransitEventSource() { return new TransitEventSource(); } /** * Create an instance of {@link TransitInformation } * */ public TransitInformation createTransitInformation() { return new TransitInformation(); } /** * Create an instance of {@link TransitVehicleInvolved } * */ public TransitVehicleInvolved createTransitVehicleInvolved() { return new TransitVehicleInvolved(); } /** * Create an instance of {@link VehicleData } * */ public VehicleData createVehicleData() { return new VehicleData(); } /** * Create an instance of {@link VehMAYDAY } * */ public VehMAYDAY createVehMAYDAY() { return new VehMAYDAY(); } /** * Create an instance of {@link WatchFor } * */ public WatchFor createWatchFor() { return new WatchFor(); } /** * Create an instance of {@link WatchForResponse } * */ public WatchForResponse createWatchForResponse() { return new WatchForResponse(); } /** * Create an instance of {@link WeatherInformation } * */ public WeatherInformation createWeatherInformation() { return new WeatherInformation(); } /** * Create an instance of {@link WitnessIdenty } * */ public WitnessIdenty createWitnessIdenty() { return new WitnessIdenty(); } /** * Create an instance of {@link WitnessList } * */ public WitnessList createWitnessList() { return new WitnessList(); } /** * Create an instance of {@link WitnessStatement } * */ public WitnessStatement createWitnessStatement() { return new WitnessStatement(); } /** * Create an instance of {@link WorkZoneData } * */ public WorkZoneData createWorkZoneData() { return new WorkZoneData(); } }
[ "visar.ramku@nyct.com" ]
visar.ramku@nyct.com
88ae1c31d8f325e84f1dbf108b51ffd9284c0c98
db99ecb8435588d71851c5362117d938c9eac1a2
/firstcode/chapter14_coolweather/src/main/java/com/me/diankun/coolweather/db/CoolWeatherOpenHelper.java
230b5ce97339f4b31d0810a96c4293e01a979cdb
[ "Apache-2.0" ]
permissive
qdiankun/firstcode
4d36768c39a3b9157cdb44a68a3eebafa718f68c
6858ceffb4b80d33dedded99bc95ef4c4fb1ad96
refs/heads/master
2021-01-10T04:49:27.030497
2016-03-11T10:36:27
2016-03-11T10:36:27
52,836,706
0
1
null
null
null
null
UTF-8
Java
false
false
1,613
java
package com.me.diankun.coolweather.db; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; /** * Created by diankun on 2016/3/10. */ public class CoolWeatherOpenHelper extends SQLiteOpenHelper { /** * Province表建表语句 */ public static final String CREATE_PROVINCE = "create table Province(id integer primary key autoincrement," + "province_name text,province_code text)"; /** * City表建表语句 */ public static final String CREATE_CITY = "create table City(id integer primary key autoincrement," + "city_name text," + "city_code text," + "province_id integer)"; /** * Country表的建表语句 */ public static final String CREATE_COUNTRY = "create table Country(id integer primary key autoincrement," + "country_name text,country_code text, city_id integer)"; public CoolWeatherOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { super(context, name, factory, version); } @Override public void onCreate(SQLiteDatabase db) { // 创建Province表 db.execSQL(CREATE_PROVINCE); // 创建City表 db.execSQL(CREATE_CITY); // 创建Country表 db.execSQL(CREATE_COUNTRY); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } }
[ "nervergup@126.com" ]
nervergup@126.com
8f1d1629992dac489a4c37a8587da855bd6d7b5e
fef99bb243d5a63791d45cd176760f3564e68269
/lab7/src/functional/Ex4_Consumer.java
5c4ecb141478579f941f27f99df33c4b449bdaa6
[]
no_license
diana-stoica-ub/PAO
20022e253308d8123c21b611419e3903571cdff2
97189aa4c80403268e7e594ec734723ff2545426
refs/heads/master
2023-05-03T05:54:22.864986
2021-05-19T06:57:09
2021-05-19T06:57:09
339,512,977
5
0
null
null
null
null
UTF-8
Java
false
false
1,185
java
package functional; import java.util.Arrays; import java.util.function.*; public class Ex4_Consumer { public void printBiConsumer() { BiConsumer<String, String> echo = (x, y) -> { System.out.println(x); System.out.println(y); }; echo.accept("This is first line.", "Here is another line"); } public void convertToLowercase() { Consumer<String> convertToLowercase = s -> System.out.println(s.toLowerCase()); convertToLowercase.accept("convert to ALL lowercase"); } public void printPrefix() { Consumer<String> sayHello = name -> System.out.println("Hello, " + name); for (String name : Arrays.asList("Silvia", "John", "Doe")) { sayHello.accept(name); } } public void printDoubleConsumer() { DoubleConsumer echo = System.out::println; //echo = d -> System.out.println(d); echo.accept(3.3); } public void printIntConsumer() { IntConsumer echo = System.out::println; echo.accept(3); } public void printLongConsumer() { LongConsumer echo = System.out::println; echo.accept(34L); } }
[ "Diana.Balutoiu@endava.com" ]
Diana.Balutoiu@endava.com
57e206dc18d5c46a18b2064d8c76482688b1600b
c35e0bab1a41421176f4bab3d1fe9cdfde21eb74
/app/src/main/java/com/omegar/RSSparser/RSSUtil.java
082f019bb48e7f13dfefed10e5eea2c1ada4134e
[]
no_license
JosiasSena/RSS-Reader
2f54a232bd6e49429e6bf3bd363ef83db8f65bea
94960be95fa0e00d5de7283b161f10028ea6d518
refs/heads/master
2021-05-28T08:15:16.445058
2014-12-19T21:02:28
2014-12-19T21:02:28
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,647
java
package com.omegar.RSSparser; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.preference.PreferenceManager; import android.view.Gravity; import android.widget.TextView; import com.omegar.Tools.LoadRSSFeed; import java.net.URI; import java.net.URISyntaxException; public class RSSUtil { // Put your RSS feed URL here public static String RSSFEEDURL = "http://www.androidpit.com/feed/main.xml"; // Change to a given feed public static void changeFeed(Context context){ changeURL(context); } // Returns the filename of the stored feed public static String getFeedName(){ return getDomainName(RSSFEEDURL); } // Strips a URL to the domain private static String getDomainName(String url) { String domain = null; try { domain = new URI(url).getHost(); } catch (URISyntaxException e) { e.printStackTrace(); } return domain.startsWith("www.") ? domain.substring(4) : domain; } // Takes a string URL as a new feed private static void changeURL(final Context context){ // Set the content view AlertDialog.Builder builder = new AlertDialog.Builder(context); // Set the alert title builder.setTitle("The link we will use:") // Set the alert message .setMessage("http://www.androidpit.com/feed/main.xml") // Can't exit via back button .setCancelable(false) // Set the positive button action .setPositiveButton("OK", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int whichButton){ RSSFEEDURL = "http://www.androidpit.com/feed/main.xml"; // Parse the feed new LoadRSSFeed(context).execute(); } }) // Set the negative button actions .setNegativeButton("Cancel", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int whichButton){ // If it's during initial loading if(!PreferenceManager.getDefaultSharedPreferences(context).getBoolean("isSetup", false)){ // Exit the application ((Activity)context).finish(); } else { // Otherwise do nothing dialog.dismiss(); } } }); // Create dialog from builder AlertDialog alert = builder.create(); // Don't exit the dialog when the screen is touched alert.setCanceledOnTouchOutside(false); // Show the alert alert.show(); // Center the message ((TextView)alert.findViewById(android.R.id.message)).setGravity(Gravity.CENTER); // Center the title of the dialog ((TextView)alert.findViewById((context.getResources().getIdentifier("alertTitle", "id", "android")))).setGravity(Gravity.CENTER); } }
[ "jsena@jsquareddevelopment.com" ]
jsena@jsquareddevelopment.com
a3673b839503596d7a8219f3842f24ded3c4a375
db336e3a8ba3682fcfd0c97a47deaaa595ef267a
/src/main/java/com/example/demo/ErrorHandler/ErrorMessage/IsNameError.java
b0f65f4012dabeb96a685b981514cb0c5c565fb8
[]
no_license
joelfalk/RouteBuilder
544d6b43ab267713ef67e9303fdb39d68e36b5c1
4a5f2bcc0f1c85b88dc39bed53d7acb6648aed62
refs/heads/master
2023-01-01T11:22:58.781743
2020-10-21T13:23:20
2020-10-21T13:23:20
296,367,099
0
0
null
null
null
null
UTF-8
Java
false
false
369
java
package com.example.demo.ErrorHandler.ErrorMessage; import org.apache.camel.Exchange; import org.apache.camel.Predicate; import org.springframework.stereotype.Component; @Component public class IsNameError implements Predicate { @Override public boolean matches(Exchange exchange) { return exchange.getIn().getHeader("FailReason").equals(1); } }
[ "joel.falk@evry.com" ]
joel.falk@evry.com
dfdf0136db207ec08758ca8b28e2f1df530dcd26
5232bc28d2bdb1eddd38e9f1eec4dda714257bd7
/CommandExecutor.java
5d3a4b10b4379aa6fc8eb568ae7be256d8894ba0
[]
no_license
chadaldrich93/MiniDatabase
efbb72f70ca8190ecc9a3a03b596c59c4f3dc01e
9cbd05c7f67cd12695dcca43f94ad4754cf9569d
refs/heads/master
2020-03-27T17:26:41.305878
2019-01-10T21:05:14
2019-01-10T21:05:14
146,851,869
0
0
null
null
null
null
UTF-8
Java
false
false
111
java
package minidatabase; import java.util.Vector; class CommandExecutor{ executeQuery(Vector<String>) }
[ "chadaldrich93@gmail.com" ]
chadaldrich93@gmail.com
bdb282cf644f8a75e55d4f6a5051102bef8cc87c
a0953114c07db399ffdf97d29a1258d8fc097e07
/src/main/java/org/example/leetcode/CompressString.java
c648b87a944de251bba0d2e8944a17b59cc9e531
[]
no_license
herolove/leetcodev2
da1866262cf67209cd0903229f65b0f395cb3ed0
ec418369a3f96b39fb770d95350cb144e5583856
refs/heads/master
2023-01-08T21:30:46.586493
2020-11-11T08:55:20
2020-11-11T08:55:20
274,327,969
0
0
null
2020-11-11T08:56:16
2020-06-23T06:34:52
Java
UTF-8
Java
false
false
782
java
package org.example.leetcode; /** * @Description TODO * @Author zhangtao02 * @Date 2020/6/16 **/ public class CompressString { public String compressString(String S) { if (S == null || S.length() <= 2) { return S; } StringBuilder sb = new StringBuilder().append(S.charAt(0)); int cnt = 1; for (int i = 1; i < S.length(); i++) { // 如果i与i-1相同,cnt累加 if (S.charAt(i) == S.charAt(i - 1)) { cnt++; } else { // 否则拼接上i-1的次数,从i开始重新计数 sb.append(cnt).append(S.charAt(i)); cnt = 1; } } return sb.append(cnt).length() < S.length()? sb.toString(): S; } }
[ "zhangtao02@weidian.com" ]
zhangtao02@weidian.com
9b744fbc2a28f83ab88ed38746f6b0c13b3b1a02
7109ce635db200f132a748f9a93e18bbea855874
/architecture-demo-bridge/src/main/java/com/architecture/example/topology/submit/LocalSubmitTopology.java
7d714486da58ebb2df65710b2848cab515e19c0d
[]
no_license
yiyongfei/jea-demo
8da49aeaaaf8e499dfe880e9584abdfdc03c0678
8e0ff2f0d3fc1691ba33b1de98d8c9d40e2d839a
refs/heads/master
2016-08-05T14:04:27.855336
2014-12-13T12:26:05
2014-12-13T12:26:05
27,707,129
3
4
null
null
null
null
UTF-8
Java
false
false
1,615
java
package com.architecture.example.topology.submit; import java.util.ArrayList; import java.util.Collection; import java.util.List; import backtype.storm.Config; import backtype.storm.LocalCluster; import com.ea.core.storm.TopologyDefinition; import com.ea.core.storm.cluster.StormCluster; import com.ea.core.storm.main.AbstractLocalSubmitTopology; import com.ea.core.storm.topology.AbstractDRPCTopology; import com.ea.core.storm.topology.ITopology; public class LocalSubmitTopology extends AbstractLocalSubmitTopology { public LocalSubmitTopology(){ super(); Config conf = new Config(); conf.setDebug(false); conf.setMaxTaskParallelism(3); conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 30);//30秒超时 conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1); StormCluster cluster = new StormCluster(new LocalCluster()); super.init(cluster, conf); } @Override protected Collection<ITopology> findTopologys() { // TODO Auto-generated method stub List<ITopology> list = new ArrayList<ITopology>(); Collection<ITopology> topolotys = TopologyDefinition.findAll(); ITopology tmp = null; String topologyName = null; for(ITopology topology : topolotys){ try { topologyName = topology.getTopologyName(); tmp = topology.getClass().newInstance(); tmp.setTopologyName(topologyName); if(tmp instanceof AbstractDRPCTopology){ ((AbstractDRPCTopology)tmp).setLocalDRPC(this.getClient()); } list.add(tmp); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return list; } }
[ "each51@hotmail.com" ]
each51@hotmail.com
0b7af350bb8d540145734b2f5cf1865ae88b3e6d
f7f99ee59500f1b83aef5c7893a3f8000501cf33
/app/src/main/java/kr/hs/emirim/s2019w04/mirimtabhost/MainActivity.java
691e64affd1d4227f89f06551c21e3df29580bf3
[]
no_license
Nayoung-apeach/MirimTabHost
d1af170fe749310e178c96cbb4457817ab5cec24
af1cf077e5482191b8c55802471a7ad23b2461e7
refs/heads/master
2023-01-08T00:24:24.866818
2020-11-09T11:43:51
2020-11-09T11:43:51
311,300,949
1
0
null
null
null
null
UTF-8
Java
false
false
994
java
package kr.hs.emirim.s2019w04.mirimtabhost; import androidx.appcompat.app.AppCompatActivity; import android.app.TabActivity; import android.os.Bundle; import android.widget.TabHost; public class MainActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TabHost tabHost = getTabHost(); TabHost.TabSpec tabSpecJun = tabHost.newTabSpec("Jun").setIndicator("김준규"); tabSpecJun.setContent(R.id.linear_jun); tabHost.addTab(tabSpecJun); TabHost.TabSpec tabSpecJi = tabHost.newTabSpec("Jun").setIndicator("박지훈"); tabSpecJi.setContent(R.id.linear_ji); tabHost.addTab(tabSpecJi); TabHost.TabSpec tabSpecYo = tabHost.newTabSpec("Jun").setIndicator("요시"); tabSpecYo.setContent(R.id.linear_yo); tabHost.addTab(tabSpecYo); tabHost.setCurrentTab(0); } }
[ "s2019w04@e-mirim.hs.kr" ]
s2019w04@e-mirim.hs.kr
e9fdce7e35c89806b66799430a11d550bd331d50
9ad7fe1a6ce560e4294c4637ee4a40a47317911e
/src/java/work/controllers/util/PaginationHelper.java
1ca14bff68a0483035e0aab9860d69c20f49bd79
[]
no_license
gksamuel/work
a1b5760a77e50aedf6c415f9631e2a28f33d4bc2
3422d2b54b37ac0ce40d57a1e86d118d78d67fd5
refs/heads/master
2020-07-06T10:16:47.149511
2019-08-18T09:47:58
2019-08-18T09:47:58
202,983,171
0
0
null
null
null
null
UTF-8
Java
false
false
1,119
java
package work.controllers.util; import javax.faces.model.DataModel; public abstract class PaginationHelper { public int pageSize; private int page; public PaginationHelper(int pageSize) { this.pageSize = pageSize; } public abstract int getItemsCount(); public abstract DataModel createPageDataModel(); public int getPageFirstItem() { return page * pageSize; } public int getPageLastItem() { int i = getPageFirstItem() + pageSize - 1; int count = getItemsCount() - 1; if (i > count) { i = count; } if (i < 0) { i = 0; } return i; } public boolean isHasNextPage() { return (page + 1) * pageSize + 1 <= getItemsCount(); } public void nextPage() { if (isHasNextPage()) { page++; } } public boolean isHasPreviousPage() { return page > 0; } public void previousPage() { if (isHasPreviousPage()) { page--; } } public int getPageSize() { return pageSize; } }
[ "gksamuel1@gmail.com" ]
gksamuel1@gmail.com
8a81b4cb64b1a08aea0d4ece59b1556bc4a65d8b
4ac72e49f1d47373651e1b4d71ec8b2fc797fd0e
/src/main/java/com/example/webjpah2/advice/EmployeeNotFoundAdvice.java
818a560fea5843e128327f62efb3816414114ace
[]
no_license
khoanxl918/web-jpa-h2-hateoas
b6b9973824c3d40b55ff6f8d7bb608a0982a57ef
f349424e15551a1c914250397e8704dac03a5132
refs/heads/master
2022-11-04T22:43:32.276548
2020-06-20T11:02:56
2020-06-20T11:02:56
273,691,322
0
0
null
null
null
null
UTF-8
Java
false
false
681
java
package com.example.webjpah2.advice; import com.example.webjpah2.exception.EmployeeNotFoundException; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; @ControllerAdvice public class EmployeeNotFoundAdvice { @ResponseBody @ExceptionHandler(EmployeeNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) public String empNotFoundHandler(EmployeeNotFoundException e) { return e.getMessage(); } }
[ "khoanxl918@gmail.com" ]
khoanxl918@gmail.com
a9bcbd98cb5095d9f3fbed71a3a41620c1a1bc72
053d1cb89bd59b38e5481863c4b1c6d24c5d08c5
/PassengerMS/src/main/java/com/cg/controller/ExceptionController.java
ebb2d5b74c424b66b7a87850ac2fa480d2013819
[]
no_license
Akash985/online-Bus-Booking-System
b39d2c60fa005f7cabd2211a37702d318c7f6b87
d4d9a1d4c15ed0be6c585692b5c4fd1b4f16cedb
refs/heads/master
2022-12-29T22:08:15.743005
2020-06-15T06:28:10
2020-06-15T06:28:10
272,183,994
0
0
null
2020-10-13T22:48:27
2020-06-14T10:59:58
Java
UTF-8
Java
false
false
1,553
java
package com.cg.controller; import javax.persistence.RollbackException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import com.cg.exception.BookingIdNotFoundException; import com.cg.exception.NoPassengerInBusException; import com.cg.exception.PassengerNotFoundException; @RestControllerAdvice public class ExceptionController { @ExceptionHandler public ResponseEntity<String> handleBookingIdNotFoundException(BookingIdNotFoundException ex) { return new ResponseEntity<>(ex.getMessage(),HttpStatus.NOT_FOUND); } @ExceptionHandler public ResponseEntity<String> handleNumberFormatException(NumberFormatException ex) { return new ResponseEntity<>("You can enter only numeric value --> "+ex.getMessage()+"not a numeric value",HttpStatus.NOT_ACCEPTABLE); } @ExceptionHandler public ResponseEntity<String> handleNoPassengerInBusException(NoPassengerInBusException ex) { return new ResponseEntity<>(ex.getMessage(),HttpStatus.NOT_FOUND); } @ExceptionHandler public ResponseEntity<String> handlePassengerNotFoundException(PassengerNotFoundException ex) { return new ResponseEntity<>(ex.getMessage(),HttpStatus.NOT_FOUND); } @ExceptionHandler public ResponseEntity<String> handleRollbackException(RollbackException ex) { return new ResponseEntity<>(ex.getMessage()+"Please check the fileds you have entered",HttpStatus.NOT_ACCEPTABLE); } }
[ "akashshyamyadav1997@gmail.com" ]
akashshyamyadav1997@gmail.com
f1da053aabafc830170c7cda68e601b432e13f03
45d454c5721aa604c55a00966dd7058740331000
/Decorator/DecoratorDemo.java
fd7353545db7f7de888effa4a9004fed9295a896
[]
no_license
doubleZ0108/Design-Pattern
b4b72198d1ea59a089ed751afc56ebd925996034
c191aba298c7acedfa7456fd810da16fba151869
refs/heads/master
2021-07-17T12:06:35.516760
2020-09-19T12:41:52
2020-09-19T12:41:52
214,565,626
12
5
null
null
null
null
UTF-8
Java
false
false
1,273
java
/** * @program: Design Pattern * @description: 装饰器 * @author: doubleZ * @create: 2020/02/22 **/ /** * 抽象构建 */ interface Component{ void operation(); } /** * 具体构建 */ class ConcreteComponent implements Component{ @Override public void operation() { System.out.println("ConcreteComponent.operation"); } } /** * 抽象装饰器 */ class Decorator implements Component{ private Component component; public Decorator(Component component) { this.component = component; } @Override public void operation() { component.operation(); } } /** * 具体装饰器 */ class ConcreteDecorator extends Decorator{ public ConcreteDecorator(Component component) { super(component); } @Override public void operation() { super.operation(); addedOperation(); } public void addedOperation(){ System.out.println("为构建增加的额外功能addedOperation"); } } public class DecoratorDemo { public static void main(String[] args) { Component component = new ConcreteComponent(); component.operation(); Component decorator = new ConcreteDecorator(component); decorator.operation(); } }
[ "doubleZ0108@163.com" ]
doubleZ0108@163.com
462258287e23b038d3c142b33ba954881aef40c8
5ad826c24c8932700fa77008c217a89bb63bed5e
/src/main/java/com/springboot/config/WebMvcConfig.java
99d4cb18e2835e30e863e51f757adc4699bae8e0
[]
no_license
zhou-github-name/spring-boot-druid
16e5cb4589bb041e4d093eb29e55de1876c1f61a
d2679a35171d2c4a369186fcec83344d1c115eb0
refs/heads/master
2023-01-08T20:11:11.135077
2020-11-11T02:16:07
2020-11-11T02:16:07
311,834,131
1
0
null
null
null
null
UTF-8
Java
false
false
1,138
java
package com.springboot.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.springboot.interceptor.UserTokenInterceptor; @Configuration public class WebMvcConfig implements WebMvcConfigurer { @Bean public UserTokenInterceptor userTokenInterceptor() { return new UserTokenInterceptor(); } /** * 注册拦截器 * * @param registry * @param.重写addInterceptors 添加监听的路径 * @paramaddPathPatterns 添加监听的路径地址 * @paramexcludePathPatterns 排除一些路径 */ @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(userTokenInterceptor()) .addPathPatterns("/hello") .addPathPatterns("/shopcart/add") .addPathPatterns("/shopcart/del") .excludePathPatterns("/myorders/deliver") .excludePathPatterns("/orders/notifyMerchantOrderPaid"); WebMvcConfigurer.super.addInterceptors(registry); } }
[ "zhouyworks@163.com" ]
zhouyworks@163.com
b899e45e5227bb65f06c260e58e5a918a92a87c1
331434190b7659aedd8ec85367b2bd37c9970276
/src/BinaryTree/CommonAncestorOfBinaryTree.java
bfb245412ccdcfadc21e2135845ce0bee8bcb755
[]
no_license
bigwego/algorithm
0eac330abecf795d526099f45327792ffee9851e
23551df69d8443adad8001b1a33ab090230b55e4
refs/heads/master
2021-07-13T17:55:08.031184
2020-07-17T01:25:26
2020-07-17T01:25:26
159,403,625
1
0
null
null
null
null
UTF-8
Java
false
false
655
java
package BinaryTree; /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class CommonAncestorOfBinaryTree { private TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if (root == null || root == p || root == q) { return root; } TreeNode left = lowestCommonAncestor(root.left, p, q); TreeNode right = lowestCommonAncestor(root.right, p, q); if (left != null && right != null) { return root; } return left == null ? right : left; } }
[ "zhangwei@team-lab.com" ]
zhangwei@team-lab.com
e64904e1f36eb46c9d8858a5ef5ee304979352c4
42b5a9797a0ccd1449ae5c0f2be581e23dce2c60
/core/src/com/jga/jumper/levels/Level_8.java
083481e6d4a27cd72a268f793d59d44f0a874e00
[]
no_license
will-anthony/Monster-Jumper
1b0082934942685bd446618cac5d5fae49a31627
6a9788fdb4c6e93cbbf961a5839ad77d21a79173
refs/heads/master
2022-12-10T10:10:35.413357
2020-09-01T20:55:41
2020-09-01T20:55:41
272,233,543
0
0
null
null
null
null
UTF-8
Java
false
false
3,108
java
package com.jga.jumper.levels; import com.jga.jumper.controllers.ControllerRegister; import com.jga.jumper.controllers.MageController; import com.jga.jumper.controllers.SlugController; public class Level_8 implements Level { private final ControllerRegister controllerRegister; private final SlugController slugController; private final MageController mageController; private float levelTimer; private boolean levelBrake; private boolean hasFirstWaveSpawned; private boolean hasSecondWaveSpawned; private boolean hasThirdWaveSpawned; private boolean hasFourthWaveSpawned; private boolean hasFifthWaveSpawned; private boolean hasSixthWaveSpawned; private static final float FINAL_WAVE_TIME = 5f; public Level_8(ControllerRegister controllerRegister) { this.controllerRegister = controllerRegister; slugController = controllerRegister.getSlugController(); mageController = controllerRegister.getMageController(); levelBrake = false; levelTimer = 0f; hasFirstWaveSpawned = false; hasSecondWaveSpawned = false; hasThirdWaveSpawned = false; hasFourthWaveSpawned = false; hasFifthWaveSpawned = false; hasSixthWaveSpawned = false; } @Override public void update(float delta) { if (levelTimer >= 0 && !hasFirstWaveSpawned) { System.out.println("Level 8"); slugController.tryToAddSlugs(2); hasFirstWaveSpawned = true; } if (levelTimer >= 6 && !hasSecondWaveSpawned) { mageController.tryToAddMages(1); slugController.tryToAddSlugs(1); hasSecondWaveSpawned = true; } // if (levelTimer >= 10 && !hasThirdWaveSpawned) { // slugController.tryToAddSlugs(1); // hasThirdWaveSpawned = true; // } // // if (levelTimer >= 12 && !hasFourthWaveSpawned) { // slugController.tryToAddSlugs(1); // hasFourthWaveSpawned = true; // } // // if (levelTimer >= 16 && !hasFifthWaveSpawned) { // slugController.tryToAddSlugs(1); // hasFifthWaveSpawned = true; // } // // if (levelTimer >= FINAL_WAVE_TIME && !hasSixthWaveSpawned) { // mageController.tryToAddMages(1); // slugController.tryToAddSlugs(1); // hasSixthWaveSpawned = true; // } levelTimer += delta; } @Override public boolean hasLevelFinished() { if (levelTimer >= FINAL_WAVE_TIME && levelBrake == false) { levelBrake = true; levelTimer = 0; System.out.println("Level completed"); return true; } else { return false; } } @Override public void reset() { levelBrake = false; levelTimer = 0f; hasFirstWaveSpawned = false; hasSecondWaveSpawned = false; hasThirdWaveSpawned = false; hasFourthWaveSpawned = false; hasFifthWaveSpawned = false; hasSixthWaveSpawned = false; } }
[ "will-anthony@hotmail.com" ]
will-anthony@hotmail.com
90f3cf7080e299001ff4d06c158d632175c23081
c474b03758be154e43758220e47b3403eb7fc1fc
/apk/decompiled/com.tinder_2018-07-26_source_from_JADX/sources/com/tinder/chat/view/ae.java
e799c62ad65f28aa5ad897ff6d45172a25aab4f1
[]
no_license
EstebanDalelR/tinderAnalysis
f80fe1f43b3b9dba283b5db1781189a0dd592c24
941e2c634c40e5dbf5585c6876ef33f2a578b65c
refs/heads/master
2020-04-04T09:03:32.659099
2018-11-23T20:41:28
2018-11-23T20:41:28
155,805,042
0
0
null
2018-11-18T16:02:45
2018-11-02T02:44:34
null
UTF-8
Java
false
false
304
java
package com.tinder.chat.view; import rx.functions.Action1; final /* synthetic */ class ae implements Action1 { /* renamed from: a */ static final Action1 f43649a = new ae(); private ae() { } public void call(Object obj) { ChatInputBoxContainer.e((Throwable) obj); } }
[ "jdguzmans@hotmail.com" ]
jdguzmans@hotmail.com
66eddfeb50a271bb6b337a1c4414fa1b1cb511a9
8d135ded56b906dde12a40a679c4a77ec1b24a49
/app/src/main/java/com/rarahat02/rarahat02/spl3/ui/activity/login/User.java
16e4be39f32ed0dc6cde8b1ce7c68da78a24e8c3
[ "Apache-2.0" ]
permissive
rarahat02/spl3
1d6dcee25c3d555099111d7da57f912e46e56ced
b6fe7498209adc5c223492ef8548b512497f7f12
refs/heads/master
2021-01-20T11:38:13.359032
2017-12-21T13:51:39
2017-12-21T13:51:39
101,675,037
0
0
null
2017-10-07T08:58:27
2017-08-28T18:35:03
null
UTF-8
Java
false
false
1,252
java
package com.rarahat02.rarahat02.spl3.ui.activity.login; /** * Created by AndroidBash on 10/07/16 */ public class User { private String id; private String name; private String phoneNumber; private String email; private String password; public User() { } public User(String id, String name, String phoneNumber, String email, String password) { this.id = id; this.name = name; this.phoneNumber = phoneNumber; this.email = email; this.password = password; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
[ "rarahat02@gmail.com" ]
rarahat02@gmail.com
c4b1360c95cb4c6bd9659305e19787b814aa17db
49fe3c80f4ae2001a9b332b8318cc5946de2ea19
/src/MaratonaJava/Jmodificadofinal/classes/Comprador.java
928a0225180024d9148eaae7732abe54079cc769
[]
no_license
IgorDmoura/MaratonaJava
45c32be72d6a3744f1e70de34ce666a4ec588149
862c452f53981cfb4cd56420328f988d667a0006
refs/heads/master
2023-06-01T23:36:13.773090
2021-06-18T12:28:39
2021-06-18T12:28:39
346,050,920
0
0
null
null
null
null
UTF-8
Java
false
false
374
java
package MaratonaJava.Jmodificadofinal.classes; public class Comprador { private String nome; @Override public String toString() { return "Comprador{" + "nome='" + nome + '\'' + '}'; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } }
[ "igor.dmoura01@gmail.com" ]
igor.dmoura01@gmail.com
2fc14fb65ad3e72407a024f19dbb98db4d181fc4
cfab485f5ff8438f881816c92e96d9571984b98e
/wifi4eu-persistence/src/main/java/wifi4eu/wifi4eu/entity/exportImport/GlobalCommitment.java
eb8e9d086475685c50c77b0d92ef0bbac1de5a44
[]
no_license
wifi4eu/master
f9f0b7d9a29e997cd6ab0a5087bdfe91cd55f2d6
cc4c60449e7b7ea23a47183b42869e8df2092d54
refs/heads/master
2021-09-25T01:16:53.953994
2018-10-16T07:54:45
2018-10-16T07:54:45
153,153,932
8
5
null
null
null
null
UTF-8
Java
false
false
1,640
java
package wifi4eu.wifi4eu.entity.exportImport; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "global_commitment") public class GlobalCommitment { @Column(name = "id") @Id private Integer id; @Column(name = "call") private Integer call; @Column(name = "globalCommitment") private String globalCommitment; @Column(name = "ammount") private String ammount; @Column(name = "priority") private Integer priority; public GlobalCommitment() {} public GlobalCommitment(Integer id, Integer call, String globalCommitment, String ammount, Integer priority) { this.id = id; this.call = call; this.globalCommitment = globalCommitment; this.ammount = ammount; this.priority = priority; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getCall() { return call; } public void setCall(Integer call) { this.call = call; } public String getGlobalCommitment() { return globalCommitment; } public void setGlobalCommitment(String globalCommitment) { this.globalCommitment = globalCommitment; } public String getAmmount() { return ammount; } public void setAmmount(String ammount) { this.ammount = ammount; } public Integer getPriority() { return priority; } public void setPriority(Integer priority) { this.priority = priority; } }
[ "david.romero.rodriguez@everis.com" ]
david.romero.rodriguez@everis.com
5107f6f1a5405144df458dcd8f74fa154d90d4b1
2a55c133a56db06f98998bbe8750eb692444df1b
/src/test/Test.java
64834d2dc9c3ff6a4f1dbe1efdb95536ef143743
[]
no_license
analaurap/AnaTestProject
54ac8afefa52d69fe6b37f127d894ada95062bd0
8c6045fad97e3e9b76bc7a5ed0acbec6e6e7f90d
refs/heads/master
2021-01-12T14:06:52.427360
2016-10-06T14:26:10
2016-10-06T14:26:10
70,161,282
0
0
null
null
null
null
UTF-8
Java
false
false
219
java
package test; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Sharing a project using GIT."); System.out.println("Test 2."); } }
[ "analaura.pace@tangoe.com" ]
analaura.pace@tangoe.com
90e090a40f5c30cf384420b545f316b4fca5ce01
baee3ef7cc98badf8a87e9f74ddd1a6d70b096b0
/.urionlinejudge/src/GRAPH/MillasToChicago.java
9f8133bde1e3ac97021684e26d3bc4a9e399254d
[]
no_license
groverinho/Java
eb4863737888d552ac313e23f0e7e2fd2dc45aa7
0b0c612eb03cf27b8310448bcf72da4565be0af6
refs/heads/master
2021-12-25T11:32:46.222179
2021-09-10T22:48:14
2021-09-10T22:48:14
47,481,887
2
0
null
null
null
null
UTF-8
Java
false
false
1,598
java
package GRAPH; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class MillasToChicago { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); while (true) { int nodo = entrada.nextInt();//cantidad de nodos if (nodo== 0) break; int n = entrada.nextInt();//cantidad de vertices - conexiones double [][] matrizAdyacencia = new double[nodo][nodo]; // inicio todas las posiciones de mi matriz en 0 for (int i = 0; i < matrizAdyacencia.length; i++) for (int j = 0; j < matrizAdyacencia.length; j++) matrizAdyacencia[i][j]=0.0; //cargamos inicio, fin y pesos hasta n (cant de conexiones) for (int i = 0; i < n; i++) { int a = entrada.nextInt(); int b = entrada.nextInt(); int peso = entrada.nextInt(); matrizAdyacencia[a-1][b-1]=peso/100.0; matrizAdyacencia[b-1][a-1]=peso/100.0; } double[][]nueva = floyd(matrizAdyacencia,nodo); // for (int i = 0; i < matrizAdyacencia.length; i++) // { // for (int j = 0; j < matrizAdyacencia.length; j++) // { // System.out.print(matrizAdyacencia[i][j]+"\t"); // } // System.out.println(); // } System.out.printf("%.6f percent\n",nueva[0][nodo-1]*100.0); } } //algoritmo de floyd-warshall static double[][] floyd (double w[][],int n) { for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if(i!=j) w[i][j]=Math.max(w[i][j],w[i][k]*w[k][j]);//anadimos ruta minima en la posision } } } return w; } }
[ "grover_ariel@hotmail.com" ]
grover_ariel@hotmail.com
72a085bcb1603e2507ea00e82ffff0644c55314d
9ef21441f2ef0ede95747ba7c49ba08259fb5448
/src/main/java/me/lqw/blog8/job/DatabaseBackupJob.java
f097354d6ea5d69315aa704108e24f3d83a9a484
[]
no_license
qwli6/blog8
d00a9f0ba4ae5c6a2de39cd22af91418c7621996
b8569d9d34208563b4b845211dd456cdfeff7635
refs/heads/master
2022-12-16T13:37:26.289134
2020-09-29T09:02:43
2020-09-29T09:02:43
114,002,196
1
1
null
null
null
null
UTF-8
Java
false
false
4,033
java
package me.lqw.blog8.job; import me.lqw.blog8.BlogProperties; import me.lqw.blog8.service.SimpleMailHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.*; /** * 数据库数据备份 job * * @author liqiwen * @version 1.2 * @since 1.2 * @since 2.3 */ @Component public class DatabaseBackupJob implements DisposableBean { /** * 记录日志 */ private final Logger logger = LoggerFactory.getLogger(getClass().getSimpleName()); /** * 博客配置文件 */ private final BlogProperties blogProperties; /** * 邮件处理 */ private final SimpleMailHandler mailHandler; /** * 构造方法 * @param blogProperties blogProperties * @param mailHandler mailHandler */ public DatabaseBackupJob(BlogProperties blogProperties, SimpleMailHandler mailHandler) { this.blogProperties = blogProperties; this.mailHandler = mailHandler; } /** * 定时备份数据库 * 每天晚上 22 点 45 分 3 秒执行一次,备份成功后将备份文件通过邮件发送至指定邮箱 * @since 2.3 */ @Scheduled(cron = "3 45 22 * * ?") @Async("blogThreadPoolExecutor") public void backup() { boolean backupDb = blogProperties.isBackupDb(); if(!backupDb){ logger.info("DatabaseBackupJob backup has closed!"); return; } String dbUser = blogProperties.getDbUser(); String dbHost = blogProperties.getDbHost(); String dbPass = blogProperties.getDbPassword(); String dbPort = blogProperties.getDbPort(); String dbName = blogProperties.getDbName(); String backPath = blogProperties.getBackPath(); String[] commands = new String[]{"mysqldump", dbName, "--default-character-set=utf8mb4", "-h" + dbHost, "-P" + dbPort, "-u" + dbUser , "-p" + dbPass, "--result-file=" + backPath}; ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command(commands); Process process = null; try { process = processBuilder.start(); process.waitFor(); //获取线程输入流 InputStream inputStream = process.getInputStream(); //获取进程错误流 InputStream errorStream = process.getErrorStream(); //获取输出流 OutputStream outputStream = process.getOutputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); String temp; while ((temp = bufferedReader.readLine()) != null){ //流中的内容需要读取出来,不然会阻塞 JVM logger.info("temp: [{}]", temp); } logger.info("backup.sql back finished!"); File backSqlFile = new File(backPath); if(backSqlFile.exists()){ logger.info("backup.sql file send file to admin!"); boolean sendResult = mailHandler.sendMailAttach(backSqlFile); if(sendResult) { logger.info("backup.sql file send file finished!"); boolean delete = backSqlFile.delete(); logger.info("file delete finished [{}]", delete); } } } catch (IOException | InterruptedException e) { logger.error("DatabaseBackupJob exception:[{}]", e.getMessage(), e); e.printStackTrace(); } finally { if(process != null && process.isAlive()){ process.destroy(); } } } @Override public void destroy() throws Exception { logger.info("DatabaseBackupJob destroy()"); } }
[ "selfassu@gmail.com" ]
selfassu@gmail.com
248304d17efc95b2a51f5b83f93056633f464049
1b0ea8ad5a9b20d4c2993b3619016f883d835560
/src/net/jforum/view/admin/ForumAction.java
5a988e7570a939a8be37b105482d881899b291c0
[]
no_license
yecpster/igearbook
97606843da226bd3f08b6c1d58c900a419cc3d9a
35d6304bffaca9867f3acb514f48ff854054e060
refs/heads/master
2021-01-17T10:59:05.254408
2016-07-23T09:12:04
2016-07-23T09:12:04
13,015,069
0
0
null
null
null
null
UTF-8
Java
false
false
18,868
java
/* * Copyright (c) JForum Team * All rights reserved. * * Redistribution and use in source and binary forms, * with or without modification, are permitted provided * that the following conditions are met: * * 1) Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * 2) Redistributions in binary form must reproduce the * above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or * other materials provided with the distribution. * 3) Neither the name of "Rafael Steil" nor * the names of its contributors may be used to endorse * or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * * This file creation date: Mar 28, 2003 / 8:21:56 PM * The JForum Project * http://www.jforum.net */ package net.jforum.view.admin; import java.util.List; import net.jforum.dao.CategoryDAO; import net.jforum.dao.DataAccessDriver; import net.jforum.dao.ForumDAO; import net.jforum.dao.GroupDAO; import net.jforum.dao.GroupSecurityDAO; import net.jforum.dao.TopicDAO; import net.jforum.dao.UserDAO; import net.jforum.entities.Category; import net.jforum.entities.Forum; import net.jforum.entities.Group; import net.jforum.entities.User; import net.jforum.repository.ForumRepository; import net.jforum.repository.RolesRepository; import net.jforum.repository.SecurityRepository; import net.jforum.security.PermissionControl; import net.jforum.security.Role; import net.jforum.security.RoleValue; import net.jforum.security.RoleValueCollection; import net.jforum.security.SecurityConstants; import net.jforum.util.preferences.ConfigKeys; import net.jforum.util.preferences.SystemGlobals; import net.jforum.util.preferences.TemplateKeys; import net.jforum.view.admin.common.ModerationCommon; import com.google.common.collect.Lists; /** * @author Rafael Steil * @version $Id: ForumAction.java,v 1.34 2007/08/25 00:11:29 rafaelsteil Exp $ */ public class ForumAction extends AdminCommand { // Listing @Override public void list() { this.context.put("categories", DataAccessDriver.getInstance().newCategoryDAO().selectAll()); this.context.put("repository", new ForumRepository()); this.setTemplateName(TemplateKeys.FORUM_ADMIN_LIST); } // One more, one more public void insert() { final CategoryDAO cm = DataAccessDriver.getInstance().newCategoryDAO(); final GroupDAO groupDao = DataAccessDriver.getInstance().newGroupDAO(); final List<Group> selectedGroups = Lists.newArrayList(); final List<Group> candidateGrups = groupDao.getCandidateGroups(selectedGroups); this.context.put("accessCandidateGroups", candidateGrups); this.context.put("replyCandidateGroups", candidateGrups); this.context.put("postCandidateGroups", candidateGrups); this.context.put("htmlCandidateGroups", candidateGrups); this.context.put("accessSelectedGroups", selectedGroups); this.context.put("replySelectedGroups", selectedGroups); this.context.put("postSelectedGroups", selectedGroups); this.context.put("htmlSelectedGroups", selectedGroups); this.context.put("categories", cm.selectAll()); this.context.put("action", "insertSave"); this.setTemplateName(TemplateKeys.FORUM_ADMIN_INSERT); } // A new one public void insertSave() { final Forum f = new Forum(); f.setDescription(this.request.getParameter("description")); f.setCategoryId(this.request.getIntParameter("categories_id")); f.setName(this.request.getParameter("forum_name")); f.setLogo(this.request.getParameter("forum_Logo")); f.setModerated("1".equals(this.request.getParameter("moderate"))); final int forumId = DataAccessDriver.getInstance().newForumDAO().addNew(f); f.setId(forumId); ForumRepository.addForum(f); final GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO(); final PermissionControl pc = new PermissionControl(); pc.setSecurityModel(gmodel); // Access final GroupDAO groupDao = DataAccessDriver.getInstance().newGroupDAO(); final Group accessGroup = groupDao.addNewEntitlementGroup(SecurityConstants.PERM_FORUM, forumId); this.addRole(pc, SecurityConstants.PERM_FORUM, forumId, accessGroup); final String[] groupsAccess = request.getParameterValues("groupsAccess"); updateChildGroups(accessGroup, groupsAccess, groupDao); // Anonymous posts final Group anonymousPostsGroup = groupDao.addNewEntitlementGroup(SecurityConstants.PERM_ANONYMOUS_POST, forumId); this.addRole(pc, SecurityConstants.PERM_ANONYMOUS_POST, forumId, anonymousPostsGroup); final boolean permitAnonymousPosts = "1".equals(this.request.getParameter("permitAnonymousPosts")); if (permitAnonymousPosts) { final UserDAO um = DataAccessDriver.getInstance().newUserDAO(); final int anonymousUid = Integer.parseInt(SystemGlobals.getValue(ConfigKeys.ANONYMOUS_USER_ID)); um.addToGroup(anonymousUid, new int[] { anonymousPostsGroup.getId() }); } // Permit to replay final Group replyGroup = groupDao.addNewEntitlementGroup(SecurityConstants.PERM_REPLY, forumId); this.addRole(pc, SecurityConstants.PERM_REPLY, forumId, replyGroup); final String[] groupsReply = request.getParameterValues("groupsReply"); updateChildGroups(replyGroup, groupsReply, groupDao); // Permit to new post final Group newPostGroup = groupDao.addNewEntitlementGroup(SecurityConstants.PERM_NEW_POST, forumId); this.addRole(pc, SecurityConstants.PERM_NEW_POST, forumId, newPostGroup); final String[] groupsPost = request.getParameterValues("groupsPost"); updateChildGroups(newPostGroup, groupsPost, groupDao); // HTML final Group htmlGroup = groupDao.addNewEntitlementGroup(SecurityConstants.PERM_HTML_DISABLED, forumId); this.addRole(pc, SecurityConstants.PERM_HTML_DISABLED, forumId, htmlGroup); final String[] groupsHtml = request.getParameterValues("groupsHtml"); updateChildGroups(htmlGroup, groupsHtml, groupDao); SecurityRepository.clean(); RolesRepository.clear(); // this.handleMailIntegration(); this.list(); } // Edit public void edit() { final int forumId = this.request.getIntParameter("forum_id"); final ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO(); final CategoryDAO cm = DataAccessDriver.getInstance().newCategoryDAO(); final GroupDAO groupDao = DataAccessDriver.getInstance().newGroupDAO(); final Group accessGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_FORUM, forumId); final List<Group> accessSelectedGroups = groupDao.getChildGroups(accessGroup.getId()); this.context.put("accessSelectedGroups", accessSelectedGroups); this.context.put("accessCandidateGroups", groupDao.getCandidateGroups(accessSelectedGroups)); final int anonymousUid = Integer.parseInt(SystemGlobals.getValue(ConfigKeys.ANONYMOUS_USER_ID)); final boolean permitAnonymousPosts = SecurityRepository.canAccess(anonymousUid, SecurityConstants.PERM_ANONYMOUS_POST, String.valueOf(forumId)); this.context.put("permitAnonymousPosts", permitAnonymousPosts); Group moderationGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_MODERATION_FORUMS, forumId); if (moderationGroup == null) { moderationGroup = this.createModerationGroup(groupDao, forumId); } final List<User> moderators = DataAccessDriver.getInstance().newUserDAO().selectAllByGroup(moderationGroup.getId(), 0, 50); this.context.put("moderationGroup", moderationGroup); this.context.put("moderators", moderators); final Group replyGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_REPLY, forumId); final List<Group> replySelectedGroups = groupDao.getChildGroups(replyGroup.getId()); this.context.put("replySelectedGroups", replySelectedGroups); this.context.put("replyCandidateGroups", groupDao.getCandidateGroups(replySelectedGroups)); final Group newPostGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_NEW_POST, forumId); final List<Group> postSelectedGroups = groupDao.getChildGroups(newPostGroup.getId()); this.context.put("postSelectedGroups", postSelectedGroups); this.context.put("postCandidateGroups", groupDao.getCandidateGroups(postSelectedGroups)); final Group htmlPostGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_HTML_DISABLED, forumId); final List<Group> htmlSelectedGroups = groupDao.getChildGroups(htmlPostGroup.getId()); this.context.put("htmlSelectedGroups", htmlSelectedGroups); this.context.put("htmlCandidateGroups", groupDao.getCandidateGroups(htmlSelectedGroups)); this.setTemplateName(TemplateKeys.FORUM_ADMIN_EDIT); this.context.put("categories", cm.selectAll()); this.context.put("action", "editSave"); this.context.put("forum", forumDao.selectById(forumId)); // Mail Integration // MailIntegrationDAO integrationDao = // DataAccessDriver.getInstance().newMailIntegrationDAO(); // this.context.put("mailIntegration", integrationDao.find(forumId)); } public void editSave() { final ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO(); final int forumId = this.request.getIntParameter("forum_id"); final Forum f = forumDao.selectById(forumId); final boolean moderated = f.isModerated(); final int categoryId = f.getCategoryId(); f.setDescription(this.request.getParameter("description")); f.setCategoryId(this.request.getIntParameter("categories_id")); f.setName(this.request.getParameter("forum_name")); f.setLogo(this.request.getParameter("forum_logo")); f.setModerated("1".equals(this.request.getParameter("moderate"))); forumDao.update(f); if (moderated != f.isModerated()) { new ModerationCommon().setTopicModerationStatus(f.getId(), f.isModerated()); } if (categoryId != f.getCategoryId()) { f.setCategoryId(categoryId); ForumRepository.removeForum(f); f.setCategoryId(this.request.getIntParameter("categories_id")); ForumRepository.addForum(f); } else { ForumRepository.reloadForum(f.getId()); } // this.handleMailIntegration(); // Forum access final GroupDAO groupDao = DataAccessDriver.getInstance().newGroupDAO(); final Group accessGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_FORUM, forumId); final String[] groupsAccess = request.getParameterValues("groupsAccess"); updateChildGroups(accessGroup, groupsAccess, groupDao); // Anonymous post final boolean permitAnonymousPosts = "1".equals(this.request.getParameter("permitAnonymousPosts")); final Group anonymousPostsGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_ANONYMOUS_POST, forumId); final UserDAO um = DataAccessDriver.getInstance().newUserDAO(); final int anonymousUid = Integer.parseInt(SystemGlobals.getValue(ConfigKeys.ANONYMOUS_USER_ID)); final int[] groupIds = { anonymousPostsGroup.getId() }; um.removeFromGroup(anonymousUid, groupIds); if (permitAnonymousPosts) { um.addToGroup(anonymousUid, groupIds); } // Permit to reply final Group replyGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_REPLY, forumId); final String[] groupsReply = request.getParameterValues("groupsReply"); updateChildGroups(replyGroup, groupsReply, groupDao); // Permit to new post final Group newPostGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_NEW_POST, forumId); final String[] groupsPost = request.getParameterValues("groupsPost"); updateChildGroups(newPostGroup, groupsPost, groupDao); // HTML final Group htmlGroup = groupDao.getEntitlementGroup(SecurityConstants.PERM_HTML_DISABLED, forumId); final String[] groupsHtml = request.getParameterValues("groupsHtml"); updateChildGroups(htmlGroup, groupsHtml, groupDao); SecurityRepository.clean(); RolesRepository.clear(); this.list(); } // private void handleMailIntegration() { // int forumId = this.request.getIntParameter("forum_id"); // MailIntegrationDAO dao = // DataAccessDriver.getInstance().newMailIntegrationDAO(); // // if (!"1".equals(this.request.getParameter("mail_integration"))) { // dao.delete(forumId); // } else { // boolean exists = dao.find(forumId) != null; // // MailIntegration m = this.fillMailIntegrationFromRequest(); // // if (exists) { // dao.update(m); // } else { // dao.add(m); // } // } // } // // private MailIntegration fillMailIntegrationFromRequest() { // MailIntegration m = new MailIntegration(); // // m.setForumId(this.request.getIntParameter("forum_id")); // m.setForumEmail(this.request.getParameter("forum_email")); // m.setPopHost(this.request.getParameter("pop_host")); // m.setPopUsername(this.request.getParameter("pop_username")); // m.setPopPassword(this.request.getParameter("pop_password")); // m.setPopPort(this.request.getIntParameter("pop_port")); // m.setSSL("1".equals(this.request.getParameter("requires_ssl"))); // // return m; // } public void up() { this.processOrdering(true); } public void down() { this.processOrdering(false); } private void processOrdering(final boolean up) { final Forum toChange = new Forum(ForumRepository.getForum(Integer.parseInt(this.request.getParameter("forum_id")))); final Category category = ForumRepository.getCategory(toChange.getCategoryId()); final List<Forum> forums = Lists.newArrayList(category.getForums()); final int index = forums.indexOf(toChange); if (index == -1 || (up && index == 0) || (!up && index + 1 == forums.size())) { this.list(); return; } final ForumDAO fm = DataAccessDriver.getInstance().newForumDAO(); if (up) { // Get the forum which comes *before* the forum we're changing final Forum otherForum = new Forum(forums.get(index - 1)); fm.setOrderUp(toChange, otherForum); } else { // Get the forum which comes *after* the forum we're changing final Forum otherForum = new Forum(forums.get(index + 1)); fm.setOrderDown(toChange, otherForum); } category.changeForumOrder(toChange); ForumRepository.refreshCategory(category); this.list(); } // Delete public void delete() { final String ids[] = this.request.getParameterValues("forum_id"); final ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO(); final TopicDAO topicDao = DataAccessDriver.getInstance().newTopicDAO(); if (ids != null) { for (int i = 0; i < ids.length; i++) { final int forumId = Integer.parseInt(ids[i]); topicDao.deleteByForum(forumId); forumDao.delete(forumId); final Forum f = new Forum(ForumRepository.getForum(forumId)); ForumRepository.removeForum(f); } SecurityRepository.clean(); RolesRepository.clear(); } this.list(); } private Group createModerationGroup(final GroupDAO groupDao, final int forumId) { final GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO(); final PermissionControl pc = new PermissionControl(); pc.setSecurityModel(gmodel); final Group moderationGroup = groupDao.addNewEntitlementGroup(SecurityConstants.PERM_MODERATION_FORUMS, forumId); this.addRole(pc, SecurityConstants.PERM_CREATE_STICKY_ANNOUNCEMENT_TOPICS, forumId, moderationGroup); this.addRole(pc, SecurityConstants.PERM_MODERATION_FORUMS, forumId, moderationGroup); this.addRole(pc, SecurityConstants.PERM_MODERATION_APPROVE_MESSAGES, forumId, moderationGroup); this.addRole(pc, SecurityConstants.PERM_MODERATION_POST_REMOVE, forumId, moderationGroup); this.addRole(pc, SecurityConstants.PERM_MODERATION_POST_EDIT, forumId, moderationGroup); this.addRole(pc, SecurityConstants.PERM_MODERATION_TOPIC_MOVE, forumId, moderationGroup); this.addRole(pc, SecurityConstants.PERM_MODERATION_TOPIC_LOCK_UNLOCK, forumId, moderationGroup); return moderationGroup; } private void updateChildGroups(final Group parentGroup, String[] groups, final GroupDAO groupDao) { if (groups == null) { groups = new String[] {}; } final int[] childGroupIDs = new int[groups.length]; for (int i = 0; i < groups.length; i++) { childGroupIDs[i] = Integer.parseInt(groups[i]); } groupDao.updateChildGroups(parentGroup.getId(), childGroupIDs); } private void addRole(final PermissionControl pc, final String roleName, final int forumId, final Group group) { final Role role = new Role(); role.setName(roleName); final RoleValueCollection roleValues = new RoleValueCollection(); final RoleValue rv = new RoleValue(); rv.setValue(Integer.toString(forumId)); roleValues.add(rv); pc.addRoleValue(group.getId(), role, roleValues); } }
[ "yecpster@gmail.com" ]
yecpster@gmail.com
0a8c555c571dbe602e782dd76242250ded2c034e
5b936e0fb3752966a66a0094d4575b21f7824ac8
/src/main/java/com/atguigu/common/pojo/aop/math3/ArithmeticCalculatorXMLImpl.java
edc42cbe241517d4e45226245528c9bbbabd2680
[]
no_license
lhh1994hello/ssm_demo1
eeb9f42eca3aee70659cbe432513fea614aa9712
c8ea8dc5611129ca700d72c7a301a2be685ca66f
refs/heads/master
2020-04-16T01:54:06.810152
2019-04-23T15:05:51
2019-04-23T15:05:51
165,190,011
1
0
null
null
null
null
UTF-8
Java
false
false
775
java
package com.atguigu.common.pojo.aop.math3; import com.atguigu.common.pojo.aop.math2.ArithmeticCalculator2; import org.springframework.stereotype.Component; /** * @Author: lhh * @Date: 2019/4/7 15:57 * @Version 1.0 * 测试基于XML方式配置AOP */ @Component public class ArithmeticCalculatorXMLImpl implements ArithmeticCalculatorXML { @Override public int add(int i, int j) { int result = i + j; return result; } @Override public int sub(int i, int j) { int result = i - j; return result; } @Override public int mul(int i, int j) { int result = i * j; return result; } @Override public int div(int i, int j) { int result = i / j; return result; } }
[ "1497392219@qq.com" ]
1497392219@qq.com
eb6910a0fda3772edbf071b41fcf844a726cc8d5
650aa000f7a32b3e160819bd76878857770b33b4
/weixin-sdk/src/main/java/com/kenanai/weixin/sdk/bus/BusLineSearch.java
70e0be7c7acb9500f49bc0ef78604bdc4f223d2b
[]
no_license
guoyunsky/weixin
1b930ee5ebb6778c79a434d8d4b64bfb7d79775a
ddc4a39b23cc13bc637ddbfe02b59586f64f63af
refs/heads/master
2020-12-11T05:51:45.643431
2014-04-06T07:17:38
2014-04-06T07:17:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
205
java
package com.kenanai.weixin.sdk.bus; /** * * @ClassName: BusLineSearch * @Description: 公交线路查询 * @author leixl * @date 2014年4月3日 下午12:09:20 * */ public class BusLineSearch { }
[ "leixl0324@163.com" ]
leixl0324@163.com
1b2dfad91bc64db1be22a8d573278cacaea888fb
d222de126163144bef5f6bf5c733451a36218690
/app/src/main/java/com/example/appmabbicaracommunity/HiraganaActivity.java
09de64ef77e31ae6801e8362fcfda39c07b1c73a
[]
no_license
mrum13/kamus-3-bahasa-app
9771b71202beffab5c1a4904d95c2b5d10b5dd94
fc8e50635fae2f47e8fc81410e7e07aa630667c7
refs/heads/master
2023-08-06T08:48:11.994827
2021-09-18T09:25:47
2021-09-18T09:25:47
352,307,967
0
0
null
null
null
null
UTF-8
Java
false
false
1,474
java
package com.example.appmabbicaracommunity; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; public class HiraganaActivity extends AppCompatActivity implements AdapterRecyclerView.ItemClickListener { AdapterRecyclerView adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hiragana); // data to populate the RecyclerView with String[] data = {"あ A", "い I", "う U", "え E", "お O", "か KA", "き KI", "く KU", "け KE", "こ KO", "さ SA", "し SHI","す SU", "せ SE","そ SO","た TA","ち CHI","つ TSU","て TE","と TO","な NA","に NI","ぬ NU","ね NE","の NO","は HA","ひ HI","ふ FU","へ HE", "ほ HO","ま MA","み MI","む MU","め ME","も MO","や YA","","ゆ YU","よ YO","ら RA","り RI","る RU","れ RE","ろ RO","わ WA", "","を WO","","ん N"}; // set up the RecyclerView RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rvNumbers); int numberOfColumns = 5; recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns)); adapter = new AdapterRecyclerView(this, data); adapter.setClickListener(this); recyclerView.setAdapter(adapter); } }
[ "muhammadrum135@gmail.com" ]
muhammadrum135@gmail.com
438e133399d8a5f1427aab3690927c4d8b0df928
8cd120823f23ba7ceb4ed034489e8efa2a115d00
/MyApplication/app/src/main/java/com/example/xj/myapplication/MainActivity.java
4abcaa54f4d568f41bc37afc1ab6145b87297ffb
[]
no_license
szxj2012/cfzz_android_studio2
684a83b22d1f4398144e396175108d52de81c1be
c0c3b4bba51a6391cd505a3dab9c62ba8ab94f91
refs/heads/master
2020-06-05T15:54:51.183862
2015-02-12T07:50:19
2015-02-12T07:50:19
30,689,801
0
0
null
null
null
null
UTF-8
Java
false
false
1,338
java
package com.example.xj.myapplication; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; public class MainActivity extends ActionBarActivity { @InjectView(R.id.text1) TextView text1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); text1.setText("xxxxx"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
[ "czxj2003@gmail.com" ]
czxj2003@gmail.com
8af064c4bc70476f84693dc513078ef4181633c1
8b0ae134884d6f84217587194a2a0f775866ef55
/Vivo_y93/src/main/java/android/text/TextUtils.java
0afcdd1a52014b8da6db7e20479e91e24c673a6c
[]
no_license
wanbing/VivoFramework
69032750f376178d27d0d1ac170cf89bba907cc7
8d31381ecc788afb023960535bafbfa3b7df7d9b
refs/heads/master
2023-05-11T16:57:04.582985
2019-02-27T04:43:44
2019-02-27T04:43:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
49,000
java
package android.text; import android.content.Context; import android.content.res.Resources; import android.icu.lang.UCharacter; import android.icu.text.CaseMap; import android.icu.text.Edits; import android.icu.util.ULocale; import android.os.Parcel; import android.os.Parcelable.Creator; import android.os.SystemProperties; import android.provider.Settings.Global; import android.text.format.DateFormat; import android.text.style.AbsoluteSizeSpan; import android.text.style.AccessibilityClickableSpan; import android.text.style.AccessibilityURLSpan; import android.text.style.AlignmentSpan.Standard; import android.text.style.BackgroundColorSpan; import android.text.style.BulletSpan; import android.text.style.CharacterStyle; import android.text.style.EasyEditSpan; import android.text.style.ForegroundColorSpan; import android.text.style.LeadingMarginSpan; import android.text.style.LocaleSpan; import android.text.style.MetricAffectingSpan; import android.text.style.ParagraphStyle; import android.text.style.QuoteSpan; import android.text.style.RelativeSizeSpan; import android.text.style.ReplacementSpan; import android.text.style.ScaleXSpan; import android.text.style.SpellCheckSpan; import android.text.style.StrikethroughSpan; import android.text.style.StyleSpan; import android.text.style.SubscriptSpan; import android.text.style.SuggestionRangeSpan; import android.text.style.SuggestionSpan; import android.text.style.SuperscriptSpan; import android.text.style.TextAppearanceSpan; import android.text.style.TtsSpan; import android.text.style.TypefaceSpan; import android.text.style.URLSpan; import android.text.style.UnderlineSpan; import android.text.style.UpdateAppearance; import android.util.Log; import android.util.Printer; import com.android.internal.R; import com.android.internal.content.NativeLibraryHelper; import com.android.internal.util.ArrayUtils; import com.android.internal.util.Preconditions; import java.lang.reflect.Array; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.regex.Pattern; public class TextUtils { public static final int ABSOLUTE_SIZE_SPAN = 16; public static final int ACCESSIBILITY_CLICKABLE_SPAN = 25; public static final int ACCESSIBILITY_URL_SPAN = 26; public static final int ALIGNMENT_SPAN = 1; public static final int ANNOTATION = 18; public static final int BACKGROUND_COLOR_SPAN = 12; public static final int BULLET_SPAN = 8; public static final int CAP_MODE_CHARACTERS = 4096; public static final int CAP_MODE_SENTENCES = 16384; public static final int CAP_MODE_WORDS = 8192; public static final Creator<CharSequence> CHAR_SEQUENCE_CREATOR = new Creator<CharSequence>() { public CharSequence createFromParcel(Parcel p) { int kind = p.readInt(); String string = p.readString(); if (string == null) { return null; } if (kind == 1) { return string; } SpannableString sp = new SpannableString(string); while (true) { kind = p.readInt(); if (kind == 0) { return sp; } switch (kind) { case 1: TextUtils.readSpan(p, sp, new Standard(p)); break; case 2: TextUtils.readSpan(p, sp, new ForegroundColorSpan(p)); break; case 3: TextUtils.readSpan(p, sp, new RelativeSizeSpan(p)); break; case 4: TextUtils.readSpan(p, sp, new ScaleXSpan(p)); break; case 5: TextUtils.readSpan(p, sp, new StrikethroughSpan(p)); break; case 6: TextUtils.readSpan(p, sp, new UnderlineSpan(p)); break; case 7: TextUtils.readSpan(p, sp, new StyleSpan(p)); break; case 8: TextUtils.readSpan(p, sp, new BulletSpan(p)); break; case 9: TextUtils.readSpan(p, sp, new QuoteSpan(p)); break; case 10: TextUtils.readSpan(p, sp, new LeadingMarginSpan.Standard(p)); break; case 11: TextUtils.readSpan(p, sp, new URLSpan(p)); break; case 12: TextUtils.readSpan(p, sp, new BackgroundColorSpan(p)); break; case 13: TextUtils.readSpan(p, sp, new TypefaceSpan(p)); break; case 14: TextUtils.readSpan(p, sp, new SuperscriptSpan(p)); break; case 15: TextUtils.readSpan(p, sp, new SubscriptSpan(p)); break; case 16: TextUtils.readSpan(p, sp, new AbsoluteSizeSpan(p)); break; case 17: TextUtils.readSpan(p, sp, new TextAppearanceSpan(p)); break; case 18: TextUtils.readSpan(p, sp, new Annotation(p)); break; case 19: TextUtils.readSpan(p, sp, new SuggestionSpan(p)); break; case 20: TextUtils.readSpan(p, sp, new SpellCheckSpan(p)); break; case 21: TextUtils.readSpan(p, sp, new SuggestionRangeSpan(p)); break; case 22: TextUtils.readSpan(p, sp, new EasyEditSpan(p)); break; case 23: TextUtils.readSpan(p, sp, new LocaleSpan(p)); break; case 24: TextUtils.readSpan(p, sp, new TtsSpan(p)); break; case 25: TextUtils.readSpan(p, sp, new AccessibilityClickableSpan(p)); break; case 26: TextUtils.readSpan(p, sp, new AccessibilityURLSpan(p)); break; default: throw new RuntimeException("bogus span encoding " + kind); } } } public CharSequence[] newArray(int size) { return new CharSequence[size]; } }; public static final int EASY_EDIT_SPAN = 22; static final char[] ELLIPSIS_NORMAL = new char[]{8230}; public static final String ELLIPSIS_STRING = new String(ELLIPSIS_NORMAL); static final char[] ELLIPSIS_TWO_DOTS = new char[]{8229}; private static final String ELLIPSIS_TWO_DOTS_STRING = new String(ELLIPSIS_TWO_DOTS); private static String[] EMPTY_STRING_ARRAY = new String[0]; public static final int FIRST_SPAN = 1; public static final int FOREGROUND_COLOR_SPAN = 2; public static final int LAST_SPAN = 26; public static final int LEADING_MARGIN_SPAN = 10; public static final int LOCALE_SPAN = 23; public static final int QUOTE_SPAN = 9; public static final int RELATIVE_SIZE_SPAN = 3; public static final int SCALE_X_SPAN = 4; public static final int SPELL_CHECK_SPAN = 20; public static final int STRIKETHROUGH_SPAN = 5; public static final int STYLE_SPAN = 7; public static final int SUBSCRIPT_SPAN = 15; public static final int SUGGESTION_RANGE_SPAN = 21; public static final int SUGGESTION_SPAN = 19; public static final int SUPERSCRIPT_SPAN = 14; private static final String TAG = "TextUtils"; public static final int TEXT_APPEARANCE_SPAN = 17; public static final int TTS_SPAN = 24; public static final int TYPEFACE_SPAN = 13; public static final int UNDERLINE_SPAN = 6; public static final int URL_SPAN = 11; private static final char ZWNBS_CHAR = ''; private static Object sLock = new Object(); private static char[] sTemp = null; public interface EllipsizeCallback { void ellipsized(int i, int i2); } private static class Reverser implements CharSequence, GetChars { private int mEnd; private CharSequence mSource; private int mStart; public Reverser(CharSequence source, int start, int end) { this.mSource = source; this.mStart = start; this.mEnd = end; } public int length() { return this.mEnd - this.mStart; } public CharSequence subSequence(int start, int end) { char[] buf = new char[(end - start)]; getChars(start, end, buf, 0); return new String(buf); } public String toString() { return subSequence(0, length()).toString(); } public char charAt(int off) { return (char) UCharacter.getMirror(this.mSource.charAt((this.mEnd - 1) - off)); } public void getChars(int start, int end, char[] dest, int destoff) { TextUtils.getChars(this.mSource, this.mStart + start, this.mStart + end, dest, destoff); AndroidCharacter.mirror(dest, 0, end - start); int len = end - start; int n = (end - start) / 2; for (int i = 0; i < n; i++) { char tmp = dest[destoff + i]; dest[destoff + i] = dest[((destoff + len) - i) - 1]; dest[((destoff + len) - i) - 1] = tmp; } } } public interface StringSplitter extends Iterable<String> { void setString(String str); } public static class SimpleStringSplitter implements StringSplitter, Iterator<String> { private char mDelimiter; private int mLength; private int mPosition; private String mString; public SimpleStringSplitter(char delimiter) { this.mDelimiter = delimiter; } public void setString(String string) { this.mString = string; this.mPosition = 0; this.mLength = this.mString.length(); } public Iterator<String> iterator() { return this; } public boolean hasNext() { return this.mPosition < this.mLength; } public String next() { int end = this.mString.indexOf(this.mDelimiter, this.mPosition); if (end == -1) { end = this.mLength; } String nextString = this.mString.substring(this.mPosition, end); this.mPosition = end + 1; return nextString; } public void remove() { throw new UnsupportedOperationException(); } } public enum TruncateAt { START, MIDDLE, END, MARQUEE, END_SMALL } private TextUtils() { } public static void getChars(CharSequence s, int start, int end, char[] dest, int destoff) { Class<? extends CharSequence> c = s.getClass(); if (c == String.class) { ((String) s).getChars(start, end, dest, destoff); } else if (c == StringBuffer.class) { ((StringBuffer) s).getChars(start, end, dest, destoff); } else if (c == StringBuilder.class) { ((StringBuilder) s).getChars(start, end, dest, destoff); } else if (s instanceof GetChars) { ((GetChars) s).getChars(start, end, dest, destoff); } else { int i = start; int destoff2 = destoff; while (i < end) { destoff = destoff2 + 1; dest[destoff2] = s.charAt(i); i++; destoff2 = destoff; } destoff = destoff2; } } public static int indexOf(CharSequence s, char ch) { return indexOf(s, ch, 0); } public static int indexOf(CharSequence s, char ch, int start) { if (s.getClass() == String.class) { return ((String) s).indexOf(ch, start); } return indexOf(s, ch, start, s.length()); } public static int indexOf(CharSequence s, char ch, int start, int end) { Class<? extends CharSequence> c = s.getClass(); int i; if ((s instanceof GetChars) || c == StringBuffer.class || c == StringBuilder.class || c == String.class) { char[] temp = obtain(500); while (start < end) { int segend = start + 500; if (segend > end) { segend = end; } getChars(s, start, segend, temp, 0); int count = segend - start; for (i = 0; i < count; i++) { if (temp[i] == ch) { recycle(temp); return i + start; } } start = segend; } recycle(temp); return -1; } for (i = start; i < end; i++) { if (s.charAt(i) == ch) { return i; } } return -1; } public static int lastIndexOf(CharSequence s, char ch) { return lastIndexOf(s, ch, s.length() - 1); } public static int lastIndexOf(CharSequence s, char ch, int last) { if (s.getClass() == String.class) { return ((String) s).lastIndexOf(ch, last); } return lastIndexOf(s, ch, 0, last); } public static int lastIndexOf(CharSequence s, char ch, int start, int last) { if (last < 0) { return -1; } if (last >= s.length()) { last = s.length() - 1; } int end = last + 1; Class<? extends CharSequence> c = s.getClass(); int i; if ((s instanceof GetChars) || c == StringBuffer.class || c == StringBuilder.class || c == String.class) { char[] temp = obtain(500); while (start < end) { int segstart = end - 500; if (segstart < start) { segstart = start; } getChars(s, segstart, end, temp, 0); for (i = (end - segstart) - 1; i >= 0; i--) { if (temp[i] == ch) { recycle(temp); return i + segstart; } } end = segstart; } recycle(temp); return -1; } for (i = end - 1; i >= start; i--) { if (s.charAt(i) == ch) { return i; } } return -1; } public static int indexOf(CharSequence s, CharSequence needle) { return indexOf(s, needle, 0, s.length()); } public static int indexOf(CharSequence s, CharSequence needle, int start) { return indexOf(s, needle, start, s.length()); } public static int indexOf(CharSequence s, CharSequence needle, int start, int end) { int nlen = needle.length(); if (nlen == 0) { return start; } char c = needle.charAt(0); while (true) { start = indexOf(s, c, start); if (start > end - nlen || start < 0) { return -1; } if (regionMatches(s, start, needle, 0, nlen)) { return start; } start++; } } public static boolean regionMatches(CharSequence one, int toffset, CharSequence two, int ooffset, int len) { int tempLen = len * 2; if (tempLen < len) { throw new IndexOutOfBoundsException(); } char[] temp = obtain(tempLen); getChars(one, toffset, toffset + len, temp, 0); getChars(two, ooffset, ooffset + len, temp, len); boolean match = true; for (int i = 0; i < len; i++) { if (temp[i] != temp[i + len]) { match = false; break; } } recycle(temp); return match; } public static String substring(CharSequence source, int start, int end) { if (source instanceof String) { return ((String) source).substring(start, end); } if (source instanceof StringBuilder) { return ((StringBuilder) source).substring(start, end); } if (source instanceof StringBuffer) { return ((StringBuffer) source).substring(start, end); } char[] temp = obtain(end - start); getChars(source, start, end, temp, 0); String ret = new String(temp, 0, end - start); recycle(temp); return ret; } public static String join(CharSequence delimiter, Object[] tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token : tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } sb.append(token); } return sb.toString(); } public static String join(CharSequence delimiter, Iterable tokens) { StringBuilder sb = new StringBuilder(); Iterator<?> it = tokens.iterator(); if (it.hasNext()) { sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } } return sb.toString(); } public static String[] split(String text, String expression) { if (text.length() == 0) { return EMPTY_STRING_ARRAY; } return text.split(expression, -1); } public static String[] split(String text, Pattern pattern) { if (text.length() == 0) { return EMPTY_STRING_ARRAY; } return pattern.split(text, -1); } public static CharSequence stringOrSpannedString(CharSequence source) { if (source == null) { return null; } if (source instanceof SpannedString) { return source; } if (source instanceof Spanned) { return new SpannedString(source); } return source.toString(); } public static boolean isEmpty(CharSequence str) { return str == null || str.length() == 0; } public static String nullIfEmpty(String str) { return isEmpty(str) ? null : str; } public static String emptyIfNull(String str) { return str == null ? "" : str; } public static String firstNotEmpty(String a, String b) { return !isEmpty(a) ? a : (String) Preconditions.checkStringNotEmpty(b); } public static int length(String s) { return isEmpty(s) ? 0 : s.length(); } public static String safeIntern(String s) { return s != null ? s.intern() : null; } public static int getTrimmedLength(CharSequence s) { int len = s.length(); int start = 0; while (start < len && s.charAt(start) <= ' ') { start++; } int end = len; while (end > start && s.charAt(end - 1) <= ' ') { end--; } return end - start; } public static boolean equals(CharSequence a, CharSequence b) { if (a == b) { return true; } if (!(a == null || b == null)) { int length = a.length(); if (length == b.length()) { if ((a instanceof String) && (b instanceof String)) { return a.equals(b); } for (int i = 0; i < length; i++) { if (a.charAt(i) != b.charAt(i)) { return false; } } return true; } } return false; } @Deprecated public static CharSequence getReverse(CharSequence source, int start, int end) { return new Reverser(source, start, end); } public static void writeToParcel(CharSequence cs, Parcel p, int parcelableFlags) { if (cs instanceof Spanned) { p.writeInt(0); p.writeString(cs.toString()); Spanned sp = (Spanned) cs; Object[] os = sp.getSpans(0, cs.length(), Object.class); for (int i = 0; i < os.length; i++) { Object o = os[i]; ParcelableSpan prop = os[i]; if (prop instanceof CharacterStyle) { prop = ((CharacterStyle) prop).getUnderlying(); } if (prop instanceof ParcelableSpan) { ParcelableSpan ps = prop; int spanTypeId = ps.getSpanTypeIdInternal(); if (spanTypeId < 1 || spanTypeId > 26) { Log.e(TAG, "External class \"" + ps.getClass().getSimpleName() + "\" is attempting to use the frameworks-only ParcelableSpan" + " interface"); } else { p.writeInt(spanTypeId); ps.writeToParcelInternal(p, parcelableFlags); writeWhere(p, sp, o); } } } p.writeInt(0); return; } p.writeInt(1); if (cs != null) { p.writeString(cs.toString()); } else { p.writeString(null); } } private static void writeWhere(Parcel p, Spanned sp, Object o) { p.writeInt(sp.getSpanStart(o)); p.writeInt(sp.getSpanEnd(o)); p.writeInt(sp.getSpanFlags(o)); } public static void dumpSpans(CharSequence cs, Printer printer, String prefix) { if (cs instanceof Spanned) { Spanned sp = (Spanned) cs; Object[] os = sp.getSpans(0, cs.length(), Object.class); for (Object o : os) { printer.println(prefix + cs.subSequence(sp.getSpanStart(o), sp.getSpanEnd(o)) + ": " + Integer.toHexString(System.identityHashCode(o)) + " " + o.getClass().getCanonicalName() + " (" + sp.getSpanStart(o) + NativeLibraryHelper.CLEAR_ABI_OVERRIDE + sp.getSpanEnd(o) + ") fl=#" + sp.getSpanFlags(o)); } return; } printer.println(prefix + cs + ": (no spans)"); } public static CharSequence replace(CharSequence template, String[] sources, CharSequence[] destinations) { int i; CharSequence tb = new SpannableStringBuilder(template); for (i = 0; i < sources.length; i++) { int where = indexOf(tb, sources[i]); if (where >= 0) { tb.setSpan(sources[i], where, sources[i].length() + where, 33); } } for (i = 0; i < sources.length; i++) { int start = tb.getSpanStart(sources[i]); int end = tb.getSpanEnd(sources[i]); if (start >= 0) { tb.replace(start, end, destinations[i]); } } return tb; } public static CharSequence expandTemplate(CharSequence template, CharSequence... values) { if (values.length > 9) { throw new IllegalArgumentException("max of 9 values are supported"); } SpannableStringBuilder ssb = new SpannableStringBuilder(template); int i = 0; while (i < ssb.length()) { try { if (ssb.charAt(i) == '^') { char next = ssb.charAt(i + 1); if (next == '^') { ssb.delete(i + 1, i + 2); i++; } else if (Character.isDigit(next)) { int which = Character.getNumericValue(next) - 1; if (which < 0) { throw new IllegalArgumentException("template requests value ^" + (which + 1)); } else if (which >= values.length) { throw new IllegalArgumentException("template requests value ^" + (which + 1) + "; only " + values.length + " provided"); } else { ssb.replace(i, i + 2, values[which]); i += values[which].length(); } } } i++; } catch (IndexOutOfBoundsException e) { } } return ssb; } public static int getOffsetBefore(CharSequence text, int offset) { if (offset == 0 || offset == 1) { return 0; } char c = text.charAt(offset - 1); if (c < 56320 || c > 57343) { offset--; } else { char c1 = text.charAt(offset - 2); if (c1 < 55296 || c1 > 56319) { offset--; } else { offset -= 2; } } if (text instanceof Spanned) { ReplacementSpan[] spans = (ReplacementSpan[]) ((Spanned) text).getSpans(offset, offset, ReplacementSpan.class); for (int i = 0; i < spans.length; i++) { int start = ((Spanned) text).getSpanStart(spans[i]); int end = ((Spanned) text).getSpanEnd(spans[i]); if (start < offset && end > offset) { offset = start; } } } return offset; } public static int getOffsetAfter(CharSequence text, int offset) { int len = text.length(); if (offset == len || offset == len - 1) { return len; } char c = text.charAt(offset); if (c < 55296 || c > 56319) { offset++; } else { char c1 = text.charAt(offset + 1); if (c1 < 56320 || c1 > 57343) { offset++; } else { offset += 2; } } if (text instanceof Spanned) { ReplacementSpan[] spans = (ReplacementSpan[]) ((Spanned) text).getSpans(offset, offset, ReplacementSpan.class); for (int i = 0; i < spans.length; i++) { int start = ((Spanned) text).getSpanStart(spans[i]); int end = ((Spanned) text).getSpanEnd(spans[i]); if (start < offset && end > offset) { offset = end; } } } return offset; } private static void readSpan(Parcel p, Spannable sp, Object o) { sp.setSpan(o, p.readInt(), p.readInt(), p.readInt()); } public static void copySpansFrom(Spanned source, int start, int end, Class kind, Spannable dest, int destoff) { if (kind == null) { kind = Object.class; } Object[] spans = source.getSpans(start, end, kind); for (int i = 0; i < spans.length; i++) { int st = source.getSpanStart(spans[i]); int en = source.getSpanEnd(spans[i]); int fl = source.getSpanFlags(spans[i]); if (st < start) { st = start; } if (en > end) { en = end; } dest.setSpan(spans[i], (st - start) + destoff, (en - start) + destoff, fl); } } public static CharSequence toUpperCase(Locale locale, CharSequence source, boolean copySpans) { Edits edits = new Edits(); if (copySpans) { SpannableStringBuilder result = (SpannableStringBuilder) CaseMap.toUpper().apply(locale, source, new SpannableStringBuilder(), edits); if (!edits.hasChanges()) { return source; } Edits.Iterator iterator = edits.getFineIterator(); int sourceLength = source.length(); Spanned spanned = (Spanned) source; for (Object span : spanned.getSpans(0, sourceLength, Object.class)) { int destStart; int destEnd; int sourceStart = spanned.getSpanStart(span); int sourceEnd = spanned.getSpanEnd(span); int flags = spanned.getSpanFlags(span); if (sourceStart == sourceLength) { destStart = result.length(); } else { destStart = toUpperMapToDest(iterator, sourceStart); } if (sourceEnd == sourceLength) { destEnd = result.length(); } else { destEnd = toUpperMapToDest(iterator, sourceEnd); } result.setSpan(span, destStart, destEnd, flags); } return result; } StringBuilder result2 = (StringBuilder) CaseMap.toUpper().apply(locale, source, new StringBuilder(), edits); if (!edits.hasChanges()) { CharSequence result22 = source; } return result22; } private static int toUpperMapToDest(Edits.Iterator iterator, int sourceIndex) { iterator.findSourceIndex(sourceIndex); if (sourceIndex == iterator.sourceIndex()) { return iterator.destinationIndex(); } if (iterator.hasChange()) { return iterator.destinationIndex() + iterator.newLength(); } return iterator.destinationIndex() + (sourceIndex - iterator.sourceIndex()); } public static CharSequence ellipsize(CharSequence text, TextPaint p, float avail, TruncateAt where) { return ellipsize(text, p, avail, where, false, null); } public static CharSequence ellipsize(CharSequence text, TextPaint paint, float avail, TruncateAt where, boolean preserveLength, EllipsizeCallback callback) { return ellipsize(text, paint, avail, where, preserveLength, callback, TextDirectionHeuristics.FIRSTSTRONG_LTR, where == TruncateAt.END_SMALL ? ELLIPSIS_TWO_DOTS_STRING : ELLIPSIS_STRING); } public static CharSequence ellipsize(CharSequence text, TextPaint paint, float avail, TruncateAt where, boolean preserveLength, EllipsizeCallback callback, TextDirectionHeuristic textDir, String ellipsis) { int len = text.length(); MeasuredText mt = MeasuredText.obtain(); try { if (setPara(mt, paint, text, 0, text.length(), textDir) <= avail) { if (callback != null) { callback.ellipsized(0, 0); } MeasuredText.recycle(mt); return text; } avail -= paint.measureText(ellipsis); int left = 0; int right = len; if (avail >= 0.0f) { if (where == TruncateAt.START) { right = len - mt.breakText(len, false, avail); } else if (where == TruncateAt.END || where == TruncateAt.END_SMALL) { left = mt.breakText(len, true, avail); } else { right = len - mt.breakText(len, false, avail / 2.0f); left = mt.breakText(right, true, avail - mt.measure(right, len)); } } if (callback != null) { callback.ellipsized(left, right); } char[] buf = mt.mChars; Spanned sp = text instanceof Spanned ? (Spanned) text : null; int remaining = len - (right - left); CharSequence charSequence; if (preserveLength) { if (remaining > 0) { int left2; int ellIndex = 0; while (true) { left2 = left; if (ellIndex >= ellipsis.length() || left2 >= right) { left = left2; } else { left = left2 + 1; buf[left2] = ellipsis.charAt(ellIndex); ellIndex++; } } left = left2; } for (int i = left; i < right; i++) { buf[i] = ZWNBS_CHAR; } String str = new String(buf, 0, len); if (sp == null) { MeasuredText.recycle(mt); return str; } SpannableString ss = new SpannableString(str); copySpansFrom(sp, 0, len, Object.class, ss, 0); MeasuredText.recycle(mt); return ss; } else if (remaining == 0) { charSequence = ""; MeasuredText.recycle(mt); return charSequence; } else if (sp == null) { StringBuilder stringBuilder = new StringBuilder(ellipsis.length() + remaining); stringBuilder.append(buf, 0, left); stringBuilder.append(ellipsis); stringBuilder.append(buf, right, len - right); charSequence = stringBuilder.toString(); MeasuredText.recycle(mt); return charSequence; } else { SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.append(text, 0, left); ssb.append((CharSequence) ellipsis); ssb.append(text, right, len); MeasuredText.recycle(mt); return ssb; } } catch (Throwable th) { MeasuredText.recycle(mt); } } public static CharSequence listEllipsize(Context context, List<CharSequence> elements, String separator, TextPaint paint, float avail, int moreId) { if (elements == null) { return ""; } int totalLen = elements.size(); if (totalLen == 0) { return ""; } Resources res; BidiFormatter bidiFormatter; int i; if (context == null) { res = null; bidiFormatter = BidiFormatter.getInstance(); } else { res = context.getResources(); bidiFormatter = BidiFormatter.getInstance(res.getConfiguration().getLocales().get(0)); } SpannableStringBuilder output = new SpannableStringBuilder(); int[] endIndexes = new int[totalLen]; for (i = 0; i < totalLen; i++) { output.append(bidiFormatter.unicodeWrap((CharSequence) elements.get(i))); if (i != totalLen - 1) { output.append((CharSequence) separator); } endIndexes[i] = output.length(); } for (i = totalLen - 1; i >= 0; i--) { output.delete(endIndexes[i], output.length()); int remainingElements = (totalLen - i) - 1; if (remainingElements > 0) { CharSequence morePiece; if (res == null) { morePiece = ELLIPSIS_STRING; } else { morePiece = res.getQuantityString(moreId, remainingElements, new Object[]{Integer.valueOf(remainingElements)}); } output.append(bidiFormatter.unicodeWrap(morePiece)); } if (paint.measureText(output, 0, output.length()) <= avail) { return output; } } return ""; } @Deprecated public static CharSequence commaEllipsize(CharSequence text, TextPaint p, float avail, String oneMore, String more) { return commaEllipsize(text, p, avail, oneMore, more, TextDirectionHeuristics.FIRSTSTRONG_LTR); } @Deprecated public static CharSequence commaEllipsize(CharSequence text, TextPaint p, float avail, String oneMore, String more, TextDirectionHeuristic textDir) { MeasuredText mt = MeasuredText.obtain(); try { int len = text.length(); if (setPara(mt, p, text, 0, len, textDir) <= avail) { return text; } int i; char[] buf = mt.mChars; int commaCount = 0; for (i = 0; i < len; i++) { if (buf[i] == ',') { commaCount++; } } int remaining = commaCount + 1; int ok = 0; String okFormat = ""; int w = 0; int count = 0; float[] widths = mt.mWidths; MeasuredText tempMt = MeasuredText.obtain(); for (i = 0; i < len; i++) { w = (int) (((float) w) + widths[i]); if (buf[i] == ',') { String format; count++; remaining--; if (remaining == 1) { format = " " + oneMore; } else { format = " " + String.format(more, new Object[]{Integer.valueOf(remaining)}); } tempMt.setPara(format, 0, format.length(), textDir, null); if (((float) w) + tempMt.addStyleRun(p, tempMt.mLen, null) <= avail) { ok = i + 1; okFormat = format; } } } MeasuredText.recycle(tempMt); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(okFormat); spannableStringBuilder.insert(0, text, 0, ok); MeasuredText.recycle(mt); return spannableStringBuilder; } finally { MeasuredText.recycle(mt); } } private static float setPara(MeasuredText mt, TextPaint paint, CharSequence text, int start, int end, TextDirectionHeuristic textDir) { mt.setPara(text, start, end, textDir, null); Spanned sp = text instanceof Spanned ? (Spanned) text : null; int len = end - start; if (sp == null) { return mt.addStyleRun(paint, len, null); } float width = 0.0f; int spanStart = 0; while (spanStart < len) { int spanEnd = sp.nextSpanTransition(spanStart, len, MetricAffectingSpan.class); width += mt.addStyleRun(paint, (MetricAffectingSpan[]) removeEmptySpans((MetricAffectingSpan[]) sp.getSpans(spanStart, spanEnd, MetricAffectingSpan.class), sp, MetricAffectingSpan.class), spanEnd - spanStart, null); spanStart = spanEnd; } return width; } static boolean couldAffectRtl(char c) { if ((1424 <= c && c <= 2303) || c == 8206 || c == 8207) { return true; } if (8234 <= c && c <= 8238) { return true; } if (8294 <= c && c <= 8297) { return true; } if (55296 <= c && c <= 57343) { return true; } if (64285 <= c && c <= 65023) { return true; } if (65136 > c || c > 65278) { return false; } return true; } static boolean doesNotNeedBidi(char[] text, int start, int len) { int end = start + len; for (int i = start; i < end; i++) { if (couldAffectRtl(text[i])) { return false; } } return true; } static char[] obtain(int len) { char[] buf; synchronized (sLock) { buf = sTemp; sTemp = null; } if (buf == null || buf.length < len) { return ArrayUtils.newUnpaddedCharArray(len); } return buf; } static void recycle(char[] temp) { if (temp.length <= 1000) { synchronized (sLock) { sTemp = temp; } } } public static String htmlEncode(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '\"': sb.append("&quot;"); break; case '&': sb.append("&amp;"); break; case '\'': sb.append("&#39;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; default: sb.append(c); break; } } return sb.toString(); } public static CharSequence concat(CharSequence... text) { int i = 0; if (text.length == 0) { return ""; } if (text.length == 1) { return text[0]; } int length; CharSequence piece; boolean spanned = false; for (CharSequence piece2 : text) { if (piece2 instanceof Spanned) { spanned = true; break; } } if (spanned) { SpannableStringBuilder ssb = new SpannableStringBuilder(); length = text.length; while (i < length) { piece2 = text[i]; if (piece2 == null) { piece2 = "null"; } ssb.append(piece2); i++; } return new SpannedString(ssb); } StringBuilder sb = new StringBuilder(); length = text.length; while (i < length) { sb.append(text[i]); i++; } return sb.toString(); } public static boolean isGraphic(CharSequence str) { int len = str.length(); int i = 0; while (i < len) { int cp = Character.codePointAt(str, i); int gc = Character.getType(cp); if (gc != 15 && gc != 16 && gc != 19 && gc != 0 && gc != 13 && gc != 14 && gc != 12) { return true; } i += Character.charCount(cp); } return false; } @Deprecated public static boolean isGraphic(char c) { int gc = Character.getType(c); if (gc == 15 || gc == 16 || gc == 19 || gc == 0 || gc == 13 || gc == 14 || gc == 12) { return false; } return true; } public static boolean isDigitsOnly(CharSequence str) { int len = str.length(); int i = 0; while (i < len) { int cp = Character.codePointAt(str, i); if (!Character.isDigit(cp)) { return false; } i += Character.charCount(cp); } return true; } public static boolean isPrintableAscii(char c) { if ((' ' <= c && c <= '~') || c == 13 || c == 10) { return true; } return false; } public static boolean isPrintableAsciiOnly(CharSequence str) { int len = str.length(); for (int i = 0; i < len; i++) { if (!isPrintableAscii(str.charAt(i))) { return false; } } return true; } public static int getCapsMode(CharSequence cs, int off, int reqModes) { if (off < 0) { return 0; } int mode = 0; if ((reqModes & 4096) != 0) { mode = 4096; } if ((reqModes & 24576) == 0) { return mode; } char c; int i = off; while (i > 0) { c = cs.charAt(i - 1); if (c != '\"' && c != DateFormat.QUOTE && Character.getType(c) != 21) { break; } i--; } int j = i; while (j > 0) { c = cs.charAt(j - 1); if (c != ' ' && c != 9) { break; } j--; } if (j == 0 || cs.charAt(j - 1) == 10) { return mode | 8192; } if ((reqModes & 16384) == 0) { if (i != j) { mode |= 8192; } return mode; } else if (i == j) { return mode; } else { while (j > 0) { c = cs.charAt(j - 1); if (c != '\"' && c != DateFormat.QUOTE && Character.getType(c) != 22) { break; } j--; } if (j > 0) { c = cs.charAt(j - 1); if (c == '.' || c == '?' || c == '!') { if (c == '.') { for (int k = j - 2; k >= 0; k--) { c = cs.charAt(k); if (c == '.') { return mode; } if (!Character.isLetter(c)) { break; } } } return mode | 16384; } } return mode; } } public static boolean delimitedStringContains(String delimitedString, char delimiter, String item) { if (isEmpty(delimitedString) || isEmpty(item)) { return false; } int pos = -1; int length = delimitedString.length(); while (true) { pos = delimitedString.indexOf(item, pos + 1); if (pos == -1) { return false; } if (pos <= 0 || delimitedString.charAt(pos - 1) == delimiter) { int expectedDelimiterPos = pos + item.length(); if (expectedDelimiterPos == length || delimitedString.charAt(expectedDelimiterPos) == delimiter) { return true; } } } } public static <T> T[] removeEmptySpans(T[] spans, Spanned spanned, Class<T> klass) { T[] copy = null; int count = 0; for (int i = 0; i < spans.length; i++) { T span = spans[i]; if (spanned.getSpanStart(span) == spanned.getSpanEnd(span)) { if (copy == null) { copy = (Object[]) Array.newInstance(klass, spans.length - 1); System.arraycopy(spans, 0, copy, 0, i); count = i; } } else if (copy != null) { copy[count] = span; count++; } } if (copy == null) { return spans; } Object[] result = (Object[]) Array.newInstance(klass, count); System.arraycopy(copy, 0, result, 0, count); return result; } public static long packRangeInLong(int start, int end) { return (((long) start) << 32) | ((long) end); } public static int unpackRangeStartFromLong(long range) { return (int) (range >>> 32); } public static int unpackRangeEndFromLong(long range) { return (int) (4294967295L & range); } public static int getLayoutDirectionFromLocale(Locale locale) { if ((locale == null || (locale.equals(Locale.ROOT) ^ 1) == 0 || !ULocale.forLocale(locale).isRightToLeft()) && !SystemProperties.getBoolean(Global.DEVELOPMENT_FORCE_RTL, false)) { return 0; } return 1; } public static CharSequence formatSelectedCount(int count) { return Resources.getSystem().getQuantityString(R.plurals.selected_count, count, new Object[]{Integer.valueOf(count)}); } public static boolean hasStyleSpan(Spanned spanned) { boolean z; if (spanned != null) { z = true; } else { z = false; } Preconditions.checkArgument(z); for (Class<?> clazz : new Class[]{CharacterStyle.class, ParagraphStyle.class, UpdateAppearance.class}) { if (spanned.nextSpanTransition(-1, spanned.length(), clazz) < spanned.length()) { return true; } } return false; } public static CharSequence trimNoCopySpans(CharSequence charSequence) { if (charSequence == null || !(charSequence instanceof Spanned)) { return charSequence; } return new SpannableStringBuilder(charSequence); } public static void wrap(StringBuilder builder, String start, String end) { builder.insert(0, start); builder.append(end); } }
[ "lygforbs0@gmail.com" ]
lygforbs0@gmail.com
75742f8cda1353652b18d39164dfa187baff1e0e
91934389484a2a6afba2782d6a3915b913e1a6c9
/moco-core/src/main/java/com/github/dreamhead/moco/extractor/FormsRequestExtractor.java
d4b51e06b328167941331c28e2e578d5d254be8a
[ "MIT" ]
permissive
edgevagrant/moco
7ce1f1936578b6da72d9d80735d8e427fcfa4da4
9b3ab80f6b45612c80fc172b9814051f76e6c79d
refs/heads/master
2021-01-14T12:14:41.397409
2013-12-10T23:04:16
2013-12-10T23:04:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,914
java
package com.github.dreamhead.moco.extractor; import com.github.dreamhead.moco.RequestExtractor; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.multipart.Attribute; import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder; import io.netty.handler.codec.http.multipart.InterfaceHttpData; import java.io.IOException; import java.util.List; import java.util.Map; import static com.google.common.base.Optional.absent; import static com.google.common.base.Optional.of; import static com.google.common.collect.ImmutableMap.copyOf; import static com.google.common.collect.Maps.newHashMap; public class FormsRequestExtractor implements RequestExtractor { public Optional<ImmutableMap<String, String>> extract(FullHttpRequest request) { HttpPostRequestDecoder decoder = null; try { decoder = new HttpPostRequestDecoder(request); return of(doExtractForms(decoder)); } catch (HttpPostRequestDecoder.IncompatibleDataDecoderException idde) { return absent(); } catch (IOException e) { throw new RuntimeException(e); } finally { if (decoder != null) { decoder.destroy(); } } } private ImmutableMap<String, String> doExtractForms(HttpPostRequestDecoder decoder) throws IOException { List<InterfaceHttpData> bodyHttpDatas = decoder.getBodyHttpDatas(); Map<String, String> forms = newHashMap(); for (InterfaceHttpData data : bodyHttpDatas) { if (data.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) { Attribute attribute = (Attribute) data; forms.put(attribute.getName(), attribute.getValue()); } } return copyOf(forms); } }
[ "dreamhead.cn@gmail.com" ]
dreamhead.cn@gmail.com
0c9b9eaa4fbaf18efae2c6b14427d503f4af80ef
def82370964655905717674e0be7b783ebed7731
/trading-api/src/main/java/ca/ulaval/glo4002/trading/domain/market/Market.java
87e5df5ebcbca901295511135f0de211fa702905
[]
no_license
olgam4/GLO-4002_TradingAPI
67dbeb0be4e074837f930b1da4b08e19bbc24880
a0255075227ce9d9c0d870b03e5a716f56b06c66
refs/heads/master
2020-05-17T11:53:29.120913
2019-04-26T21:37:28
2019-04-26T21:45:36
183,696,923
0
0
null
null
null
null
UTF-8
Java
false
false
1,902
java
package ca.ulaval.glo4002.trading.domain.market; import ca.ulaval.glo4002.trading.domain.commons.Period; import ca.ulaval.glo4002.trading.domain.money.Currency; import java.time.*; import java.util.List; public class Market { private String marketSymbol; private List<Period> openHours; private ZoneOffset zoneOffset; private Currency currency; public Market(String marketSymbol, ZoneOffset zoneOffset, List<Period> openHours, Currency currency) { this.marketSymbol = marketSymbol; this.openHours = openHours; this.zoneOffset = zoneOffset; this.currency = currency; } public List<Period> getOpenHours() { return openHours; } public ZoneOffset getZoneOffset() { return zoneOffset; } public boolean isMarketOpen(LocalDateTime date) { OffsetDateTime transactionDate = date.atOffset(ZoneOffset.UTC); OffsetDateTime transactionAtMarketTime = transactionDate.withOffsetSameInstant(getZoneOffset()); if (isWeekDay(transactionAtMarketTime)) { for (Period period : getOpenHours()) { LocalTime localTime = transactionAtMarketTime.toLocalTime(); if (period.contains(LocalDateTime.of(LocalDate.now(), localTime))) { return true; } } } return false; } public boolean isMarketClose(LocalDateTime date) { return !isMarketOpen(date); } private boolean isWeekDay(OffsetDateTime date) { DayOfWeek dayOfWeek = date.getDayOfWeek(); return !(dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY); } public String getMarketSymbol() { return marketSymbol; } public Currency getCurrency() { return currency; } public void setCurrency(Currency currency) { this.currency = currency; } }
[ "ogamache@nexapp.ca" ]
ogamache@nexapp.ca
619837ef3e8afa2e3d95ba4d7b85952edf148276
f904d350275f033d45ea4eb35c1233b757be3b01
/libandroidplot/src/com/androidplot/xy/BarRenderer.java
ecf5c9db5b50108463f35919ad49535bc4b9b375
[]
no_license
evermax/sciencetoolkit
1407c16217575fa799edc4b7c9000623a4bb97a5
be70f34b4b434d3f89ca909e233c26167417bb51
refs/heads/master
2021-01-17T08:23:50.236728
2016-03-10T16:59:38
2016-03-10T16:59:38
52,116,957
0
0
null
2016-02-19T21:16:27
2016-02-19T21:16:27
null
UTF-8
Java
false
false
13,744
java
/* * Copyright 2012 AndroidPlot.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.androidplot.xy; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map.Entry; import java.util.TreeMap; import android.graphics.Canvas; import android.graphics.RectF; import com.androidplot.exception.PlotRenderException; import com.androidplot.util.ValPixConverter; /** * Renders a point as a Bar */ public class BarRenderer<T extends BarFormatter> extends XYSeriesRenderer<T> { private BarRenderStyle renderStyle = BarRenderStyle.OVERLAID; // default Render Style private BarWidthStyle widthStyle = BarWidthStyle.FIXED_WIDTH; // default Width Style private float barWidth = 5; private float barGap = 1; public enum BarRenderStyle { OVERLAID, // bars are overlaid in descending y-val order (largest val in back) STACKED, // bars are drawn stacked vertically on top of each other SIDE_BY_SIDE // bars are drawn horizontally next to each-other } public enum BarWidthStyle { FIXED_WIDTH, // bar width is always barWidth VARIABLE_WIDTH // bar width is calculated so that there is only barGap between each bar } public BarRenderer(XYPlot plot) { super(plot); } /** * Sets the width of the bars when using the FIXED_WIDTH render style * @param barWidth */ public void setBarWidth(float barWidth) { this.barWidth = barWidth; } /** * Sets the size of the gap between the bar (or bar groups) when using the VARIABLE_WIDTH render style * @param barGap */ public void setBarGap(float barGap) { this.barGap = barGap; } public void setBarRenderStyle(BarRenderStyle renderStyle) { this.renderStyle = renderStyle; } public void setBarWidthStyle(BarWidthStyle widthStyle) { this.widthStyle = widthStyle; } public void setBarWidthStyle(BarWidthStyle style, float value) { setBarWidthStyle(style); switch (style) { case FIXED_WIDTH: setBarWidth(value); break; case VARIABLE_WIDTH: setBarGap(value); break; default: break; } } @Override public void doDrawLegendIcon(Canvas canvas, RectF rect, BarFormatter formatter) { canvas.drawRect(rect, formatter.getFillPaint()); canvas.drawRect(rect, formatter.getBorderPaint()); } /** * Retrieves the BarFormatter instance that corresponds with the series passed in. * Can be overridden to return other BarFormatters as a result of touch events etc. * @param index index of the point being rendered. * @param series XYSeries to which the point being rendered belongs. * @return */ @SuppressWarnings("UnusedParameters") public T getFormatter(int index, XYSeries series) { return getFormatter(series); } public void onRender(Canvas canvas, RectF plotArea) throws PlotRenderException { List<XYSeries> sl = getPlot().getSeriesListForRenderer(this.getClass()); TreeMap<Number, BarGroup> axisMap = new TreeMap<Number, BarGroup>(); // dont try to render anything if there's nothing to render. if(sl == null) return; /* * Build the axisMap (yVal,BarGroup)... a TreeMap of BarGroups * BarGroups represent a point on the X axis where a single or group of bars need to be drawn. */ // For each Series for(XYSeries series : sl) { BarGroup barGroup; // For each value in the series for(int i = 0; i < series.size(); i++) { if (series.getX(i) != null) { // get a new bar object Bar b = new Bar(series,i,plotArea); // Find or create the barGroup if (axisMap.containsKey(b.intX)) { barGroup = axisMap.get(b.intX); } else { barGroup = new BarGroup(b.intX,plotArea); axisMap.put(b.intX, barGroup); } barGroup.addBar(b); } } } // Loop through the axisMap linking up prev pointers BarGroup prev, current; prev = null; for(Entry<Number, BarGroup> mapEntry : axisMap.entrySet()) { current = mapEntry.getValue(); current.prev = prev; prev = current; } // The default gap between each bar section int gap = (int) barGap; // Determine roughly how wide (rough_width) this bar should be. This is then used as a default width // when there are gaps in the data or for the first/last bars. float f_rough_width = ((plotArea.width() - ((axisMap.size() - 1) * gap)) / (axisMap.size() - 1)); int rough_width = (int) f_rough_width; if (rough_width < 0) rough_width = 0; if (gap > rough_width) { gap = rough_width / 2; } //Log.d("PARAMTER","PLOT_WIDTH=" + plotArea.width()); //Log.d("PARAMTER","BAR_GROUPS=" + axisMap.size()); //Log.d("PARAMTER","ROUGH_WIDTH=" + rough_width); //Log.d("PARAMTER","GAP=" + gap); /* * Calculate the dimensions of each barGroup and then draw each bar within it according to * the Render Style and Width Style. */ for(Number key : axisMap.keySet()) { BarGroup barGroup = axisMap.get(key); // Determine the exact left and right X for the Bar Group switch (widthStyle) { case FIXED_WIDTH: // use intX and go halfwidth either side. barGroup.leftX = barGroup.intX - (int) (barWidth / 2); barGroup.width = (int) barWidth; barGroup.rightX = barGroup.leftX + barGroup.width; break; case VARIABLE_WIDTH: if (barGroup.prev != null) { if (barGroup.intX - barGroup.prev.intX - gap - 1 > (int)(rough_width * 1.5)) { // use intX and go halfwidth either side. barGroup.leftX = barGroup.intX - (rough_width / 2); barGroup.width = rough_width; barGroup.rightX = barGroup.leftX + barGroup.width; } else { // base left off prev right to get the gap correct. barGroup.leftX = barGroup.prev.rightX + gap + 1; if (barGroup.leftX > barGroup.intX) barGroup.leftX = barGroup.intX; // base right off intX + halfwidth. barGroup.rightX = barGroup.intX + (rough_width / 2); // calculate the width barGroup.width = barGroup.rightX - barGroup.leftX; } } else { // use intX and go halfwidth either side. barGroup.leftX = barGroup.intX - (rough_width / 2); barGroup.width = rough_width; barGroup.rightX = barGroup.leftX + barGroup.width; } break; default: break; } //Log.d("BAR_GROUP", "rough_width=" + rough_width + " width=" + barGroup.width + " <" + barGroup.leftX + "|" + barGroup.intX + "|" + barGroup.rightX + ">"); /* * Draw the bars within the barGroup area. */ switch (renderStyle) { case OVERLAID: Collections.sort(barGroup.bars, new BarComparator()); for (Bar b : barGroup.bars) { BarFormatter formatter = b.formatter(); PointLabelFormatter plf = formatter.getPointLabelFormatter(); PointLabeler pointLabeler = null; if (formatter != null) { pointLabeler = formatter.getPointLabeler(); } //Log.d("BAR", b.series.getTitle() + " <" + b.barGroup.leftX + "|" + b.barGroup.intX + "|" + b.barGroup.rightX + "> " + b.intY); if (b.barGroup.width >= 2) { canvas.drawRect(b.barGroup.leftX, b.intY, b.barGroup.rightX, b.barGroup.plotArea.bottom, formatter.getFillPaint()); } canvas.drawRect(b.barGroup.leftX, b.intY, b.barGroup.rightX, b.barGroup.plotArea.bottom, formatter.getBorderPaint()); if(plf != null && pointLabeler != null) { canvas.drawText(pointLabeler.getLabel(b.series, b.seriesIndex), b.intX + plf.hOffset, b.intY + plf.vOffset, plf.getTextPaint()); } } break; case SIDE_BY_SIDE: int width = (int) barGroup.width / barGroup.bars.size(); int leftX = barGroup.leftX; Collections.sort(barGroup.bars, new BarComparator()); for (Bar b : barGroup.bars) { BarFormatter formatter = b.formatter(); PointLabelFormatter plf = formatter.getPointLabelFormatter(); PointLabeler pointLabeler = null; if (formatter != null) { pointLabeler = formatter.getPointLabeler(); } //Log.d("BAR", "width=" + width + " <" + leftX + "|" + b.intX + "|" + (leftX + width) + "> " + b.intY); if (b.barGroup.width >= 2) { canvas.drawRect(leftX, b.intY, leftX + width, b.barGroup.plotArea.bottom, formatter.getFillPaint()); } canvas.drawRect(leftX, b.intY, leftX + width, b.barGroup.plotArea.bottom, formatter.getBorderPaint()); if(plf != null && pointLabeler != null) { canvas.drawText(pointLabeler.getLabel(b.series, b.seriesIndex), leftX + width/2 + plf.hOffset, b.intY + plf.vOffset, plf.getTextPaint()); } leftX = leftX + width; } break; case STACKED: int bottom = (int) barGroup.plotArea.bottom; Collections.sort(barGroup.bars, new BarComparator()); for (Bar b : barGroup.bars) { BarFormatter formatter = b.formatter(); PointLabelFormatter plf = formatter.getPointLabelFormatter(); PointLabeler pointLabeler = null; if (formatter != null) { pointLabeler = formatter.getPointLabeler(); } int height = (int) b.barGroup.plotArea.bottom - b.intY; int top = bottom - height; //Log.d("BAR", "top=" + top + " bottom=" + bottom + " height=" + height); if (b.barGroup.width >= 2) { canvas.drawRect(b.barGroup.leftX, top, b.barGroup.rightX, bottom, formatter.getFillPaint()); } canvas.drawRect(b.barGroup.leftX, top, b.barGroup.rightX, bottom, formatter.getBorderPaint()); if(plf != null && pointLabeler != null) { canvas.drawText(pointLabeler.getLabel(b.series, b.seriesIndex), b.intX + plf.hOffset, b.intY + plf.vOffset, plf.getTextPaint()); } bottom = top; } break; default: break; } } } private class Bar { public XYSeries series; public int seriesIndex; public double yVal, xVal; public int intX, intY; public float pixX, pixY; public BarGroup barGroup; public Bar(XYSeries series, int seriesIndex, RectF plotArea) { this.series = series; this.seriesIndex = seriesIndex; this.xVal = series.getX(seriesIndex).doubleValue(); this.pixX = ValPixConverter.valToPix(xVal, getPlot().getCalculatedMinX().doubleValue(), getPlot().getCalculatedMaxX().doubleValue(), plotArea.width(), false) + (plotArea.left); this.intX = (int) pixX; if (series.getY(seriesIndex) != null) { this.yVal = series.getY(seriesIndex).doubleValue(); this.pixY = ValPixConverter.valToPix(yVal, getPlot().getCalculatedMinY().doubleValue(), getPlot().getCalculatedMaxY().doubleValue(), plotArea.height(), true) + plotArea.top; this.intY = (int) pixY; } else { this.yVal = 0; this.pixY = plotArea.bottom; this.intY = (int) pixY; } } public BarFormatter formatter() { return getFormatter(seriesIndex, series); } } private class BarGroup { public ArrayList<Bar> bars; public int intX; public int width, leftX, rightX; public RectF plotArea; public BarGroup prev; public BarGroup(int intX, RectF plotArea) { // Setup the TreeMap with the required comparator this.bars = new ArrayList<Bar>(); // create a comparator that compares series title given the index. this.intX = intX; this.plotArea = plotArea; } public void addBar(Bar bar) { bar.barGroup = this; this.bars.add(bar); } } @SuppressWarnings("WeakerAccess") public class BarComparator implements Comparator<Bar>{ @Override public int compare(Bar bar1, Bar bar2) { switch (renderStyle) { case OVERLAID: return Integer.valueOf(bar1.intY).compareTo(bar2.intY); case SIDE_BY_SIDE: return bar1.series.getTitle().compareToIgnoreCase(bar2.series.getTitle()); case STACKED: return bar1.series.getTitle().compareToIgnoreCase(bar2.series.getTitle()); default: return 0; } } } }
[ "evilfer@gmail.com" ]
evilfer@gmail.com
0bf28d14e5368199ef2be7cf4695513df5348061
356b6a422755a7f7b7003ef114f891d8a598148b
/gantryCranes_quanZhou/src/main/java/net/pingfang/service/websoket/SocketIoClient_Bay.java
d62f4d5a913c139837dd541bba60c70714217406
[]
no_license
JackietLee/allproject
886be6e5bd7d08ddeb2ef093fa4b64adc080ef48
743d96cdca50f5da19ddbe8ea035b18c3699091e
refs/heads/main
2023-06-24T17:35:10.292447
2021-07-20T11:25:28
2021-07-20T11:25:28
null
0
0
null
null
null
null
UTF-8
Java
false
false
12,212
java
package net.pingfang.service.websoket; import java.net.URISyntaxException; import javax.annotation.Resource; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; import net.pingfang.entity.config.Config; import net.pingfang.utils.DateUtil; /** * @author:cgf * @describe:连接消息服务,进入房间,更新消息服务等操作。 * @date:2019年10月16日上午14:00:30 */ @Component public class SocketIoClient_Bay { private static final Logger log = LoggerFactory.getLogger(SocketIoClient_Bay.class); private Socket socket; @Resource private Config config; public static final String MESSAGE_TYPE_FOUR = "16"; //车牌检查作业报文类型 /** * 连接消息服务器方法 **/ public void connectSocket() throws URISyntaxException { socket = IO.socket(config.getCon_url() + ":" + config.getCon_port() + "?clientid=" + config.getServiceCode()); /** * 输出连接消息服务信息 **/ socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() { @Override public void call(Object... args) { log.info("用户 [" + config.getServiceCode() + "] 已连接消息服务!"); try { inToServiceToRoom(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); /** * 进入或者离开房间提示 **/ socket.on("JoinOrLeaveRoom", new Emitter.Listener() { @Override public void call(Object... args) { String Date = args[0].toString(); JSONObject roomDataJson = null; try { roomDataJson = new JSONObject(Date); log.info("用户 [" + config.getServiceCode() + "] 已进入 [" + roomDataJson.getString("roomName") + "] 房间!"); } catch (JSONException e) { log.error("json 错误:" + e.getMessage()); } } }); /** * 编辑JobQueue数据后返回uuid **/ socket.on("uuid", new Emitter.Listener() { @Override public void call(Object... args) { log.info("编辑redis缓存返回uuid:" + args[0].toString()); String uuid = args[0].toString(); String jsonStr = args[1].toString(); if (null != uuid && !"".equals(uuid) && null != jsonStr && !"".equals(jsonStr)) { try { JSONObject json = new JSONObject(jsonStr); /*String conmmandName = json.getString("commandName"); if("updateBay".equals(conmmandName)) { messageContent(uuid, conmmandName); // 广播编辑消息 }*/ messageContent(uuid, json.getString("commandName"),json.getString("crane_num"),json.get("state").toString(),json.getString("workData")); // 广播编辑消息 } catch (JSONException e) { e.printStackTrace(); } } } }); /** * 删除缓存返回UUID **/ socket.on("returnUuid", new Emitter.Listener() { @Override public void call(Object... args) { log.info("删除redis缓存uuid:" + args[0].toString()); String uuid = args[0].toString(); String jsonStr = args[1].toString(); if (null != uuid && !"".equals(uuid) && null != jsonStr && !"".equals(jsonStr)) { //VariableTemp vt = JSON.parseObject(jsonStr, VariableTemp.class); //messageContent(uuid, vt.getCommandName()); // 广播编辑消息 //log.info("岸桥编号:" + vt.getSenderCode()); //log.info("commandName:" + vt.getCommandName()); } } }); /*** * 输出返回消息 */ socket.on("message", new Emitter.Listener() { @Override public void call(Object... args) { log.info("消息服务返回信息:" + args[0].toString()); } }); /** * 接收(service)房间广播消息和点对点消息 */ /* socket.on("messageevent", new Emitter.Listener() { @Override public void call(Object... args) { JSONObject jsonData = new JSONObject(args[0].toString()); log.info("用户 [" + jsonData.get("sourceClientId") + "] 发来的信息:" + jsonData.get("msgContent")); //1、解析消息 String msgContent = jsonData.get("msgContent").toString(); JSONObject contentJson = new JSONObject(msgContent); if(msgContent.contains("message_type")) { if(contentJson.getString("message_type").equals("06")){ //1 调用API修改数据库 JSONObject objt = new JSONObject(contentJson.get("parameter").toString()); JSONObject jobJson = new JSONObject(objt.get("job").toString()); JobData jobData = new JobData(); jobData.setJobkey(objt.getString("jobkey")); jobData.setJob(jobJson.toString()); //调用API放行结果保存到数据库! log.info("开始调用API修改数据"); try { //apiUrl = config.getApiUrl() + "/work/insertWorkRecord"; apiUrl = config.getApiUrl() + "/dataService/insertWorkRecord"; HttpEntity<String> entity = new HttpEntity<String>(jobData.getJob(), headers); ResponseEntity<String> respMsg = restTemplate.exchange(apiUrl, HttpMethod.POST,entity, String.class); log.info("修改数据API返回信息:" + respMsg); } catch (Exception e) { log.error("调用API修改数据错误,错误信息:"+e.getMessage()); } //2删除redis deleteByKey(jobData.getJobkey(),jobJson.getString("crane_num"),"deletejob"); }else { log.info("报文类型错误!收到的报文类型是:"+contentJson.getString("message_type")); } }else { //上锁或解锁 if(contentJson.getString("commandName").equals("lock")){ log.info("上锁指令!"); VariableTemp variable = new VariableTemp(); variable.setCommandName("lock"); variable.setJobkey(contentJson.getJSONObject("parameter").getString("jobkey")); variable.setSenderCode(contentJson.getString("senderCode")); variable.setSendTime(contentJson.getString("sendTime")); findDateByRoomAndKeySave(contentJson.getJSONObject("parameter").getString("jobkey"),variable); }else if(contentJson.getString("commandName").equals("unlock")) { log.info("解锁指令!"); VariableTemp variable = new VariableTemp(); variable.setCommandName("unlock"); variable.setJobkey(contentJson.getJSONObject("parameter").getString("jobkey")); variable.setSenderCode(""); variable.setSendTime(""); findDateByRoomAndKeySave(contentJson.getJSONObject("parameter").getString("jobkey"),variable); } } } }); */ /*** * 输出类型获取所有数据 */ socket.on("findAllDate", new Emitter.Listener() { public void call(Object... args) { /*try { String jsonList = args[0].toString();//查找出来的数据 JSONObject json = new JSONObject(jsonList); Iterator<String> it = json.keys();// 使用迭代器 JSONObject jsonObject = new JSONObject(args[1].toString()); //传过来的参数 //System.out.println("findAllDate ->" +jsonObject.toString()); String craneNum = jsonObject.getString("laneCode"); //岸桥编号 List<String> delKeyList = new ArrayList<String>(); //需要删除的KEY String key = null; while (it.hasNext()) { key = it.next(); // 获取key JSONObject jsonData = new JSONObject(json.getString(key).toString()); //报文类型("16") if(MESSAGE_TYPE_FOUR.equals(jsonData.getString("message_type"))) { //岸桥编号 if(craneNum.equals(jsonData.getString("crane_num"))) { delKeyList.add(key); // System.out.println("key: "+key); //System.out.println(jsonData); log.info("删除16号报文key: "+key); log.info("删除16号报文key: "+jsonData.toString()); } } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ } }); /** * 输出断开连接方法消息 */ socket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { @Override public void call(Object... args) { log.info("用户 [" + config.getServiceCode() + "] 已断开消息服务!"); } }); socket.connect(); } /*** * 进入房间 * * @throws JSONException */ public void inToServiceToRoom() throws JSONException { JSONObject obj = new JSONObject(); obj.put("roomName", "Service"); obj.put("clientId", config.getServiceCode()); obj.put("state", 1); socket.emit("joinOrLeaveRoom", obj); } /*** * 广播的消息内容 * @throws JSONException **/ public void messageContent(String uuid, String updateOrdel,String crane_num,String state,String workData) throws JSONException { /** * "commandCode":"bfea0d75-7aff-4e1c-b4e4-93abe65ad6d8", * "commandName":"updatejob", * "senderCode":"webuser", * "recipientCode":"serviceid", * "parameter":{"jobkey":"0db9d70c-040b-4b19-914f-9de2504c79ce","job":"完整Jobqueue",}, * "sendTime":"2018-08-11 16:17:55" */ JSONObject objectData = new JSONObject(); JSONObject serverkeyObject = new JSONObject(); serverkeyObject.put("jobkey", uuid); serverkeyObject.put("crane_num", crane_num); serverkeyObject.put("state", state); objectData.put("commandCode", "bfea0d75-7aff-4e1c-b4e4-93abe65ad6d8"); objectData.put("commandName", updateOrdel); objectData.put("senderCode", config.getServiceCode()); objectData.put("recipientCode", "Client"); objectData.put("sendTime", DateUtil.getDate("yyyy-MM-dd HH:mm:ss")); if(null !=workData) { serverkeyObject.put("workData", workData); } objectData.put("parameter", serverkeyObject); sendBroadcast(objectData.toString()); } /*** * 广播消息 * @throws JSONException */ public void sendBroadcast(String objectData) throws JSONException { JSONObject obj = new JSONObject(); obj.put("sourceClientId", config.getServiceCode()); obj.put("roomsName", "Client"); obj.put("state", 1); obj.put("msgContent", objectData); log.info("广播消息内容:" + obj); socket.emit("broadcast", obj); } /** * 新增数据service房间JobQueue数据 * @param keyId UUID * @param crane_num 岸桥编号 * @param jobQueue 作业报文JSON字符串 * @throws InterruptedException * @throws JSONException */ public void addJobQueueDate(String operationType,String msgType,String craneNum, String workData) { try { JSONObject jobQueueJson = new JSONObject(); JSONObject objStr = new JSONObject(); objStr.put("message_type", msgType); objStr.put("passtime", DateUtil.getDate("yyyy-MM-dd HH:mm:ss")); objStr.put("work_type", msgType); objStr.put("operation_type", operationType); objStr.put("state", 1); jobQueueJson.put("d5a36f80-df93-449c-824f-bde81d89885f", objStr); jobQueueJson.put("message_type", msgType); /** * sourceClientId: * roomsName:房间名称 * msgContent:消息内容 * typeName:消息类型 * State:状态,状态为1 */ JSONObject obj = new JSONObject(); obj.put("sourceClientId", config.getServiceCode()); obj.put("roomsName", "Service"); obj.put("msgContent", jobQueueJson.toString()); obj.put("typeName", "work"); obj.put("State", 1); //obj.put("keyId", UUID.randomUUID().toString()); obj.put("keyId", "d5a36f80-df93-449c-824f-bde81d89885f"); JSONObject msgJson = new JSONObject(); msgJson.put("msgType", msgType); msgJson.put("commandName", operationType); msgJson.put("crane_num", craneNum); msgJson.put("state", 1); msgJson.put("workData", workData); obj.put("railWayCode", msgJson.toString()); //新增数据 socket.emit("insertDateByRoomId", obj); } catch (JSONException e1) { e1.printStackTrace(); } } /**** * 断开连接 **/ public void disconnection() { if (socket.connected()) { socket.disconnect(); } } }
[ "280075924@qq.com" ]
280075924@qq.com
fb9ec0190db2cf8cec9d976443b312887f9610ae
30f62fe9ee60f49acfe1b08567246a26ea362c67
/src/main/java/com/edugility/maven/ArtifactsProcessingException.java
b9e3b15976b858d90f6c27cda838dc6a5decf297
[ "MIT" ]
permissive
ljnelson/artifact-maven-plugin
e55bfbb919017e90a7bf8dffe85efd8422a6cd43
e64bfb315363945aba389d9ec167c5162a9e1a04
refs/heads/master
2021-03-12T19:17:10.322099
2015-10-12T23:18:23
2015-10-12T23:18:23
25,285,790
0
0
null
null
null
null
UTF-8
Java
false
false
3,900
java
/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- * * Copyright (c) 2014 Edugility LLC. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * The original copy of this license is available at * http://www.opensource.org/license/mit-license.html. */ package com.edugility.maven; import java.io.Serializable; // for javadoc only import java.util.Collection; import org.apache.maven.artifact.Artifact; /** * An {@link Exception} indicating that something has gone wrong * during {@linkplain ArtifactsProcessor#process(MavenProject, * Collection, Log) <code>Artifact</code> processing}. * * @author <a href="http://about.me/lairdnelson" * target="_parent">Laird Nelson</a> * * @see ArtifactsProcessor * * @see ArtifactMojo */ public class ArtifactsProcessingException extends Exception { /** * The version of this class for {@linkplain Serializable * serialization} purposes. */ private static final long serialVersionUID = 1L; /** * The {@link Collection} of {@link Artifact}s that caused this * {@link ArtifactsProcessingException} to be thrown. * * <p>This field may be {@code null}.</p> * * @see #setArtifacts(Collection) */ private Collection<? extends Artifact> artifacts; /** * Creates a new {@link ArtifactsProcessingException}. */ public ArtifactsProcessingException() { super(); } /** * Creates a new {@link ArtifactsProcessingException}. * * @param message a message describing the error; may be {@code * null} */ public ArtifactsProcessingException(final String message) { super(message); } /** * Creates a new {@link ArtifactsProcessingException}. * * @param cause the {@link Throwable} that caused this {@link * ArtifactsProcessingException} to be thrown; may be {@code null} */ public ArtifactsProcessingException(final Throwable cause) { super(cause); } /** * Returns the {@link Collection} of {@link Artifact}s that caused * this {@link ArtifactsProcessingException} to be thrown. * * <p>This method may return {@code null}.</p> * * @return the {@link Collection} of {@link Artifact}s that caused * this {@link ArtifactsProcessingException} to be thrown, or {@code * null} * * @see #setArtifacts(Collection) */ public Collection<? extends Artifact> getArtifacts() { return this.artifacts; } /** * Sets the {@link Collection} of {@link Artifact}s that caused this * {@link ArtifactsProcessingException} to be thrown. * * @param artifacts the {@link Collection} of {@link Artifact}s that * caused this {@link ArtifactsProcessingException} to be thrown; * may be {@code null} * * @see #getArtifacts() */ public void setArtifacts(final Collection<? extends Artifact> artifacts) { this.artifacts = artifacts; } }
[ "ljnelson@gmail.com" ]
ljnelson@gmail.com
35f4c7da46b322034228570c05cbb2077b926ef8
4f5cd2de89cfd0131ed04100dc68e6b557d7f908
/src/main/java/constant/AppConstants.java
613aeece7aecb225594da7590aa1938ad9bf8e62
[]
no_license
673229632/XTspeakService
ac699b5808cf4d6111d90b86c1217af7de1284fd
a1f4203647d1068011dfa6955690e08b6ee1aab7
refs/heads/master
2022-12-04T21:07:37.079148
2022-11-18T02:02:34
2022-11-18T02:02:34
199,411,738
1
1
null
null
null
null
UTF-8
Java
false
false
192
java
package constant; /** * 默认常量类. * * @author zhangrui.i */ public class AppConstants { /** * 服务器Socket端口. */ public static final int PORT = 30000; }
[ "673229632@qq.com" ]
673229632@qq.com
864b5f47a559bd111fafeeff3d7d6a031f74ef2a
71e2fd514d8c5d6973577ab36958205b3859830e
/src/h10/H10_4.java
9a530abce9cd39122fa0a01a35a7e13410559e20
[]
no_license
Ranz-ran/inleiding-java
61849dbc44c4436d63ba7c117a15e5332097a7db
715d34074df99b8b0f87589e8e995c7af38352c2
refs/heads/master
2023-01-27T23:42:20.196214
2020-12-02T10:53:55
2020-12-02T10:53:55
285,982,975
0
0
null
2020-08-08T05:54:29
2020-08-08T05:54:29
null
UTF-8
Java
false
false
1,560
java
package h10; //Breid de applet zo uit, dat ook het jaar ingegeven kan worden en aan de hand daarvan wordt // bepaald of het om een schrikkeljaar gaat om het juiste aantal dagen voor februari te kunnen // vaststellen. // // import java.applet.Applet; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class H10_4 extends Applet { //general Color b; int y1,jaartal; TextField txv1; String jaar; @Override public void init() { //general b = new Color (193, 210, 239); setBackground(b); y1 = 30; jaar = (""); //TextField txv1 = new TextField(); add(txv1); txv1.addActionListener(new Al()); } @Override public void paint(Graphics g) { txv1.setSize (50,25); txv1.setLocation (200,y1); g.drawString("Voer hier een jaartal in:",55,y1+16); g.drawString(jaar,55,y1+50); } private class Al implements ActionListener { @Override public void actionPerformed(ActionEvent e) { jaar = txv1.getText(); jaartal = Integer.parseInt(jaar); if ( (jaartal % 4 == 0 && !(jaartal % 100 == 0)) || jaartal % 400 == 0 ) { jaar = ""+ jaartal + " is schrikkeljaar, februarie heeft dus 29 dagen."; } else { jaar = ""+ jaartal + " is geen schrikkeljaar, februarie heeft alleen 28 dagen."; } repaint(); } } }
[ "62795553+Ranz-ran@users.noreply.github.com" ]
62795553+Ranz-ran@users.noreply.github.com
3131a656c0240219c14e4a8dd86c19459a2b37a6
9db1fa08c7aabab96d291f18b7c4165eb0081058
/practica3/src/main/java/es/unican/is2/controller/AlarmaOffAction.java
680efa425eebe57897a147dbafa0082625572cd1
[]
no_license
Loboshj/Practica3
f0912e983de333fb400e4151ff3403e40b120ba8
197106fd96413c3f24f6f68723ef437bd9b2977d
refs/heads/master
2023-06-14T02:18:25.845896
2021-07-07T17:12:46
2021-07-07T17:12:46
382,682,177
0
0
null
null
null
null
UTF-8
Java
false
false
585
java
package es.unican.is2.controller; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.Action; import es.unican.is2.model.Despertador; import es.unican.is2.view.InterfazGrafica; public class AlarmaOffAction extends AbstractAction{ private InterfazGrafica vista; private Despertador despertador; public AlarmaOffAction(InterfazGrafica vista,Despertador despertador) { putValue(Action.NAME,"Alarma Off"); this.vista=vista; this.despertador=despertador; } public void actionPerformed(ActionEvent arg0) { despertador.alarmaOff(); } }
[ "loboshj8@gmail.com" ]
loboshj8@gmail.com
203388e06a49ba4066453a74afef1aff20c0d96d
84ad53d3f4e5cc305ccc82c711e756f1f946188b
/app/src/main/java/com/example/dabuff/speechevaluation/speech/setting/IseSettings.java
75f7eefc087f92af6e81a9eed2eff6b739157fc8
[]
no_license
nbdwddbf/SpeechEvaluation
85d2b55e1a4158140cd543f02b529d610a4b25d0
529f73abdc9374cf9f3137d947afeb7bf3bc835d
refs/heads/master
2020-03-28T15:44:00.636048
2018-09-13T10:25:20
2018-09-13T10:25:20
148,620,792
2
1
null
null
null
null
UTF-8
Java
false
false
7,689
java
package com.example.dabuff.speechevaluation.speech.setting; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceChangeListener; import android.text.InputType; import android.text.TextUtils; import android.view.Window; import android.widget.Toast; import com.iflytek.cloud.SpeechConstant; import com.example.dabuff.speechevaluation.voicedemo.R; /** * 评测设置界面 */ public class IseSettings extends PreferenceActivity { private final static String PREFER_NAME = "ise_settings"; private ListPreference mLanguagePref; private ListPreference mCategoryPref; private ListPreference mResultLevelPref; private EditTextPreference mVadBosPref; private EditTextPreference mVadEosPref; private EditTextPreference mSpeechTimeoutPref; private Toast mToast; @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); getPreferenceManager().setSharedPreferencesName(PREFER_NAME); addPreferencesFromResource(R.xml.ise_settings); initUI(); } private void initUI() { mLanguagePref = (ListPreference) findPreference(SpeechConstant.LANGUAGE); mCategoryPref = (ListPreference) findPreference(SpeechConstant.ISE_CATEGORY); mResultLevelPref = (ListPreference) findPreference(SpeechConstant.RESULT_LEVEL); mVadBosPref = (EditTextPreference) findPreference(SpeechConstant.VAD_BOS); mVadEosPref = (EditTextPreference) findPreference(SpeechConstant.VAD_EOS); mSpeechTimeoutPref = (EditTextPreference) findPreference(SpeechConstant.KEY_SPEECH_TIMEOUT); mToast = Toast.makeText(IseSettings.this, "", Toast.LENGTH_LONG); mLanguagePref.setSummary("当前:" + mLanguagePref.getEntry()); mCategoryPref.setSummary("当前:" + mCategoryPref.getEntry()); mResultLevelPref.setSummary("当前:" + mResultLevelPref.getEntry()); mVadBosPref.setSummary("当前:" + mVadBosPref.getText() + "ms"); mVadEosPref.setSummary("当前:" + mVadEosPref.getText() + "ms"); String speech_timeout = mSpeechTimeoutPref.getText(); String summary = "当前:" + speech_timeout; if (!"-1".equals(speech_timeout)) { summary += "ms"; } mSpeechTimeoutPref.setSummary(summary); mLanguagePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if ("zh_cn".equals(newValue.toString())) { if ("plain".equals(mResultLevelPref.getValue())) { showTip("汉语评测结果格式不支持plain设置"); return false; } } else { if ("read_syllable".equals(mCategoryPref.getValue())) { showTip("英语评测不支持单字"); return false; } } int newValueIndex = mLanguagePref.findIndexOfValue(newValue.toString()); String newEntry = (String) mLanguagePref.getEntries()[newValueIndex]; mLanguagePref.setSummary("当前:" + newEntry); return true; } }); mCategoryPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if ("en_us".equals(mLanguagePref.getValue()) && "read_syllable".equals(newValue.toString())) { showTip("英语评测不支持单字,请选其他项"); return false; } int newValueIndex = mCategoryPref.findIndexOfValue(newValue.toString()); String newEntry = (String) mCategoryPref.getEntries()[newValueIndex]; mCategoryPref.setSummary("当前:" + newEntry); return true; } }); mResultLevelPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if ("zh_cn".equals(mLanguagePref.getValue()) && "plain".equals(newValue.toString())) { showTip("汉语评测不支持plain,请选其他项"); return false; } mResultLevelPref.setSummary("当前:" + newValue.toString()); return true; } }); mVadBosPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); mVadBosPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int bos; try { bos = Integer.parseInt(newValue.toString()); } catch (Exception e) { showTip("无效输入!"); return false; } if (bos < 0 || bos > 30000) { showTip("取值范围为0~30000"); return false; } mVadBosPref.setSummary("当前:" + bos + "ms"); return true; } }); mVadEosPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); mVadEosPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int eos; try { eos = Integer.parseInt(newValue.toString()); } catch (Exception e) { showTip("无效输入!"); return false; } if (eos < 0 || eos > 30000) { showTip("取值范围为0~30000"); return false; } mVadEosPref.setSummary("当前:" + eos + "ms"); return true; } }); mSpeechTimeoutPref.getEditText().setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED|InputType.TYPE_CLASS_NUMBER); mSpeechTimeoutPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int speech_timeout; try { speech_timeout = Integer.parseInt(newValue.toString()); } catch (Exception e) { showTip("无效输入!"); return false; } if (speech_timeout < -1) { showTip("必须大于等于-1"); return false; } if (speech_timeout == -1) { mSpeechTimeoutPref.setSummary("当前:-1"); } else { mSpeechTimeoutPref.setSummary("当前:" + speech_timeout + "ms"); } return true; } }); } private void showTip(String str) { if(!TextUtils.isEmpty(str)) { mToast.setText(str); mToast.show(); } } }
[ "bfding@cloume.com" ]
bfding@cloume.com
0a0dffb6901153582973cadb8b9572f270220971
1eaacabdf2a8b6688211c4e627a68fa69643c78d
/src/com/algorithms/Average.java
af779eb55dc20d9ae89e0811cc3a4c46d00984a0
[]
no_license
mrLysyi/AlgorithmsOne
59a20291193db3ec798f5c3f03cc10d037d49fc7
005ddc324191f23d3481498e88e5fb6ea2656889
refs/heads/master
2016-09-05T13:53:57.759280
2014-11-26T15:19:30
2014-11-26T15:19:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,639
java
package com.algorithms; /************************************************************************* * Compilation: javac Average.java * Execution: java Average < data.txt * Dependencies: StdIn.java StdOut.java * * Reads in a sequence of real numbers, and computes their average. * * % java Average * 10.0 5.0 6.0 * 3.0 7.0 32.0 * <Ctrl-d> * Average is 10.5 * Note <Ctrl-d> signifies the end of file on Unix. * On windows use <Ctrl-z>. * *************************************************************************/ /** * The <tt>Average</tt> class provides a client for reading in a sequence * of real numbers and printing out their average. * <p> * For additional documentation, see <a href="http://algs4.cs.princeton.edu/11model">Section 1.1</a> of * <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne. * * @author Robert Sedgewick * @author Kevin Wayne */ public class Average { // this class should not be instantiated private Average() { } /** * Reads in a sequence of real numbers from standard input and prints * out their average to standard output. */ public static void main(String[] args) { int count = 0; // number input values double sum = 0.0; // sum of input values // read data and compute statistics while (!StdIn.isEmpty()) { double value = StdIn.readDouble(); sum += value; count++; } // compute the average double average = sum / count; // print results StdOut.println("Average is " + average); } }
[ "cheburano@gmail.com" ]
cheburano@gmail.com
2de305c4b0f2b6d937ae361c6de2712d053c02c7
e8469ceede4c429ce6ac3a4d1d210c48702a6894
/src/main/java/ch/sbb/fss/uic301/parser/StatementPeriod.java
7eebda30f637c2c3426fc27674f5520030b1c13a
[]
no_license
dzaks/parser2
7c9981e0906c8d77d10bcfaaa66efde97a61f353
ac90e6b8ac1ddf69dda4e7ddd8c90205325e007f
refs/heads/master
2023-04-12T08:44:14.915979
2020-05-22T18:35:52
2020-05-22T18:35:52
268,142,662
0
0
null
2021-04-26T20:20:16
2020-05-30T19:01:58
Java
UTF-8
Java
false
false
6,668
java
package ch.sbb.fss.uic301.parser; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.ElementType.TYPE_USE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; import javax.validation.Constraint; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; import javax.validation.Payload; /** * Statement period. YY=Year, MM=Month, PP=Period in the month (00 default, * other usage must be bilaterally agreed upon). */ public final class StatementPeriod implements Comparable<StatementPeriod> { private final int year; private final int month; private final int period; /** * Constructor with all data. * * @param year * Year (0-99). * @param month * Month (1-12). * @param period * Period - Default 0, other usage must be bilaterally agreed * upon (&gt;=0). */ public StatementPeriod(final int year, final int month, final int period) { super(); if (year < 0 || year > 99) { throw new IllegalArgumentException( "Expected year >=0 and <=99, but was: " + year); } if (month < 1 || month > 12) { throw new IllegalArgumentException( "Expected month 1-12, but was: " + month); } if (period < 0 || period > 99) { throw new IllegalArgumentException( "Expected period > 0, but was: " + period); } this.year = year; this.month = month; this.period = period; } /** * Returns the year. * * @return Year (&gt;= 1900). */ public final int getYear() { return year; } /** * Returns the month. * * @return Month (1-12). */ public final int getMonth() { return month; } /** * Returns the period. * * @return Period - Default 0, other usage must be bilaterally agreed upon * (&gt;=0) */ public final int getPeriod() { return period; } @Override public final int hashCode() { final int prime = 31; int result = 1; result = prime * result + year; result = prime * result + month; result = prime * result + period; return result; } @Override public final boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final StatementPeriod other = (StatementPeriod) obj; if (year != other.year) { return false; } if (month != other.month) { return false; } if (period != other.period) { return false; } return true; } @Override public final int compareTo(final StatementPeriod other) { // Year if (year > other.year) { return 1; } if (year < other.year) { return -1; } // Month if (month > other.month) { return 1; } if (month < other.month) { return -1; } // Period if (period > other.period) { return 1; } if (period < other.period) { return -1; } return 0; } @Override public String toString() { return year + "/" + month + "-" + period; } /** * Determines if the given string is a valid statement period. * * @param str * String to verify or <code>null</code>. * * @return <code>true</code> if the string can be converted into a statement * period. */ public static boolean valid(final String str) { if (str == null) { return true; } if (str.length() != 6 || !str.matches("\\d{6}")) { return false; } final String yearStr = str.substring(0, 2); final String monthStr = str.substring(2, 4); final String periodStr = str.substring(4, 6); final int year = Integer.valueOf(yearStr); final int month = Integer.valueOf(monthStr); final int period = Integer.valueOf(periodStr); if (year < 0 || year > 99) { return false; } if (month < 1 || month > 12) { return false; } if (period < 0 || period > 99) { return false; } return true; } /** * Creates an instance from the given string. * * @param str * Statement period (YYMMPP). YY=Year, MM=Month, PP=Period in the * month or <code>null</code>. * * @return New instance or <code>null</code>. */ public static StatementPeriod valueOf(final String str) { if (str == null) { return null; } if (!valid(str)) { throw new IllegalArgumentException( "Expected YYMMPP, but was: '" + str + "'"); } final String year = str.substring(0, 2); final String month = str.substring(2, 4); final String period = str.substring(4, 6); return new StatementPeriod(Integer.valueOf(year), Integer.valueOf(month), Integer.valueOf(period)); } /** * String that contains a statement period in format 'YYMMPP'. */ @Documented @Constraint(validatedBy = Validator.class) @Target({ METHOD, FIELD, ANNOTATION_TYPE, PARAMETER, TYPE_USE }) @Retention(RUNTIME) public @interface StatementPeriodStr { String message() default "Expected 'YYMMPP', but was: '${validatedValue}'"; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; } /** * Verifies if a string has format 'YYMMPP'. */ public static final class Validator implements ConstraintValidator<StatementPeriodStr, String> { @Override public boolean isValid(final String value, final ConstraintValidatorContext context) { return StatementPeriod.valid(value); } } }
[ "michael@fuin.org" ]
michael@fuin.org
ed8c204d7265134e0abebcefc6b7f530c79e78dd
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/23/23_1c40b22f43dc7557f032d24e21f2b5b496d197cb/Processor/23_1c40b22f43dc7557f032d24e21f2b5b496d197cb_Processor_t.java
1887847b67ddbabe85a45a675c6082f3155476c0
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
263,362
java
/* Processor.java Michael Black, 6/10 Simulates the x86 processor */ package simulator; import java.util.ArrayList; import java.util.Scanner; public class Processor { public ProcessorGUICode processorGUICode; private int instructionCount=0; private Computer computer; //registers public Register eax, ebx, edx, ecx, esi, edi, esp, ebp, eip; public Register cr0, cr2, cr3, cr4; public Segment cs, ds, ss, es, fs, gs; public Segment idtr, gdtr, ldtr, tss; //flags public Flag carry, parity, auxiliaryCarry, zero, sign, trap, interruptEnable, direction, overflow, interruptEnableSoon, ioPrivilegeLevel1, ioPrivilegeLevel0, nestedTask, alignmentCheck, idFlag; //protection level public int current_privilege_level; public int interruptFlags; //devices public IOPorts ioports; public InterruptController interruptController; private boolean addressDecoded=false; private boolean haltMode=false; public int lastInterrupt=-1; public LinearMemory linearMemory; public Processor(Computer computer) { this.computer=computer; this.ioports=computer.ioports; interruptController=null; processorGUICode=null; linearMemory=new LinearMemory(computer); cs=new Segment(Segment.CS,computer.physicalMemory); ds=new Segment(Segment.DS,computer.physicalMemory); ss=new Segment(Segment.SS,computer.physicalMemory); es=new Segment(Segment.ES,computer.physicalMemory); fs=new Segment(Segment.FS,computer.physicalMemory); gs=new Segment(Segment.GS,computer.physicalMemory); idtr=new Segment(Segment.IDTR,computer.physicalMemory); // idtr=new Segment(Segment.IDTR,linearMemory); idtr.setDescriptorValue(0); gdtr=new Segment(Segment.GDTR,computer.physicalMemory); // gdtr=new Segment(Segment.GDTR,linearMemory); gdtr.setDescriptorValue(0); ldtr=new Segment(Segment.LDTR,linearMemory); ldtr.setDescriptorValue(0); tss=new Segment(Segment.TSS,linearMemory); tss.setDescriptorValue(0); eax=new Register(Register.EAX,0); ebx=new Register(Register.EBX,0); ecx=new Register(Register.ECX,0); edx=new Register(Register.EDX,0); esp=new Register(Register.ESP,0); ebp=new Register(Register.EBP,0); esi=new Register(Register.ESI,0); edi=new Register(Register.EDI,0); eip=new Register(Register.EIP,0x0000fff0); cr0=new Register(Register.CR0,0); cr2=new Register(Register.CR2,0); cr3=new Register(Register.CR3,0); cr4=new Register(Register.CR4,0); carry=new Flag(Flag.CARRY); parity=new Flag(Flag.PARITY); auxiliaryCarry=new Flag(Flag.AUXILIARYCARRY); zero=new Flag(Flag.ZERO); sign=new Flag(Flag.SIGN); trap=new Flag(Flag.OTHER); interruptEnable=new Flag(Flag.OTHER); direction=new Flag(Flag.OTHER); overflow=new Flag(Flag.OVERFLOW); interruptEnableSoon=new Flag(Flag.OTHER); ioPrivilegeLevel1=new Flag(Flag.OTHER); ioPrivilegeLevel0=new Flag(Flag.OTHER); nestedTask=new Flag(Flag.OTHER); alignmentCheck=new Flag(Flag.OTHER); idFlag=new Flag(Flag.OTHER); setCPL(0); // current_privilege_level=0; fetchQueue=new FetchQueue(); initializeDecoder(); reset(); } public String saveState() { String state=""; state+=cs.saveState()+":"; state+=ss.saveState()+":"; state+=ds.saveState()+":"; state+=es.saveState()+":"; state+=fs.saveState()+":"; state+=gs.saveState()+":"; state+=idtr.saveState()+":"; state+=gdtr.saveState()+":"; state+=ldtr.saveState()+":"; state+=tss.saveState()+":"; state+=eax.saveState()+":"; state+=ebx.saveState()+":"; state+=ecx.saveState()+":"; state+=edx.saveState()+":"; state+=esp.saveState()+":"; state+=ebp.saveState()+":"; state+=esi.saveState()+":"; state+=edi.saveState()+":"; state+=eip.saveState()+":"; state+=cr0.saveState()+":"; state+=cr2.saveState()+":"; state+=cr3.saveState()+":"; state+=cr4.saveState()+":"; state+=carry.saveState()+":"; state+=parity.saveState()+":"; state+=auxiliaryCarry.saveState()+":"; state+=zero.saveState()+":"; state+=sign.saveState()+":"; state+=trap.saveState()+":"; state+=interruptEnable.saveState()+":"; state+=direction.saveState()+":"; state+=overflow.saveState()+":"; state+=interruptEnableSoon.saveState()+":"; state+=ioPrivilegeLevel1.saveState()+":"; state+=ioPrivilegeLevel0.saveState()+":"; state+=nestedTask.saveState()+":"; state+=alignmentCheck.saveState()+":"; state+=idFlag.saveState()+":"; state+=interruptFlags; return state; } public void loadState(String state) { String[] states=state.split(":"); cs.loadState(states[0]); ss.loadState(states[1]); ds.loadState(states[2]); es.loadState(states[3]); fs.loadState(states[4]); gs.loadState(states[5]); idtr.loadState(states[6]); gdtr.loadState(states[7]); ldtr.loadState(states[8]); tss.loadState(states[9]); eax.loadState(states[10]); ebx.loadState(states[11]); ecx.loadState(states[12]); edx.loadState(states[13]); esp.loadState(states[14]); ebp.loadState(states[15]); esi.loadState(states[16]); edi.loadState(states[17]); eip.loadState(states[18]); cr0.loadState(states[19]); cr2.loadState(states[20]); cr3.loadState(states[21]); cr4.loadState(states[22]); carry.loadState(states[23]); parity.loadState(states[24]); auxiliaryCarry.loadState(states[25]); zero.loadState(states[26]); sign.loadState(states[27]); trap.loadState(states[28]); interruptEnable.loadState(states[29]); direction.loadState(states[30]); overflow.loadState(states[31]); interruptEnableSoon.loadState(states[32]); ioPrivilegeLevel1.loadState(states[33]); ioPrivilegeLevel0.loadState(states[34]); nestedTask.loadState(states[35]); alignmentCheck.loadState(states[36]); idFlag.loadState(states[37]); interruptFlags=new Scanner(states[38]).nextInt(); } public void reset() { linearMemory=new LinearMemory(computer); eax.setValue(0); ebx.setValue(0); ecx.setValue(0); edx.setValue(0); esp.setValue(0); ebp.setValue(0); esi.setValue(0); edi.setValue(0); eip.setValue(0x0000fff0); carry.clear(); parity.clear(); auxiliaryCarry.clear(); zero.clear(); sign.clear(); trap.clear(); interruptEnable.clear(); direction.clear(); overflow.clear(); interruptEnableSoon.clear(); ioPrivilegeLevel1.clear(); ioPrivilegeLevel0.clear(); nestedTask.clear(); interruptFlags=0; cs.setValue(0xf000); ds.setValue(0); ss.setValue(0); es.setValue(0); fs.setValue(0); gs.setValue(0); parity.set(); zero.set(); setCR0(0x60000010); setCR2(0); setCR3(0); setCR4(0); /* cr0.setValue(0x60000010); cr2.setValue(0); cr3.setValue(0); cr4.setValue(0);*/ haltMode=false; } public void setInterruptController(InterruptController interruptController) { this.interruptController=interruptController; } //executes a single instruction public void executeAnInstruction() { processorGUICode=null; // if (computer.processorGUI!=null || computer.memoryGUI!=null || computer.registerGUI!=null) // { if (computer.debugMode || computer.updateGUIOnPlay || computer.trace!=null) processorGUICode=new ProcessorGUICode(); // } if (haltMode) { if (processorGUICode!=null) processorGUICode.push(GUICODE.EXECUTE_HALT); try{Thread.sleep(10);}catch(InterruptedException e){} return; } if(processorGUICode!=null) processorGUICode.pushFetch(eip.getValue()); fetchQueue.fetch(); decodeInstruction(cs.getDefaultSize()); executeInstruction(); if(processorGUICode!=null) { if (computer.trace!=null) computer.trace.addProcessorCode(processorGUICode); processorGUICode.updateMemoryGUI(); processorGUICode.updateGUI(); } } public void printRegisters() { // System.out.printf("IP: %x, AX: %x, BX: %x, CX: %x, DX: %x, SI: %x, DI: %x, SP: %x, BP: %x, CS: %x, CSbase: %x, SS: %x, DS: %x, ES: %x, FLAGS: %x\n",eip.getValue(),eax.getValue(),ebx.getValue(),ecx.getValue(),edx.getValue(),esi.getValue(),edi.getValue(),esp.getValue(),ebp.getValue(),cs.getValue(),cs.getBase(),ss.getValue(),ds.getValue(),es.getValue(),getFlags()); System.out.printf("IP: %x\n",eip.getValue()); System.out.printf("@ AX: %x, BX: %x, CX: %x, DX: %x, SI: %x, DI: %x, SP: %x, BP: %x, CS: %x, SS: %x, DS: %x, ES: %x\n",eax.getValue(),ebx.getValue(),ecx.getValue(),edx.getValue(),esi.getValue(),edi.getValue(),esp.getValue(),ebp.getValue(),cs.getValue(),ss.getValue(),ds.getValue(),es.getValue()); } public void printMicrocode(int[] code) { System.out.print("Microcode: "); for(int i=0; i<code.length; i++) System.out.printf("%x ",code[i]); System.out.println(); } public void setCR0(int value) { value|=0x10; if (value==cr0.getValue()) return; int changedBits=cr0.getValue()^value; cr0.setValue(value); if (isModeReal()) { setCPL(0); cs.memory=computer.physicalMemory; ss.memory=computer.physicalMemory; ds.memory=computer.physicalMemory; es.memory=computer.physicalMemory; fs.memory=computer.physicalMemory; gs.memory=computer.physicalMemory; // current_privilege_level=0; if(processorGUICode!=null) processorGUICode.push(GUICODE.MODE_REAL); // System.out.println("Switching to Real Mode"); // System.out.printf("New segment bases: CS: %x, SS: %x, DS: %x, ES: %x, FS: %x, GS: %x\n",cs.getBase(),ss.getBase(),ds.getBase(),es.getBase(),fs.getBase(),gs.getBase()); } else { cs.memory=linearMemory; ss.memory=linearMemory; ds.memory=linearMemory; es.memory=linearMemory; fs.memory=linearMemory; gs.memory=linearMemory; if(processorGUICode!=null) processorGUICode.push(GUICODE.MODE_PROTECTED); // System.out.println("Switching to Protected Mode"); // System.out.printf("New segment bases: CS: %x, SS: %x, DS: %x, ES: %x, FS: %x, GS: %x\n",cs.getBase(),ss.getBase(),ds.getBase(),es.getBase(),fs.getBase(),gs.getBase()); } if ((value&0x2)!=0) panic("implement CR0 monitor coprocessor"); if ((value&0x4)!=0) panic("implement CR0 fpu emulation"); if ((value&0x8)!=0) panic("implement CR0 task switched"); if ((value&0x20)!=0) panic("implement CR0 numeric error"); if ((value&0x40000)!=0) panic("implement CR0 alignment mask"); if ((value&0x20000000)==0) panic("implement CR0 writethrough"); if ((changedBits&0x10000)!=0) { panic("implement CR0 write protect"); linearMemory.setWriteProtectUserPages((value&0x10000)!=0); } if ((changedBits&0x40000000)!=0) { //page caching linearMemory.setPagingEnabled((value&0x80000000)!=0); linearMemory.setPageCacheEnabled((value&0x40000000)==0); } if ((changedBits&0x80000000)!=0) { //paging linearMemory.setPagingEnabled((value&0x80000000)!=0); linearMemory.setPageCacheEnabled((value&0x40000000)==0); } } public void setCR2(int value) { cr2.setValue(value); if (value!=0) panic("setting CR2 to "+value); } public void setCR3(int value) { cr3.setValue(value); linearMemory.setPageDirectoryBaseAddress(value); linearMemory.setPageCacheEnabled((value&0x10)==0); // if ((value&0x8)==0) // panic("implement CR3 writes transparent"); } public void setCR4(int value) { cr4.setValue((cr4.getValue()&~0x5f)|(value&0x5f)); linearMemory.setGlobalPagesEnabled((value&0x80)!=0); linearMemory.setPageSizeExtensionsEnabled((value&0x10)!=0); } public boolean isModeReal() { if((cr0.getValue()&1)==0) return true; return false; } private void setCPL(int cpl) { current_privilege_level=cpl; linearMemory.setSupervisor(cpl==0); } //models a register //public class Register extends MonitoredRegister public class Register { static final int EAX=100, EBX=101, ECX=102, EDX=103, ESI=104, EDI=105, ESP=106, EBP=107, CR0=108, CR2=109, CR3=110, CR4=111, EIP=112; int id; int value; public String saveState() { String state=""; state+=id+" "+value; return state; } public void loadState(String state) { Scanner loader=new Scanner(state); id=loader.nextInt(); value=loader.nextInt(); } public Register(int id) { this.id=id; this.value=0; // super(0); } public Register(int id, int value) { this.id=id; this.value=value; // super(value); } public int getValue() { // super.updateGUI(); if(processorGUICode!=null) processorGUICode.pushRegister(id,0,value); return value; } public void setValue(int value) { // super.updateGUI(); if(processorGUICode!=null) processorGUICode.pushRegister(id,1,value); this.value=value; } public short getLower16Value() { return (short)(getValue()&0xffff); } public byte getLower8Value() { return (byte)(getValue()&0xff); } public byte getUpper8Value() { return (byte)((getValue()>>8)&0xff); } public void setLower16Value(int v) { setValue((getValue()&0xffff0000)|(0x0000ffff&v)); } public void setLower8Value(int v) { setValue((getValue()&0xffffff00)|(0x000000ff&v)); } public void setUpper8Value(int v) { setValue((getValue()&0xffff00ff)|(0x0000ff00&(v<<8))); } } //public class Flag extends MonitoredFlag public class Flag { int type; public static final int AUXILIARYCARRY=100, CARRY=101, ZERO=102, SIGN=103, PARITY=104, OVERFLOW=105, OTHER=106; public static final int AC_XOR = 1; public static final int AC_BIT4_NEQ = 2; public static final int AC_LNIBBLE_MAX = 3; public static final int AC_LNIBBLE_ZERO = 4; public static final int AC_LNIBBLE_NZERO = 5; public static final int OF_NZ = 1; public static final int OF_NOT_BYTE = 2; public static final int OF_NOT_SHORT = 3; public static final int OF_NOT_INT = 3; public static final int OF_LOW_WORD_NZ = 5; public static final int OF_HIGH_BYTE_NZ = 6; public static final int OF_BIT6_XOR_CARRY = 7; public static final int OF_BIT7_XOR_CARRY = 8; public static final int OF_BIT14_XOR_CARRY = 9; public static final int OF_BIT15_XOR_CARRY = 10; public static final int OF_BIT30_XOR_CARRY = 11; public static final int OF_BIT31_XOR_CARRY = 12; public static final int OF_BIT7_DIFFERENT = 13; public static final int OF_BIT15_DIFFERENT = 14; public static final int OF_BIT31_DIFFERENT = 15; public static final int OF_MAX_BYTE = 16; public static final int OF_MAX_SHORT = 17; public static final int OF_MAX_INT = 18; public static final int OF_MIN_BYTE = 19; public static final int OF_MIN_SHORT = 20; public static final int OF_MIN_INT = 21; public static final int OF_ADD_BYTE = 22; public static final int OF_ADD_SHORT = 23; public static final int OF_ADD_INT = 24; public static final int OF_SUB_BYTE = 25; public static final int OF_SUB_SHORT = 26; public static final int OF_SUB_INT = 27; public static final int CY_NZ = 1; public static final int CY_NOT_BYTE = 2; public static final int CY_NOT_SHORT = 3; public static final int CY_NOT_INT = 4; public static final int CY_LOW_WORD_NZ = 5; public static final int CY_HIGH_BYTE_NZ = 6; public static final int CY_NTH_BIT_SET = 7; public static final int CY_GREATER_FF = 8; public static final int CY_TWIDDLE_FF = 9; public static final int CY_TWIDDLE_FFFF = 10; public static final int CY_TWIDDLE_FFFFFFFF = 11; public static final int CY_SHL_OUTBIT_BYTE = 12; public static final int CY_SHL_OUTBIT_SHORT = 13; public static final int CY_SHL_OUTBIT_INT = 14; public static final int CY_SHR_OUTBIT = 15; public static final int CY_LOWBIT = 16; public static final int CY_HIGHBIT_BYTE = 17; public static final int CY_HIGHBIT_SHORT = 18; public static final int CY_HIGHBIT_INT = 19; public static final int CY_OFFENDBIT_BYTE = 20; public static final int CY_OFFENDBIT_SHORT = 21; public static final int CY_OFFENDBIT_INT = 22; private boolean value; private int v1, v2, v3, method; private long v1long; public String saveState() { String state=""; state+=type+" "+(value?1:0)+" "+v1+" "+v2+" "+v3+" "+method+" "+v1long; return state; } public void loadState(String state) { Scanner loader=new Scanner(state); type=loader.nextInt(); value=loader.nextInt()==1; v1=loader.nextInt(); v2=loader.nextInt(); v3=loader.nextInt(); method=loader.nextInt(); v1long=loader.nextLong(); } public Flag(int type) { // super(false); this.type=type; } public void clear() { if(processorGUICode!=null) processorGUICode.pushFlag(type,0); value=false; // super.updateGUI(); } public void set() { if(processorGUICode!=null) processorGUICode.pushFlag(type,1); value=true; // super.updateGUI(); } public boolean read() { // super.updateGUI(); if(processorGUICode!=null) processorGUICode.pushFlag(type,2); return value; } public void toggle() { if (value) clear(); else set(); } public void set(boolean value) { if (value) set(); else clear(); } private void calculate() { switch(type) { case AUXILIARYCARRY: calculateAuxiliaryCarry(); break; case ZERO: calculateZero(); break; case OVERFLOW: calculateOverflow(); break; case PARITY: calculateParity(); break; case SIGN: calculateSign(); break; case CARRY: calculateCarry(); break; } } private void calculateAuxiliaryCarry() { if (method==AC_XOR) set((((v1^v2)^v3)&0x10)!=0); else if (method==AC_LNIBBLE_MAX) set((v1&0xf)==0xf); else if (method==AC_LNIBBLE_ZERO) set((v1&0xf)==0x0); else if (method==AC_BIT4_NEQ) set((v1&0x8)!=(v2&0x8)); else if (method==AC_LNIBBLE_NZERO) set((v1&0xf)!=0); } private void calculateParity() { set((Integer.bitCount(v1&0xff)&0x1)==0); } private void calculateOverflow() { if (method==OF_ADD_BYTE) set(((v2&0x80)==(v3&0x80))&&((v2&0x80)!=(v1&0x80))); else if (method==OF_ADD_SHORT) set(((v2&0x8000)==(v3&0x8000))&&((v2&0x8000)!=(v1&0x8000))); else if (method==OF_ADD_INT) set(((v2&0x80000000)==(v3&0x80000000))&&((v2&0x80000000)!=(v1&0x80000000))); else if (method==OF_SUB_BYTE) set(((v2&0x80)!=(v3&0x80))&&((v2&0x80)!=(v1&0x80))); else if (method==OF_SUB_SHORT) set(((v2&0x8000)!=(v3&0x8000))&&((v2&0x8000)!=(v1&0x8000))); else if (method==OF_SUB_INT) set(((v2&0x80000000)!=(v3&0x80000000))&&((v2&0x80000000)!=(v1&0x80000000))); else if (method==OF_MAX_BYTE) set(v1==0x7f); else if (method==OF_MIN_BYTE) set(v1==(byte)0x80); else if (method==OF_MAX_SHORT) set(v1==0x7fff); else if (method==OF_MIN_SHORT) set(v1==(short)0x8000); else if (method==OF_MAX_INT) set(v1==0x7fffffff); else if (method==OF_MIN_INT) set(v1==0x80000000); else if (method==OF_BIT6_XOR_CARRY) set(((v1&0x40)!=0)^carry.read()); else if (method==OF_BIT7_XOR_CARRY) set(((v1&0x80)!=0)^carry.read()); else if (method==OF_BIT14_XOR_CARRY) set(((v1&0x4000)!=0)^carry.read()); else if (method==OF_BIT15_XOR_CARRY) set(((v1&0x8000)!=0)^carry.read()); else if (method==OF_BIT30_XOR_CARRY) set(((v1&0x40000000)!=0)^carry.read()); else if (method==OF_BIT31_XOR_CARRY) set(((v1&0x80000000)!=0)^carry.read()); else if (method==OF_BIT7_DIFFERENT) set((v1&0x80)!=(v2&0x80)); else if (method==OF_BIT15_DIFFERENT) set((v1&0x8000)!=(v2&0x8000)); else if (method==OF_BIT31_DIFFERENT) set((v1&0x80000000)!=(v2&0x80000000)); else if (method==OF_NZ) set(v1!=0); else if (method==OF_NOT_BYTE) set(v1!=(byte)v1); else if (method==OF_NOT_SHORT) set(v1!=(short)v1); else if (method==OF_NOT_INT) set(v1long!=(int)v1long); else if (method==OF_LOW_WORD_NZ) set((v1&0xffff)!=0); else if (method==OF_HIGH_BYTE_NZ) set((v1&0xff00)!=0); } private void calculateCarry() { if (method==CY_TWIDDLE_FF) set((v1&(~0xff))!=0); else if (method==CY_TWIDDLE_FFFF) set((v1&(~0xffff))!=0); else if (method==CY_TWIDDLE_FFFFFFFF) set((v1long&(~0xffffffffl))!=0); else if (method==CY_SHR_OUTBIT) set(((v1>>>(v2-1))&0x1)!=0); else if (method==CY_SHL_OUTBIT_BYTE) set(((v1<<(v2-1))&0x80)!=0); else if (method==CY_SHL_OUTBIT_SHORT) set(((v1<<(v2-1))&0x8000)!=0); else if (method==CY_SHL_OUTBIT_INT) set(((v1<<(v2-1))&0x80000000)!=0); else if (method==CY_NZ) set(v1!=0); else if (method==CY_NOT_BYTE) set(v1!=(byte)v1); else if (method==CY_NOT_SHORT) set(v1!=(short)v1); else if (method==CY_NOT_INT) set(v1long!=(int)v1long); else if (method==CY_LOW_WORD_NZ) set((v1&0xffff)!=0); else if (method==CY_HIGH_BYTE_NZ) set((v1&0xff00)!=0); else if (method==CY_NTH_BIT_SET) set((v1&(1<<v2))!=0); else if (method==CY_GREATER_FF) set(v1>0xff); else if (method==CY_LOWBIT) set((v1&0x1)!=0); else if (method==CY_HIGHBIT_BYTE) set((v1&0x80)!=0); else if (method==CY_HIGHBIT_SHORT) set((v1&0x8000)!=0); else if (method==CY_HIGHBIT_INT) set((v1&0x80000000)!=0); else if (method==CY_OFFENDBIT_BYTE) set((v1&0x100)!=0); else if (method==CY_OFFENDBIT_SHORT) set((v1&0x10000)!=0); else if (method==CY_OFFENDBIT_INT) set((v1long&0x100000000l)!=0); } private void calculateZero() { set(v1==0); } private void calculateSign() { set(v1<0); } public void set(int d1, int d2, int d3, int m) { v1=d1; v2=d2; v3=d3; method=m; calculate(); } public void set(int d1, int d2, int m) { v1=d1; v2=d2; method=m; calculate(); } public void set(int d1, int m) { v1=d1; method=m; calculate(); } public void set(long d1, int m) { v1long=d1; method=m; calculate(); } public void set(int d1) { v1=d1; calculate(); } } //models a segment register //public class Segment extends MonitoredRegister public class Segment { public static final int CS=100,SS=101,DS=102,ES=103,FS=104,GS=105,IDTR=106,GDTR=107,LDTR=108,TSS=109; private int value; private int id; private int base; private long limit; private MemoryDevice memory; long descriptor; boolean granularity,defaultSize,present,system; int rpl,dpl; public String saveState() { String state=""; state+=value+" "+id+" "+base+" "+limit+" "+descriptor+" "+(granularity?1:0)+" "+(defaultSize?1:0)+" "+(present?1:0)+" "+(system?1:0)+" "+rpl+" "+dpl; return state; } public void loadState(String state) { Scanner loader=new Scanner(state); value=loader.nextInt(); id=loader.nextInt(); base=loader.nextInt(); limit=loader.nextLong(); descriptor=loader.nextLong(); granularity=loader.nextInt()==1; defaultSize=loader.nextInt()==1; present=loader.nextInt()==1; system=loader.nextInt()==1; rpl=loader.nextInt(); dpl=loader.nextInt(); } public Segment(int id, MemoryDevice memory) { // super(0); this.id=id; this.memory=memory; limit=0xffff; } public void setDescriptorValue(int value) { if(processorGUICode!=null) processorGUICode.pushSegment(id,1,value); this.value=value; this.base=value; this.limit=0xffff; // super.updateGUI(); } public void setDescriptorValue(int value, int limit) { if(processorGUICode!=null) processorGUICode.pushSegment(id,1,value); this.value=value; this.base=value; this.limit=limit; // super.updateGUI(); } public void setValue(int value) { if(processorGUICode!=null) processorGUICode.pushSegment(id,1,value); if(isModeReal()) setRealValue(value); else setProtectedValue(value); // super.updateGUI(); } public int getValue() { if(processorGUICode!=null) processorGUICode.pushSegment(id,0,value); // super.updateGUI(); return value; } public void setRealValue(int value) { this.value=value; this.base=(0xffff0 & (value<<4)); defaultSize=false; } public void setProtectedValue(int value) { //first get the descriptor boolean sup=linearMemory.isSupervisor; linearMemory.setSupervisor(true); if ((value&4)==0) { descriptor=gdtr.loadQuadWord(value&0xfff8); } else { if (ldtr==null) { System.out.println("LDTR is null"); throw GENERAL_PROTECTION; } descriptor=ldtr.loadQuadWord(value&0xfff8); } setProtectedValue(value,descriptor); linearMemory.setSupervisor(sup); } public void setProtectedValue(int value, long descriptor) { this.value=value; this.descriptor=descriptor; granularity=(descriptor&0x80000000000000l)!=0; if(granularity) limit=((descriptor<<12)&0xffff000l)|((descriptor>>>20)&0xf0000000l)|0xffl; else limit=(descriptor&0xffffl)|((descriptor>>>32)&0xf0000l); base=(int)((0xffffffl & (descriptor>>16))|((descriptor>>32)&0xffffffffff000000l)); rpl=value&0x3; dpl=(int)((descriptor>>45)&0x3); defaultSize=(descriptor&(1l<<54))!=0; present=(descriptor&(1l<<47))!=0; system=(descriptor&(1l<<44))!=0; if (id==CS && !defaultSize) System.out.println("operating in 16 bit protected mode "+descriptor+" "+value); else if (id==CS) System.out.println("operating in 32 bit protected mode "+descriptor+" "+value); } public int getBase() { return base; } public int getLimit() { return (int)limit; } //16 or 32? public boolean getDefaultSize() { return defaultSize; } public int address(int offset) { // return (0xffff0&base)+(0xffff&offset); return base+offset; } public int physicalAddress(int offset) { if(memory==computer.physicalMemory) return base+offset; return linearMemory.virtualAddressLookup(base+offset); } public byte loadByte(int offset) { byte memvalue=memory.getByte(address(offset)); if(processorGUICode!=null) processorGUICode.pushMemory(id,value,0,address(offset),memvalue); return memvalue; } public short loadWord(int offset) { short memvalue=memory.getWord(address(offset)); if(processorGUICode!=null) processorGUICode.pushMemory(id,value,0,address(offset),memvalue); return memvalue; } public int loadDoubleWord(int offset) { int memvalue=memory.getDoubleWord(address(offset)); if(processorGUICode!=null) processorGUICode.pushMemory(id,value,0,address(offset),memvalue); return memvalue; } public long loadQuadWord(int offset) { long memvalue=memory.getQuadWord(address(offset)); if(processorGUICode!=null) processorGUICode.pushMemory(id,value,0,address(offset),memvalue); return memvalue; } public void storeByte(int offset, byte value) { if(processorGUICode!=null) processorGUICode.pushMemory(id,this.value,1,address(offset),value); memory.setByte(address(offset),value); fetchQueue.flush(); } public void storeWord(int offset, short value) { if(processorGUICode!=null) processorGUICode.pushMemory(id,this.value,1,address(offset),value); memory.setWord(address(offset),value); fetchQueue.flush(); } public void storeDoubleWord(int offset, int value) { if(processorGUICode!=null) processorGUICode.pushMemory(id,this.value,1,address(offset),value); memory.setDoubleWord(address(offset),value); fetchQueue.flush(); } public void storeQuadWord(int offset, long value) { if(processorGUICode!=null) processorGUICode.pushMemory(id,this.value,1,address(offset),value); memory.setQuadWord(address(offset),value); fetchQueue.flush(); } } public int getFlags() { int result=0x2; if(carry.read()) result|=0x1; if(parity.read()) result|=0x4; if(auxiliaryCarry.read()) result|=0x10; if(zero.read()) result|=0x40; if(sign.read()) result|=0x80; if(trap.read()) result|=0x100; if(interruptEnable.read()) result|=0x200; if(direction.read()) result|=0x400; if(overflow.read()) result|=0x800; if(ioPrivilegeLevel0.read()) result|=0x1000; if(ioPrivilegeLevel1.read()) result|=0x2000; if(nestedTask.read()) result|=0x4000; if(alignmentCheck.read()) result|=0x40000; if(idFlag.read()) result|=0x200000; return result; } public void setFlags(int code) { carry.set((code&1)!=0); parity.set((code&(1<<2))!=0); auxiliaryCarry.set((code&(1<<4))!=0); zero.set((code&(1<<6))!=0); sign.set((code&(1<<7))!=0); trap.set((code&(1<<8))!=0); interruptEnable.set((code&(1<<9))!=0); interruptEnableSoon.set((code&(1<<9))!=0); direction.set((code&(1<<10))!=0); overflow.set((code&(1<<11))!=0); ioPrivilegeLevel0.set((code&(1<<12))!=0); ioPrivilegeLevel1.set((code&(1<<13))!=0); nestedTask.set((code&(1<<14))!=0); alignmentCheck.set((code&(1<<18))!=0); idFlag.set((code&(1<<21))!=0); } public void handleProcessorException(Processor_Exception e) { if (e.vector==PAGE_FAULT.vector) { setCR2(linearMemory.lastPageFaultAddress); System.out.println("A page fault exception just happened: "+e.vector); } //REMOVE THIS LINE WHEN I'M CONFIDENT THAT EXCEPTIONS WORK panic("A processor exception happened "+e.vector); System.out.println("A Processor Exception just happened: "+e.vector); if(processorGUICode!=null) processorGUICode.push(GUICODE.EXCEPTION,e.vector); handleInterrupt(e.vector); } public void waitForInterrupt() { System.out.println("Halting machine (probably a PANIC happened)"); haltMode=true; } //call this periodically to accept incoming interrupts public void processInterrupts() { //if disable interrupt mode, just ignore if(!interruptEnable.read()) { interruptEnable.set(interruptEnableSoon.read()); return; } //is there a hardware interrupt outstanding? if((interruptFlags & 0x1) == 0) return; //turn off the flag interruptFlags &= ~0x1; //get the interrupt haltMode=false; lastInterrupt=interruptController.cpuGetInterrupt(); handleInterrupt(lastInterrupt); } //tell the cpu that there is a hardware interrupt ready public void raiseInterrupt() { // System.out.println("raiseInterrupt called"); interruptFlags |= 0x1; } //tell the cpu that there is no longer a hardware interrupt ready public void clearInterrupt() { interruptFlags &= ~ 0x1; } //deal with a real mode interrupt public void handleInterrupt(int vector) { int newIP=0, newSegment=0; long descriptor=0; if (isModeReal()) { //get the new CS:IP from the IVT vector=vector*4; newIP = 0xffff & idtr.loadWord(vector); newSegment = 0xffff & idtr.loadWord(vector+2); //save the flags on the stack short sesp = (short) esp.getValue(); sesp-=2; int eflags = getFlags() & 0xffff; ss.storeWord(sesp & 0xffff, (short)eflags); //disable interrupts interruptEnable.clear(); interruptEnableSoon.clear(); //save CS:IP on the stack sesp-=2; ss.storeWord(sesp&0xffff, (short)cs.getValue()); sesp-=2; ss.storeWord(sesp&0xffff, (short)eip.getValue()); esp.setValue((0xffff0000 & esp.getValue()) | (sesp & 0xffff)); //change CS and IP to the ISR's values cs.setValue(newSegment); eip.setValue(newIP); } else { //get the new CS:EIP from the IDT boolean sup=linearMemory.isSupervisor; linearMemory.setSupervisor(true); vector=vector*8; descriptor=idtr.loadQuadWord(vector); int segIndex=(int)((descriptor>>16)&0xffff); if ((segIndex&4)!=0) descriptor=ldtr.loadQuadWord(segIndex&0xfff8); else descriptor=gdtr.loadQuadWord(segIndex&0xfff8); linearMemory.setSupervisor(sup); int dpl=(int)((descriptor>>45)&0x3); newIP = (int)(((descriptor>>32)&0xffff0000)|(descriptor&0x0000ffff)); newSegment = (int)((descriptor>>16)&0xffff); if (dpl<current_privilege_level) { int stackAddress=dpl*8+4; int newSS=0xffff&(tss.loadWord(stackAddress+4)); int newSP=tss.loadDoubleWord(stackAddress); int oldSS=ss.getValue(); int oldSP=esp.getValue(); ss.setValue(newSS); esp.setValue(newSP); //save SS:ESP on the stack int sesp1 = esp.getValue(); sesp1-=4; ss.storeDoubleWord(sesp1, oldSS); sesp1-=4; ss.storeDoubleWord(sesp1, oldSP); esp.setValue(sesp1); } //save the flags on the stack int sesp=esp.getValue(); int eflags = getFlags(); ss.storeDoubleWord(sesp, eflags); //disable interrupts interruptEnable.clear(); interruptEnableSoon.clear(); //save CS:IP on the stack sesp-=4; ss.storeDoubleWord(sesp, cs.getValue()); sesp-=4; ss.storeDoubleWord(sesp, eip.getValue()); esp.setValue(sesp); //change CS and IP to the ISR's values cs.setProtectedValue(newSegment,descriptor); eip.setValue(newIP); setCPL(dpl); // current_privilege_level=dpl; } if(processorGUICode!=null) processorGUICode.push(GUICODE.HARDWARE_INTERRUPT,vector); //System.out.printf("Hardware interrupt happened %x\n",vector); } public FetchQueue fetchQueue; public class FetchQueue { private static final int PREFETCH_QUANTITY=40; private static final int MAX_INST_LENGTH=16; private byte[] bytearray; private int[] iparray; private boolean dofetch; int counter; int ilength; public void fetch() { ilength=0; if (!dofetch) { if (iparray[counter]!=eip.getValue()) dofetch=true; if (counter>PREFETCH_QUANTITY-MAX_INST_LENGTH) dofetch=true; } if (dofetch) { counter=0; int pc=eip.getValue(); for (int i=0; i<PREFETCH_QUANTITY; i++) { bytearray[i]=cs.loadByte(pc+i); iparray[i]=pc+i; } dofetch=false; } } public void flush() { dofetch=true; } public FetchQueue() { bytearray=new byte[PREFETCH_QUANTITY]; iparray=new int[PREFETCH_QUANTITY]; counter=0; ilength=0; dofetch=true; } public byte readByte() { return bytearray[counter]; } public byte readByte(int i) { return bytearray[counter+i]; } public int instructionLength() { return ilength; } public void advance(int i) { if (computer.trace!=null) { for (int j=0; j<i; j++) computer.trace.postInstructionByte(bytearray[counter+j]); } counter+=i; ilength+=i; if (counter>bytearray.length) panic("Reached end of fetch queue"); } } private MICROCODE[] code = new MICROCODE[100]; private int[] icode = new int[100]; private int icodeLength=0; private int icodesHandled=0; public int codeLength=0; public int codesHandled=0; public static int[][][] operandTable; public void executeInstruction() { //move IP to the next instruction int pc = eip.getValue(); pc=pc+getInstructionLength(); eip.setValue(pc); /* //check whether we're out of range if ((pc & 0xffff0000) != 0) { eip.setValue(eip.getValue() - getInstructionLength()); throw GENERAL_PROTECTION; } */ executeMicroInstructions(); } public void executeMicroInstructions() { //internal registers int reg0=0, reg1=0, reg2=0, addr=0; long reg0l=0; Segment seg=null; boolean condition=false; int displacement=0; codesHandled=0; icodesHandled=0; MICROCODE microcode; boolean op32,addr32; try { while (codesHandled < codeLength) { microcode=getCode(); op32=isCode(MICROCODE.PREFIX_OPCODE_32BIT); addr32=isCode(MICROCODE.PREFIX_ADDRESS_32BIT); if(computer.debugMode) { System.out.println(code[codesHandled]); System.out.printf("reg0=%x, reg1=%x, addr=%x ",reg0,reg1,addr); System.out.println(microcode+" op32="+" addr32="+addr32); } switch (microcode) { //reads and writes case LOAD0_AX: reg0 = eax.getValue() & 0xffff; break; case LOAD0_BX: reg0 = ebx.getValue() & 0xffff; break; case LOAD0_CX: reg0 = ecx.getValue() & 0xffff; break; case LOAD0_DX: reg0 = edx.getValue() & 0xffff; break; case LOAD0_SP: reg0 = esp.getValue() & 0xffff; break; case LOAD0_BP: reg0 = ebp.getValue() & 0xffff; break; case LOAD0_SI: reg0 = esi.getValue() & 0xffff; break; case LOAD0_DI: reg0 = edi.getValue() & 0xffff; break; case LOAD0_EAX: reg0 = eax.getValue(); break; case LOAD0_EBX: reg0 = ebx.getValue(); break; case LOAD0_ECX: reg0 = ecx.getValue(); break; case LOAD0_EDX: reg0 = edx.getValue(); break; case LOAD0_ESP: reg0 = esp.getValue(); break; case LOAD0_EBP: reg0 = ebp.getValue(); break; case LOAD0_ESI: reg0 = esi.getValue(); break; case LOAD0_EDI: reg0 = edi.getValue(); break; case LOAD0_AL: reg0 = eax.getValue() & 0xff; break; case LOAD0_AH: reg0 = (eax.getValue()>>8) & 0xff; break; case LOAD0_BL: reg0 = ebx.getValue() & 0xff; break; case LOAD0_BH: reg0 = (ebx.getValue()>>8) & 0xff; break; case LOAD0_CL: reg0 = ecx.getValue() & 0xff; break; case LOAD0_CH: reg0 = (ecx.getValue()>>8) & 0xff; break; case LOAD0_DL: reg0 = edx.getValue() & 0xff; break; case LOAD0_DH: reg0 = (edx.getValue()>>8) & 0xff; break; case LOAD0_CS: reg0 = cs.getValue() & 0xffff; break; case LOAD0_SS: reg0 = ss.getValue() & 0xffff; break; case LOAD0_DS: reg0 = ds.getValue() & 0xffff; break; case LOAD0_ES: reg0 = es.getValue() & 0xffff; break; case LOAD0_FS: reg0 = fs.getValue() & 0xffff; break; case LOAD0_GS: reg0 = gs.getValue() & 0xffff; break; case LOAD0_FLAGS: reg0 = getFlags() & 0xffff; break; case LOAD0_EFLAGS: reg0 = getFlags(); break; case LOAD0_IB: reg0 = getiCode() & 0xff; break; case LOAD0_IW: reg0 = getiCode() & 0xffff; break; case LOAD0_ID: reg0 = getiCode(); break; case LOAD0_ADDR: reg0=addr; break; case LOAD0_CR0: reg0 = cr0.getValue(); break; case LOAD0_CR2: reg0 = cr2.getValue(); break; case LOAD0_CR3: reg0 = cr3.getValue(); break; case LOAD0_CR4: reg0 = cr4.getValue(); break; case LOAD1_AX: reg1 = eax.getValue() & 0xffff; break; case LOAD1_BX: reg1 = ebx.getValue() & 0xffff; break; case LOAD1_CX: reg1 = ecx.getValue() & 0xffff; break; case LOAD1_DX: reg1 = edx.getValue() & 0xffff; break; case LOAD1_SP: reg1 = esp.getValue() & 0xffff; break; case LOAD1_BP: reg1 = ebp.getValue() & 0xffff; break; case LOAD1_SI: reg1 = esi.getValue() & 0xffff; break; case LOAD1_DI: reg1 = edi.getValue() & 0xffff; break; case LOAD1_EAX: reg1 = eax.getValue(); break; case LOAD1_EBX: reg1 = ebx.getValue(); break; case LOAD1_ECX: reg1 = ecx.getValue(); break; case LOAD1_EDX: reg1 = edx.getValue(); break; case LOAD1_ESP: reg1 = esp.getValue(); break; case LOAD1_EBP: reg1 = ebp.getValue(); break; case LOAD1_ESI: reg1 = esi.getValue(); break; case LOAD1_EDI: reg1 = edi.getValue(); break; case LOAD1_AL: reg1 = eax.getValue() & 0xff; break; case LOAD1_AH: reg1 = (eax.getValue()>>8) & 0xff; break; case LOAD1_BL: reg1 = ebx.getValue() & 0xff; break; case LOAD1_BH: reg1 = (ebx.getValue()>>8) & 0xff; break; case LOAD1_CL: reg1 = ecx.getValue() & 0xff; break; case LOAD1_CH: reg1 = (ecx.getValue()>>8) & 0xff; break; case LOAD1_DL: reg1 = edx.getValue() & 0xff; break; case LOAD1_DH: reg1 = (edx.getValue()>>8) & 0xff; break; case LOAD1_CS: reg1 = cs.getValue() & 0xffff; break; case LOAD1_SS: reg1 = ss.getValue() & 0xffff; break; case LOAD1_DS: reg1 = ds.getValue() & 0xffff; break; case LOAD1_ES: reg1 = es.getValue() & 0xffff; break; case LOAD1_FS: reg1 = fs.getValue() & 0xffff; break; case LOAD1_GS: reg1 = gs.getValue() & 0xffff; break; case LOAD1_FLAGS: reg1 = getFlags() & 0xffff; break; case LOAD1_EFLAGS: reg1 = getFlags(); break; case LOAD1_IB: reg1 = getiCode() & 0xff; break; case LOAD1_IW: reg1 = getiCode() & 0xffff; break; case LOAD1_ID: reg1 = getiCode(); break; case LOAD2_IB: reg2 = getiCode() & 0xff; break; case LOAD2_AL: reg2 = eax.getValue() & 0xff; break; case LOAD2_AX: reg2 = eax.getValue() & 0xffff; break; case LOAD2_EAX: reg2 = eax.getValue(); break; case LOAD2_CL: reg2 = ecx.getValue() & 0xff; break; case STORE0_AX: eax.setLower16Value(0xffff & reg0); break; case STORE0_BX: ebx.setLower16Value(0xffff & reg0); break; case STORE0_CX: ecx.setLower16Value(0xffff & reg0); break; case STORE0_DX: edx.setLower16Value(0xffff & reg0); break; case STORE0_SP: esp.setLower16Value(0xffff & reg0); break; case STORE0_BP: ebp.setLower16Value(0xffff & reg0); break; case STORE0_SI: esi.setLower16Value(0xffff & reg0); break; case STORE0_DI: edi.setLower16Value(0xffff & reg0); break; case STORE0_EAX: eax.setValue(reg0); break; case STORE0_EBX: ebx.setValue(reg0); break; case STORE0_ECX: ecx.setValue(reg0); break; case STORE0_EDX: edx.setValue(reg0); break; case STORE0_ESP: esp.setValue(reg0); break; case STORE0_EBP: ebp.setValue(reg0); break; case STORE0_ESI: esi.setValue(reg0); break; case STORE0_EDI: edi.setValue(reg0); break; case STORE0_AL: eax.setLower8Value(0xff & reg0); break; case STORE0_AH: eax.setUpper8Value(0xff & reg0); break; case STORE0_BL: ebx.setLower8Value(0xff & reg0); break; case STORE0_BH: ebx.setUpper8Value(0xff & reg0); break; case STORE0_CL: ecx.setLower8Value(0xff & reg0); break; case STORE0_CH: ecx.setUpper8Value(0xff & reg0); break; case STORE0_DL: edx.setLower8Value(0xff & reg0); break; case STORE0_DH: edx.setUpper8Value(0xff & reg0); break; case STORE0_CS: cs.setValue(0xffff & reg0); break; case STORE0_SS: ss.setValue(0xffff & reg0); break; case STORE0_DS: ds.setValue(0xffff & reg0); break; case STORE0_ES: es.setValue(0xffff & reg0); break; case STORE0_FS: fs.setValue(0xffff & reg0); break; case STORE0_GS: gs.setValue(0xffff & reg0); break; case STORE0_FLAGS: setFlags(0xffff & reg0); break; case STORE0_EFLAGS: setFlags(reg0); break; case STORE0_CR0: setCR0(reg0); break; case STORE0_CR2: setCR2(reg0); break; case STORE0_CR3: setCR3(reg0); break; case STORE0_CR4: setCR4(reg0); break; case STORE1_AX: eax.setLower16Value(0xffff & reg1); break; case STORE1_BX: ebx.setLower16Value(0xffff & reg1); break; case STORE1_CX: ecx.setLower16Value(0xffff & reg1); break; case STORE1_DX: edx.setLower16Value(0xffff & reg1); break; case STORE1_SP: esp.setLower16Value(0xffff & reg1); break; case STORE1_BP: ebp.setLower16Value(0xffff & reg1); break; case STORE1_SI: esi.setLower16Value(0xffff & reg1); break; case STORE1_DI: edi.setLower16Value(0xffff & reg1); break; case STORE1_EAX: eax.setValue(reg1); break; case STORE1_EBX: ebx.setValue(reg1); break; case STORE1_ECX: ecx.setValue(reg1); break; case STORE1_EDX: edx.setValue(reg1); break; case STORE1_ESP: esp.setValue(reg1); break; case STORE1_EBP: ebp.setValue(reg1); break; case STORE1_ESI: esi.setValue(reg1); break; case STORE1_EDI: edi.setValue(reg1); break; case STORE1_AL: eax.setLower8Value(0xff & reg1); break; case STORE1_AH: eax.setUpper8Value(0xff & reg1); break; case STORE1_BL: ebx.setLower8Value(0xff & reg1); break; case STORE1_BH: ebx.setUpper8Value(0xff & reg1); break; case STORE1_CL: ecx.setLower8Value(0xff & reg1); break; case STORE1_CH: ecx.setUpper8Value(0xff & reg1); break; case STORE1_DL: edx.setLower8Value(0xff & reg1); break; case STORE1_DH: edx.setUpper8Value(0xff & reg1); break; case STORE1_CS: cs.setValue(0xffff & reg1); break; case STORE1_SS: ss.setValue(0xffff & reg1); break; case STORE1_DS: ds.setValue(0xffff & reg1); break; case STORE1_ES: es.setValue(0xffff & reg1); break; case STORE1_FS: fs.setValue(0xffff & reg1); break; case STORE1_GS: gs.setValue(0xffff & reg1); break; case STORE1_FLAGS: setFlags(0xffff & reg1); break; case STORE1_EFLAGS: setFlags(reg1); break; case LOAD0_MEM_BYTE: reg0 = 0xff & seg.loadByte(addr); break; case LOAD1_MEM_BYTE: reg1 = 0xff & seg.loadByte(addr); break; case STORE0_MEM_BYTE: seg.storeByte(addr,(byte)reg0); break; case STORE1_MEM_BYTE: seg.storeByte(addr,(byte)reg1); break; case LOAD0_MEM_WORD: reg0 = 0xffff & seg.loadWord(addr); break; case LOAD1_MEM_WORD: reg1 = 0xffff & seg.loadWord(addr); break; case STORE0_MEM_WORD: seg.storeWord(addr,(short)reg0); break; case STORE1_MEM_WORD: seg.storeWord(addr,(short)reg1); break; case LOAD0_MEM_DOUBLE: reg0 = seg.loadDoubleWord(addr); break; case LOAD1_MEM_DOUBLE: reg1 = seg.loadDoubleWord(addr); break; case STORE0_MEM_DOUBLE: seg.storeDoubleWord(addr,reg0); break; case STORE1_MEM_DOUBLE: seg.storeDoubleWord(addr,reg1); break; //addressing case ADDR_AX: addr += (short)eax.getValue(); break; case ADDR_AL: addr += ((0xff)&eax.getValue()); break; case ADDR_BX: addr += (short)ebx.getValue(); break; case ADDR_CX: addr += (short)ecx.getValue(); break; case ADDR_DX: addr += (short)edx.getValue(); break; case ADDR_SP: addr += (short)esp.getValue(); break; case ADDR_BP: addr += (short)ebp.getValue(); break; case ADDR_SI: addr += (short)esi.getValue(); break; case ADDR_DI: addr += (short)edi.getValue(); break; case ADDR_EAX: addr += eax.getValue(); break; case ADDR_EBX: addr += ebx.getValue(); break; case ADDR_ECX: addr += ecx.getValue(); break; case ADDR_EDX: addr += edx.getValue(); break; case ADDR_ESP: addr += esp.getValue(); break; case ADDR_EBP: addr += ebp.getValue(); break; case ADDR_ESI: addr += esi.getValue(); break; case ADDR_EDI: addr += edi.getValue(); break; case ADDR_2EAX: addr += (eax.getValue()<<1); break; case ADDR_2EBX: addr += (ebx.getValue()<<1); break; case ADDR_2ECX: addr += (ecx.getValue()<<1); break; case ADDR_2EDX: addr += (edx.getValue()<<1); break; case ADDR_2EBP: addr += (ebp.getValue()<<1); break; case ADDR_2ESI: addr += (esi.getValue()<<1); break; case ADDR_2EDI: addr += (edi.getValue()<<1); break; case ADDR_4EAX: addr += (eax.getValue()<<2); break; case ADDR_4EBX: addr += (ebx.getValue()<<2); break; case ADDR_4ECX: addr += (ecx.getValue()<<2); break; case ADDR_4EDX: addr += (edx.getValue()<<2); break; case ADDR_4EBP: addr += (ebp.getValue()<<2); break; case ADDR_4ESI: addr += (esi.getValue()<<2); break; case ADDR_4EDI: addr += (edi.getValue()<<2); break; case ADDR_8EAX: addr += (eax.getValue()<<3); break; case ADDR_8EBX: addr += (ebx.getValue()<<3); break; case ADDR_8ECX: addr += (ecx.getValue()<<3); break; case ADDR_8EDX: addr += (edx.getValue()<<3); break; case ADDR_8EBP: addr += (ebp.getValue()<<3); break; case ADDR_8ESI: addr += (esi.getValue()<<3); break; case ADDR_8EDI: addr += (edi.getValue()<<3); break; case ADDR_IB: displacement=((byte)getiCode()); addr += displacement; break; case ADDR_IW: displacement= (short)getiCode(); addr += displacement; break; case ADDR_ID: displacement= getiCode(); addr += displacement; break; case ADDR_MASK_16: addr=addr&0xffff; break; case LOAD_SEG_CS: seg = cs; addr=0; break; case LOAD_SEG_SS: seg = ss; addr=0; break; case LOAD_SEG_DS: seg = ds; addr=0; break; case LOAD_SEG_ES: seg = es; addr=0; break; case LOAD_SEG_FS: seg = fs; addr=0; break; case LOAD_SEG_GS: seg = gs; addr=0; break; //operations //control case OP_JMP_FAR: jump_far(reg0, reg1); break; case OP_JMP_ABS: eip.setValue(reg0); break; case OP_CALL: call(reg0, op32, addr32); break; case OP_CALL_FAR: call_far(reg0, reg1, op32, addr32); break; case OP_CALL_ABS: call_abs(reg0, op32, addr32); break; case OP_RET: ret(op32, addr32); break; case OP_RET_IW: ret_iw((short)reg0,op32,addr32); break; case OP_RET_FAR: ret_far(op32,addr32); break; case OP_RET_FAR_IW: ret_far_iw((short)reg0,op32,addr32); break; case OP_ENTER: enter(reg0, reg1,op32,addr32); break; case OP_LEAVE: leave(op32,addr32); break; case OP_JMP_08: jump_08((byte) reg0); break; case OP_JMP_16_32: if (!op32) { jump_16((short) reg0); } else { jump_32(reg0); } break; case OP_JO: if (overflow.read()) { condition=true; jump_08((byte) reg0); } break; case OP_JO_16_32: if (!op32) { if (overflow.read()) { condition=true; jump_16((short) reg0);} } else { if (overflow.read()) { condition=true; jump_32(reg0);} } break; case OP_JNO: if (!overflow.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNO_16_32: if (!op32) { if (!overflow.read()) { condition=true; jump_16((short) reg0);} } else { if (!overflow.read()) { condition=true; jump_32(reg0);} } break; case OP_JC: if (carry.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JC_16_32: if (!op32) { if (carry.read()) { condition=true; jump_16((short) reg0);} } else { if (carry.read()) { condition=true; jump_32(reg0);} } break; case OP_JNC: if (!carry.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNC_16_32: if (!op32) { if (!carry.read()) { condition=true; jump_16((short) reg0);} } else { if (!carry.read()) { condition=true; jump_32(reg0);} } break; case OP_JZ: if (zero.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JZ_16_32: if (!op32) { if (zero.read()) { condition=true; jump_16((short) reg0);} } else { if (zero.read()) { condition=true; jump_32(reg0);} } break; case OP_JNZ: if (!zero.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNZ_16_32: if (!op32) { if (!zero.read()) { condition=true; jump_16((short) reg0);} } else { if (!zero.read()) { condition=true; jump_32(reg0);} } break; case OP_JS: if (sign.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JS_16_32: if (!op32) { if (sign.read()) { condition=true; jump_16((short) reg0);} } else { if (sign.read()) { condition=true; jump_32(reg0);} } break; case OP_JNS: if (!sign.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNS_16_32: if (!op32) { if (!sign.read()) { condition=true; jump_16((short) reg0);} } else { if (!sign.read()) { condition=true; jump_32(reg0);} } break; case OP_JP: if (parity.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JP_16_32: if (!op32) { if (parity.read()) { condition=true; jump_16((short) reg0);} } else { if (parity.read()) { condition=true; jump_32(reg0);} } break; case OP_JNP: if (!parity.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNP_16_32: if (!op32) { if (!parity.read()) { condition=true; jump_16((short) reg0);} } else { if (!parity.read()) { condition=true; jump_32(reg0);} } break; case OP_JA: if ((!carry.read()) && (!zero.read())) { condition=true; jump_08((byte) reg0);} break; case OP_JA_16_32: if (!op32) { if ((!carry.read()) && (!zero.read())) { condition=true; jump_16((short) reg0);} } else { if ((!carry.read()) && (!zero.read())) { condition=true; jump_32(reg0);} } break; case OP_JNA: if (carry.read() || zero.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNA_16_32: if (!op32) { if (carry.read() || zero.read()) { condition=true; jump_16((short) reg0);} } else { if (carry.read() || zero.read()) { condition=true; jump_32(reg0);} } break; case OP_JL: if (sign.read()!=overflow.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JL_16_32: if (!op32) { if (sign.read()!=overflow.read()) { condition=true; jump_16((short) reg0);} } else { if (sign.read()!=overflow.read()) { condition=true; jump_32(reg0);} } break; case OP_JNL: if (sign.read()==overflow.read()) { condition=true; jump_08((byte) reg0);} break; case OP_JNL_16_32: if (!op32) { if (sign.read()==overflow.read()) { condition=true; jump_16((short) reg0);} } else { if (sign.read()==overflow.read()) { condition=true; jump_32(reg0);} } break; case OP_JG: if ((!zero.read()) && (sign.read()==overflow.read())) { condition=true; jump_08((byte) reg0);} break; case OP_JG_16_32: if (!op32) { if ((!zero.read()) && (sign.read()==overflow.read())) { condition=true; jump_16((short) reg0);} } else { if ((!zero.read()) && (sign.read()==overflow.read())) { condition=true; jump_32(reg0);} } break; case OP_JNG: if (zero.read() || (sign.read()!=overflow.read())) { condition=true; jump_08((byte) reg0);} break; case OP_JNG_16_32: if (!op32) { if (zero.read() || (sign.read()!=overflow.read())) { condition=true; jump_16((short) reg0);} } else { if (zero.read() || (sign.read()!=overflow.read())) { condition=true; jump_32(reg0);} } break; case OP_INT: intr(reg0,op32,addr32); break; case OP_INT3: intr(reg0,op32,addr32); break; case OP_IRET: reg0 = iret(op32,addr32); break; //input/output case OP_IN_08: reg0 = 0xff & ioports.ioPortReadByte(reg0); break; case OP_IN_16_32: if (!op32) reg0 = 0xffff & ioports.ioPortReadWord(reg0); else reg0 = ioports.ioPortReadLong(reg0); break; case OP_OUT_08: ioports.ioPortWriteByte(reg0, reg1); break; case OP_OUT_16_32: if (!op32) ioports.ioPortWriteWord(reg0, reg1); else ioports.ioPortWriteLong(reg0, reg1); break; //arithmetic case OP_INC: reg0=reg0+1; break; case OP_DEC: reg0=reg0-1; break; case OP_ADD: reg2=reg0; reg0=reg2+reg1; break; case OP_ADC: reg2=reg0; reg0=reg2+reg1+(carry.read()? 1:0); break; case OP_SUB: reg2=reg0; reg0=reg2-reg1; break; case OP_CMP: reg2=reg0; reg0=reg2-reg1; break; case OP_SBB: reg2=reg0; reg0=reg2-reg1-(carry.read()? 1:0); break; case OP_AND: reg0=reg0&reg1; break; case OP_TEST: reg0=reg0&reg1; break; case OP_OR: reg0=reg0|reg1; break; case OP_XOR: reg0=reg0^reg1; break; case OP_ROL_08: reg2=reg1&0x7; reg0=(reg0<<reg2)|(reg0>>>(8-reg2)); break; case OP_ROL_16_32: if(!op32) {reg2=reg1&0xf; reg0=(reg0<<reg2)|(reg0>>>(16-reg2)); } else {reg1=reg1&0x1f; reg0=(reg0<<reg1)|(reg0>>>(32-reg1)); } break; case OP_ROR_08: reg1=reg1&0x7; reg0=(reg0>>>reg1)|(reg0<<(8-reg1)); break; case OP_ROR_16_32: if (!op32) {reg1=reg1&0xf; reg0=(reg0>>>reg1)|(reg0<<(16-reg1)); } else {reg1=reg1&0x1f; reg0=(reg0>>>reg1)|(reg0<<(32-reg1));} break; case OP_RCL_08: reg1=reg1&0x1f; reg1=reg1%9; reg0=reg0|(carry.read()? 0x100:0); reg0=(reg0<<reg1)|(reg0>>>(9-reg1)); break; case OP_RCL_16_32: if(!op32){reg1=reg1&0x1f; reg1=reg1%17; reg0=reg0|(carry.read()? 0x10000:0); reg0=(reg0<<reg1)|(reg0>>>(17-reg1)); } else {reg1=reg1&0x1f; reg0l=(0xffffffffl&reg0)|(carry.read()? 0x100000000l:0); reg0=(int)(reg0l=(reg0l<<reg1)|(reg0l>>>(33-reg1))); } break; case OP_RCR_08: reg1=reg1&0x1f; reg1=reg1%9; reg0=reg0|(carry.read()? 0x100:0); reg2=(carry.read()^((reg0&0x80)!=0)? 1:0); reg0=(reg0>>>reg1)|(reg0<<(9-reg1)); break; case OP_RCR_16_32: if(!op32) { reg1=reg1&0x1f; reg1=reg1%17; reg2=(carry.read()^((reg0&0x8000)!=0)? 1:0); reg0=reg0|(carry.read()? 0x10000:0); reg0=(reg0>>>reg1)|(reg0<<(17-reg1)); } else {reg1=reg1&0x1f; reg0l=(0xffffffffl&reg0)|(carry.read()? 0x100000000l:0); reg2=(carry.read()^((reg0&0x80000000)!=0)? 1:0); reg0=(int)(reg0l=(reg0l>>>reg1)|(reg0l<<(33-reg1))); } break; case OP_SHL: reg1 &= 0x1f; reg2 = reg0; reg0 <<= reg1; break; case OP_SHR: reg1=reg1&0x1f; reg2=reg0; reg0=reg0>>>reg1; break; case OP_SAR_08: reg1=reg1&0x1f; reg2=reg0; reg0=((byte)reg0)>>reg1; break; case OP_SAR_16_32: if (!op32) {reg1=reg1&0x1f; reg2=reg0; reg0=((short)reg0)>>reg1; } else { reg1=reg1&0x1f; reg2=reg0; reg0=reg0>>reg1; } break; case OP_NOT: reg0=~reg0; break; case OP_NEG: reg0=-reg0; break; case OP_MUL_08: mul_08(reg0); break; case OP_MUL_16_32: if(!op32) mul_16(reg0); else mul_32(reg0); break; case OP_IMULA_08: imula_08((byte)reg0); break; case OP_IMULA_16_32: if(!op32) imula_16((short)reg0); else imula_32(reg0); break; case OP_IMUL_16_32: if(!op32) reg0=imul_16((short)reg0, (short)reg1); else reg0=imul_32(reg0,reg1); break; case OP_DIV_08: div_08(reg0); break; case OP_DIV_16_32: if (!op32) div_16(reg0); else div_32(reg0); break; case OP_IDIV_08: idiv_08((byte)reg0); break; case OP_IDIV_16_32: if (!op32) idiv_16((short)reg0); else idiv_32(reg0); break; case OP_SCASB: case OP_SCASW: { int a; if (!addr32) a=edi.getValue()&0xffff; else a=edi.getValue(); int i,n; if (microcode==MICROCODE.OP_SCASB) { i=0xff&es.loadByte(a); n=1; } else if (!op32) { i=0xffff&es.loadWord(a); n=2; } else { i=es.loadDoubleWord(a); n=4; } if(direction.read()) a-=n; else a+=n; if (!addr32) edi.setValue((edi.getValue()&~0xffff)|(a&0xffff)); else edi.setValue(a); reg2=reg0; if (microcode==MICROCODE.OP_SCASW && op32) reg0=(int)((0xffffffffl&reg0)-(0xffffffffl&i)); else reg0=reg0-i; reg1=i; } break; case OP_REPNE_SCASB: case OP_REPE_SCASB: case OP_REPNE_SCASW: case OP_REPE_SCASW: { int count,a; if(!op32) count=ecx.getValue()&0xffff; else count=ecx.getValue(); if (!addr32) a=edi.getValue()&0xffff; else a=edi.getValue(); boolean used=count!=0; int input=0; while(count!=0) { if (microcode==MICROCODE.OP_REPNE_SCASB || microcode==MICROCODE.OP_REPE_SCASB) { input=0xff&es.loadByte(a); count--; if(direction.read()) a-=1; else a+=1; } else if (!op32) { input=0xffff&es.loadWord(a); count--; if(direction.read()) a-=2; else a+=2; } else { input=es.loadDoubleWord(a); count--; if(direction.read()) a-=4; else a+=4; } if (microcode==MICROCODE.OP_REPNE_SCASB || microcode==MICROCODE.OP_REPNE_SCASW) { if(reg0==input) break; } else { if(reg0!=input) break; } } if (!op32) ecx.setValue((ecx.getValue()&~0xffff)|(count&0xffff)); else ecx.setValue(count); if (!addr32) edi.setValue((edi.getValue()&~0xffff)|(a&0xffff)); else edi.setValue(a); reg2=reg0; reg1=input; reg0=used? 1:0; } break; case OP_CMPSB: case OP_CMPSW: { int addrOne,addrTwo; if (!addr32) { addrOne=esi.getValue()&0xffff; addrTwo=edi.getValue()&0xffff; } else { addrOne=esi.getValue(); addrTwo=edi.getValue(); } int dataOne; int dataTwo; int n; if (microcode==MICROCODE.OP_CMPSB) { dataOne=0xff&seg.loadByte(addrOne); dataTwo=0xff&es.loadByte(addrTwo); n=1; } else if (!op32) { dataOne=0xffff&seg.loadWord(addrOne); dataTwo=0xffff&es.loadWord(addrTwo); n=2; } else { dataOne=seg.loadDoubleWord(addrOne); dataTwo=es.loadDoubleWord(addrTwo); n=4; } if(direction.read()) { addrOne-=n; addrTwo-=n; } else { addrOne+=n; addrTwo+=n; } if(!addr32) { esi.setValue((esi.getValue()&~0xffff)|(addrOne&0xffff)); edi.setValue((edi.getValue()&~0xffff)|(addrTwo&0xffff)); } else { esi.setValue(addrOne); edi.setValue(addrTwo); } reg2=dataOne; reg1=dataTwo; if(microcode==MICROCODE.OP_CMPSW && op32) reg0=(int)((0xffffffffl&dataOne)-(0xffffffffl&dataTwo)); else reg0=dataOne-dataTwo; } break; case OP_REPNE_CMPSB: case OP_REPE_CMPSB: case OP_REPNE_CMPSW: case OP_REPE_CMPSW: { int count,addrOne,addrTwo; if(!op32) count=ecx.getValue()&0xffff; else count=ecx.getValue(); if(!addr32) { addrOne=esi.getValue()&0xffff; addrTwo=edi.getValue()&0xffff; } else { addrOne=esi.getValue(); addrTwo=edi.getValue(); } boolean used=count!=0; int dataOne=0; int dataTwo=0; while(count!=0) { if(microcode==MICROCODE.OP_REPE_CMPSB || microcode==MICROCODE.OP_REPNE_CMPSB) { dataOne=0xff&seg.loadByte(addrOne); dataTwo=0xff&es.loadByte(addrTwo); count--; if(direction.read()) { addrOne-=1; addrTwo-=1; } else { addrOne+=1; addrTwo+=1; } } else if(!op32) { dataOne=0xffff&seg.loadWord(addrOne); dataTwo=0xffff&es.loadWord(addrTwo); count--; if(direction.read()) { addrOne-=2; addrTwo-=2; } else { addrOne+=2; addrTwo+=2; } } else { dataOne=seg.loadDoubleWord(addrOne); dataTwo=es.loadDoubleWord(addrTwo); count--; if(direction.read()) { addrOne-=4; addrTwo-=4; } else { addrOne+=4; addrTwo+=4; } } if (microcode==MICROCODE.OP_REPE_CMPSB || microcode==MICROCODE.OP_REPE_CMPSW) { if(dataOne!=dataTwo) break; } else { if(dataOne==dataTwo) break; } } if(!op32) ecx.setValue((ecx.getValue()&~0xffff)|(count&0xffff)); else ecx.setValue(count); if(!addr32) { esi.setValue((esi.getValue()&~0xffff)|(addrOne&0xffff)); edi.setValue((edi.getValue()&~0xffff)|(addrTwo&0xffff)); } else { esi.setValue(addrOne); edi.setValue(addrTwo); } reg0=used? 1:0; reg1=dataTwo; reg2=dataOne; } break; case OP_BSF: reg0 = bsf(reg1, reg0); break; case OP_BSR: reg0 = bsr(reg1, reg0); break; case OP_BT_MEM: bt_mem(reg1, seg, addr); break; case OP_BTS_MEM: bts_mem(reg1, seg, addr); break; case OP_BTR_MEM: btr_mem(reg1, seg, addr); break; case OP_BTC_MEM: btc_mem(reg1, seg, addr); break; case OP_BT_16_32: if (!op32) {reg1 &= 0xf;} else {reg1&=0x1f;} carry.set(reg0, reg1, Flag.CY_NTH_BIT_SET); break; case OP_BTS_16_32: if (!op32) {reg1 &= 0xf;} else {reg1&=0x1f;} carry.set(reg0, reg1, Flag.CY_NTH_BIT_SET); reg0 |= (1 << reg1); break; case OP_BTR_16_32: if (!op32) {reg1 &= 0xf;} else {reg1&=0x1f;} carry.set(reg0, reg1, Flag.CY_NTH_BIT_SET); reg0 &= ~(1 << reg1); break; case OP_BTC_16_32: if (!op32) {reg1 &= 0xf;} else {reg1&=0x1f;} carry.set(reg0, reg1, Flag.CY_NTH_BIT_SET); reg0 ^= (1 << reg1); break; case OP_SHLD_16_32: if (!op32) { int i = reg0; reg2 &= 0x1f; if (reg2 < 16) { reg0 = (reg0 << reg2) | (reg1 >>> (16 - reg2)); reg1 = reg2; reg2 = i; } else { i = (reg1 & 0xFFFF) | (reg0 << 16); reg0 = (reg1 << (reg2 - 16)) | ((reg0 & 0xFFFF) >>> (32 - reg2)); reg1 = reg2 - 15; reg2 = i >> 1; } } else { int i = reg0; reg2 &= 0x1f; if (reg2!=0) reg0=(reg0<<reg2)|(reg1>>>(32-reg2)); reg1=reg2; reg2=i; } break; case OP_SHRD_16_32: if (!op32) { int i = reg0; reg2 &= 0x1f; if (reg2 < 16) { reg0 = (reg0 >>> reg2) | (reg1 << (16 - reg2)); reg1 = reg2; reg2 = i; } else { i = (reg0 & 0xFFFF) | (reg1 << 16); reg0 = (reg1 >>> (reg2 - 16)) | (reg0 << (32 - reg2)); reg1 = reg2; reg2 = i; } } else { int i = reg0; reg2 &= 0x1f; if(reg2 != 0) reg0=(reg0>>>reg2)|(reg1<<(32-reg2)); reg1=reg2; reg2=i; } break; case OP_CWD: if(!op32) { if ((eax.getValue() & 0x8000) == 0) edx.setValue(edx.getValue() & 0xffff0000); else edx.setValue(edx.getValue() | 0x0000ffff); } else { if ((eax.getValue() & 0x80000000) == 0) edx.setValue(0); else edx.setValue(-1); } break; case OP_AAA: aaa(); break; case OP_AAD: aad(reg0); break; case OP_AAM: reg0 = aam(reg0); break; case OP_AAS: aas(); break; case OP_DAA: daa(); break; case OP_DAS: das(); break; case OP_BOUND: { if(!op32) { short lower = (short)reg0; short upper = (short)(reg0 >> 16); short index = (short)reg1; if ((index < lower) || (index > (upper + 2))) throw BOUND_RANGE; } } break; //flag instructions case OP_CLC: carry.clear(); break; case OP_STC: carry.set(); break; case OP_CLI: interruptEnable.clear(); interruptEnableSoon.clear(); break; case OP_STI: interruptEnableSoon.set(); break; case OP_CLD: direction.clear(); break; case OP_STD: direction.set(); break; case OP_CMC: carry.toggle(); break; case OP_SETO: reg0 = overflow.read() ? 1 : 0; break; case OP_SETNO: reg0 = overflow.read() ? 0 : 1; break; case OP_SETC: reg0 = carry.read() ? 1 : 0; break; case OP_SETNC: reg0 = carry.read() ? 0 : 1; break; case OP_SETZ: reg0 = zero.read() ? 1 : 0; break; case OP_SETNZ: reg0 = zero.read() ? 0 : 1; break; case OP_SETNA: reg0 = carry.read() || zero.read() ? 1 : 0; break; case OP_SETA: reg0 = carry.read() || zero.read() ? 0 : 1; break; case OP_SETS: reg0 = sign.read() ? 1 : 0; break; case OP_SETNS: reg0 = sign.read() ? 0 : 1; break; case OP_SETP: reg0 = parity.read() ? 1 : 0; break; case OP_SETNP: reg0 = parity.read() ? 0 : 1; break; case OP_SETL: reg0 = sign.read() != overflow.read() ? 1 : 0; break; case OP_SETNL: reg0 = sign.read() != overflow.read() ? 0 : 1; break; case OP_SETNG: reg0 = zero.read() || (sign.read() != overflow.read()) ? 1 : 0; break; case OP_SETG: reg0 = zero.read() || (sign.read() != overflow.read()) ? 0 : 1; break; case OP_SALC: reg0 = carry.read() ? -1 : 0; break; case OP_CMOVO: if(overflow.read()) { condition=true; reg0=reg1; } break; case OP_CMOVNO: if(!overflow.read()) { condition=true; reg0=reg1; } break; case OP_CMOVC: if(carry.read()) { condition=true; reg0=reg1; } break; case OP_CMOVNC: if(!carry.read()) { condition=true; reg0=reg1; } break; case OP_CMOVZ: if(zero.read()) { condition=true; reg0=reg1; } break; case OP_CMOVNZ: if(!zero.read()) { condition=true; reg0=reg1; } break; case OP_CMOVNA: if((carry.read()||(zero.read()))) { condition=true; reg0=reg1; } break; case OP_CMOVA: if(!(carry.read()||(zero.read()))) { condition=true; reg0=reg1; } break; case OP_CMOVS: if(sign.read()) { condition=true; reg0=reg1; } break; case OP_CMOVNS: if(!sign.read()) { condition=true; reg0=reg1; } break; case OP_CMOVP: if(parity.read()) { condition=true; reg0=reg1; } break; case OP_CMOVNP: if(!parity.read()) { condition=true; reg0=reg1; } break; case OP_CMOVL: if((sign.read() != overflow.read())) { condition=true; reg0=reg1; } break; case OP_CMOVNL: if(!(sign.read() != overflow.read())) { condition=true; reg0=reg1; } break; case OP_CMOVNG: if((zero.read() || (sign.read() != overflow.read()))) { condition=true; reg0=reg1; } break; case OP_CMOVG: if(!(zero.read() || (sign.read() != overflow.read()))) { condition=true; reg0=reg1; } break; case OP_LAHF: lahf(); break; case OP_SAHF: sahf(); break; //stack instructions case OP_POP: if(!op32 && !addr32) { reg0 = ss.loadWord(esp.getValue()&0xffff); esp.setValue((esp.getValue()&~0xffff) | ((esp.getValue()+2)&0xffff)); } else if (!op32 && addr32) { reg0 = ss.loadWord(esp.getValue()); esp.setValue((esp.getValue()+2)); } else if (op32 && !addr32) { reg0 = ss.loadDoubleWord(esp.getValue()&0xffff); esp.setValue((esp.getValue()&~0xffff) | ((esp.getValue()+4)&0xffff)); } else { reg0 = ss.loadDoubleWord(esp.getValue()&0xffffffff); esp.setValue((esp.getValue()&~0xffff) | ((esp.getValue()+4)&0xffff)); } if (code[codesHandled]==MICROCODE.STORE0_SS) interruptEnable.clear(); break; case OP_POPF: if (isModeReal()) { if (!op32 && !addr32) { reg0 = ss.loadWord(esp.getValue()&0xffff); esp.setValue((esp.getValue()&~0xffff)|((esp.getValue()+2)&0xffff)); } else if (op32 && !addr32) { reg0 = (getFlags()&0x20000)|(ss.loadDoubleWord(esp.getValue()&0xffff)&~0x1a0000); esp.setValue((esp.getValue()&~0xffff)|((esp.getValue()+4)&0xffff)); } else if (!op32 && addr32) { reg0 = ss.loadWord(esp.getValue()); esp.setValue(esp.getValue()+2); } else if (op32 && addr32) { reg0 = (getFlags()&0x20000)|(ss.loadDoubleWord(esp.getValue())&~0x1a0000); esp.setValue(esp.getValue()+4); } } else { int flagPrivilegeLevel=(ioPrivilegeLevel1.value?2:0)+(ioPrivilegeLevel0.value?1:0); if (!op32 && !addr32) { reg0 = ss.loadWord(esp.getValue()&0xffff); esp.setValue((esp.getValue()&~0xffff)|((esp.getValue()+2)&0xffff)); if (current_privilege_level>0) { if (current_privilege_level>flagPrivilegeLevel) reg0=(getFlags()&0x3200)|(reg0&~0x3200); else reg0=(getFlags()&0x3000)|(reg0&~0x3000); } } else if (!op32 && addr32) { reg0 = ss.loadWord(esp.getValue()); esp.setValue(esp.getValue()+2); if (current_privilege_level>0) { if (current_privilege_level>flagPrivilegeLevel) reg0=(getFlags()&0x3200)|(reg0&~0x3200); else reg0=(getFlags()&0x3000)|(reg0&~0x3000); } } else if (op32 && !addr32) { reg0 = ss.loadDoubleWord(esp.getValue()&0xffff); esp.setValue((esp.getValue()&~0xffff)|((esp.getValue()+4)&0xffff)); if (current_privilege_level>0) { if (current_privilege_level>flagPrivilegeLevel) reg0=(getFlags()&0x23200)|(reg0&~(0x23200|0x180000)); else reg0=(getFlags()&0x23000)|(reg0&~(0x23000|0x180000)); } else reg0=(getFlags()&0x20000)|(reg0&~(0x20000|0x180000)); } else if (op32 && addr32) { reg0 = ss.loadDoubleWord(esp.getValue()); esp.setValue(esp.getValue()+4); if (current_privilege_level>0) { if (current_privilege_level>flagPrivilegeLevel) reg0=(getFlags()&0x23200)|(reg0&~(0x23200|0x180000)); else reg0=(getFlags()&0x23000)|(reg0&~(0x23000|0x180000)); } else reg0=(getFlags()&0x20000)|(reg0&~(0x20000|0x180000)); } } break; case OP_PUSH: if(!op32) push_16((short)reg0,addr32); else push_32(reg0,addr32); break; case OP_PUSHF: if(!op32) push_16((short)reg0,addr32); else push_32(~0x30000&reg0,addr32); break; case OP_PUSHA: if(!op32) pusha(); else pushad(); break; case OP_POPA: if(!op32) popa(); else popad(); break; case OP_SIGN_EXTEND: if(!op32) reg0 = 0xffff & ((byte)reg0); else reg0 = ((short)reg0); break; case OP_SIGN_EXTEND_8_16: reg0 = 0xffff & ((byte)reg0); break; case OP_SIGN_EXTEND_8_32: if(op32) reg0 = ((byte)reg0); break; case OP_SIGN_EXTEND_16_32: if(op32) reg0 = ((short)reg0); break; case OP_INSB: ins(reg0,1,addr32); break; case OP_INSW: ins(reg0,op32?4:2,addr32); break; case OP_REP_INSB: rep_ins(reg0,1,addr32); break; case OP_REP_INSW: rep_ins(reg0,op32?4:2,addr32); break; case OP_LODSB: lods(seg,1,addr32); break; case OP_LODSW: lods(seg,op32?4:2,addr32); break; case OP_REP_LODSB: rep_lods(seg,1,addr32); break; case OP_REP_LODSW: rep_lods(seg,op32?4:2,addr32); break; case OP_MOVSB: movs(seg,1,addr32); break; case OP_MOVSW: movs(seg,op32?4:2,addr32); break; case OP_REP_MOVSB: rep_movs(seg,1,addr32); break; case OP_REP_MOVSW: rep_movs(seg,op32?4:2,addr32); break; case OP_OUTSB: outs(reg0, seg, 1,addr32); break; case OP_OUTSW: outs(reg0, seg, op32?4:2,addr32); break; case OP_REP_OUTSB: rep_outs(reg0, seg, 1,addr32); break; case OP_REP_OUTSW: rep_outs(reg0, seg, op32?4:2,addr32); break; case OP_STOSB: stos(reg0,1,addr32); break; case OP_STOSW: stos(reg0,op32?4:2,addr32); break; case OP_REP_STOSB: rep_stos(reg0,1,addr32); break; case OP_REP_STOSW: rep_stos(reg0,op32?4:2,addr32); break; case OP_LOOP_CX: if (!op32) { ecx.setValue((ecx.getValue() & ~0xffff) | ((ecx.getValue() - 1) & 0xffff)); if ((0xffff & ecx.getValue()) != 0) jump_08((byte)reg0); } else {ecx.setValue(ecx.getValue()-1); if (ecx.getValue() != 0) jump_08((byte)reg0); }break; case OP_LOOPZ_CX: if(!op32){ecx.setValue((ecx.getValue() & ~0xffff) | ((ecx.getValue() - 1) & 0xffff)); if (((0xffff & ecx.getValue()) != 0) && zero.read()) jump_08((byte)reg0); } else { ecx.setValue(ecx.getValue()-1); if ((ecx.getValue() != 0) && zero.read()) jump_08((byte)reg0); } break; case OP_LOOPNZ_CX: if(!op32){ecx.setValue((ecx.getValue() & ~0xffff) | ((ecx.getValue() - 1) & 0xffff)); if (((0xffff & ecx.getValue()) != 0) && !zero.read()) jump_08((byte)reg0);} else{ecx.setValue(ecx.getValue()-1); if ((ecx.getValue() != 0) && !zero.read()) jump_08((byte)reg0);} break; case OP_JCXZ: if(!op32) jcxz((byte)reg0); else jecxz((byte)reg0); break; case OP_HALT: waitForInterrupt(); break; case OP_CPUID: cpuid(); break; case OP_LGDT: gdtr.memory=linearMemory; gdtr.setDescriptorValue(op32? reg1:(reg1&0x00ffffff),reg0); System.out.printf("New GDT starts at %x\n", gdtr.getBase()); break; case OP_LIDT: idtr.memory=linearMemory; idtr.setDescriptorValue(op32? reg1:(reg1&0x00ffffff),reg0); break; case OP_SGDT: if (op32) reg1=gdtr.getBase(); else reg1=gdtr.getBase()&0x00ffffff; reg0=gdtr.getLimit(); break; case OP_SIDT: if (op32) reg1=idtr.getBase(); else reg1=idtr.getBase()&0x00ffffff; reg0=gdtr.getLimit(); break; case OP_SMSW: reg0 = cr0.getValue() & 0xffff; break; case OP_LMSW: setCR0((cr0.getValue()&~0xf)|(reg0&0xf)); break; case OP_SLDT: reg0=0xffff&ldtr.getBase(); break; case OP_STR: reg0=0xffff&tss.getBase(); break; case OP_LLDT: ldtr.setProtectedValue(reg0&~0x4); System.out.printf("New LDT starts at %x\n",ldtr.getBase()); break; case OP_LTR: tss.setProtectedValue(reg0); System.out.printf("New TSS starts at %x\n",tss.getBase()); break; case OP_CLTS: setCR3(cr3.getValue()&~0x4); break; case OP_RDTSC: long tsc = rdtsc(); reg0=(int)tsc; reg1=(int)(tsc>>>32); break; case OP_NOP: break; case OP_MOV: break; case OP_FLOAT_NOP: break; //prefices case PREFIX_LOCK: case PREFIX_REPNE: case PREFIX_REPE: case PREFIX_CS: case PREFIX_SS: case PREFIX_DS: case PREFIX_ES: case PREFIX_FS: case PREFIX_GS: case PREFIX_OPCODE_32BIT: case PREFIX_ADDRESS_32BIT: break; //flag setting commands case FLAG_BITWISE_08: bitwise_flags((byte)reg0); break; case FLAG_BITWISE_16: bitwise_flags((short)reg0); break; case FLAG_BITWISE_32: bitwise_flags(reg0); break; case FLAG_SUB_08: sub_flags_08(reg0, reg2, reg1); break; case FLAG_SUB_16: sub_flags_16(reg0, reg2, reg1); break; case FLAG_SUB_32: sub_flags_32(reg0l, reg2, reg1); break; case FLAG_REP_SUB_08: rep_sub_flags_08(reg0, reg2, reg1); break; case FLAG_REP_SUB_16: rep_sub_flags_16(reg0, reg2, reg1); break; case FLAG_REP_SUB_32: rep_sub_flags_32(reg0, reg2, reg1); break; case FLAG_ADD_08: add_flags_08(reg0, reg2, reg1); break; case FLAG_ADD_16: add_flags_16(reg0, reg2, reg1); break; case FLAG_ADD_32: add_flags_32(reg0l, reg2, reg1); break; case FLAG_ADC_08: adc_flags_08(reg0, reg2, reg1); break; case FLAG_ADC_16: adc_flags_16(reg0, reg2, reg1); break; case FLAG_ADC_32: adc_flags_32(reg0l, reg2, reg1); break; case FLAG_SBB_08: sbb_flags_08(reg0, reg2, reg1); break; case FLAG_SBB_16: sbb_flags_16(reg0, reg2, reg1); break; case FLAG_SBB_32: sbb_flags_32(reg0l, reg2, reg1); break; case FLAG_DEC_08: dec_flags_08((byte)reg0); break; case FLAG_DEC_16: dec_flags_16((short)reg0); break; case FLAG_DEC_32: dec_flags_32(reg0); break; case FLAG_INC_08: inc_flags_08((byte)reg0); break; case FLAG_INC_16: inc_flags_16((short)reg0); break; case FLAG_INC_32: inc_flags_32(reg0); break; case FLAG_SHL_08: shl_flags_08((byte)reg0, (byte)reg2, reg1); break; case FLAG_SHL_16: shl_flags_16((short)reg0, (short)reg2, reg1); break; case FLAG_SHL_32: shl_flags_32(reg0, reg2, reg1); break; case FLAG_SHR_08: shr_flags_08((byte)reg0, reg2, reg1); break; case FLAG_SHR_16: shr_flags_16((short)reg0, reg2, reg1); break; case FLAG_SHR_32: shr_flags_32(reg0, reg2, reg1); break; case FLAG_SAR_08: sar_flags((byte)reg0, (byte)reg2, reg1); break; case FLAG_SAR_16: sar_flags((short)reg0, (short)reg2, reg1); break; case FLAG_SAR_32: sar_flags(reg0, reg2, reg1); break; case FLAG_RCL_08: rcl_flags_08(reg0, reg1); break; case FLAG_RCL_16: rcl_flags_16(reg0, reg1); break; case FLAG_RCL_32: rcl_flags_32(reg0l, reg1); break; case FLAG_RCR_08: rcr_flags_08(reg0, reg1, reg2); break; case FLAG_RCR_16: rcr_flags_16(reg0, reg1, reg2); break; case FLAG_RCR_32: rcr_flags_32(reg0l, reg1, reg2); break; case FLAG_ROL_08: rol_flags_08((byte)reg0, reg1); break; case FLAG_ROL_16: rol_flags_16((short)reg0, reg1); break; case FLAG_ROL_32: rol_flags_32(reg0, reg1); break; case FLAG_ROR_08: ror_flags_08((byte)reg0, reg1); break; case FLAG_ROR_16: ror_flags_16((short)reg0, reg1); break; case FLAG_ROR_32: ror_flags_32(reg0, reg1); break; case FLAG_NEG_08: neg_flags_08((byte)reg0); break; case FLAG_NEG_16: neg_flags_16((short)reg0); break; case FLAG_NEG_32: neg_flags_32(reg0); break; case FLAG_NONE: break; case FLAG_FLOAT_NOP: break; //errors case OP_BAD: panic("Bad microcode"); case OP_UNIMPLEMENTED: panic("Unimplemented microcode"); default: System.out.println(microcode); panic("Unhandled microcode"); } if(processorGUICode!=null) processorGUICode.pushMicrocode(microcode,reg0,reg1,reg2,addr,displacement,condition); } } catch (Processor_Exception e) { handleProcessorException(e); } } private void jump_08(byte offset) { int pc = eip.getValue(); pc=pc+offset; eip.setValue(pc); //check whether we're out of range /* if ((pc & 0xffff0000) != 0) { eip.setValue(eip.getValue() - offset); throw GENERAL_PROTECTION; } */ } private void jump_16(short offset) { eip.setValue((eip.getValue()+offset)&0xffff); } private void jump_32(int offset) { int pc = eip.getValue(); pc=pc+offset; eip.setValue(pc); /* //check whether we're out of range if ((pc & 0xffff0000) != 0) { eip.setValue(eip.getValue() - offset); throw GENERAL_PROTECTION; } */ } private void call(int target, boolean op32, boolean addr32) { int sp=esp.getValue(); int pc=eip.getValue(); // if (((sp&0xffff)<2)&&((sp&0xffff)>0)) // throw STACK_SEGMENT; if (!op32 && !addr32) { int offset = (sp-2)&0xffff; ss.storeWord(offset, (short)pc); esp.setValue((sp & 0xffff0000) | offset); eip.setValue((pc+target)&0xffff); } else if (op32 && !addr32) { int offset = (sp-4)&0xffff; ss.storeDoubleWord(offset, pc); esp.setValue((sp & 0xffff0000) | offset); eip.setValue(pc+target); } else if (!op32 && addr32) { int offset = (sp-2); ss.storeWord(offset, (short)pc); esp.setValue(offset); eip.setValue((pc+target)&0xffff); } else { int offset = (sp-4); ss.storeDoubleWord(offset, pc); esp.setValue(offset); eip.setValue(pc+target); } } private void ret(boolean op32, boolean addr32) { int sp=esp.getValue(); if(!op32 && !addr32) { eip.setValue(ss.loadWord(sp&0xffff)&0xffff); esp.setValue((sp&~0xffff)|((sp+2)&0xffff)); } else if (op32 && !addr32) { eip.setValue(ss.loadDoubleWord(sp&0xffff)); esp.setValue((sp&~0xffff)|((sp+4)&0xffff)); } else if (!op32 && addr32) { eip.setValue(ss.loadWord(sp)&0xffff); esp.setValue(sp+2); } else { eip.setValue(ss.loadDoubleWord(sp)); esp.setValue(sp+4); } } private void ret_iw(short data, boolean op32, boolean addr32) { ret(op32,addr32); int sp=esp.getValue(); if (!addr32) esp.setValue((sp&~0xffff)|((sp+data)&0xffff)); else esp.setValue(sp+data); } private void ret_far(boolean op32, boolean addr32) { int sp=esp.getValue(); if (!op32 && !addr32) { eip.setValue(ss.loadWord(sp&0xffff)&0xffff); cs.setValue(ss.loadWord((sp+2)&0xffff)&0xffff); esp.setValue((sp&~0xffff)|((sp+4)&0xffff)); } else if (!op32 && addr32) { eip.setValue(ss.loadWord(sp)&0xffff); cs.setValue(ss.loadWord((sp+2))&0xffff); esp.setValue(sp+4); } else if (op32 && !addr32) { eip.setValue(ss.loadWord(sp&0xffff)); cs.setValue(ss.loadWord((sp+4)&0xffff)); esp.setValue((sp&~0xffff)|((sp+8)&0xffff)); } else { eip.setValue(ss.loadWord(sp)); cs.setValue(ss.loadWord((sp+4))); esp.setValue(sp+8); } if (!isModeReal()) { if (cs.rpl<current_privilege_level) throw GENERAL_PROTECTION; // current_privilege_level=cs.rpl; setCPL(cs.rpl); } } private void ret_far_iw(short data, boolean op32, boolean addr32) { ret_far(op32,addr32); int sp=esp.getValue(); if (!addr32) esp.setValue((sp&~0xffff)|((sp+data)&0xffff)); else esp.setValue(sp+data); } private void push_16(short data, boolean addr32) { int sp=esp.getValue(); if (((sp&0xffff)<2)&&((sp&0xffff)>0)) throw STACK_SEGMENT; if (!addr32) { int offset=(sp-2)&0xffff; ss.storeWord(offset,data); esp.setValue((sp&~0xffff)|offset); } else { int offset=(sp-2); ss.storeWord(offset,data); esp.setValue(offset); } } private void push_32(int data, boolean addr32) { int sp=esp.getValue(); if (((sp&0xffff)<4)&&((sp&0xffff)>0)) throw STACK_SEGMENT; if (!addr32) { int offset=(sp-4)&0xffff; ss.storeDoubleWord(offset,data); esp.setValue((sp&~0xffff)|offset); } else { int offset=(sp-4); ss.storeDoubleWord(offset,data); esp.setValue(offset); } } private void jump_far(int ip, int segment) { eip.setValue(ip); cs.setValue(segment); if (!isModeReal()) { if (cs.dpl<current_privilege_level) throw GENERAL_PROTECTION; cs.rpl=current_privilege_level; } } private void call_far(int ip, int segment, boolean op32, boolean addr32) { int sp=esp.getValue(); if (!op32 && !addr32) if (((sp&0xffff)<4)&&((sp&0xffff)>0)) throw STACK_SEGMENT; else if (!op32 && addr32) if (sp<4 && sp>0) throw STACK_SEGMENT; else if (op32 && !addr32) if (((sp&0xffff)<8)&&((sp&0xffff)>0)) throw STACK_SEGMENT; else if (sp<8 && sp>0) throw STACK_SEGMENT; if (!op32 && !addr32) { ss.storeWord((sp-2)&0xffff, (short)cs.getValue()); ss.storeWord((sp-4)&0xffff, (short)eip.getValue()); esp.setValue((sp&~0xffff)|((sp-4)&0xffff)); } else if (!op32 && addr32) { ss.storeWord((sp-2), (short)cs.getValue()); ss.storeWord((sp-4), (short)eip.getValue()); esp.setValue(sp-4); } else if (op32 && !addr32) { ss.storeDoubleWord((sp-4)&0xffff, 0xffff&cs.getValue()); ss.storeDoubleWord((sp-8)&0xffff, eip.getValue()); esp.setValue((sp&~0xffff)|((sp-8)&0xffff)); } else { ss.storeDoubleWord((sp-4), 0xffff&cs.getValue()); ss.storeDoubleWord((sp-8), eip.getValue()); esp.setValue(sp-8); } eip.setValue(ip); cs.setValue(segment); if (!isModeReal()) { if (cs.dpl<current_privilege_level) throw GENERAL_PROTECTION; cs.rpl=current_privilege_level; } } private void jcxz(byte offset) { if ((ecx.getValue() & 0xffff) == 0) jump_08(offset); } private void jecxz(byte offset) { if (ecx.getValue() == 0) jump_08(offset); } private void enter(int frameSize, int nestingLevel, boolean op32, boolean addr32) { if (op32||addr32) { panic("Implement enter 32"); } nestingLevel %= 32; int tempESP = esp.getValue(); int tempEBP = ebp.getValue(); tempESP = (tempESP & ~0xffff) | ((tempESP - 2) & 0xffff); ss.storeWord(tempESP & 0xffff, (short)tempEBP); int frameTemp = tempESP & 0xffff; if (nestingLevel != 0) { while (--nestingLevel != 0) { tempEBP = (tempEBP & ~0xffff) | ((tempEBP - 2) & 0xffff); tempESP = (tempESP & ~0xffff) | ((tempESP - 2) & 0xffff); ss.storeWord(tempESP & 0xffff, ss.loadWord(tempEBP & 0xffff)); } tempESP = (tempESP & ~0xffff) | ((tempESP - 2) & 0xffff); ss.storeWord(tempESP & 0xffff, (short)frameTemp); } ebp.setValue((tempEBP & ~0xffff) | (frameTemp & 0xffff)); esp.setValue((tempESP & ~0xffff) | ((tempESP - frameSize -2*nestingLevel) & 0xffff)); } private void leave(boolean op32, boolean addr32) { if (!op32 && !addr32) { int tempESP = (esp.getValue() & ~0xffff) | (ebp.getValue() & 0xffff); int tempEBP = (ebp.getValue() & ~0xffff) | (ss.loadWord(tempESP & 0xffff) & 0xffff); // if (((tempESP & 0xffff) > 0xffff) || ((tempESP & 0xffff) < 0)) { // throw GENERAL_PROTECTION; // } esp.setValue((tempESP & ~0xffff) | ((tempESP + 2) & 0xffff)); ebp.setValue(tempEBP); } else if (op32 && !addr32) { int tempESP = (ebp.getValue() & 0xffff); int tempEBP = ss.loadDoubleWord(tempESP); esp.setValue((tempESP & ~0xffff) | ((tempESP+4) & 0xffff)); ebp.setValue(tempEBP); } else if (!op32 && addr32) { int tempESP=ebp.getValue()&0xffff; int tempEBP=ss.loadWord(tempESP)&0xffff; esp.setValue((esp.getValue()&~0xffff)|(tempESP+2)); ebp.setValue((ebp.getValue()&~0xffff)|(tempEBP)); } else if (op32 && addr32) { int tempESP=ebp.getValue(); int tempEBP=ss.loadDoubleWord(tempESP); esp.setValue(tempESP+4); ebp.setValue(tempEBP); } } private void pusha() { int offset = esp.getValue()&0xffff; // if ((offset<16)&&((offset&1)==1)&&(offset<6)) // throw GENERAL_PROTECTION; int temp = esp.getValue(); offset -= 2; ss.storeWord(offset & 0xffff, (short) eax.getValue()); offset -= 2; ss.storeWord(offset & 0xffff, (short) ecx.getValue()); offset -= 2; ss.storeWord(offset & 0xffff, (short) edx.getValue()); offset -= 2; ss.storeWord(offset & 0xffff, (short) ebx.getValue()); offset -= 2; ss.storeWord(offset & 0xffff, (short) temp); offset -= 2; ss.storeWord(offset & 0xffff, (short) ebp.getValue()); offset -= 2; ss.storeWord(offset & 0xffff, (short) esi.getValue()); offset -= 2; ss.storeWord(offset & 0xffff, (short) edi.getValue()); esp.setValue((temp & ~0xffff) | (offset & 0xffff)); } public void pushad() { int offset = esp.getValue()&0xffff; // if ((offset<32)&&(offset>0)) // throw GENERAL_PROTECTION; int temp = esp.getValue(); offset -= 4; ss.storeDoubleWord(offset, eax.getValue()); offset -= 4; ss.storeDoubleWord(offset, ecx.getValue()); offset -= 4; ss.storeDoubleWord(offset, edx.getValue()); offset -= 4; ss.storeDoubleWord(offset, ebx.getValue()); offset -= 4; ss.storeDoubleWord(offset, temp); offset -= 4; ss.storeDoubleWord(offset, ebp.getValue()); offset -= 4; ss.storeDoubleWord(offset, esi.getValue()); offset -= 4; ss.storeDoubleWord(offset, edi.getValue()); esp.setValue((temp & ~0xffff) | (offset)); } private void popa() { int offset = 0xffff & esp.getValue(); edi.setValue((edi.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 2; esi.setValue((esi.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 2; ebp.setValue((ebp.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 4; //skip SP ebx.setValue((ebx.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 2; edx.setValue((edx.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 2; ecx.setValue((ecx.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 2; eax.setValue((eax.getValue() & ~0xffff) | (0xffff & ss.loadWord(0xffff & offset))); offset += 2; esp.setValue((esp.getValue() & ~0xffff) | (offset & 0xffff)); } public void popad() { int offset = 0xffff & esp.getValue(); edi.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 4; esi.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 4; ebp.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 8; //skip SP ebx.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 4; edx.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 4; ecx.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 4; eax.setValue(ss.loadDoubleWord(0xffff & offset)); offset += 4; esp.setValue((esp.getValue() & ~0xffff) | (offset & 0xffff)); } private final void call_abs(int target, boolean op32, boolean addr32) { int sp=esp.getValue(); if (!op32 && !addr32) { if (((sp & 0xffff) < 2) && ((sp & 0xffff) > 0)) throw STACK_SEGMENT; ss.storeWord((sp - 2) & 0xffff, (short)eip.getValue()); esp.setValue(sp-2); } else if (!op32 && addr32) { if (sp< 2 && sp > 0) throw STACK_SEGMENT; ss.storeWord((sp - 2), (short)eip.getValue()); esp.setValue((sp&0xffff0000)|((sp-2)&0xffff)); } else if (op32 && !addr32) { if (((sp & 0xffff) < 4) && ((sp & 0xffff) > 0)) throw STACK_SEGMENT; ss.storeDoubleWord((sp - 4) & 0xffff, eip.getValue()); esp.setValue((sp&0xffff0000)|((sp-4)&0xffff)); } else { if (sp < 4 && sp > 0) throw STACK_SEGMENT; ss.storeDoubleWord((sp - 4), eip.getValue()); esp.setValue(sp-4); } eip.setValue(target); } private void intr(int vector, boolean op32, boolean addr32) { if (vector == 0) panic("INT 0 called"); if (((esp.getValue()&0xffff)<6)&&((esp.getValue()&0xffff)>0)) panic("No room on stack for interrupt"); if (!isModeReal()) { intr_protected(vector,op32,addr32); return; } if (!op32 && !addr32) { esp.setValue((esp.getValue() & 0xffff0000) | (0xffff & (esp.getValue() - 2))); int flags = getFlags() & 0xffff; ss.storeWord(esp.getValue() & 0xffff, (short)flags); interruptEnable.clear(); interruptEnableSoon.clear(); trap.clear(); esp.setValue((esp.getValue()&0xffff0000)|(0xffff&(esp.getValue()-2))); ss.storeWord(esp.getValue()&0xffff,(short)cs.getValue()); esp.setValue((esp.getValue()&0xffff0000)|(0xffff&(esp.getValue()-2))); ss.storeWord(esp.getValue()&0xffff,(short)eip.getValue()); eip.setValue(0xffff & idtr.loadWord(4*vector)); cs.setValue(0xffff & idtr.loadWord(4*vector+2)); } else if (op32 && !addr32) { esp.setValue((esp.getValue() & 0xffff0000) | (0xffff & (esp.getValue() - 4))); int flags = getFlags(); ss.storeDoubleWord(esp.getValue() & 0xffff, flags); interruptEnable.clear(); interruptEnableSoon.clear(); trap.clear(); esp.setValue((esp.getValue()&0xffff0000)|(0xffff&(esp.getValue()-4))); ss.storeDoubleWord(esp.getValue()&0xffff,cs.getValue()); esp.setValue((esp.getValue()&0xffff0000)|(0xffff&(esp.getValue()-4))); ss.storeDoubleWord(esp.getValue()&0xffff,eip.getValue()); eip.setValue(idtr.loadDoubleWord(8*vector)); cs.setValue(0xffff & idtr.loadDoubleWord(8*vector+4)); } else if (!op32 && addr32) { esp.setValue(esp.getValue()-2); int flags = getFlags() & 0xffff; ss.storeWord(esp.getValue(), (short)flags); interruptEnable.clear(); interruptEnableSoon.clear(); trap.clear(); esp.setValue(esp.getValue()-2); ss.storeWord(esp.getValue(),(short)cs.getValue()); esp.setValue(esp.getValue()-2); ss.storeWord(esp.getValue(),(short)eip.getValue()); eip.setValue(0xffff & idtr.loadWord(4*vector)); cs.setValue(0xffff & idtr.loadWord(4*vector+2)); } else if (op32 && addr32) { esp.setValue(esp.getValue()-4); int flags = getFlags(); ss.storeDoubleWord(esp.getValue(), flags); interruptEnable.clear(); interruptEnableSoon.clear(); trap.clear(); esp.setValue(esp.getValue()-4); ss.storeDoubleWord(esp.getValue(),cs.getValue()); esp.setValue(esp.getValue()-4); ss.storeDoubleWord(esp.getValue(),eip.getValue()); eip.setValue(idtr.loadDoubleWord(8*vector)); cs.setValue(0xffff & idtr.loadDoubleWord(8*vector+4)); } // System.out.printf("Software Interrupt %x\n",vector); if(processorGUICode!=null) processorGUICode.push(GUICODE.SOFTWARE_INTERRUPT,vector); } private void intr_protected(int vector,boolean op32, boolean addr32) { int newIP=0, newCS=0; int dpl; long descriptor=0; if (!op32 || !addr32) panic("Only handling 32 bit mode protected interrupts"); //get the new CS:EIP from the IDT boolean sup=linearMemory.isSupervisor; linearMemory.setSupervisor(true); vector=vector*8; descriptor=idtr.loadQuadWord(vector); int segIndex=(int)((descriptor>>16)&0xffff); long newSegmentDescriptor=0; if ((segIndex&4)!=0) newSegmentDescriptor=ldtr.loadQuadWord(segIndex&0xfff8); else newSegmentDescriptor=gdtr.loadQuadWord(segIndex&0xfff8); linearMemory.setSupervisor(sup); dpl=(int)((newSegmentDescriptor>>45)&0x3); newIP = (int)(((descriptor>>32)&0xffff0000)|(descriptor&0x0000ffff)); newCS = (int)((descriptor>>16)&0xffff); int sesp = esp.getValue(); if (dpl<current_privilege_level) { //calculate new stack segment int stackAddress=dpl*8+4; int newSS=0xffff&(tss.loadWord(stackAddress+4)); int newSP=tss.loadDoubleWord(stackAddress); int oldSS=ss.getValue(); int oldSP=esp.getValue(); ss.setValue(newSS); esp.setValue(newSP); //save SS:ESP on the stack sesp=newSP; sesp-=4; ss.storeDoubleWord(sesp, oldSS); sesp-=4; ss.storeDoubleWord(sesp, oldSP); } //save the flags on the stack sesp-=4; int flags = getFlags(); ss.storeDoubleWord(esp.getValue(), flags); //disable interrupts interruptEnable.clear(); interruptEnableSoon.clear(); //save CS:IP on the stack sesp-=4; ss.storeDoubleWord(sesp, cs.getValue()); sesp-=4; ss.storeDoubleWord(sesp, eip.getValue()); esp.setValue(sesp); //change CS and IP to the ISR's values cs.setProtectedValue(newCS,descriptor); eip.setValue(newIP); setCPL(dpl); // current_privilege_level=dpl; } public int iret(boolean op32, boolean addr32) { if (!isModeReal()) { return iret_protected(op32,addr32); } int flags=0; if (!op32 && !addr32) { eip.setValue(ss.loadWord(esp.getValue()&0xffff)&0xffff); esp.setValue((esp.getValue()&0xffff0000)|((esp.getValue()+2)&0xffff)); cs.setValue(ss.loadWord(esp.getValue()&0xffff)&0xffff); esp.setValue((esp.getValue()&0xffff0000)|((esp.getValue()+2)&0xffff)); flags=(ss.loadWord(esp.getValue()&0xffff)&0xffff); esp.setValue((esp.getValue()&0xffff0000)|((esp.getValue()+2)&0xffff)); } else if (op32 && !addr32) { eip.setValue(ss.loadDoubleWord(esp.getValue()&0xffff)); esp.setValue((esp.getValue()&0xffff0000)|((esp.getValue()+4)&0xffff)); cs.setValue(ss.loadDoubleWord(esp.getValue()&0xffff)&0xffff); esp.setValue((esp.getValue()&0xffff0000)|((esp.getValue()+4)&0xffff)); flags=(ss.loadDoubleWord(esp.getValue()&0xffff)); esp.setValue((esp.getValue()&0xffff0000)|((esp.getValue()+4)&0xffff)); } else if (!op32 && addr32) { eip.setValue(ss.loadWord(esp.getValue())&0xffff); esp.setValue(esp.getValue()+2); cs.setValue(ss.loadWord(esp.getValue())&0xffff); esp.setValue(esp.getValue()+2); flags=(ss.loadWord(esp.getValue())&0xffff); esp.setValue(esp.getValue()+2); } else { eip.setValue(ss.loadDoubleWord(esp.getValue())); esp.setValue(esp.getValue()+4); cs.setValue(ss.loadDoubleWord(esp.getValue())&0xffff); esp.setValue(esp.getValue()+4); flags=(ss.loadDoubleWord(esp.getValue())); esp.setValue(esp.getValue()+4); } // System.out.println("Returning from interrupt"); return flags; } private int iret_protected(boolean op32, boolean addr32) { int flags=0; eip.setValue(ss.loadDoubleWord(esp.getValue())); esp.setValue(esp.getValue()+4); cs.setValue(ss.loadDoubleWord(esp.getValue())&0xffff); esp.setValue(esp.getValue()+4); flags=(ss.loadDoubleWord(esp.getValue())); esp.setValue(esp.getValue()+4); if (cs.rpl>current_privilege_level) { int newSP=ss.loadDoubleWord(esp.getValue()); esp.setValue(esp.getValue()+4); int newSS=ss.loadDoubleWord(esp.getValue()); esp.setValue(newSP); ss.setValue(newSS); setCPL(cs.rpl); // current_privilege_level=cs.rpl; } return flags; } private void ins(int port, int b, boolean addr32) { if (!addr32) { int addr = edi.getValue() & 0xffff; if (b==1) es.storeByte(addr & 0xffff, (byte)ioports.ioPortReadByte(port)); else if (b==2) es.storeWord(addr & 0xffff, (short)ioports.ioPortReadWord(port)); else es.storeDoubleWord(addr & 0xffff, ioports.ioPortReadLong(port)); if (direction.read()) addr -= b; else addr += b; edi.setValue((edi.getValue()&~0xffff)|(addr&0xffff)); } else { int addr = edi.getValue(); if (b==1) es.storeByte(addr, (byte)ioports.ioPortReadByte(port)); else if (b==2) es.storeWord(addr, (short)ioports.ioPortReadWord(port)); else es.storeDoubleWord(addr, ioports.ioPortReadLong(port)); if (direction.read()) addr -= b; else addr += b; edi.setValue(addr); } } private void rep_ins(int port, int b, boolean addr32) { if (!addr32) { int count = ecx.getValue() & 0xffff; int addr = edi.getValue() & 0xffff; while (count != 0) { if (b==1) es.storeByte(addr & 0xffff, (byte)ioports.ioPortReadByte(port)); else if (b==2) es.storeWord(addr & 0xffff, (short)ioports.ioPortReadWord(port)); else es.storeDoubleWord(addr & 0xffff, ioports.ioPortReadLong(port)); count--; if (direction.read()) addr -= b; else addr += b; } ecx.setValue((ecx.getValue() & ~0xffff) | (count & 0xffff)); edi.setValue((edi.getValue() & ~0xffff) | (addr & 0xffff)); } else { int count = ecx.getValue(); int addr = edi.getValue(); while (count != 0) { if (b==1) es.storeByte(addr, (byte)ioports.ioPortReadByte(port)); else if (b==2) es.storeWord(addr, (short)ioports.ioPortReadWord(port)); else es.storeDoubleWord(addr, ioports.ioPortReadLong(port)); count--; if (direction.read()) addr -= b; else addr += b; } ecx.setValue(count); edi.setValue(addr); } } private void outs(int port, Segment seg, int b, boolean addr32) { if (!addr32) { int addr = esi.getValue() & 0xffff; if (b==1) ioports.ioPortWriteByte(port, 0xff & seg.loadByte(addr&0xffff)); else if (b==2) ioports.ioPortWriteWord(port, 0xffff & seg.loadWord(addr&0xffff)); else ioports.ioPortWriteLong(port, seg.loadDoubleWord(addr&0xffff)); if (direction.read()) addr -= b; else addr += b; if (esi.getValue()==0x3ffff) System.out.println("outs addr16 "+esi.getValue()+" "+addr); esi.setValue((esi.getValue()&~0xffff)|(addr&0xffff)); } else { int addr = esi.getValue(); if (b==1) ioports.ioPortWriteByte(port, 0xff & seg.loadByte(addr)); else if (b==2) ioports.ioPortWriteWord(port, 0xffff & seg.loadWord(addr)); else ioports.ioPortWriteLong(port, seg.loadDoubleWord(addr)); if (direction.read()) addr -= b; else addr += b; if (esi.getValue()==0x3ffff) System.out.println("outs addr32 "+esi.getValue()+" "+addr); esi.setValue(addr); } } private void rep_outs(int port, Segment seg, int b, boolean addr32) { if (!addr32) { int count = ecx.getValue() & 0xffff; int addr = esi.getValue() & 0xffff; while (count != 0) { if (b==1) ioports.ioPortWriteByte(port, 0xff & seg.loadByte(addr&0xffff)); else if (b==2) ioports.ioPortWriteWord(port, 0xffff & seg.loadWord(addr&0xffff)); else ioports.ioPortWriteLong(port, seg.loadDoubleWord(addr&0xffff)); count--; if (direction.read()) addr -= b; else addr += b; } ecx.setValue((ecx.getValue() & ~0xffff) | (count & 0xffff)); esi.setValue((esi.getValue() & ~0xffff) | (addr & 0xffff)); } else { int count = ecx.getValue(); int addr = esi.getValue(); while (count != 0) { if (b==1) ioports.ioPortWriteByte(port, 0xff & seg.loadByte(addr)); else if (b==2) ioports.ioPortWriteWord(port, 0xffff & seg.loadWord(addr)); else ioports.ioPortWriteLong(port, seg.loadDoubleWord(addr)); count--; if (direction.read()) addr -= b; else addr += b; } ecx.setValue(count); esi.setValue(addr); } } private void lods(Segment seg, int b, boolean addr32) { int addr; if(!addr32) addr = esi.getValue() & 0xffff; else addr = esi.getValue(); if (b==1) eax.setValue((eax.getValue()&~0xff)|(0xff&seg.loadByte(addr))); else if (b==2) eax.setValue((eax.getValue()&~0xffff)|(0xffff&seg.loadWord(addr))); else eax.setValue(seg.loadDoubleWord(addr)); if(direction.read()) addr-=b; else addr+=b; if(!addr32) esi.setValue((esi.getValue()&~0xffff)|(addr&0xffff)); else esi.setValue(addr); } private void rep_lods(Segment seg, int b, boolean addr32) { int count,addr,data; if(!addr32) { count = ecx.getValue()&0xffff; addr = esi.getValue()&0xffff; } else { count=ecx.getValue(); addr=esi.getValue(); } if(b==1) data = eax.getValue()&0xff; else if (b==2) data = eax.getValue()&0xffff; else data = eax.getValue(); while(count!=0) { if(!addr32) { if(b==1) data=0xff&seg.loadByte(addr&0xffff); else if (b==2) data=0xffff&seg.loadWord(addr&0xffff); else data=seg.loadDoubleWord(addr&0xffff); } else { if(b==1) data=0xff&seg.loadByte(addr); else if (b==2) data=0xffff&seg.loadWord(addr); else data=seg.loadDoubleWord(addr); } count--; if (direction.read()) addr-=b; else addr+=b; } if (b==1) eax.setValue((eax.getValue()&~0xff)|data); else if (b==2) eax.setValue((eax.getValue()&~0xffff)|data); else eax.setValue(data); if(!addr32) { ecx.setValue((ecx.getValue()&~0xffff)|(count&0xffff)); esi.setValue((esi.getValue()&~0xffff)|(addr&0xffff)); } else { ecx.setValue(count); esi.setValue(addr); } } private void movs(Segment seg, int b, boolean addr32) { int inaddr,outaddr; if(!addr32) { inaddr = edi.getValue() & 0xffff; outaddr = esi.getValue() & 0xffff; } else { inaddr = edi.getValue(); outaddr = esi.getValue(); } if (b==1) es.storeByte(inaddr, seg.loadByte(outaddr)); else if (b==2) es.storeWord(inaddr, seg.loadWord(outaddr)); else es.storeDoubleWord(inaddr, seg.loadDoubleWord(outaddr)); if(direction.read()) { inaddr-=b; outaddr-=b; } else { inaddr+=b; outaddr+=b; } if(!addr32) { esi.setValue((esi.getValue()&~0xffff)|(outaddr&0xffff)); edi.setValue((edi.getValue()&~0xffff)|(inaddr&0xffff)); } else { esi.setValue(outaddr); edi.setValue(inaddr); } } private void rep_movs(Segment seg, int b, boolean addr32) { int count,inaddr,outaddr; if(!addr32) { count = ecx.getValue()&0xffff; outaddr = esi.getValue()&0xffff; inaddr = edi.getValue()&0xffff; } else { count=ecx.getValue(); outaddr=esi.getValue(); inaddr=edi.getValue(); } while(count!=0) { if(!addr32) { if(b==1) es.storeByte(inaddr&0xffff, seg.loadByte(outaddr&0xffff)); else if (b==2) es.storeWord(inaddr&0xffff, seg.loadWord(outaddr&0xffff)); else es.storeDoubleWord(inaddr&0xffff, seg.loadDoubleWord(outaddr&0xffff)); } else { if(b==1) es.storeByte(inaddr, seg.loadByte(outaddr)); else if (b==2) es.storeWord(inaddr, seg.loadWord(outaddr)); else es.storeDoubleWord(inaddr, seg.loadDoubleWord(outaddr)); } count--; if (direction.read()) { inaddr-=b; outaddr-=b; } else { inaddr+=b; outaddr+=b; } } if(!addr32) { ecx.setValue((ecx.getValue()&~0xffff)|(count&0xffff)); esi.setValue((esi.getValue()&~0xffff)|(outaddr&0xffff)); edi.setValue((edi.getValue()&~0xffff)|(inaddr&0xffff)); } else { ecx.setValue(count); esi.setValue(outaddr); edi.setValue(inaddr); } } private void stos(int data, int b, boolean addr32) { int addr; if(!addr32) addr = edi.getValue() & 0xffff; else addr = edi.getValue(); if (b==1) es.storeByte(addr,(byte)data); else if (b==2) es.storeWord(addr,(short)data); else es.storeDoubleWord(addr,data); if(direction.read()) addr-=b; else addr+=b; if(!addr32) edi.setValue((edi.getValue()&~0xffff)|(addr&0xffff)); else edi.setValue(addr); } private void rep_stos(int data, int b, boolean addr32) { int count,addr; if(!addr32) { count = ecx.getValue()&0xffff; addr = edi.getValue()&0xffff; } else { count=ecx.getValue(); addr=edi.getValue(); } while(count!=0) { if(!addr32) { if(b==1) es.storeByte(addr&0xffff,(byte)data); else if (b==2) es.storeWord(addr&0xffff,(short)data); else es.storeDoubleWord(addr&0xffff,data); } else { if(b==1) es.storeByte(addr,(byte)data); else if (b==2) es.storeWord(addr,(short)data); else es.storeDoubleWord(addr,data); } count--; if (direction.read()) addr-=b; else addr+=b; } if(!addr32) { ecx.setValue((ecx.getValue()&~0xffff)|(count&0xffff)); edi.setValue((edi.getValue()&~0xffff)|(addr&0xffff)); } else { ecx.setValue(count); edi.setValue(addr); } } private void mul_08(int data) { int x = eax.getValue()&0xff; int result = x*data; eax.setValue((eax.getValue()&0xffff0000)|(result&0xffff)); overflow.set(result, Flag.OF_HIGH_BYTE_NZ); carry.set(result, Flag.CY_HIGH_BYTE_NZ); } private void mul_16(int data) { int x = eax.getValue()&0xffff; int result = x*data; eax.setValue((eax.getValue()&0xffff0000)|(result&0xffff)); result=result>>16; edx.setValue((edx.getValue()&0xffff0000)|(result&0xffff)); overflow.set(result, Flag.OF_LOW_WORD_NZ); carry.set(result, Flag.CY_LOW_WORD_NZ); } private void mul_32(int data) { long x = eax.getValue()&0xffffffffl; long y = 0xffffffffl&data; long result=x*y; eax.setValue((int)result); result=result>>>32; edx.setValue((int)result); overflow.set((int)result, Flag.OF_NZ); carry.set((int)result, Flag.CY_NZ); } private void imula_08(byte data) { byte x = (byte)eax.getValue(); int result = x*data; eax.setValue((eax.getValue()&~0xffff)|(result&0xffff)); overflow.set(result, Flag.OF_NOT_BYTE); carry.set(result, Flag.CY_NOT_BYTE); } private void imula_16(short data) { short x = (short)eax.getValue(); int result = x*data; eax.setValue((eax.getValue()&~0xffff)|(result&0xffff)); edx.setValue((edx.getValue()&~0xffff)|(result>>>16)); overflow.set(result, Flag.OF_NOT_SHORT); carry.set(result, Flag.CY_NOT_SHORT); } private void imula_32(int data) { long eaxvalue = (long)eax.getValue(); long y=(long)data; long result=eaxvalue*y; eax.setValue((int)result); edx.setValue((int)(result>>>32)); overflow.set(result,Flag.OF_NOT_INT); carry.set(result,Flag.CY_NOT_INT); } private int imul_16(short data0, short data1) { int result = data0*data1; overflow.set(result, Flag.OF_NOT_SHORT); carry.set(result, Flag.CY_NOT_SHORT); return result; } private int imul_32(int data0, int data1) { long result = ((long)data0)*((long)data1); overflow.set(result, Flag.OF_NOT_SHORT); carry.set(result, Flag.CY_NOT_SHORT); return (int)result; } private void div_08(int data) { if(data==0) throw DIVIDE_ERROR; int x = (eax.getValue()&0xffff); int result=x/data; if (result>0xff) throw DIVIDE_ERROR; int remainder = (x%data)<<8; eax.setValue((eax.getValue()&~0xffff)|(0xff&result)|(0xff00&remainder)); } private void div_16(int data) { if(data==0) throw DIVIDE_ERROR; long x = (edx.getValue()&0xffffl); x<<=16; x|=(eax.getValue()&0xffffl); long result=x/data; if (result>0xffffl) throw DIVIDE_ERROR; long remainder = (x%data); eax.setValue((eax.getValue()&~0xffff)|(int)(result&0xffff)); edx.setValue((edx.getValue()&~0xffff)|(int)(remainder&0xffff)); } private void div_32(int data) { long d = 0xffffffffl&data; if(d==0) throw DIVIDE_ERROR; long t = (long)edx.getValue(); t<<=32; t|=(0xffffffffl&eax.getValue()); long r2=t&1; long n2=t>>>1; long q2=n2/d; long m2=n2%d; long q=q2<<1; long r=(m2<<1)+r2; q+=(r/d); r%=d; if (q>0xffffffffl) throw DIVIDE_ERROR; eax.setValue((int)q); edx.setValue((int)r); } private void idiv_08(byte data) { if(data==0) throw DIVIDE_ERROR; short x = (short)eax.getValue(); int result=x/(short)data; int remainder = (x%data); if((result>Byte.MAX_VALUE)||(result<Byte.MIN_VALUE)) throw DIVIDE_ERROR; eax.setValue((eax.getValue()&~0xffff)|(0xff&result)|((0xff&remainder)<<8)); } private void idiv_16(short data) { if(data==0) throw DIVIDE_ERROR; int x = (edx.getValue()<<16) | (eax.getValue()&0xffff); int result=x/(int)data; int remainder = (x%data); if((result>Short.MAX_VALUE)||(result<Short.MIN_VALUE)) throw DIVIDE_ERROR; eax.setValue((eax.getValue()&~0xffff)|(0xffff&result)); edx.setValue((edx.getValue()&~0xffff)|(0xffff&remainder)); } private void idiv_32(int data) { if(data==0) throw DIVIDE_ERROR; long t=(0xffffffffl&edx.getValue())<<32; t|=(0xffffffffl&eax.getValue()); long result=t/data; if(result>Integer.MAX_VALUE || result<Integer.MIN_VALUE) throw DIVIDE_ERROR; long r = t%data; eax.setValue((int)result); edx.setValue((int)r); } private void btc_mem(int offset, Segment seg, int addr) { addr+=(offset>>>3); offset&=0x7; int data=0xff&seg.loadByte(addr); seg.storeByte(addr,(byte)(data^(1<<offset))); carry.set(data,offset,Flag.CY_NTH_BIT_SET); } private void bts_mem(int offset, Segment seg, int addr) { addr+=(offset>>>3); offset&=0x7; int data=0xff&seg.loadByte(addr); seg.storeByte(addr,(byte)(data|(1<<offset))); carry.set(data,offset,Flag.CY_NTH_BIT_SET); } private void btr_mem(int offset, Segment seg, int addr) { addr+=(offset>>>3); offset&=0x7; int data=0xff&seg.loadByte(addr); seg.storeByte(addr,(byte)(data&~(1<<offset))); carry.set(data,offset,Flag.CY_NTH_BIT_SET); } private void bt_mem(int offset, Segment seg, int addr) { addr+=(offset>>>3); offset&=0x7; int data=0xff&seg.loadByte(addr); carry.set(data,offset,Flag.CY_NTH_BIT_SET); } private int bsf(int source, int initial) { if (source == 0) { zero.set(); return initial; } else { zero.clear(); int y; int i=source; if (i==0) return 32; int n=31; y=i<<16; if (y!=0) {n-=16; i=y;} y=i<<8; if (y!=0) {n-=8; i=y;} y=i<<4; if (y!=0) {n-=4; i=y;} y=i<<2; if (y!=0) {n-=2; i=y;} return n-((i<<1)>>>31); } } private int bsr(int source, int initial) { if (source==0) { zero.set(); return initial; } else { zero.clear(); int i=source; if (i == 0) return -1; int n=1; if (i >>> 16 == 0) { n += 16; i <<= 16; } if (i >>> 24 == 0) { n += 8; i <<= 8; } if (i >>> 28 == 0) { n += 4; i <<= 4; } if (i >>> 30 == 0) { n += 2; i <<= 2; } n-=i>>>31; return 31-n; } } private void aaa() { if (((eax.getValue() & 0xf) > 0x9) || auxiliaryCarry.read()) { int alCarry = ((eax.getValue() & 0xff) > 0xf9) ? 0x100 : 0x000; eax.setValue((0xffff0000 & eax.getValue()) | (0x0f & (eax.getValue() + 6)) | (0xff00 & (eax.getValue() + 0x100 + alCarry))); auxiliaryCarry.set(); carry.set(); } else { auxiliaryCarry.clear(); carry.clear(); eax.setValue(eax.getValue()&0xffffff0f); } } private void aad(int base) { int tl = (eax.getValue() & 0xff); int th = ((eax.getValue() >> 8) & 0xff); int ax1 = th * base; int ax2 = ax1 + tl; eax.setValue((eax.getValue() & ~0xffff) | (ax2 & 0xff)); zero.set((byte)ax2); parity.set((byte)ax2); sign.set((byte)ax2); auxiliaryCarry.set(ax1, ax2, Flag.AC_BIT4_NEQ); carry.set(ax2, Flag.CY_GREATER_FF); overflow.set(ax2, tl, Flag.OF_BIT7_DIFFERENT); } private int aam(int base) { int tl = 0xff & eax.getValue(); if (base == 0) throw DIVIDE_ERROR; int ah = 0xff & (tl / base); int al = 0xff & (tl % base); eax.setValue(eax.getValue() & ~0xffff); eax.setValue(eax.getValue() | (al | (ah << 8))); auxiliaryCarry.clear(); return (byte) al; } private void aas() { if (((eax.getValue() & 0xf) > 0x9) || auxiliaryCarry.read()) { int alBorrow = (eax.getValue() & 0xff) < 6 ? 0x100 : 0x000; eax.setValue((0xffff0000 & eax.getValue()) | (0x0f & (eax.getValue() - 6)) | (0xff00 & (eax.getValue() - 0x100 - alBorrow))); auxiliaryCarry.set(); carry.set(); } else { auxiliaryCarry.clear(); carry.clear(); eax.setValue(eax.getValue()&0xffffff0f); } } private void daa() { int al = eax.getValue() & 0xff; boolean newCF; if (((eax.getValue() & 0xf) > 0x9) || auxiliaryCarry.read()) { al += 6; auxiliaryCarry.set(); } else auxiliaryCarry.clear(); if (((al & 0xff) > 0x9f) || carry.read()) { al += 0x60; newCF = true; } else newCF = false; eax.setValue((eax.getValue()&~0xff)|(0xff&al)); overflow.clear(); zero.set((byte)al); parity.set((byte)al); sign.set((byte)al); carry.set(newCF); } private void das() { boolean tempCF = false; int tempAL = 0xff & eax.getValue(); if (((tempAL & 0xf) > 0x9) || auxiliaryCarry.read()) { auxiliaryCarry.set(); eax.setValue((eax.getValue() & ~0xff) | ((eax.getValue() - 0x06) & 0xff)); tempCF = (tempAL < 0x06) || carry.read(); } if ((tempAL > 0x99) || carry.read()) { eax.setValue( (eax.getValue() & ~0xff) | ((eax.getValue() - 0x60) & 0xff)); tempCF = true; } overflow.clear(); zero.set((byte)eax.getValue()); parity.set((byte)eax.getValue()); sign.set((byte)eax.getValue()); carry.set(tempCF); } private void lahf() { int result = 0x0200; if (sign.read()) result|=0x8000; if (zero.read()) result|=0x4000; if (auxiliaryCarry.read()) result|=0x1000; if (parity.read()) result|=0x0400; if (carry.read()) result|=0x0100; eax.setValue((eax.getValue()&0xffff00ff)|result); } private void sahf() { int ah = (eax.getValue()&0xff00); carry.set(0!=(ah&0x0100)); parity.set(0!=(ah&0x0400)); auxiliaryCarry.set(0!=(ah&0x1000)); zero.set(0!=(ah&0x4000)); sign.set(0!=(ah&0x8000)); } private long rdtsc() { return computer.clock.getTime(); } private void cpuid() { switch(eax.getValue()) { case 0x00: eax.setValue(0x02); //this spells out "GenuineIntel" ebx.setValue(0x756e6547); edx.setValue(0x49656e69); ecx.setValue(0x6c65746e); break; case 0x01: eax.setValue(0x633); //use Pentium II model 8 stepping 3 until I can find specs for an older proc. ebx.setValue(8<<8); ecx.setValue(0); int features=0; features|=0; //no features at all // features |= 0x01; //Have an FPU; features |= 0x00; //Have no FPU; // features |= (1<< 8); // Support CMPXCHG8B instruction // features |= (1<< 4); // implement TSC // features |= (1<< 5); // support RDMSR/WRMSR //features |= (1<<23); // support MMX //features |= (1<<24); // Implement FSAVE/FXRSTOR instructions. // features |= (1<<15); // Implement CMOV instructions. //features |= (1<< 9); // APIC on chip //features |= (1<<25); // support SSE features |= (1<< 3); // Support Page-Size Extension (4M pages) features |= (1<<13); // Support Global pages. //features |= (1<< 6); // Support PAE. // features |= (1<<11); // SYSENTER/SYSEXIT edx.setValue(features); break; case 0x02: eax.setValue(0x410601); ebx.setValue(0); ecx.setValue(0); edx.setValue(0); break; } } private void bitwise_flags(int result) { overflow.clear(); carry.clear(); zero.set(result); parity.set(result); sign.set(result); } private void arithmetic_flags_08(int result, int operand1, int operand2) { zero.set((byte)result); parity.set(result); sign.set((byte)result); carry.set(result, Flag.CY_TWIDDLE_FF); auxiliaryCarry.set(operand1, operand2, result, Flag.AC_XOR); } private void arithmetic_flags_16(int result, int operand1, int operand2) { zero.set((short)result); parity.set(result); sign.set((short)result); carry.set(result, Flag.CY_TWIDDLE_FFFF); auxiliaryCarry.set(operand1, operand2, result, Flag.AC_XOR); } private void arithmetic_flags_32(long result, int operand1, int operand2) { zero.set((int)result); parity.set((int)result); sign.set((int)result); carry.set(result, Flag.CY_TWIDDLE_FFFFFFFF); auxiliaryCarry.set(operand1, operand2, (int)result, Flag.AC_XOR); } private void add_flags_08(int result, int operand1, int operand2) { arithmetic_flags_08(result, operand1, operand2); overflow.set(result, operand1 , operand2, Flag.OF_ADD_BYTE); } private void add_flags_16(int result, int operand1, int operand2) { arithmetic_flags_16(result, operand1, operand2); overflow.set(result, operand1 , operand2, Flag.OF_ADD_SHORT); } private void add_flags_32(long result, int operand1, int operand2) { long res = (0xffffffffl & operand1) + (0xffffffffl & operand2); arithmetic_flags_32(res, operand1, operand2); overflow.set((int)res, operand1 , operand2, Flag.OF_ADD_INT); } private void adc_flags_08(int result, int operand1, int operand2) { if (carry.read() && (operand2 == 0xff)) { arithmetic_flags_08(result, operand1, operand2); overflow.clear(); carry.set(); } else { overflow.set(result, operand1, operand2, Flag.OF_ADD_BYTE); arithmetic_flags_08(result, operand1, operand2); } } private void adc_flags_16(int result, int operand1, int operand2) { if (carry.read() && (operand2 == 0xffff)) { arithmetic_flags_16(result, operand1, operand2); overflow.clear(); carry.set(); } else { overflow.set(result, operand1, operand2, Flag.OF_ADD_SHORT); arithmetic_flags_16(result, operand1, operand2); } } private void adc_flags_32(long result, int operand1, int operand2) { long res = (0xffffffffl & operand1) + (0xffffffffl & operand2) + (carry.read()? 1l:0l); if (carry.read() && (operand2 == 0xffffffff)) { arithmetic_flags_32(res, operand1, operand2); overflow.clear(); carry.set(); } else { overflow.set((int)res, operand1, operand2, Flag.OF_ADD_INT); arithmetic_flags_32(res, operand1, operand2); } } private void sub_flags_08(int result, int operand1, int operand2) { arithmetic_flags_08(result, operand1, operand2); overflow.set(result, operand1, operand2, Flag.OF_SUB_BYTE); } private void sub_flags_16(int result, int operand1, int operand2) { arithmetic_flags_16(result, operand1, operand2); overflow.set(result, operand1, operand2, Flag.OF_SUB_SHORT); } private void sub_flags_32(long result, int operand1, int operand2) { long res = (0xffffffffl&operand1) - (0xffffffffl&operand2); arithmetic_flags_32(res, operand1, operand2); overflow.set((int)res, operand1, operand2, Flag.OF_SUB_INT); } private void rep_sub_flags_08(int used, int operand1, int operand2) { if (used == 0) return; int result = operand1 - operand2; arithmetic_flags_08(result, operand1, operand2); overflow.set(result, operand1, operand2, Flag.OF_SUB_BYTE); } private void rep_sub_flags_16(int used, int operand1, int operand2) { if (used == 0) return; int result = operand1 - operand2; arithmetic_flags_16(result, operand1, operand2); overflow.set(result, operand1, operand2, Flag.OF_SUB_SHORT); } private void rep_sub_flags_32(int used, int operand1, int operand2) { if (used == 0) return; long res = (0xffffffffl&operand1) - (0xffffffffl&operand2); arithmetic_flags_32(res, operand1, operand2); overflow.set((int)res, operand1, operand2, Flag.OF_SUB_INT); } private void sbb_flags_08(int result, int operand1, int operand2) { overflow.set(result, operand1, operand2, Flag.OF_SUB_BYTE); arithmetic_flags_08(result, operand1, operand2); } private void sbb_flags_16(int result, int operand1, int operand2) { overflow.set(result, operand1, operand2, Flag.OF_SUB_SHORT); arithmetic_flags_16(result, operand1, operand2); } private void sbb_flags_32(long result, int operand1, int operand2) { long res = (0xffffffffl&operand1) - (0xffffffffl&operand2) - (carry.read()? 1l:0l); overflow.set((int)res, operand1, operand2, Flag.OF_SUB_INT); arithmetic_flags_32(res, operand1, operand2); } private void dec_flags_08(byte result) { zero.set(result); parity.set(result); sign.set(result); overflow.set(result, Flag.OF_MAX_BYTE); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_MAX); } private void dec_flags_16(short result) { zero.set(result); parity.set(result); sign.set(result); overflow.set(result, Flag.OF_MAX_SHORT); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_MAX); } private void dec_flags_32(int result) { zero.set(result); parity.set(result); sign.set(result); overflow.set(result, Flag.OF_MAX_INT); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_MAX); } private void inc_flags_08(byte result) { zero.set(result); parity.set(result); sign.set(result); overflow.set(result, Flag.OF_MIN_BYTE); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_ZERO); } private void inc_flags_16(short result) { zero.set(result); parity.set(result); sign.set(result); overflow.set(result, Flag.OF_MIN_SHORT); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_ZERO); } private void inc_flags_32(int result) { zero.set(result); parity.set(result); sign.set(result); overflow.set(result, Flag.OF_MIN_INT); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_ZERO); } private void shl_flags_08(byte result, byte initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHL_OUTBIT_BYTE); if (count == 1) overflow.set(result, Flag.OF_BIT7_XOR_CARRY); zero.set(result); parity.set(result); sign.set(result); } } private void shl_flags_16(short result, short initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHL_OUTBIT_SHORT); if (count == 1) overflow.set(result, Flag.OF_BIT15_XOR_CARRY); zero.set(result); parity.set(result); sign.set(result); } } private void shl_flags_32(int result, int initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHL_OUTBIT_INT); if (count == 1) overflow.set(result, Flag.OF_BIT31_XOR_CARRY); zero.set(result); parity.set(result); sign.set(result); } } private void shr_flags_08(byte result, int initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHR_OUTBIT); if (count == 1) overflow.set(result, initial, Flag.OF_BIT7_DIFFERENT); zero.set(result); parity.set(result); sign.set(result); } } private void shr_flags_16(short result, int initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHR_OUTBIT); if (count == 1) overflow.set(result, initial, Flag.OF_BIT15_DIFFERENT); zero.set(result); parity.set(result); sign.set(result); } } private void shr_flags_32(int result, int initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHR_OUTBIT); if (count == 1) overflow.set(result, initial, Flag.OF_BIT31_DIFFERENT); zero.set(result); parity.set(result); sign.set(result); } } private void sar_flags(int result, int initial, int count) { if (count > 0) { carry.set(initial, count, Flag.CY_SHR_OUTBIT); if (count == 1) overflow.clear(); zero.set(result); parity.set(result); sign.set(result); } } private void rol_flags_08(byte result, int count) { if (count>0) { carry.set(result, Flag.CY_LOWBIT); if (count==1) overflow.set(result, Flag.OF_BIT7_XOR_CARRY); } } private void rol_flags_16(short result, int count) { if (count>0) { carry.set(result, Flag.CY_LOWBIT); if (count==1) overflow.set(result, Flag.OF_BIT15_XOR_CARRY); } } private void rol_flags_32(int result, int count) { if (count>0) { carry.set(result, Flag.CY_LOWBIT); if (count==1) overflow.set(result, Flag.OF_BIT31_XOR_CARRY); } } private void ror_flags_08(byte result, int count) { if (count>0) { carry.set(result, Flag.CY_HIGHBIT_BYTE); if (count==1) overflow.set(result, Flag.OF_BIT6_XOR_CARRY); } } private void ror_flags_16(short result, int count) { if (count>0) { carry.set(result, Flag.CY_HIGHBIT_SHORT); if (count==1) overflow.set(result, Flag.OF_BIT14_XOR_CARRY); } } private void ror_flags_32(int result, int count) { if (count>0) { carry.set(result, Flag.CY_HIGHBIT_INT); if (count==1) overflow.set(result, Flag.OF_BIT30_XOR_CARRY); } } private void rcl_flags_08(int result, int count) { if (count>0) { carry.set(result, Flag.CY_OFFENDBIT_BYTE); if (count==1) overflow.set(result, Flag.OF_BIT7_XOR_CARRY); } } private void rcl_flags_16(int result, int count) { if (count>0) { carry.set(result, Flag.CY_OFFENDBIT_SHORT); if (count==1) overflow.set(result, Flag.OF_BIT15_XOR_CARRY); } } private void rcl_flags_32(long result, int count) { if (count>0) { carry.set(result, Flag.CY_OFFENDBIT_INT); if (count==1) overflow.set(result, Flag.OF_BIT31_XOR_CARRY); } } private void rcr_flags_08(int result, int count, int over) { if (count>0) { carry.set(result, Flag.CY_OFFENDBIT_BYTE); if (count==1) overflow.set(over>0); } } private void rcr_flags_16(int result, int count, int over) { if (count>0) { carry.set(result, Flag.CY_OFFENDBIT_SHORT); if (count==1) overflow.set(over>0); } } private void rcr_flags_32(long result, int count, int over) { if (count>0) { carry.set(result, Flag.CY_OFFENDBIT_INT); if (count==1) overflow.set(over>0); } } private void neg_flags_08(byte result) { carry.set(result, Flag.CY_NZ); overflow.set(result, Flag.OF_MIN_BYTE); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_NZERO); zero.set(result); parity.set(result); sign.set(result); } private void neg_flags_16(short result) { carry.set(result, Flag.CY_NZ); overflow.set(result, Flag.OF_MIN_SHORT); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_NZERO); zero.set(result); parity.set(result); sign.set(result); } private void neg_flags_32(int result) { carry.set(result, Flag.CY_NZ); overflow.set(result, Flag.OF_MIN_INT); auxiliaryCarry.set(result, Flag.AC_LNIBBLE_NZERO); zero.set(result); parity.set(result); sign.set(result); } public void initializeDecoder() { //assemble the table of instruction inputs and outputs by instrution //this will speed processing //29 different sources / destinations, + 1 miscellaneous int types=30; operandTable = new int[0x200][types][4]; for (int i=0; i<types; i++) { for (int j=0; j<inputTable0[i].length; j++) { int inst = inputTable0[i][j]; if (inst>=0xf00) inst-=0xe00; operandTable[inst][i][0]=1; } for (int j=0; j<inputTable1[i].length; j++) { int inst = inputTable1[i][j]; if (inst>=0xf00) inst-=0xe00; operandTable[inst][i][1]=1; } for (int j=0; j<outputTable0[i].length; j++) { int inst = outputTable0[i][j]; if (inst>=0xf00) inst-=0xe00; operandTable[inst][i][2]=1; } for (int j=0; j<outputTable1[i].length; j++) { int inst = outputTable1[i][j]; if (inst>=0xf00) inst-=0xe00; operandTable[inst][i][3]=1; } } } //this routine will eventually be turned into a normal exception public void panic(String reason) { System.out.println("PANIC: "+reason); System.out.println("icount = "+computer.icount); //System.exit(0); } //call this to start the decoding public void decodeInstruction(boolean is32bit) { codeLength=0; icodeLength=0; addressDecoded=false; if(is32bit) { pushCode(MICROCODE.PREFIX_OPCODE_32BIT); pushCode(MICROCODE.PREFIX_ADDRESS_32BIT); } decodePrefix(is32bit); decodeOpcode(); if(isCode(MICROCODE.PREFIX_OPCODE_32BIT)) replaceFlags1632(); } //returns microinstruction codes public MICROCODE[] getCodes() { return code; } //returns the length of the instruction in bytes public int getInstructionLength() { return fetchQueue.instructionLength(); } //add a new microcode to the sequence private void pushCode(MICROCODE code) { this.code[codeLength++]=code; } private void pushCode(int code) { this.icode[icodeLength++]=code; } public MICROCODE getCode() { if(codesHandled>=codeLength) panic("No more codes to read"); return this.code[codesHandled++]; } private int getLastiCode() { if (icodesHandled==0) return this.icode[0]; return this.icode[icodesHandled-1]; } private int getiCode() { if(icodesHandled>=icodeLength) panic("No more icodes to read"); return this.icode[icodesHandled++]; } //is a particular microcode already in the array? private boolean isCode(MICROCODE code) { for (int i=0; i<codeLength; i++) if (this.code[i]==code) return true; return false; } private void removeCode(MICROCODE code) { int i; for (i=0; i<codeLength; i++) if (this.code[i]==code) break; if (i==codeLength) return; for (int j=i; j<codeLength-1; j++) this.code[j]=this.code[j+1]; codeLength--; } private void decodePrefix(boolean is32bit) { int prefix; //keep decoding prefices until no more while(true) { prefix = (0xff & fetchQueue.readByte()); switch(prefix) { //Group 1, page 34 case 0xf0: pushCode(MICROCODE.PREFIX_LOCK); break; case 0xf2: pushCode(MICROCODE.PREFIX_REPNE); break; case 0xf3: pushCode(MICROCODE.PREFIX_REPE); break; //Group 2, page 34 case 0x2e: pushCode(MICROCODE.PREFIX_CS); break; case 0x36: pushCode(MICROCODE.PREFIX_SS); break; case 0x3e: pushCode(MICROCODE.PREFIX_DS); break; case 0x26: pushCode(MICROCODE.PREFIX_ES); break; case 0x64: pushCode(MICROCODE.PREFIX_FS); break; case 0x65: pushCode(MICROCODE.PREFIX_GS); break; case 0x66: if(!is32bit) pushCode(MICROCODE.PREFIX_OPCODE_32BIT); else removeCode(MICROCODE.PREFIX_OPCODE_32BIT); break; case 0x67: if(!is32bit) pushCode(MICROCODE.PREFIX_ADDRESS_32BIT); else removeCode(MICROCODE.PREFIX_ADDRESS_32BIT); break; case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde: case 0xdf: return; // panic("Floating point not implemented"); default: //this isn't a prefix - it's the opcode return; } //move beyond the prefix byte fetchQueue.advance(1); } } private void decodeOpcode() { //the opcode is either one or two bytes //(intel manual mentions three, but I'll ignore that for now) int opcode; int modrm; boolean hasmodrm; int hasimmediate, hasdisplacement; int tableindex=0; int displacement; long immediate; int sib; opcode=0xff & fetchQueue.readByte(); fetchQueue.advance(1); tableindex=opcode; //0x0f means a second byte if (opcode==0x0f) { opcode=(opcode<<8) | (0xff & fetchQueue.readByte()); fetchQueue.advance(1); tableindex=(opcode&0xff)+0x100; } else if (opcode>=0xd8 && opcode<=0xdf) { //floating point: throw away next byte fetchQueue.advance(1); } if(computer.debugMode) System.out.printf("opcode %x\n",opcode); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_OPCODE_32BIT)) processorGUICode.push(GUICODE.DECODE_PREFIX,"op32"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) processorGUICode.push(GUICODE.DECODE_PREFIX,"addr32"); if (processorGUICode!=null && !isCode(MICROCODE.PREFIX_OPCODE_32BIT)) processorGUICode.push(GUICODE.DECODE_PREFIX,"op16"); if (processorGUICode!=null && !isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) processorGUICode.push(GUICODE.DECODE_PREFIX,"addr16"); if (processorGUICode!=null && (isCode(MICROCODE.PREFIX_REPE)||isCode(MICROCODE.PREFIX_REPNE))) processorGUICode.push(GUICODE.DECODE_PREFIX,"rep"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_CS)) processorGUICode.push(GUICODE.DECODE_PREFIX,"cs"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_SS)) processorGUICode.push(GUICODE.DECODE_PREFIX,"ss"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_DS)) processorGUICode.push(GUICODE.DECODE_PREFIX,"ds"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_ES)) processorGUICode.push(GUICODE.DECODE_PREFIX,"es"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_FS)) processorGUICode.push(GUICODE.DECODE_PREFIX,"fs"); if (processorGUICode!=null && isCode(MICROCODE.PREFIX_GS)) processorGUICode.push(GUICODE.DECODE_PREFIX,"gs"); if(processorGUICode!=null) processorGUICode.push(GUICODE.DECODE_OPCODE,opcode); hasmodrm=(modrmTable[tableindex]==1); //the next byte is the mod r/m byte, if the instruction has one if (hasmodrm) { modrm = (0xff & fetchQueue.readByte()); fetchQueue.advance(1); if(processorGUICode!=null) processorGUICode.push(GUICODE.DECODE_MODRM,modrm); } else modrm=-1; //the next byte might be the sib sib=-1; if (modrm!=-1 && isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) { if (sibTable[modrm]==1) { sib=(0xff&fetchQueue.readByte()); fetchQueue.advance(1); if(processorGUICode!=null) processorGUICode.push(GUICODE.DECODE_SIB,sib); } } //get the displacement, if any hasdisplacement=0; if(hasDisplacementTable[tableindex]==1) { if(!isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) { if ((modrm & 0xc0)==0 && (modrm & 0x7)==0x6) hasdisplacement=2; else if ((modrm & 0xc0)==0x40) hasdisplacement=1; else if ((modrm & 0xc0)==0x80) hasdisplacement=2; } else { if ((modrm & 0xc0)==0 && (modrm & 0x7)==0x5) hasdisplacement=4; else if ((modrm & 0xc0)==0 && (modrm & 0x7)==0x4 && (sib!=-1) && (sib & 0x7)==0x5) hasdisplacement=4; else if ((modrm & 0xc0)==0x40) hasdisplacement=1; else if ((modrm & 0xc0)==0x80) hasdisplacement=4; } } displacement=0; //handle the special a0-a3 case if(hasDisplacementTable[tableindex]==4) { if(!isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) hasdisplacement=2; else hasdisplacement=4; } if (hasdisplacement==1) { displacement=(0xff & fetchQueue.readByte()); fetchQueue.advance(1); } else if (hasdisplacement==2) { displacement=(0xff & fetchQueue.readByte()); fetchQueue.advance(1); displacement=(displacement&0xff)|(0xff00 & (fetchQueue.readByte()<<8)); fetchQueue.advance(1); } else if (hasdisplacement==4) { displacement=(0xff & fetchQueue.readByte()); fetchQueue.advance(1); displacement=(displacement&0xff)|(0xff00 & (fetchQueue.readByte()<<8)); fetchQueue.advance(1); displacement=(displacement&0xffff)|(0xff0000 & (fetchQueue.readByte()<<16)); fetchQueue.advance(1); displacement=(displacement&0xffffff)|(0xff000000 & (fetchQueue.readByte()<<24)); fetchQueue.advance(1); } if (hasdisplacement>0) if(processorGUICode!=null) processorGUICode.push(GUICODE.DECODE_DISPLACEMENT,displacement); //get the immediate //get the displacement, if any hasimmediate=hasImmediateTable[tableindex]; //since we're in 16-bit mode, change the 32-bit to 20-bit if (!isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { if(hasimmediate==4) hasimmediate=2; else if(hasimmediate==6) hasimmediate=4; } //the una instructions (f6 and f7) may or may not have an immediate, depending on modrm if(opcode==0xf6 && (modrm&0x38)==0) hasimmediate=1; else if(opcode==0xf7 && (modrm&0x38)==0 && !isCode(MICROCODE.PREFIX_OPCODE_32BIT)) hasimmediate=2; else if(opcode==0xf7 && (modrm&0x38)==0 && isCode(MICROCODE.PREFIX_OPCODE_32BIT)) hasimmediate=4; immediate=0; if (hasimmediate>=1) { immediate=fetchQueue.readByte(); fetchQueue.advance(1); } if (hasimmediate>=2) { immediate = (immediate&0xff)|(0xff00&(fetchQueue.readByte()<<8)); fetchQueue.advance(1); } if (hasimmediate>=3) { immediate = (immediate&0xffff)|(0xff0000&(fetchQueue.readByte()<<16)); fetchQueue.advance(1); } if (hasimmediate>=4) { immediate = (immediate&0xffffff)|(0xff000000&(fetchQueue.readByte()<<24)); fetchQueue.advance(1); } if (hasimmediate>=6) { immediate = (immediate&0xffffffffl)|(((fetchQueue.readByte()&0xffl)|((fetchQueue.readByte(1)<<8)&0xff00l))<<32); fetchQueue.advance(2); } if (hasimmediate>0) if(processorGUICode!=null) processorGUICode.push(GUICODE.DECODE_IMMEDIATE,(int)immediate); decodeOperands(opcode, modrm, sib, displacement, immediate, true); decodeOperation(opcode, modrm); decodeOperands(opcode, modrm, sib, displacement, immediate, false); decodeFlags(opcode, modrm); } private void decodeOperands(int opcode, int modrm, int sib, int displacement, long immediate, boolean inputOperands) { //30 different operand types int types=30; int opcodeLookup = opcode; if (opcodeLookup>=0xf00) opcodeLookup-=0xe00; //step through load 0, load 1, store 0, store 1 int start=inputOperands? 0:2; int end=inputOperands? 2:4; for (int operand=start; operand<end; operand++) { for (int type=0; type<types; type++) { if(operandTable[opcodeLookup][type][operand]==0) continue; if (type==0) effective_byte(modrm,sib,displacement,operand); else if (type==1) { if(isCode(MICROCODE.PREFIX_OPCODE_32BIT)) effective_double(modrm,sib,displacement,operand); else effective_word(modrm,sib,displacement,operand); } else if (type==2) register_byte(modrm,operand); else if (type==3) { if(isCode(MICROCODE.PREFIX_OPCODE_32BIT)) register_double(modrm,operand); else register_word(modrm,operand); } else if (type==4) { if (operand==0) pushCode(MICROCODE.LOAD0_IB); else if (operand==1) pushCode(MICROCODE.LOAD1_IB); pushCode((int)immediate); } else if (type==5) { if(isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { if (operand==0) pushCode(MICROCODE.LOAD0_ID); else if (operand==1) pushCode(MICROCODE.LOAD1_ID); pushCode((int)immediate); } else { if (operand==0) pushCode(MICROCODE.LOAD0_IW); else if (operand==1) pushCode(MICROCODE.LOAD1_IW); pushCode((int)immediate); } } else if (type>=6 && type<=28) { MICROCODE c = operandRegisterTable[operand*23+type-6]; if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { if (c==MICROCODE.LOAD0_AX) c=MICROCODE.LOAD0_EAX; else if (c==MICROCODE.LOAD0_BX) c=MICROCODE.LOAD0_EBX; else if (c==MICROCODE.LOAD0_CX) c=MICROCODE.LOAD0_ECX; else if (c==MICROCODE.LOAD0_DX) c=MICROCODE.LOAD0_EDX; else if (c==MICROCODE.LOAD0_SI) c=MICROCODE.LOAD0_ESI; else if (c==MICROCODE.LOAD0_DI) c=MICROCODE.LOAD0_EDI; else if (c==MICROCODE.LOAD0_SP) c=MICROCODE.LOAD0_ESP; else if (c==MICROCODE.LOAD0_BP) c=MICROCODE.LOAD0_EBP; else if (c==MICROCODE.LOAD0_FLAGS) c=MICROCODE.LOAD0_EFLAGS; else if (c==MICROCODE.LOAD1_AX) c=MICROCODE.LOAD1_EAX; else if (c==MICROCODE.LOAD1_BX) c=MICROCODE.LOAD1_EBX; else if (c==MICROCODE.LOAD1_CX) c=MICROCODE.LOAD1_ECX; else if (c==MICROCODE.LOAD1_DX) c=MICROCODE.LOAD1_EDX; else if (c==MICROCODE.LOAD1_SI) c=MICROCODE.LOAD1_ESI; else if (c==MICROCODE.LOAD1_DI) c=MICROCODE.LOAD1_EDI; else if (c==MICROCODE.LOAD1_SP) c=MICROCODE.LOAD1_ESP; else if (c==MICROCODE.LOAD1_BP) c=MICROCODE.LOAD1_EBP; else if (c==MICROCODE.LOAD1_FLAGS) c=MICROCODE.LOAD1_EFLAGS; else if (c==MICROCODE.STORE0_AX) c=MICROCODE.STORE0_EAX; else if (c==MICROCODE.STORE0_BX) c=MICROCODE.STORE0_EBX; else if (c==MICROCODE.STORE0_CX) c=MICROCODE.STORE0_ECX; else if (c==MICROCODE.STORE0_DX) c=MICROCODE.STORE0_EDX; else if (c==MICROCODE.STORE0_SI) c=MICROCODE.STORE0_ESI; else if (c==MICROCODE.STORE0_DI) c=MICROCODE.STORE0_EDI; else if (c==MICROCODE.STORE0_SP) c=MICROCODE.STORE0_ESP; else if (c==MICROCODE.STORE0_BP) c=MICROCODE.STORE0_EBP; else if (c==MICROCODE.STORE0_FLAGS) c=MICROCODE.STORE0_EFLAGS; else if (c==MICROCODE.STORE1_AX) c=MICROCODE.STORE1_EAX; else if (c==MICROCODE.STORE1_BX) c=MICROCODE.STORE1_EBX; else if (c==MICROCODE.STORE1_CX) c=MICROCODE.STORE1_ECX; else if (c==MICROCODE.STORE1_DX) c=MICROCODE.STORE1_EDX; else if (c==MICROCODE.STORE1_SI) c=MICROCODE.STORE1_ESI; else if (c==MICROCODE.STORE1_DI) c=MICROCODE.STORE1_EDI; else if (c==MICROCODE.STORE1_SP) c=MICROCODE.STORE1_ESP; else if (c==MICROCODE.STORE1_BP) c=MICROCODE.STORE1_EBP; else if (c==MICROCODE.STORE1_FLAGS) c=MICROCODE.STORE1_EFLAGS; } pushCode(c); } else decodeIrregularOperand(opcode, modrm, sib, displacement, immediate, operand); break; } } //a few instructions have a third input if (inputOperands && (opcode==0xfa4 || opcode==0xfa5 || opcode==0xfac || opcode==0xfad || opcode==0xfb0 || opcode==0xfb1)) { switch(opcode) { case 0xfa4: case 0xfac: pushCode(MICROCODE.LOAD2_IB); pushCode((int)immediate); break; case 0xfa5: case 0xfad: pushCode(MICROCODE.LOAD2_CL); break; case 0xfb0: pushCode(MICROCODE.LOAD2_AL); break; case 0xfb1: if(isCode(MICROCODE.PREFIX_OPCODE_32BIT)) pushCode(MICROCODE.LOAD2_EAX); else pushCode(MICROCODE.LOAD2_AX); break; } } } private void effective_byte(int modrm, int sib, int displacement, int operand) { if ((modrm & 0xc7)>=0xc0 && (modrm & 0xc7)<=0xc7) pushCode(modrmRegisterTable[operand*9 + (modrm&7)]); else { decode_memory(modrm, sib, displacement); pushCode(modrmRegisterTable[operand*9+8]); } } private void effective_word(int modrm, int sib, int displacement, int operand) { if ((modrm & 0xc7)>=0xc0 && (modrm & 0xc7)<=0xc7) pushCode(modrmRegisterTable[36 + operand*9 + (modrm&7)]); else { decode_memory(modrm, sib, displacement); pushCode(modrmRegisterTable[36 + operand*9+8]); } } private void effective_double(int modrm, int sib, int displacement, int operand) { if ((modrm & 0xc7)>=0xc0 && (modrm & 0xc7)<=0xc7) pushCode(modrmRegisterTable[72 + operand*9 + (modrm&7)]); else { decode_memory(modrm, sib, displacement); pushCode(modrmRegisterTable[72 + operand*9+8]); } } private void register_byte(int modrm, int operand) { pushCode(modrmRegisterTable[operand*9+((modrm&0x38)>>3)]); } private void register_word(int modrm, int operand) { pushCode(modrmRegisterTable[36+operand*9+((modrm&0x38)>>3)]); } private void register_double(int modrm, int operand) { pushCode(modrmRegisterTable[72+operand*9+((modrm&0x38)>>3)]); } private boolean isAddressDecoded() { if(addressDecoded) return true; addressDecoded=true; return false; } private void store0_Rd(int modrm) { switch(modrm&0xc7) { case 0xc0: pushCode(MICROCODE.STORE0_EAX); break; case 0xc1: pushCode(MICROCODE.STORE0_ECX); break; case 0xc2: pushCode(MICROCODE.STORE0_EDX); break; case 0xc3: pushCode(MICROCODE.STORE0_EBX); break; case 0xc4: pushCode(MICROCODE.STORE0_ESP); break; case 0xc5: pushCode(MICROCODE.STORE0_EBP); break; case 0xc6: pushCode(MICROCODE.STORE0_ESI); break; case 0xc7: pushCode(MICROCODE.STORE0_EDI); break; default: panic("Bad store0 Rd"); } } private void load0_Rd(int modrm) { switch(modrm&0xc7) { case 0xc0: pushCode(MICROCODE.LOAD0_EAX); break; case 0xc1: pushCode(MICROCODE.LOAD0_ECX); break; case 0xc2: pushCode(MICROCODE.LOAD0_EDX); break; case 0xc3: pushCode(MICROCODE.LOAD0_EBX); break; case 0xc4: pushCode(MICROCODE.LOAD0_ESP); break; case 0xc5: pushCode(MICROCODE.LOAD0_EBP); break; case 0xc6: pushCode(MICROCODE.LOAD0_ESI); break; case 0xc7: pushCode(MICROCODE.LOAD0_EDI); break; default: panic("Bad store0 Rd"); } } private void load0_Cd(int modrm) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.LOAD0_CR0); break; case 0x10: pushCode(MICROCODE.LOAD0_CR2); break; case 0x18: pushCode(MICROCODE.LOAD0_CR3); break; case 0x20: pushCode(MICROCODE.LOAD0_CR4); break; default: panic("Bad load0 Cd"); } } private void store0_Cd(int modrm) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.STORE0_CR0); break; case 0x10: pushCode(MICROCODE.STORE0_CR2); break; case 0x18: pushCode(MICROCODE.STORE0_CR3); break; case 0x20: pushCode(MICROCODE.STORE0_CR4); break; default: panic("Bad load0 Cd"); } } private void decode_memory(int modrm, int sib, int displacement) { if(isAddressDecoded()) return; if (isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) { //first figure out which segment to access if (isCode(MICROCODE.PREFIX_CS)) pushCode(MICROCODE.LOAD_SEG_CS); else if (isCode(MICROCODE.PREFIX_SS)) pushCode(MICROCODE.LOAD_SEG_SS); else if (isCode(MICROCODE.PREFIX_DS)) pushCode(MICROCODE.LOAD_SEG_DS); else if (isCode(MICROCODE.PREFIX_ES)) pushCode(MICROCODE.LOAD_SEG_ES); else if (isCode(MICROCODE.PREFIX_FS)) pushCode(MICROCODE.LOAD_SEG_FS); else if (isCode(MICROCODE.PREFIX_GS)) pushCode(MICROCODE.LOAD_SEG_GS); else if ((modrm&0xc7)==0x45 || (modrm&0xc7)==0x55) pushCode(MICROCODE.LOAD_SEG_SS); else if ((modrm&0xc7)==0x04 || (modrm&0xc7)==0x44 || (modrm&0xc7)==0x84) { } else pushCode(MICROCODE.LOAD_SEG_DS); if ((modrm & 0x7)==0) pushCode(MICROCODE.ADDR_EAX); else if ((modrm & 0x7)==1) pushCode(MICROCODE.ADDR_ECX); else if ((modrm & 0x7)==2) pushCode(MICROCODE.ADDR_EDX); else if ((modrm & 0x7)==3) pushCode(MICROCODE.ADDR_EBX); else if ((modrm & 0x7)==4) { decodeSIB(modrm, sib, displacement); } else if ((modrm & 0x7)==5 && (modrm & 0xc0)==0x00) { pushCode(MICROCODE.ADDR_ID); pushCode(displacement); } else if ((modrm & 0x7)==5) pushCode(MICROCODE.ADDR_EBP); else if ((modrm & 0x7)==6) pushCode(MICROCODE.ADDR_ESI); else if ((modrm & 0x7)==7) pushCode(MICROCODE.ADDR_EDI); //now add the displacement if ((modrm & 0xc0)==0x40) { pushCode(MICROCODE.ADDR_IB); pushCode(displacement); } else if ((modrm & 0xc0)==0x80) { pushCode(MICROCODE.ADDR_ID); pushCode(displacement); } } else { //first figure out which segment to access if (isCode(MICROCODE.PREFIX_CS)) pushCode(MICROCODE.LOAD_SEG_CS); else if (isCode(MICROCODE.PREFIX_SS)) pushCode(MICROCODE.LOAD_SEG_SS); else if (isCode(MICROCODE.PREFIX_DS)) pushCode(MICROCODE.LOAD_SEG_DS); else if (isCode(MICROCODE.PREFIX_ES)) pushCode(MICROCODE.LOAD_SEG_ES); else if (isCode(MICROCODE.PREFIX_FS)) pushCode(MICROCODE.LOAD_SEG_FS); else if (isCode(MICROCODE.PREFIX_GS)) pushCode(MICROCODE.LOAD_SEG_GS); else if ((modrm&0xc7)==0x02 || (modrm&0xc7)==0x03 || (modrm&0xc7)==0x42 || (modrm&0xc7)==0x43 || (modrm&0xc7)==0x46 || (modrm&0xc7)==0x82 || (modrm&0xc7)==0x83 || (modrm&0xc7)==0x86) pushCode(MICROCODE.LOAD_SEG_SS); else pushCode(MICROCODE.LOAD_SEG_DS); if ((modrm & 0x7)==0 || (modrm & 0x7)==1 || (modrm & 0x7)==7) pushCode(MICROCODE.ADDR_BX); else if ((modrm & 0x7)==2 || (modrm & 0x7)==3) pushCode(MICROCODE.ADDR_BP); else if ((modrm & 0x7)==4) pushCode(MICROCODE.ADDR_SI); else if ((modrm & 0x7)==5) pushCode(MICROCODE.ADDR_DI); else if ((modrm & 0xc0)!=0) pushCode(MICROCODE.ADDR_BP); else { pushCode(MICROCODE.ADDR_IW); pushCode(displacement); } //in some cases SI or DI is added if ((modrm & 0x7)==0 || (modrm & 0x7)==2) pushCode(MICROCODE.ADDR_SI); else if ((modrm & 0x7)==1 || (modrm & 0x7)==3) pushCode(MICROCODE.ADDR_DI); //now add the displacement if ((modrm & 0xc0)==0x40) { pushCode(MICROCODE.ADDR_IB); pushCode(displacement); } else if ((modrm & 0xc0)==0x80) { pushCode(MICROCODE.ADDR_IW); pushCode(displacement); } pushCode(MICROCODE.ADDR_MASK_16); } } private void decodeSIB(int modrm, int sib, int displacement) { if (isCode(MICROCODE.PREFIX_CS)) pushCode(MICROCODE.LOAD_SEG_CS); else if (isCode(MICROCODE.PREFIX_SS)) pushCode(MICROCODE.LOAD_SEG_SS); else if (isCode(MICROCODE.PREFIX_DS)) pushCode(MICROCODE.LOAD_SEG_DS); else if (isCode(MICROCODE.PREFIX_ES)) pushCode(MICROCODE.LOAD_SEG_ES); else if (isCode(MICROCODE.PREFIX_FS)) pushCode(MICROCODE.LOAD_SEG_FS); else if (isCode(MICROCODE.PREFIX_GS)) pushCode(MICROCODE.LOAD_SEG_GS); else { if ((sib&0x7)==0x4) pushCode(MICROCODE.LOAD_SEG_SS); else if ((sib&0x7)==0x5) { if ((modrm&0xc0)==0) pushCode(MICROCODE.LOAD_SEG_SS); else pushCode(MICROCODE.LOAD_SEG_DS); } else pushCode(MICROCODE.LOAD_SEG_DS); } if ((sib&0x7)==0) pushCode(MICROCODE.ADDR_EAX); else if ((sib&0x7)==1) pushCode(MICROCODE.ADDR_ECX); else if ((sib&0x7)==2) pushCode(MICROCODE.ADDR_EDX); else if ((sib&0x7)==3) pushCode(MICROCODE.ADDR_EBX); else if ((sib&0x7)==4) pushCode(MICROCODE.ADDR_ESP); else if ((sib&0x7)==6) pushCode(MICROCODE.ADDR_ESI); else if ((sib&0x7)==7) pushCode(MICROCODE.ADDR_EDI); else if ((modrm&0xc0)!=0) pushCode(MICROCODE.ADDR_EBP); else { pushCode(MICROCODE.ADDR_ID); pushCode(displacement); } switch(sib&0xf8) { case 0x00: pushCode(MICROCODE.ADDR_EAX); break; case 0x08: pushCode(MICROCODE.ADDR_ECX); break; case 0x10: pushCode(MICROCODE.ADDR_EDX); break; case 0x18: pushCode(MICROCODE.ADDR_EBX); break; case 0x28: pushCode(MICROCODE.ADDR_EBP); break; case 0x30: pushCode(MICROCODE.ADDR_ESI); break; case 0x38: pushCode(MICROCODE.ADDR_EDI); break; case 0x40: pushCode(MICROCODE.ADDR_2EAX); break; case 0x48: pushCode(MICROCODE.ADDR_2ECX); break; case 0x50: pushCode(MICROCODE.ADDR_2EDX); break; case 0x58: pushCode(MICROCODE.ADDR_2EBX); break; case 0x68: pushCode(MICROCODE.ADDR_2EBP); break; case 0x70: pushCode(MICROCODE.ADDR_2ESI); break; case 0x78: pushCode(MICROCODE.ADDR_2EDI); break; case 0x80: pushCode(MICROCODE.ADDR_4EAX); break; case 0x88: pushCode(MICROCODE.ADDR_4ECX); break; case 0x90: pushCode(MICROCODE.ADDR_4EDX); break; case 0x98: pushCode(MICROCODE.ADDR_4EBX); break; case 0xa8: pushCode(MICROCODE.ADDR_4EBP); break; case 0xb0: pushCode(MICROCODE.ADDR_4ESI); break; case 0xb8: pushCode(MICROCODE.ADDR_4EDI); break; case 0xc0: pushCode(MICROCODE.ADDR_8EAX); break; case 0xc8: pushCode(MICROCODE.ADDR_8ECX); break; case 0xd0: pushCode(MICROCODE.ADDR_8EDX); break; case 0xd8: pushCode(MICROCODE.ADDR_8EBX); break; case 0xe8: pushCode(MICROCODE.ADDR_8EBP); break; case 0xf0: pushCode(MICROCODE.ADDR_8ESI); break; case 0xf8: pushCode(MICROCODE.ADDR_8EDI); break; } } private void decodeSegmentPrefix() { if (isCode(MICROCODE.PREFIX_CS)) pushCode(MICROCODE.LOAD_SEG_CS); else if (isCode(MICROCODE.PREFIX_SS)) pushCode(MICROCODE.LOAD_SEG_SS); else if (isCode(MICROCODE.PREFIX_DS)) pushCode(MICROCODE.LOAD_SEG_DS); else if (isCode(MICROCODE.PREFIX_ES)) pushCode(MICROCODE.LOAD_SEG_ES); else if (isCode(MICROCODE.PREFIX_FS)) pushCode(MICROCODE.LOAD_SEG_FS); else if (isCode(MICROCODE.PREFIX_GS)) pushCode(MICROCODE.LOAD_SEG_GS); else pushCode(MICROCODE.LOAD_SEG_DS); } private void decodeO(int modrm, int displacement) { //first figure out which segment to access if (isCode(MICROCODE.PREFIX_CS)) pushCode(MICROCODE.LOAD_SEG_CS); else if (isCode(MICROCODE.PREFIX_SS)) pushCode(MICROCODE.LOAD_SEG_SS); else if (isCode(MICROCODE.PREFIX_DS)) pushCode(MICROCODE.LOAD_SEG_DS); else if (isCode(MICROCODE.PREFIX_ES)) pushCode(MICROCODE.LOAD_SEG_ES); else if (isCode(MICROCODE.PREFIX_FS)) pushCode(MICROCODE.LOAD_SEG_FS); else if (isCode(MICROCODE.PREFIX_GS)) pushCode(MICROCODE.LOAD_SEG_GS); else if ((modrm&0xc7)==0x02 || (modrm&0xc7)==0x03 || (modrm&0xc7)==0x42 || (modrm&0xc7)==0x43 || (modrm&0xc7)==0x46 || (modrm&0xc7)==0x82 || (modrm&0xc7)==0x83 || (modrm&0xc7)==0x86) pushCode(MICROCODE.LOAD_SEG_SS); else pushCode(MICROCODE.LOAD_SEG_DS); if(isAddressDecoded()) return; if (isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) pushCode(MICROCODE.ADDR_ID); else { pushCode(MICROCODE.ADDR_IW); pushCode(MICROCODE.ADDR_MASK_16); } pushCode(displacement); } private void decodeIrregularOperand(int opcode, int modrm, int sib, int displacement, long immediate, int operand) { //input 0 /*{ 0xc8, 0x62, 0xa0, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, 0xac, 0xad, 0xfa3, 0xfab, 0xfb3, 0xfbb, 0x6e, 0x6f, 0xd7, 0xf00, 0xf01, 0xf20, 0xf21, 0xf23, 0xfba, 0xfc8, 0xfc9, 0xfca, 0xfcb, 0xfcc, 0xfcd, 0xfce, 0xfcf}*/ if (operand==0) { switch(opcode) { case 0x8e: case 0xfb7: case 0xfbf: effective_word(modrm, sib, displacement, operand); break; case 0xec: case 0xed: case 0xee: case 0xef: case 0x6c: case 0x6d: pushCode(MICROCODE.LOAD0_DX); break; case 0xc2: case 0xca: pushCode(MICROCODE.LOAD0_IW); pushCode((int)(immediate)); break; case 0xea: case 0x9a: //far jump or call if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { pushCode(MICROCODE.LOAD0_ID); pushCode((int)immediate); } else { pushCode(MICROCODE.LOAD0_IW); pushCode((int)(0xffff & immediate)); } break; case 0x8d: //lea decode_memory(modrm, sib, displacement); pushCode(MICROCODE.LOAD0_ADDR); break; case 0x8c: //store to segment register switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.LOAD0_ES); break; case 0x08: pushCode(MICROCODE.LOAD0_CS); break; case 0x10: pushCode(MICROCODE.LOAD0_SS); break; case 0x18: pushCode(MICROCODE.LOAD0_DS); break; case 0x20: pushCode(MICROCODE.LOAD0_FS); break; case 0x28: pushCode(MICROCODE.LOAD0_GS); break; // default: panic("Bad segment operand"); } break; case 0xa0: decodeO(modrm, displacement); pushCode(MICROCODE.LOAD0_MEM_BYTE); break; case 0xa1: decodeO(modrm, displacement); if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) pushCode(MICROCODE.LOAD0_MEM_DOUBLE); else pushCode(MICROCODE.LOAD0_MEM_WORD); break; case 0xa4: case 0xa5: case 0xa6: case 0xa7: case 0xac: case 0xad: decodeSegmentPrefix(); break; case 0x6e: case 0x6f: pushCode(MICROCODE.LOAD0_DX); decodeSegmentPrefix(); break; case 0xc8: pushCode(MICROCODE.LOAD0_IW); // pushCode((int)(0xffffl & (immediate>>>16))); pushCode((int)(0xffffl & immediate)); break; case 0xd7: if(isCode(MICROCODE.PREFIX_CS)) pushCode(MICROCODE.LOAD_SEG_CS); else if(isCode(MICROCODE.PREFIX_SS)) pushCode(MICROCODE.LOAD_SEG_SS); else if(isCode(MICROCODE.PREFIX_ES)) pushCode(MICROCODE.LOAD_SEG_ES); else if(isCode(MICROCODE.PREFIX_FS)) pushCode(MICROCODE.LOAD_SEG_FS); else if(isCode(MICROCODE.PREFIX_GS)) pushCode(MICROCODE.LOAD_SEG_GS); else pushCode(MICROCODE.LOAD_SEG_DS); if (isCode(MICROCODE.PREFIX_ADDRESS_32BIT)) { pushCode(MICROCODE.ADDR_EBX); pushCode(MICROCODE.ADDR_AL); } else { pushCode(MICROCODE.ADDR_BX); pushCode(MICROCODE.ADDR_AL); pushCode(MICROCODE.ADDR_MASK_16); } pushCode(MICROCODE.LOAD0_MEM_BYTE); break; case 0xf00: if ((modrm&0x38)==0x10 || (modrm&0x38)==0x18 || (modrm&0x38)==0x20 || (modrm&0x38)==0x28) effective_word(modrm,sib,displacement,operand); break; case 0xf01: if ((modrm&0x38)==0x10 || (modrm&0x38)==0x18 || (modrm&0x38)==0x30) effective_word(modrm,sib,displacement,operand); else if ((modrm&0x38)==0x38) decode_memory(modrm,sib,displacement); break; case 0xf20: load0_Cd(modrm); break; case 0xf22: load0_Rd(modrm); break; case 0xfab: case 0xfa3: case 0xfbb: case 0xfb3: if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { switch(modrm&0xc7) { case 0xc0: pushCode(MICROCODE.LOAD0_EAX); break; case 0xc1: pushCode(MICROCODE.LOAD0_ECX); break; case 0xc2: pushCode(MICROCODE.LOAD0_EDX); break; case 0xc3: pushCode(MICROCODE.LOAD0_EBX); break; case 0xc4: pushCode(MICROCODE.LOAD0_ESP); break; case 0xc5: pushCode(MICROCODE.LOAD0_EBP); break; case 0xc6: pushCode(MICROCODE.LOAD0_ESI); break; case 0xc7: pushCode(MICROCODE.LOAD0_EDI); break; default: decode_memory(modrm, sib, displacement); break; } } else { switch(modrm&0xc7) { case 0xc0: pushCode(MICROCODE.LOAD0_AX); break; case 0xc1: pushCode(MICROCODE.LOAD0_CX); break; case 0xc2: pushCode(MICROCODE.LOAD0_DX); break; case 0xc3: pushCode(MICROCODE.LOAD0_BX); break; case 0xc4: pushCode(MICROCODE.LOAD0_SP); break; case 0xc5: pushCode(MICROCODE.LOAD0_BP); break; case 0xc6: pushCode(MICROCODE.LOAD0_SI); break; case 0xc7: pushCode(MICROCODE.LOAD0_DI); break; default: decode_memory(modrm, sib, displacement); break; } } break; default: panic("Need to decode irregular input 0 operand: "+opcode); } } //input 1 /*{0xc8, 0xf6, 0xf7, 0x62, 0xc4, 0xc5, 0xfb2, 0xfb4, 0xfb5, 0xfba}*/ else if (operand==1) { switch(opcode) { case 0xc8: //enter pushCode(MICROCODE.LOAD1_IB); // pushCode((int)(0xffl & immediate)); pushCode((int)(0xffl & (immediate>>>24))); break; case 0xea: case 0x9a: //far jump or call if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { pushCode(MICROCODE.LOAD1_IW); pushCode((int)(immediate>>>32)); } else { pushCode(MICROCODE.LOAD1_IW); pushCode((int)(immediate>>>16)); } break; case 0xf6: //una if((modrm&0x38)==0) { pushCode(MICROCODE.LOAD1_IB); pushCode((int)immediate); } break; case 0xf7: //una if(isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { if((modrm&0x38)==0) { pushCode(MICROCODE.LOAD1_ID); pushCode((int)immediate); } } else { if((modrm&0x38)==0) { pushCode(MICROCODE.LOAD1_IW); pushCode((int)immediate); } } break; case 0xff: //various jumps if((modrm&0x38)==0x18 || (modrm&0x38)==0x28) { pushCode(MICROCODE.ADDR_IB); if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) pushCode(4); else pushCode(2); pushCode(MICROCODE.LOAD1_MEM_WORD); } break; case 0xd0: case 0xd1: pushCode(MICROCODE.LOAD1_IB); pushCode(1); break; case 0xc4: case 0xc5: case 0xfb2: case 0xfb4: case 0xfb5: pushCode(MICROCODE.ADDR_IB); if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) pushCode(4); else pushCode(2); pushCode(MICROCODE.LOAD1_MEM_WORD); break; case 0xf01: if ((modrm&0x38)==0x10 || (modrm&0x38)==0x18) { pushCode(MICROCODE.ADDR_ID); pushCode(2); pushCode(MICROCODE.LOAD1_MEM_DOUBLE); } break; case 0xfab: case 0xfa3: case 0xfbb: case 0xfb3: if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.LOAD1_EAX); break; case 0x08: pushCode(MICROCODE.LOAD1_ECX); break; case 0x10: pushCode(MICROCODE.LOAD1_EDX); break; case 0x18: pushCode(MICROCODE.LOAD1_EBX); break; case 0x20: pushCode(MICROCODE.LOAD1_ESP); break; case 0x28: pushCode(MICROCODE.LOAD1_EBP); break; case 0x30: pushCode(MICROCODE.LOAD1_ESI); break; case 0x38: pushCode(MICROCODE.LOAD1_EDI); break; } } else { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.LOAD1_AX); break; case 0x08: pushCode(MICROCODE.LOAD1_CX); break; case 0x10: pushCode(MICROCODE.LOAD1_DX); break; case 0x18: pushCode(MICROCODE.LOAD1_BX); break; case 0x20: pushCode(MICROCODE.LOAD1_SP); break; case 0x28: pushCode(MICROCODE.LOAD1_BP); break; case 0x30: pushCode(MICROCODE.LOAD1_SI); break; case 0x38: pushCode(MICROCODE.LOAD1_DI); break; } } break; default: panic("Need to decode irregular input 1 operand: "+opcode); } } //output 0 /*{0x8e, 0xa2, 0xd0, 0xd1, 0xf6, 0xf7, 0xf00, 0xf01, 0xf20, 0xf21, 0xf22, 0xf23, 0xf31, 0xf32, 0xfab, 0xfb3, 0xfbb, 0xfba, 0xfc8, 0xfc9, 0xfca, 0xfcb, 0xfcc, 0xfcd, 0xfce, 0xfcf}*/ else if (operand==2) { switch(opcode) { case 0x8e: //store to segment register switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.STORE0_ES); break; case 0x08: pushCode(MICROCODE.STORE0_CS); break; case 0x10: pushCode(MICROCODE.STORE0_SS); break; case 0x18: pushCode(MICROCODE.STORE0_DS); break; case 0x20: pushCode(MICROCODE.STORE0_FS); break; case 0x28: pushCode(MICROCODE.STORE0_GS); break; default: panic("Bad segment operand"); } break; case 0xff: if((modrm&0x38)==0x00 || (modrm&0x38)==0x08) { if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) effective_double(modrm,sib,displacement,2); else effective_word(modrm,sib,displacement,2); } break; case 0xf6: if((modrm&0x38)==0x10 || (modrm&0x38)==0x18) { effective_byte(modrm,sib,displacement,2); } break; case 0xf7: if((modrm&0x38)==0x10 || (modrm&0x38)==0x18) { if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) effective_double(modrm,sib,displacement,2); else effective_word(modrm,sib,displacement,2); } break; case 0xa2: decodeO(modrm, displacement); pushCode(MICROCODE.STORE0_MEM_BYTE); break; case 0xa3: decodeO(modrm, displacement); if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) pushCode(MICROCODE.STORE0_MEM_DOUBLE); else pushCode(MICROCODE.STORE0_MEM_WORD); break; case 0x80: case 0x82: if((modrm&0x38)!=0x38) effective_byte(modrm,sib,displacement,2); break; case 0x81: case 0x83: if((modrm&0x38)!=0x38) { if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) effective_double(modrm,sib,displacement,2); else effective_word(modrm,sib,displacement,2); } break; case 0xfab: case 0xfb3: case 0xfbb: if((modrm&0xc0)==0xc0) { if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) effective_double(modrm,sib,displacement,2); else effective_word(modrm,sib,displacement,2); } break; case 0xf00: if ((modrm&0x38)==0) effective_word(modrm,sib,displacement,2); else if ((modrm&0x38)==0x8) { if (isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { switch(modrm&0xc7) { case 0xc0: pushCode(MICROCODE.STORE0_EAX); break; case 0xc1: pushCode(MICROCODE.STORE0_ECX); break; case 0xc2: pushCode(MICROCODE.STORE0_EDX); break; case 0xc3: pushCode(MICROCODE.STORE0_EBX); break; case 0xc4: pushCode(MICROCODE.STORE0_ESP); break; case 0xc5: pushCode(MICROCODE.STORE0_EBP); break; case 0xc6: pushCode(MICROCODE.STORE0_ESI); break; case 0xc7: pushCode(MICROCODE.STORE0_EDI); break; default: decode_memory(modrm,sib,displacement); pushCode(MICROCODE.STORE0_MEM_WORD); break; } } else effective_word(modrm,sib,displacement,2); } break; case 0xf01: if ((modrm&0x38)==0x00 || (modrm&0x38)==0x08 || (modrm&0x38)==0x20) effective_word(modrm,sib,displacement,2); break; case 0xf20: store0_Rd(modrm); break; case 0xf22: store0_Cd(modrm); break; case 0xf31: pushCode(MICROCODE.STORE0_EAX); break; default: panic("Need to decode irregular output 0 operand: "+opcode); } } //output 1 /*{0xf01, 0xf31, 0xf32}*/ else { switch(opcode) { case 0xf01: if ((modrm&0x38)==0x0 || (modrm&0x38)==0x08) { pushCode(MICROCODE.ADDR_ID); pushCode(2); pushCode(MICROCODE.STORE1_MEM_DOUBLE); } break; case 0xf31: pushCode(MICROCODE.STORE0_EDX); break; default: panic("Need to decode irregular output 1 operand: "+opcode); } } } private void decodeFlags(int opcode, int modrm) { int tableindex=opcode; if(tableindex>=0x0f00) tableindex-=0xe00; MICROCODE code=flagTable[tableindex]; if (code==MICROCODE.FLAG_ROTATE_08) { int val=((modrm & 0x38)>>3); code=rotationTable[val]; pushCode(code); } else if (code==MICROCODE.FLAG_ROTATE_16) { int val=((modrm & 0x38)>>3); code=rotationTable[8+val]; pushCode(code); } else if (code==MICROCODE.FLAG_80_82) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.FLAG_ADD_08); break; case 0x08: pushCode(MICROCODE.FLAG_BITWISE_08); break; case 0x10: pushCode(MICROCODE.FLAG_ADC_08); break; case 0x18: pushCode(MICROCODE.FLAG_SBB_08); break; case 0x20: pushCode(MICROCODE.FLAG_BITWISE_08); break; case 0x28: pushCode(MICROCODE.FLAG_SUB_08); break; case 0x30: pushCode(MICROCODE.FLAG_BITWISE_08); break; case 0x38: pushCode(MICROCODE.FLAG_SUB_08); break; } } else if (code==MICROCODE.FLAG_81_83) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.FLAG_ADD_16); break; case 0x08: pushCode(MICROCODE.FLAG_BITWISE_16); break; case 0x10: pushCode(MICROCODE.FLAG_ADC_16); break; case 0x18: pushCode(MICROCODE.FLAG_SBB_16); break; case 0x20: pushCode(MICROCODE.FLAG_BITWISE_16); break; case 0x28: pushCode(MICROCODE.FLAG_SUB_16); break; case 0x30: pushCode(MICROCODE.FLAG_BITWISE_16); break; case 0x38: pushCode(MICROCODE.FLAG_SUB_16); break; } } else if (code==MICROCODE.FLAG_REP_SUB_08) { if (isCode(MICROCODE.PREFIX_REPNE)||isCode(MICROCODE.PREFIX_REPE)) pushCode(MICROCODE.FLAG_REP_SUB_08); else pushCode(MICROCODE.FLAG_SUB_08); } else if (code==MICROCODE.FLAG_REP_SUB_16) { if (isCode(MICROCODE.PREFIX_REPNE)||isCode(MICROCODE.PREFIX_REPE)) pushCode(MICROCODE.FLAG_REP_SUB_16); else pushCode(MICROCODE.FLAG_SUB_16); } else if (code==MICROCODE.FLAG_F6) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.FLAG_BITWISE_08); break; case 0x18: pushCode(MICROCODE.FLAG_NEG_08); break; } } else if (code==MICROCODE.FLAG_F7) { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.FLAG_BITWISE_16); break; case 0x18: pushCode(MICROCODE.FLAG_NEG_16); break; } } /* else if (code==MICROCODE.FLAG_8F) { // panic("Need to implement flags for instruction 0x8F"); if(!isCode(MICROCODE.STORE0_SP)) pushCode(MICROCODE.STORE1_ESP); }*/ else if (code==MICROCODE.FLAG_FE) { switch(modrm & 0x38) { case 0x00: pushCode(MICROCODE.FLAG_INC_08); break; case 0x08: pushCode(MICROCODE.FLAG_DEC_08); break; } } else if (code==MICROCODE.FLAG_FF) { switch(modrm & 0x38) { case 0x00: pushCode(MICROCODE.FLAG_INC_16); break; case 0x08: pushCode(MICROCODE.FLAG_DEC_16); break; } } else if (code==MICROCODE.FLAG_UNIMPLEMENTED) panic("Unimplemented flag code "+opcode); else if (code==MICROCODE.FLAG_BAD) panic("Invalid flag code "+opcode); else { pushCode(code); } } private void decodeOperation(int opcode, int modrm) { int tableindex=opcode; if(tableindex>=0x0f00) tableindex-=0xe00; MICROCODE code=opcodeTable[tableindex]; //a few codes need to be decoded further if (code==MICROCODE.OP_CBW) //CBW: 0x98 { if(!isCode(MICROCODE.PREFIX_OPCODE_32BIT)) { pushCode(MICROCODE.LOAD0_AL); pushCode(MICROCODE.OP_SIGN_EXTEND_8_16); pushCode(MICROCODE.STORE0_AX); } else { pushCode(MICROCODE.LOAD0_AX); pushCode(MICROCODE.OP_SIGN_EXTEND_16_32); pushCode(MICROCODE.STORE0_EAX); } } else if (code==MICROCODE.OP_BT_16_32) { if ((modrm&0xc7)==0) pushCode(MICROCODE.OP_BT_MEM); else pushCode(code); } else if (code==MICROCODE.OP_BTC_16_32) { if ((modrm&0xc7)==0) pushCode(MICROCODE.OP_BTC_MEM); else pushCode(code); } else if (code==MICROCODE.OP_BTR_16_32) { if ((modrm&0xc7)==0) pushCode(MICROCODE.OP_BTR_MEM); else pushCode(code); } else if (code==MICROCODE.OP_BTS_16_32) { if ((modrm&0xc7)==0) pushCode(MICROCODE.OP_BTS_MEM); else pushCode(code); } else if (code==MICROCODE.OP_ROTATE_08) //rotates: 0xc0, 0xd0, 0xd2 { int val=((modrm & 0x38)>>3); code=rotationTable[16+val]; pushCode(code); } else if (code==MICROCODE.OP_ROTATE_16_32) //rotates: 0xc1, 0xd1, 0xd3 { int val=((modrm & 0x38)>>3); code=rotationTable[24+val]; pushCode(code); } else if (code==MICROCODE.OP_80_83) //imm: 80, 81, 82, 83 { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.OP_ADD); break; case 0x08: pushCode(MICROCODE.OP_OR); break; case 0x10: pushCode(MICROCODE.OP_ADC); break; case 0x18: pushCode(MICROCODE.OP_SBB); break; case 0x20: pushCode(MICROCODE.OP_AND); break; case 0x28: pushCode(MICROCODE.OP_SUB); break; case 0x30: pushCode(MICROCODE.OP_XOR); break; case 0x38: pushCode(MICROCODE.OP_SUB); break; } } else if (code==MICROCODE.OP_F6) //una { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.OP_AND); break; case 0x10: pushCode(MICROCODE.OP_NOT); break; case 0x18: pushCode(MICROCODE.OP_NEG); break; case 0x20: pushCode(MICROCODE.OP_MUL_08); break; case 0x28: pushCode(MICROCODE.OP_IMULA_08); break; case 0x30: pushCode(MICROCODE.OP_DIV_08); break; case 0x38: pushCode(MICROCODE.OP_IDIV_08); break; // default: panic("Bad UNA F6"); } } else if (code==MICROCODE.OP_F7) //una { switch(modrm&0x38) { case 0x00: pushCode(MICROCODE.OP_AND); break; case 0x10: pushCode(MICROCODE.OP_NOT); break; case 0x18: pushCode(MICROCODE.OP_NEG); break; case 0x20: pushCode(MICROCODE.OP_MUL_16_32); break; case 0x28: pushCode(MICROCODE.OP_IMULA_16_32); break; case 0x30: pushCode(MICROCODE.OP_DIV_16_32); break; case 0x38: pushCode(MICROCODE.OP_IDIV_16_32); break; // default: panic("Bad UNA F7"); } } else if (code==MICROCODE.OP_FE) { switch(modrm & 0x38) { case 0x00: pushCode(MICROCODE.OP_INC); break; case 0x08: pushCode(MICROCODE.OP_DEC); break; } } else if (code==MICROCODE.OP_FF) { switch(modrm & 0x38) { case 0x00: pushCode(MICROCODE.OP_INC); break; case 0x08: pushCode(MICROCODE.OP_DEC); break; case 0x10: pushCode(MICROCODE.OP_CALL_ABS); break; case 0x18: pushCode(MICROCODE.OP_CALL_FAR); break; case 0x20: pushCode(MICROCODE.OP_JMP_ABS); break; case 0x28: pushCode(MICROCODE.OP_JMP_FAR); break; case 0x30: pushCode(MICROCODE.OP_PUSH); break; default: //panic("Invalid operation FF code"); } } else if (code==MICROCODE.OP_F00) { switch(modrm & 0x38) { case 0x00: pushCode(MICROCODE.OP_SLDT); break; case 0x08: pushCode(MICROCODE.OP_STR); break; case 0x10: pushCode(MICROCODE.OP_LLDT); break; case 0x18: pushCode(MICROCODE.OP_LTR); break; case 0x20: pushCode(MICROCODE.OP_VERR); break; case 0x28: pushCode(MICROCODE.OP_VERW); break; default: panic("Invalid operation F00 code: "+(modrm&0x38)); break; } } else if (code==MICROCODE.OP_F01) { switch(modrm & 0x38) { case 0x00: pushCode(MICROCODE.OP_SGDT); break; case 0x08: pushCode(MICROCODE.OP_SIDT); break; case 0x10: pushCode(MICROCODE.OP_LGDT); break; case 0x18: pushCode(MICROCODE.OP_LIDT); break; case 0x20: pushCode(MICROCODE.OP_SMSW); break; case 0x30: pushCode(MICROCODE.OP_LMSW); break; default: panic("Invalid operation F01 code"); break; } } else if (code==MICROCODE.OP_BAD) { panic("Invalid instruction "+opcode); return; } else if (code==MICROCODE.OP_UNIMPLEMENTED) { // pushCode(MICROCODE.OP_UNIMPLEMENTED); panic("Unimplemented instruction "+opcode); return; } else { //handle repeat codes if(isCode(MICROCODE.PREFIX_REPE) || isCode(MICROCODE.PREFIX_REPNE)) switch(opcode) { case 0x6c: pushCode(MICROCODE.OP_REP_INSB); break; case 0x6d: pushCode(MICROCODE.OP_REP_INSW); break; case 0x6e: pushCode(MICROCODE.OP_REP_OUTSB); break; case 0x6f: pushCode(MICROCODE.OP_REP_OUTSW); break; case 0xa4: pushCode(MICROCODE.OP_REP_MOVSB); break; case 0xa5: pushCode(MICROCODE.OP_REP_MOVSW); break; case 0xaa: pushCode(MICROCODE.OP_REP_STOSB); break; case 0xab: pushCode(MICROCODE.OP_REP_STOSW); break; case 0xac: pushCode(MICROCODE.OP_REP_LODSB); break; case 0xad: pushCode(MICROCODE.OP_REP_LODSW); break; case 0xa6: if(isCode(MICROCODE.PREFIX_REPE)) pushCode(MICROCODE.OP_REPE_CMPSB); else pushCode(MICROCODE.OP_REPNE_CMPSB); break; case 0xa7: if(isCode(MICROCODE.PREFIX_REPE)) pushCode(MICROCODE.OP_REPE_CMPSW); else pushCode(MICROCODE.OP_REPNE_CMPSW); break; case 0xae: if(isCode(MICROCODE.PREFIX_REPE)) pushCode(MICROCODE.OP_REPE_SCASB); else pushCode(MICROCODE.OP_REPNE_SCASB); break; case 0xaf: if(isCode(MICROCODE.PREFIX_REPE)) pushCode(MICROCODE.OP_REPE_SCASW); else pushCode(MICROCODE.OP_REPNE_SCASW); break; } //normal instructions: repush else pushCode(code); } if(processorGUICode!=null) processorGUICode.pushInstruction(this.code[codeLength-1],opcode); } private void replaceFlags1632() { for (int i=0; i<codeLength; i++) { if (code[i]==MICROCODE.FLAG_BITWISE_16) code[i]=MICROCODE.FLAG_BITWISE_32; else if (code[i]==MICROCODE.FLAG_ADD_16) code[i]=MICROCODE.FLAG_ADD_32; else if (code[i]==MICROCODE.FLAG_ADC_16) code[i]=MICROCODE.FLAG_ADC_32; else if (code[i]==MICROCODE.FLAG_SUB_16) code[i]=MICROCODE.FLAG_SUB_32; else if (code[i]==MICROCODE.FLAG_SBB_16) code[i]=MICROCODE.FLAG_SBB_32; else if (code[i]==MICROCODE.FLAG_SHL_16) code[i]=MICROCODE.FLAG_SHL_32; else if (code[i]==MICROCODE.FLAG_SHR_16) code[i]=MICROCODE.FLAG_SHR_32; else if (code[i]==MICROCODE.FLAG_SAR_16) code[i]=MICROCODE.FLAG_SAR_32; else if (code[i]==MICROCODE.FLAG_ROL_16) code[i]=MICROCODE.FLAG_ROL_32; else if (code[i]==MICROCODE.FLAG_ROR_16) code[i]=MICROCODE.FLAG_ROR_32; else if (code[i]==MICROCODE.FLAG_RCL_16) code[i]=MICROCODE.FLAG_RCL_32; else if (code[i]==MICROCODE.FLAG_RCR_16) code[i]=MICROCODE.FLAG_RCR_32; else if (code[i]==MICROCODE.FLAG_NEG_16) code[i]=MICROCODE.FLAG_NEG_32; else if (code[i]==MICROCODE.FLAG_REP_SUB_16) code[i]=MICROCODE.FLAG_REP_SUB_32; else if (code[i]==MICROCODE.FLAG_INC_16) code[i]=MICROCODE.FLAG_INC_32; else if (code[i]==MICROCODE.FLAG_DEC_16) code[i]=MICROCODE.FLAG_DEC_32; } } public final Processor_Exception DIVIDE_ERROR = new Processor_Exception(0x00); public final Processor_Exception DEBUG = new Processor_Exception(0x01); public final Processor_Exception BREAKPOINT = new Processor_Exception(0x03); public final Processor_Exception OVERFLOW = new Processor_Exception(0x04); public final Processor_Exception BOUND_RANGE = new Processor_Exception(0x05); public final Processor_Exception UNDEFINED = new Processor_Exception(0x06); public final Processor_Exception NO_FPU = new Processor_Exception(0x07); public final Processor_Exception DOUBLE_FAULT = new Processor_Exception(0x08); public final Processor_Exception FPU_SEGMENT_OVERRUN = new Processor_Exception(0x09); public final Processor_Exception TASK_SWITCH = new Processor_Exception(0x0a); public final Processor_Exception NOT_PRESENT = new Processor_Exception(0x0b); public final Processor_Exception STACK_SEGMENT = new Processor_Exception(0x0c); public final Processor_Exception GENERAL_PROTECTION = new Processor_Exception(0x0d); public final Processor_Exception PAGE_FAULT = new Processor_Exception(0x0e); public final Processor_Exception FLOATING_POINT = new Processor_Exception(0x10); public final Processor_Exception ALIGNMENT_CHECK = new Processor_Exception(0x11); public final Processor_Exception MACHINE_CHECK = new Processor_Exception(0x12); public final Processor_Exception SIMD_FLOATING_POINT = new Processor_Exception(0x13); public class Processor_Exception extends RuntimeException { private static final long serialVersionUID = 1L; int vector; public Processor_Exception(int vector) { this.vector=vector; } } public void constructProcessorGUICode() { processorGUICode=new ProcessorGUICode(); } public class ProcessorGUICode { private String addressString; ArrayList<GUICODE> code; ArrayList<String> name; ArrayList<String> value; int instructionNumber; // int displacement; public ProcessorGUICode() { code=new ArrayList<GUICODE>(); name=new ArrayList<String>(); value=new ArrayList<String>(); addressString=""; instructionNumber=instructionCount++; } public void updateMemoryGUI() { if (computer.memoryGUI==null) return; try{ for (int i=0; i<code.size(); i++) { int j; if (code.get(i)==null) return; switch(code.get(i)) { case CS_MEMORY_READ: computer.memoryGUI.codeRead(Integer.parseInt(name.get(i),16)); break; case CS_MEMORY_WRITE: computer.memoryGUI.codeWrite(Integer.parseInt(name.get(i),16)); break; case SS_MEMORY_READ: computer.memoryGUI.stackRead(Integer.parseInt(name.get(i),16)); break; case SS_MEMORY_WRITE: for (j=0; j<i; j++) if (code.get(j)==GUICODE.DECODE_INPUT_OPERAND_0) break; if (j<i) { int size=1; if (!name.equals("") && name.get(j).charAt(0)=='e') size=4; else if (name.get(j).equals("ax")||name.get(j).equals("bx")||name.get(j).equals("cx")||name.get(j).equals("dx")||name.get(j).equals("sp")||name.get(j).equals("bp")||name.get(j).equals("si")||name.get(j).equals("di")||name.get(j).equals("cs")||name.get(j).equals("ss")||name.get(j).equals("ds")||name.get(j).equals("es")||name.get(j).equals("fs")||name.get(j).equals("gs")||name.get(j).equals("ip")) size=2; computer.memoryGUI.stackWrite(Integer.parseInt(name.get(i),16),name.get(j),size); break; } computer.memoryGUI.stackWrite(Integer.parseInt(name.get(i),16)); break; case DS_MEMORY_READ: computer.memoryGUI.dataRead(Integer.parseInt(name.get(i),16)); break; case DS_MEMORY_WRITE: computer.memoryGUI.dataWrite(Integer.parseInt(name.get(i),16)); break; case ES_MEMORY_READ: case FS_MEMORY_READ: case GS_MEMORY_READ: computer.memoryGUI.extraRead(Integer.parseInt(name.get(i),16)); break; case ES_MEMORY_WRITE: case FS_MEMORY_WRITE: case GS_MEMORY_WRITE: computer.memoryGUI.extraWrite(Integer.parseInt(name.get(i),16)); break; case IDTR_MEMORY_READ: computer.memoryGUI.interruptRead(Integer.parseInt(name.get(i),16)); break; case IDTR_MEMORY_WRITE: computer.memoryGUI.interruptWrite(Integer.parseInt(name.get(i),16)); break; } } }catch(Exception e){} computer.memoryGUI.updateIP(cs.address(eip.getValue())); } public void updateGUI() { if (computer.processorGUI==null) return; if (!computer.debugMode && !computer.updateGUIOnPlay) return; System.out.println("Instruction "+instructionNumber+":"); for (int i=0; i<code.size(); i++) { if (computer.processorGUI!=null) computer.processorGUI.applyCode(code.get(i),name.get(i),value.get(i)); System.out.print(code.get(i)); System.out.print(" "); if (!name.get(i).equals("")) System.out.print(name.get(i)+" "); if (!value.get(i).equals("")) System.out.print(value.get(i)); System.out.println(); } } public String constructName() { boolean o0=false, i0=false; String n=""; for (int i=0; i<code.size(); i++) { if (code.get(i)==GUICODE.DECODE_INSTRUCTION) { n=name.get(i); break; } } for (int i=0; i<code.size(); i++) { if (code.get(i)==GUICODE.DECODE_OUTPUT_OPERAND_0) { n=n+" "+name.get(i); o0=true; break; } } for (int i=0; i<code.size(); i++) { if (code.get(i)==GUICODE.DECODE_INPUT_OPERAND_0) { i0=true; if(o0) n=n+" ="; if (name.get(i).equals("immediate")) n=n+" "+Integer.toHexString(getLastiCode()); else n=n+" "+name.get(i); break; } } for (int i=0; i<code.size(); i++) { if (code.get(i)==GUICODE.DECODE_INPUT_OPERAND_1) { if(i0) n=n+","; else if (o0) n=n+" ="; if (name.get(i).equals("immediate")) n=n+" "+Integer.toHexString(getLastiCode()); else n=n+" "+name.get(i); break; } } for (int i=0; i<code.size(); i++) { if (code.get(i)==GUICODE.DECODE_INPUT_OPERAND_2) { if(i0) n=n+","; else if (o0) n=n+" ="; if (name.get(i).equals("immediate")) n=n+" "+Integer.toHexString(getLastiCode()); else n=n+" "+name.get(i); break; } } return n; } public void push(GUICODE guicode) { code.add(guicode); name.add(""); value.add(""); } public void push(GUICODE guicode, String name) { code.add(guicode); this.name.add(name); value.add(""); } public void push(GUICODE guicode, String name, int value) { code.add(guicode); this.name.add(name); this.value.add(Integer.toHexString(value)); } public void push(GUICODE guicode, int name, int value) { code.add(guicode); this.name.add(Integer.toHexString(name)); this.value.add(Integer.toHexString(value)); } public void push(GUICODE guicode, int name) { code.add(guicode); this.name.add(Integer.toHexString(name)); this.value.add(""); } public void pushFetch(int ip) { push(GUICODE.FETCH,ip); } public void pushFlag(int type, int value) { String name=""; switch(type) { case Flag.AUXILIARYCARRY: name="auxiliary carry"; break; case Flag.CARRY: name="carry"; break; case Flag.SIGN: name="sign"; break; case Flag.PARITY: name="parity"; break; case Flag.ZERO: name="zero"; break; case Flag.OVERFLOW: name="overflow"; break; default: name="other"; break; } if (value==0) push(GUICODE.FLAG_CLEAR,name); else if (value==1) push(GUICODE.FLAG_SET,name); // else // push(GUICODE.FLAG_READ,name); } public void pushRegister(int id, int access, int value) { String name=""; switch(id) { case Register.EAX: name="eax"; break; case Register.EBX: name="ebx"; break; case Register.ECX: name="ecx"; break; case Register.EDX: name="edx"; break; case Register.ESI: name="esi"; break; case Register.EDI: name="edi"; break; case Register.ESP: name="esp"; break; case Register.EBP: name="ebp"; break; case Register.EIP: name="eip"; break; case Register.CR0: name="cr0"; break; case Register.CR2: name="cr2"; break; case Register.CR3: name="cr3"; break; case Register.CR4: name="cr4"; break; } if (access!=0) push(GUICODE.REGISTER_WRITE,name,value); // else // push(GUICODE.REGISTER_READ,name,value); } public void pushSegment(int id, int access, int value) { String name=""; switch(id) { case Segment.CS: name="cs"; break; case Segment.SS: name="ss"; break; case Segment.DS: name="ds"; break; case Segment.ES: name="es"; break; case Segment.FS: name="fs"; break; case Segment.GS: name="gs"; break; case Segment.IDTR: name="idtr"; break; case Segment.GDTR: name="gdtr"; break; case Segment.LDTR: name="ldtr"; break; case Segment.TSS: name="tss"; break; } if (access!=0) push(GUICODE.REGISTER_WRITE,name,value); // else // push(GUICODE.REGISTER_READ,name,value); } public void pushMemory(int segid, int segvalue, int access, int address, short value) { pushMemory(segid,segvalue,access,address,(byte)(value)); pushMemory(segid,segvalue,access,address,(byte)(value>>>8)); } public void pushMemory(int segid, int segvalue, int access, int address, int value) { pushMemory(segid,segvalue,access,address,(byte)(value)); pushMemory(segid,segvalue,access,address,(byte)(value>>>8)); pushMemory(segid,segvalue,access,address,(byte)(value>>>16)); pushMemory(segid,segvalue,access,address,(byte)(value>>>24)); } public void pushMemory(int segid, int segvalue, int access, int address, long value) { pushMemory(segid,segvalue,access,address,(byte)(value)); pushMemory(segid,segvalue,access,address,(byte)(value>>>8)); pushMemory(segid,segvalue,access,address,(byte)(value>>>16)); pushMemory(segid,segvalue,access,address,(byte)(value>>>24)); pushMemory(segid,segvalue,access,address,(byte)(value>>>32)); pushMemory(segid,segvalue,access,address,(byte)(value>>>40)); pushMemory(segid,segvalue,access,address,(byte)(value>>>48)); pushMemory(segid,segvalue,access,address,(byte)(value>>>56)); } public void pushMemory(int segid, int segvalue, int access, int address, byte value) { pushSegment(segid,0,segvalue); if(access==0) { switch(segid) { case Segment.CS: push(GUICODE.CS_MEMORY_READ,address,value); break; case Segment.SS: push(GUICODE.SS_MEMORY_READ,address,value); break; case Segment.DS: push(GUICODE.DS_MEMORY_READ,address,value); break; case Segment.ES: push(GUICODE.ES_MEMORY_READ,address,value); break; case Segment.FS: push(GUICODE.FS_MEMORY_READ,address,value); break; case Segment.GS: push(GUICODE.GS_MEMORY_READ,address,value); break; case Segment.IDTR: push(GUICODE.IDTR_MEMORY_READ,address,value); break; case Segment.GDTR: push(GUICODE.GDTR_MEMORY_READ,address,value); break; case Segment.LDTR: push(GUICODE.LDTR_MEMORY_READ,address,value); break; case Segment.TSS: push(GUICODE.TSS_MEMORY_READ,address,value); break; } } else { switch(segid) { case Segment.CS: push(GUICODE.CS_MEMORY_WRITE,address,value); break; case Segment.SS: push(GUICODE.SS_MEMORY_WRITE,address,value); break; case Segment.DS: push(GUICODE.DS_MEMORY_WRITE,address,value); break; case Segment.ES: push(GUICODE.ES_MEMORY_WRITE,address,value); break; case Segment.FS: push(GUICODE.FS_MEMORY_WRITE,address,value); break; case Segment.GS: push(GUICODE.GS_MEMORY_WRITE,address,value); break; case Segment.IDTR: push(GUICODE.IDTR_MEMORY_WRITE,address,value); break; case Segment.GDTR: push(GUICODE.GDTR_MEMORY_WRITE,address,value); break; case Segment.LDTR: push(GUICODE.LDTR_MEMORY_WRITE,address,value); break; case Segment.TSS: push(GUICODE.TSS_MEMORY_WRITE,address,value); break; } } } public void pushInstruction(MICROCODE microcode, int opcode) { String name=""; switch(microcode) { case OP_MOV: name="mov"; break; case OP_JMP_FAR: name="jmp far"; break; case OP_JMP_ABS: name="jmp abs"; break; case OP_JMP_08: name="jmp"; break; case OP_JMP_16_32: name="jmp"; break; case OP_CALL_FAR: name="call far"; break; case OP_CALL_ABS: name="call abs"; break; case OP_CALL: name="call"; break; case OP_RET: name="ret"; break; case OP_RET_IW: name="ret iw"; break; case OP_RET_FAR: name="ret far"; break; case OP_RET_FAR_IW: name="ret far iw"; break; case OP_JO: name="jo"; break; case OP_JO_16_32: name="jo"; break; case OP_JNO: name="jno"; break; case OP_JNO_16_32: name="jno"; break; case OP_JC: name="jc"; break; case OP_JC_16_32: name="jc"; break; case OP_JNC: name="jnc"; break; case OP_JNC_16_32: name="jnc"; break; case OP_JS: name="js"; break; case OP_JS_16_32: name="js"; break; case OP_JNS: name="jns"; break; case OP_JNS_16_32: name="jns"; break; case OP_JZ: name="jz"; break; case OP_JZ_16_32: name="jz"; break; case OP_JNZ: name="jnz"; break; case OP_JNZ_16_32: name="jnz"; break; case OP_JP: name="jp"; break; case OP_JP_16_32: name="jp"; break; case OP_JNP: name="jnp"; break; case OP_JNP_16_32: name="jnp"; break; case OP_JA: name="ja"; break; case OP_JA_16_32: name="ja"; break; case OP_JNA: name="jna"; break; case OP_JNA_16_32: name="jna"; break; case OP_JL: name="jl"; break; case OP_JL_16_32: name="jl"; break; case OP_JNL: name="jnl"; break; case OP_JNL_16_32: name="jnl"; break; case OP_JG: name="jg"; break; case OP_JG_16_32: name="jg"; break; case OP_JNG: name="jng"; break; case OP_JNG_16_32: name="jng"; break; case OP_LOOP_CX: name="loop cx"; break; case OP_LOOPZ_CX: name="loopz cx"; break; case OP_LOOPNZ_CX: name="loopnz cx"; break; case OP_JCXZ: name="jcxz"; break; case OP_IN_08: name="in"; break; case OP_IN_16_32: name="in"; break; case OP_INSB: name="insb"; break; case OP_INSW: name="insw"; break; case OP_REP_INSB: name="rep insb"; break; case OP_REP_INSW: name="rep insw"; break; case OP_OUT_08: name="out"; break; case OP_OUT_16_32: name="out"; break; case OP_OUTSB: name="outsb"; break; case OP_OUTSW: name="outsw"; break; case OP_REP_OUTSB: name="rep outsb"; break; case OP_REP_OUTSW: name="rep outsw"; break; case OP_INT: name="int"; break; case OP_INT3: name="int"; break; case OP_IRET: name="iret"; break; case OP_INC: name="inc"; break; case OP_DEC: name="dec"; break; case OP_ADD: name="add"; break; case OP_ADC: name="adc"; break; case OP_SUB: name="sub"; break; case OP_CMP: name="cmp"; break; case OP_SBB: name="sbb"; break; case OP_AND: name="and"; break; case OP_TEST: name="test"; break; case OP_OR: name="or"; break; case OP_XOR: name="xor"; break; case OP_ROL_08: name="rol"; break; case OP_ROL_16_32: name="rol"; break; case OP_ROR_08: name="ror"; break; case OP_ROR_16_32: name="ror"; break; case OP_RCL_08: name="rcl"; break; case OP_RCL_16_32: name="rcl"; break; case OP_RCR_08: name="rcr"; break; case OP_RCR_16_32: name="rcr"; break; case OP_SHL: name="shl"; break; case OP_SHR: name="shr"; break; case OP_SAR_08: name="sar"; break; case OP_SAR_16_32: name="sar"; break; case OP_NOT: name="not"; break; case OP_NEG: name="neg"; break; case OP_MUL_08: name="mul"; break; case OP_MUL_16_32: name="mul"; break; case OP_IMULA_08: name="imula"; break; case OP_IMULA_16_32: name="imula"; break; case OP_IMUL_16_32: name="imul"; break; case OP_DIV_08: name="div"; break; case OP_DIV_16_32: name="div"; break; case OP_IDIV_08: name="idiv"; break; case OP_IDIV_16_32: name="idiv"; break; case OP_BT_MEM: name="bt_mem"; break; case OP_BTS_MEM: name="bts_mem"; break; case OP_BTR_MEM: name="btr_mem"; break; case OP_BTC_MEM: name="btc_mem"; break; case OP_BT_16_32: name="bt"; break; case OP_BTS_16_32: name="bts"; break; case OP_BTR_16_32: name="btr"; break; case OP_BTC_16_32: name="btc"; break; case OP_SHLD_16_32: name="shld"; break; case OP_SHRD_16_32: name="shrd"; break; case OP_AAA: name="aaa"; break; case OP_AAD: name="aad"; break; case OP_AAM: name="aam"; break; case OP_AAS: name="aas"; break; case OP_CWD: name="cwd"; break; case OP_DAA: name="daa"; break; case OP_DAS: name="das"; break; case OP_BOUND: name="bound"; break; case OP_SIGN_EXTEND: name="cdw"; break; case OP_SIGN_EXTEND_8_16: name="cdw"; break; case OP_SIGN_EXTEND_8_32: name="cdw"; break; case OP_SIGN_EXTEND_16_32: name="cdw"; break; case OP_SCASB: name="scasb"; break; case OP_SCASW: name="scasw"; break; case OP_REPNE_SCASB: name="repne scasb"; break; case OP_REPE_SCASB: name="repe scasb"; break; case OP_REPNE_SCASW: name="repne scasw"; break; case OP_REPE_SCASW: name="repe scasw"; break; case OP_CMPSB: name="cmpsb"; break; case OP_CMPSW: name="cmpsw"; break; case OP_REPNE_CMPSB: name="repne cmpsb"; break; case OP_REPE_CMPSB: name="repe cmpsb"; break; case OP_REPNE_CMPSW: name="repne cmpsw"; break; case OP_REPE_CMPSW: name="repe cmpsw"; break; case OP_LODSB: name="lodsb"; break; case OP_LODSW: name="lodsw"; break; case OP_REP_LODSB: name="rep lodsb"; break; case OP_REP_LODSW: name="rep lodsw"; break; case OP_STOSB: name="stosb"; break; case OP_STOSW: name="stosw"; break; case OP_REP_STOSB: name="rep stosb"; break; case OP_REP_STOSW: name="rep stosw"; break; case OP_MOVSB: name="movsb"; break; case OP_MOVSW: name="movsw"; break; case OP_REP_MOVSB: name="rep movsb"; break; case OP_REP_MOVSW: name="rep movsw"; break; case OP_CLC: name="clc"; break; case OP_STC: name="stc"; break; case OP_CLI: name="cli"; break; case OP_STI: name="sti"; break; case OP_CLD: name="cld"; break; case OP_STD: name="std"; break; case OP_CMC: name="cmc"; break; case OP_SETO: name="seto"; break; case OP_SETNO: name="setno"; break; case OP_SETC: name="setc"; break; case OP_SETNC: name="setnc"; break; case OP_SETZ: name="setz"; break; case OP_SETNZ: name="setnz"; break; case OP_SETA: name="seta"; break; case OP_SETNA: name="setna"; break; case OP_SETL: name="setl"; break; case OP_SETNL: name="setnl"; break; case OP_SETG: name="setg"; break; case OP_SETNG: name="setng"; break; case OP_SETS: name="sets"; break; case OP_SETNS: name="setns"; break; case OP_SETP: name="setp"; break; case OP_SETNP: name="setnp"; break; case OP_SALC: name="salc"; break; case OP_LAHF: name="lahf"; break; case OP_SAHF: name="sahf"; break; case OP_CMOVO: name="cmovo"; break; case OP_CMOVNO: name="cmovno"; break; case OP_CMOVC: name="cmovc"; break; case OP_CMOVNC: name="cmovnc"; break; case OP_CMOVZ: name="cmovz"; break; case OP_CMOVNZ: name="cmovnz"; break; case OP_CMOVP: name="cmovp"; break; case OP_CMOVNP: name="cmovnp"; break; case OP_CMOVS: name="cmovs"; break; case OP_CMOVNS: name="cmovns"; break; case OP_CMOVL: name="cmovl"; break; case OP_CMOVNL: name="cmovnl"; break; case OP_CMOVG: name="cmovg"; break; case OP_CMOVNG: name="cmovng"; break; case OP_CMOVA: name="cmova"; break; case OP_CMOVNA: name="cmovna"; break; case OP_POP: name="pop"; break; case OP_POPF: name="popf"; break; case OP_POPA: name="popa"; break; case OP_LEAVE: name="leave"; break; case OP_PUSH: name="push"; break; case OP_PUSHF: name="pushf"; break; case OP_PUSHA: name="pusha"; break; case OP_ENTER: name="enter"; break; case OP_LGDT: name="lgdt"; break; case OP_LIDT: name="lidt"; break; case OP_LLDT: name="lldt"; break; case OP_LMSW: name="lmsw"; break; case OP_LTR: name="ltr"; break; case OP_SGDT: name="sgdt"; break; case OP_SIDT: name="sidt"; break; case OP_SLDT: name="sldt"; break; case OP_SMSW: name="smsw"; break; case OP_STR: name="str"; break; case OP_CLTS: name="clts"; break; case OP_CPUID: name="cpuid"; break; case OP_HALT: name="halt"; break; case OP_RDTSC: name="rdtsc"; break; default: name="nop"; break; } push(GUICODE.DECODE_INSTRUCTION, name); } public void pushMicrocode(MICROCODE microcode, int reg0, int reg1, int reg2, int addr, int displacement, boolean condition) { String name=""; switch(microcode) { case LOAD_SEG_CS: addressString="cs:"; push(GUICODE.DECODE_SEGMENT_ADDRESS,"cs"); break; case LOAD_SEG_SS: addressString="ss:"; push(GUICODE.DECODE_SEGMENT_ADDRESS,"ss"); break; case LOAD_SEG_DS: addressString="ds:"; push(GUICODE.DECODE_SEGMENT_ADDRESS,"ds"); break; case LOAD_SEG_ES: addressString="es:"; push(GUICODE.DECODE_SEGMENT_ADDRESS,"es"); break; case LOAD_SEG_FS: addressString="fs:"; push(GUICODE.DECODE_SEGMENT_ADDRESS,"fs"); break; case LOAD_SEG_GS: addressString="gs:"; push(GUICODE.DECODE_SEGMENT_ADDRESS,"gs"); break; case ADDR_AX: addressString+="ax+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"ax"); break; case ADDR_BX: addressString+="bx+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bx"); break; case ADDR_CX: addressString+="cx+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"cx"); break; case ADDR_DX: addressString+="dx+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"dx"); break; case ADDR_SP: addressString+="sp+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"sp"); break; case ADDR_BP: addressString+="bp+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bp"); break; case ADDR_SI: addressString+="si+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"si"); break; case ADDR_DI: addressString+="di+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"di"); break; case ADDR_EAX: addressString+="eax+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"ax"); break; case ADDR_EBX: addressString+="ebx+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bx"); break; case ADDR_ECX: addressString+="ecx+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"cx"); break; case ADDR_EDX: addressString+="edx+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"dx"); break; case ADDR_ESP: addressString+="esp+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"sp"); break; case ADDR_EBP: addressString+="ebp+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bp"); break; case ADDR_ESI: addressString+="esi+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"si"); break; case ADDR_EDI: addressString+="edi+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"di"); break; case ADDR_2EAX: addressString+="eax*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"ax"); break; case ADDR_2EBX: addressString+="ebx*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bx"); break; case ADDR_2ECX: addressString+="ecx*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"cx"); break; case ADDR_2EDX: addressString+="edx*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"dx"); break; case ADDR_2EBP: addressString+="ebp*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bp"); break; case ADDR_2ESI: addressString+="esi*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"si"); break; case ADDR_2EDI: addressString+="edi*2+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"di"); break; case ADDR_4EAX: addressString+="eax*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"ax"); break; case ADDR_4EBX: addressString+="ebx*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bx"); break; case ADDR_4ECX: addressString+="ecx*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"cx"); break; case ADDR_4EDX: addressString+="edx*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"dx"); break; case ADDR_4EBP: addressString+="ebp*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bp"); break; case ADDR_4ESI: addressString+="esi*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"si"); break; case ADDR_4EDI: addressString+="edi*4+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"di"); break; case ADDR_8EAX: addressString+="eax*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"ax"); break; case ADDR_8EBX: addressString+="ebx*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bx"); break; case ADDR_8ECX: addressString+="ecx*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"cx"); break; case ADDR_8EDX: addressString+="edx*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"dx"); break; case ADDR_8EBP: addressString+="ebp*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"bp"); break; case ADDR_8ESI: addressString+="esi*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"si"); break; case ADDR_8EDI: addressString+="edi*8+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"di"); break; case ADDR_IB: addressString+=Integer.toHexString(displacement)+"+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"displacement",displacement); break; case ADDR_IW: addressString+=Integer.toHexString(displacement)+"+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"displacement",displacement); break; case ADDR_ID: addressString+=Integer.toHexString(displacement)+"+"; push(GUICODE.DECODE_MEMORY_ADDRESS,"displacement",displacement); break; case LOAD2_AX: name="ax"; push(GUICODE.DECODE_INPUT_OPERAND_2,name,reg2); break; case LOAD2_EAX: name="eax"; push(GUICODE.DECODE_INPUT_OPERAND_2,name,reg2); break; case LOAD2_AL: name="al"; push(GUICODE.DECODE_INPUT_OPERAND_2,name,reg2); break; case LOAD2_CL: name="cl"; push(GUICODE.DECODE_INPUT_OPERAND_2,name,reg2); break; case LOAD2_IB: name="immediate"; push(GUICODE.DECODE_INPUT_OPERAND_2,name,reg2); break; case LOAD0_AX: name="ax"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_EAX: name="eax"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_AL: name="al"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_AH: name="ah"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_BX: name="bx"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_EBX: name="ebx"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_BL: name="bl"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_BH: name="bh"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CX: name="cx"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_ECX: name="ecx"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CL: name="cl"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CH: name="ch"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_DX: name="dx"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_EDX: name="edx"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_DL: name="dl"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_DH: name="dh"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_SI: name="si"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_ESI: name="esi"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_DI: name="di"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_EDI: name="edi"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_SP: name="sp"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_ESP: name="esp"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_BP: name="bp"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_EBP: name="ebp"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CS: name="cs"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_DS: name="ds"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_SS: name="ss"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_ES: name="es"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_FS: name="fs"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_GS: name="gs"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_FLAGS: case LOAD0_EFLAGS: name="flags"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_ADDR: name="["+addressString.substring(0,addressString.length()-1)+"]"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_IB: case LOAD0_IW: case LOAD0_ID: name="immediate"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CR0: name="cr0"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CR2: name="cr2"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CR3: name="cr3"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_CR4: name="cr4"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD0_MEM_BYTE: case LOAD0_MEM_WORD: case LOAD0_MEM_DOUBLE: name="memory["+addressString.substring(0,addressString.length()-1)+"]"; push(GUICODE.DECODE_INPUT_OPERAND_0,name,reg0); break; case LOAD1_AX: name="ax"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_EAX: name="eax"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_AL: name="al"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_AH: name="ah"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_BX: name="bx"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_EBX: name="ebx"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_BL: name="bl"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_BH: name="bh"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_CX: name="cx"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_ECX: name="ecx"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_CL: name="cl"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_CH: name="ch"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_DX: name="dx"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_EDX: name="edx"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_DL: name="dl"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_DH: name="dh"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_SI: name="si"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_ESI: name="esi"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_DI: name="di"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_EDI: name="edi"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_SP: name="sp"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_ESP: name="esp"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_BP: name="bp"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_EBP: name="ebp"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_CS: name="cs"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_DS: name="ds"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_SS: name="ss"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_ES: name="es"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_FS: name="fs"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_GS: name="gs"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_FLAGS: case LOAD1_EFLAGS: name="flags"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_IB: case LOAD1_IW: case LOAD1_ID: name="immediate"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case LOAD1_MEM_BYTE: case LOAD1_MEM_WORD: case LOAD1_MEM_DOUBLE: name="memory["+addressString.substring(0,addressString.length()-1)+"]"; push(GUICODE.DECODE_INPUT_OPERAND_1,name,reg1); break; case STORE0_AX: name="ax"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_EAX: name="eax"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_AL: name="al"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_AH: name="ah"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_BX: name="bx"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_EBX: name="ebx"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_BL: name="bl"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_BH: name="bh"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CX: name="cx"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_ECX: name="ecx"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CL: name="cl"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CH: name="ch"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_DX: name="dx"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_EDX: name="edx"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_DL: name="dl"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_DH: name="dh"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_SI: name="si"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_ESI: name="esi"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_DI: name="di"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_EDI: name="edi"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_SP: name="sp"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_ESP: name="esp"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_BP: name="bp"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_EBP: name="ebp"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CS: name="cs"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_DS: name="ds"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_SS: name="ss"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_ES: name="es"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_FS: name="fs"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_GS: name="gs"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_FLAGS: case STORE0_EFLAGS: name="flags"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CR0: name="cr0"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CR2: name="cr2"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CR3: name="cr3"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_CR4: name="cr4"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE0_MEM_BYTE: case STORE0_MEM_WORD: case STORE0_MEM_DOUBLE: name="memory["+addressString.substring(0,addressString.length()-1)+"]"; push(GUICODE.DECODE_OUTPUT_OPERAND_0,name,reg0); break; case STORE1_AX: name="ax"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_EAX: name="eax"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_AL: name="al"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_AH: name="ah"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_BX: name="bx"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_EBX: name="ebx"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_BL: name="bl"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_BH: name="bh"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_CX: name="cx"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_ECX: name="ecx"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_CL: name="cl"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_CH: name="ch"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_DX: name="dx"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_EDX: name="edx"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_DL: name="dl"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_DH: name="dh"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_SI: name="si"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_ESI: name="esi"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_DI: name="di"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_EDI: name="edi"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_SP: name="sp"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_ESP: name="esp"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_BP: name="bp"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_EBP: name="ebp"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_CS: name="cs"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_DS: name="ds"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_SS: name="ss"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_ES: name="es"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_FS: name="fs"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_GS: name="gs"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_FLAGS: case STORE1_EFLAGS: name="flags"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case STORE1_MEM_BYTE: case STORE1_MEM_WORD: case STORE1_MEM_DOUBLE: name="memory["+addressString.substring(0,addressString.length()-1)+"]"; push(GUICODE.DECODE_OUTPUT_OPERAND_1,name,reg1); break; case OP_JMP_FAR: case OP_JMP_ABS: push(GUICODE.EXECUTE_JUMP_ABSOLUTE,reg0); break; case OP_JMP_08: case OP_JMP_16_32: push(GUICODE.EXECUTE_JUMP,reg0); break; case OP_CALL_FAR: case OP_CALL_ABS: push(GUICODE.EXECUTE_CALL_STACK,reg0); push(GUICODE.EXECUTE_JUMP_ABSOLUTE,reg0); break; case OP_CALL: push(GUICODE.EXECUTE_CALL_STACK,reg0); push(GUICODE.EXECUTE_JUMP,reg0); break; case OP_RET: case OP_RET_IW: case OP_RET_FAR: case OP_RET_FAR_IW: push(GUICODE.EXECUTE_RETURN); break; case OP_JO: case OP_JO_16_32: case OP_JNO: case OP_JNO_16_32: case OP_JC: case OP_JC_16_32: case OP_JNC: case OP_JNC_16_32: case OP_JS: case OP_JS_16_32: case OP_JNS: case OP_JNS_16_32: case OP_JZ: case OP_JZ_16_32: case OP_JNZ: case OP_JNZ_16_32: case OP_JP: case OP_JP_16_32: case OP_JNP: case OP_JNP_16_32: case OP_JA: case OP_JA_16_32: case OP_JNA: case OP_JNA_16_32: case OP_JL: case OP_JL_16_32: case OP_JNL: case OP_JNL_16_32: case OP_JG: case OP_JG_16_32: case OP_JNG: case OP_JNG_16_32: case OP_LOOP_CX: case OP_LOOPZ_CX: case OP_LOOPNZ_CX: case OP_JCXZ: push(GUICODE.EXECUTE_CONDITION); if(condition) push(GUICODE.EXECUTE_JUMP,reg0); break; case OP_IN_08: case OP_IN_16_32: case OP_INSB: case OP_INSW: case OP_REP_INSB: case OP_REP_INSW: push(GUICODE.EXECUTE_PORT_READ); break; case OP_OUT_08: case OP_OUT_16_32: case OP_OUTSB: case OP_OUTSW: case OP_REP_OUTSB: case OP_REP_OUTSW: push(GUICODE.EXECUTE_PORT_WRITE); break; case OP_INT: case OP_INT3: push(GUICODE.EXECUTE_INTERRUPT,reg0); break; case OP_IRET: push(GUICODE.EXECUTE_INTERRUPT_RETURN); break; case OP_INC: case OP_DEC: case OP_NOT: case OP_NEG: case OP_SHRD_16_32: case OP_AAA: case OP_AAD: case OP_AAM: case OP_AAS: case OP_CWD: case OP_DAA: case OP_DAS: case OP_BOUND: case OP_SIGN_EXTEND: case OP_SIGN_EXTEND_8_16: case OP_SIGN_EXTEND_8_32: case OP_SIGN_EXTEND_16_32: push(GUICODE.EXECUTE_ARITHMETIC_1_1); push(GUICODE.EXECUTE_FLAG); break; case OP_ADD: case OP_ADC: case OP_SUB: case OP_CMP: case OP_SBB: case OP_AND: case OP_TEST: case OP_OR: case OP_XOR: case OP_ROL_08: case OP_ROL_16_32: case OP_ROR_08: case OP_ROR_16_32: case OP_RCL_08: case OP_RCL_16_32: case OP_RCR_08: case OP_RCR_16_32: case OP_SHL: case OP_SHR: case OP_SAR_08: case OP_SAR_16_32: case OP_MUL_08: case OP_MUL_16_32: case OP_IMULA_08: case OP_IMULA_16_32: case OP_IMUL_16_32: case OP_DIV_08: case OP_DIV_16_32: case OP_IDIV_08: case OP_IDIV_16_32: case OP_SHLD_16_32: case OP_BT_MEM: case OP_BTS_MEM: case OP_BTR_MEM: case OP_BTC_MEM: case OP_BT_16_32: case OP_BTS_16_32: case OP_BTR_16_32: case OP_BTC_16_32: push(GUICODE.EXECUTE_ARITHMETIC_2_1); push(GUICODE.EXECUTE_FLAG); break; case OP_SCASB: case OP_SCASW: case OP_REPNE_SCASB: case OP_REPE_SCASB: case OP_REPNE_SCASW: case OP_REPE_SCASW: case OP_CMPSB: case OP_CMPSW: case OP_REPNE_CMPSB: case OP_REPE_CMPSB: case OP_REPNE_CMPSW: case OP_REPE_CMPSW: push(GUICODE.EXECUTE_MEMORY_COMPARE); break; case OP_LODSB: case OP_LODSW: case OP_REP_LODSB: case OP_REP_LODSW: case OP_STOSB: case OP_STOSW: case OP_REP_STOSB: case OP_REP_STOSW: case OP_MOVSB: case OP_MOVSW: case OP_REP_MOVSB: case OP_REP_MOVSW: push(GUICODE.EXECUTE_MEMORY_TRANSFER); break; case OP_CLC: case OP_STC: case OP_CLI: case OP_STI: case OP_CLD: case OP_STD: case OP_CMC: case OP_SETO: case OP_SETNO: case OP_SETC: case OP_SETNC: case OP_SETZ: case OP_SETNZ: case OP_SETA: case OP_SETNA: case OP_SETL: case OP_SETNL: case OP_SETG: case OP_SETNG: case OP_SETS: case OP_SETNS: case OP_SETP: case OP_SETNP: case OP_SALC: case OP_LAHF: case OP_SAHF: push(GUICODE.EXECUTE_FLAG); break; case OP_CMOVO: case OP_CMOVNO: case OP_CMOVC: case OP_CMOVNC: case OP_CMOVZ: case OP_CMOVNZ: case OP_CMOVP: case OP_CMOVNP: case OP_CMOVS: case OP_CMOVNS: case OP_CMOVL: case OP_CMOVNL: case OP_CMOVG: case OP_CMOVNG: case OP_CMOVA: case OP_CMOVNA: push(GUICODE.EXECUTE_CONDITION); if(condition) push(GUICODE.EXECUTE_TRANSFER); break; case OP_POP: case OP_POPF: case OP_POPA: case OP_LEAVE: push(GUICODE.EXECUTE_POP); break; case OP_PUSH: case OP_PUSHF: case OP_PUSHA: case OP_ENTER: push(GUICODE.EXECUTE_PUSH); break; case OP_LGDT: case OP_LIDT: case OP_LLDT: case OP_LMSW: case OP_LTR: case OP_SGDT: case OP_SIDT: case OP_SLDT: case OP_SMSW: case OP_STR: case OP_CPUID: case OP_RDTSC: push(GUICODE.EXECUTE_TRANSFER); break; case OP_HALT: push(GUICODE.EXECUTE_HALT); break; } } } enum MICROCODE { PREFIX_LOCK, PREFIX_REPNE, PREFIX_REPE, PREFIX_CS, PREFIX_SS, PREFIX_DS, PREFIX_ES, PREFIX_FS, PREFIX_GS, PREFIX_OPCODE_32BIT, PREFIX_ADDRESS_32BIT, LOAD0_AX, LOAD0_AL, LOAD0_AH, LOAD0_BX, LOAD0_BL, LOAD0_BH, LOAD0_CX, LOAD0_CL, LOAD0_CH, LOAD0_DX, LOAD0_DL, LOAD0_DH, LOAD0_SP, LOAD0_BP, LOAD0_SI, LOAD0_DI, LOAD0_CS, LOAD0_SS, LOAD0_DS, LOAD0_ES, LOAD0_FS, LOAD0_GS, LOAD0_FLAGS, LOAD1_AX, LOAD1_AL, LOAD1_AH, LOAD1_BX, LOAD1_BL, LOAD1_BH, LOAD1_CX, LOAD1_CL, LOAD1_CH, LOAD1_DX, LOAD1_DL, LOAD1_DH, LOAD1_SP, LOAD1_BP, LOAD1_SI, LOAD1_DI, LOAD1_CS, LOAD1_SS, LOAD1_DS, LOAD1_ES, LOAD1_FS, LOAD1_GS, LOAD1_FLAGS, STORE0_AX, STORE0_AL, STORE0_AH, STORE0_BX, STORE0_BL, STORE0_BH, STORE0_CX, STORE0_CL, STORE0_CH, STORE0_DX, STORE0_DL, STORE0_DH, STORE0_SP, STORE0_BP, STORE0_SI, STORE0_DI, STORE0_CS, STORE0_SS, STORE0_DS, STORE0_ES, STORE0_FS, STORE0_GS, STORE1_AX, STORE1_AL, STORE1_AH, STORE1_BX, STORE1_BL, STORE1_BH, STORE1_CX, STORE1_CL, STORE1_CH, STORE1_DX, STORE1_DL, STORE1_DH, STORE1_SP, STORE1_BP, STORE1_SI, STORE1_DI, STORE1_CS, STORE1_SS, STORE1_DS, STORE1_ES, STORE1_FS, STORE1_GS, STORE1_FLAGS, LOAD0_MEM_BYTE, LOAD0_MEM_WORD, STORE0_MEM_BYTE, STORE0_MEM_WORD, LOAD1_MEM_BYTE, LOAD1_MEM_WORD, STORE1_MEM_BYTE, STORE1_MEM_WORD, STORE1_ESP, STORE0_FLAGS, LOAD0_IB, LOAD0_IW, LOAD1_IB, LOAD1_IW, LOAD_SEG_CS, LOAD_SEG_SS, LOAD_SEG_DS, LOAD_SEG_ES, LOAD_SEG_FS, LOAD_SEG_GS, LOAD0_ADDR, LOAD0_EAX, LOAD0_EBX, LOAD0_ECX, LOAD0_EDX, LOAD0_ESI, LOAD0_EDI, LOAD0_EBP, LOAD0_ESP, LOAD1_EAX, LOAD1_EBX, LOAD1_ECX, LOAD1_EDX, LOAD1_ESI, LOAD1_EDI, LOAD1_EBP, LOAD1_ESP, STORE0_EAX, STORE0_EBX, STORE0_ECX, STORE0_EDX, STORE0_ESI, STORE0_EDI, STORE0_ESP, STORE0_EBP, STORE1_EAX, STORE1_EBX, STORE1_ECX, STORE1_EDX, STORE1_ESI, STORE1_EDI, STORE1_EBP, LOAD0_MEM_DOUBLE, LOAD1_MEM_DOUBLE, STORE0_MEM_DOUBLE, STORE1_MEM_DOUBLE, LOAD0_EFLAGS, LOAD1_EFLAGS, STORE0_EFLAGS, STORE1_EFLAGS, LOAD0_ID, LOAD1_ID, LOAD0_CR0, LOAD0_CR2, LOAD0_CR3, LOAD0_CR4, STORE0_CR0, STORE0_CR2, STORE0_CR3, STORE0_CR4, LOAD2_AL, LOAD2_CL, LOAD2_AX, LOAD2_EAX, LOAD2_IB, FLAG_BITWISE_08, FLAG_BITWISE_16, FLAG_BITWISE_32, FLAG_SUB_08, FLAG_SUB_16, FLAG_SUB_32, FLAG_REP_SUB_08, FLAG_REP_SUB_16, FLAG_REP_SUB_32, FLAG_ADD_08, FLAG_ADD_16, FLAG_ADD_32, FLAG_ADC_08, FLAG_ADC_16, FLAG_ADC_32, FLAG_SBB_08, FLAG_SBB_16, FLAG_SBB_32, FLAG_DEC_08, FLAG_DEC_16, FLAG_DEC_32, FLAG_INC_08, FLAG_INC_16, FLAG_INC_32, FLAG_SHL_08, FLAG_SHL_16, FLAG_SHL_32, FLAG_SHR_08, FLAG_SHR_16, FLAG_SHR_32, FLAG_SAR_08, FLAG_SAR_16, FLAG_SAR_32, FLAG_RCL_08, FLAG_RCL_16, FLAG_RCL_32, FLAG_RCR_08, FLAG_RCR_16, FLAG_RCR_32, FLAG_ROL_08, FLAG_ROL_16, FLAG_ROL_32, FLAG_ROR_08, FLAG_ROR_16, FLAG_ROR_32, FLAG_NEG_08, FLAG_NEG_16, FLAG_NEG_32, FLAG_ROTATE_08, FLAG_ROTATE_16, FLAG_ROTATE_32, FLAG_UNIMPLEMENTED, FLAG_8F, FLAG_NONE, FLAG_BAD, FLAG_80_82, FLAG_81_83, FLAG_FF, FLAG_F6, FLAG_F7, FLAG_FE, FLAG_FLOAT_NOP, ADDR_AX, ADDR_BX, ADDR_CX, ADDR_DX, ADDR_SP, ADDR_BP, ADDR_SI, ADDR_DI, ADDR_IB, ADDR_IW, ADDR_AL, ADDR_EAX, ADDR_EBX, ADDR_ECX, ADDR_EDX, ADDR_ESP, ADDR_EBP, ADDR_ESI, ADDR_EDI, ADDR_ID, ADDR_MASK_16, ADDR_2EAX, ADDR_2EBX, ADDR_2ECX, ADDR_2EDX, ADDR_2EBP, ADDR_2ESI, ADDR_2EDI, ADDR_4EAX, ADDR_4EBX, ADDR_4ECX, ADDR_4EDX, ADDR_4EBP, ADDR_4ESI, ADDR_4EDI, ADDR_8EAX, ADDR_8EBX, ADDR_8ECX, ADDR_8EDX, ADDR_8EBP, ADDR_8ESI, ADDR_8EDI, OP_JMP_FAR, OP_JMP_ABS, OP_CALL, OP_CALL_FAR, OP_CALL_ABS, OP_RET, OP_RET_IW, OP_RET_FAR, OP_RET_FAR_IW, OP_ENTER, OP_LEAVE, OP_JMP_08, OP_JMP_16_32, OP_JO, OP_JO_16_32, OP_JNO, OP_JNO_16_32, OP_JC, OP_JC_16_32, OP_JNC, OP_JNC_16_32, OP_JZ, OP_JZ_16_32, OP_JNZ, OP_JNZ_16_32, OP_JS, OP_JS_16_32, OP_JNS, OP_JNS_16_32, OP_JP, OP_JP_16_32, OP_JNP, OP_JNP_16_32, OP_JA, OP_JA_16_32, OP_JNA, OP_JNA_16_32, OP_JL, OP_JL_16_32, OP_JNL, OP_JNL_16_32, OP_JG, OP_JG_16_32, OP_JNG, OP_JNG_16_32, OP_INT, OP_INT3, OP_IRET, OP_IN_08, OP_IN_16_32, OP_OUT_08, OP_OUT_16_32, OP_INC, OP_DEC, OP_ADD, OP_ADC, OP_SUB, OP_SBB, OP_AND, OP_TEST, OP_OR, OP_XOR, OP_ROL_08, OP_ROL_16_32, OP_ROR_08, OP_ROR_16_32, OP_RCL_08, OP_RCL_16_32, OP_RCR_08, OP_RCR_16_32, OP_SHR, OP_SAR_08, OP_SAR_16_32, OP_NOT, OP_NEG, OP_MUL_08, OP_MUL_16_32, OP_IMULA_08, OP_IMULA_16_32, OP_IMUL_16_32, OP_BSF, OP_BSR, OP_BT_MEM, OP_BTS_MEM, OP_BTR_MEM, OP_BTC_MEM, OP_BT_16_32, OP_BTS_16_32, OP_BTR_16_32, OP_BTC_16_32, OP_SHLD_16_32, OP_SHRD_16_32, OP_CWD, OP_CDQ, OP_AAA, OP_AAD, OP_AAM, OP_AAS, OP_DAA, OP_DAS, OP_BOUND, OP_CLC, OP_STC, OP_CLI, OP_STI, OP_CLD, OP_STD, OP_CMC, OP_SETO, OP_SETNO, OP_SETC, OP_SETNC, OP_SETZ, OP_SETNZ, OP_SETA, OP_SETNA, OP_SETS, OP_SETNS, OP_SETP, OP_SETNP, OP_SETL, OP_SETNL, OP_SETG, OP_SETNG, OP_SALC, OP_CMOVO, OP_CMOVNO, OP_CMOVC, OP_CMOVNC, OP_CMOVZ, OP_CMOVNZ, OP_CMOVS, OP_CMOVNS, OP_CMOVP, OP_CMOVNP, OP_CMOVA, OP_CMOVNA, OP_CMOVL, OP_CMOVNL, OP_CMOVG, OP_CMOVNG, OP_LAHF, OP_SAHF, OP_POP, OP_POPF, OP_PUSH, OP_PUSHA, OP_POPA, OP_SIGN_EXTEND_8_16, OP_SIGN_EXTEND_8_32, OP_SIGN_EXTEND_16_32, OP_SIGN_EXTEND, OP_INSB, OP_INSW, OP_REP_INSB, OP_REP_INSW, OP_LODSB, OP_LODSW, OP_REP_LODSB, OP_REP_LODSW, OP_MOVSB, OP_MOVSW, OP_REP_MOVSB, OP_REP_MOVSW, OP_OUTSB, OP_OUTSW, OP_REP_OUTSB, OP_REP_OUTSW, OP_STOSB, OP_STOSW, OP_REP_STOSB, OP_REP_STOSW, OP_LOOP_CX, OP_LOOPZ_CX, OP_LOOPNZ_CX, OP_JCXZ, OP_HALT, OP_CPUID, OP_NOP, OP_MOV, OP_CMP, OP_BAD, OP_UNIMPLEMENTED, OP_ROTATE_08, OP_ROTATE_16_32, OP_INT0, OP_CBW, OP_PUSHF, OP_SHL, OP_80_83, OP_FF, OP_F6, OP_F7, OP_DIV_08, OP_DIV_16_32, OP_IDIV_08, OP_IDIV_16_32, OP_SCASB, OP_SCASW, OP_REPE_SCASB, OP_REPE_SCASW, OP_REPNE_SCASB, OP_REPNE_SCASW, OP_CMPSB, OP_CMPSW, OP_REPE_CMPSB, OP_REPE_CMPSW, OP_REPNE_CMPSB, OP_REPNE_CMPSW, OP_FE, OP_FLOAT_NOP, OP_SGDT, OP_SIDT, OP_LGDT, OP_LIDT, OP_SMSW, OP_LMSW, OP_F01, OP_F00, OP_SLDT, OP_STR, OP_LLDT, OP_LTR, OP_VERR, OP_VERW, OP_CLTS, OP_RDTSC } enum GUICODE { //processor action codes FETCH, DECODE_PREFIX, DECODE_INSTRUCTION, DECODE_OPCODE, DECODE_MODRM, DECODE_SIB, DECODE_INPUT_OPERAND_0, DECODE_INPUT_OPERAND_1, DECODE_INPUT_OPERAND_2, DECODE_OUTPUT_OPERAND_0, DECODE_OUTPUT_OPERAND_1, DECODE_IMMEDIATE, DECODE_DISPLACEMENT, HARDWARE_INTERRUPT, SOFTWARE_INTERRUPT, EXCEPTION, DECODE_MEMORY_ADDRESS, DECODE_SEGMENT_ADDRESS, EXECUTE_JUMP, EXECUTE_JUMP_ABSOLUTE, EXECUTE_RETURN, EXECUTE_CALL_STACK, EXECUTE_CONDITION, EXECUTE_PORT_READ, EXECUTE_PORT_WRITE, EXECUTE_INTERRUPT, EXECUTE_INTERRUPT_RETURN, EXECUTE_ARITHMETIC_1_1, EXECUTE_ARITHMETIC_2_1, EXECUTE_MEMORY_COMPARE, EXECUTE_MEMORY_TRANSFER, EXECUTE_FLAG, EXECUTE_TRANSFER, EXECUTE_PUSH, EXECUTE_POP, EXECUTE_HALT, //mode codes MODE_REAL, MODE_PROTECTED, //storage codes FLAG_SET, FLAG_CLEAR, FLAG_READ, REGISTER_READ, REGISTER_WRITE, PORT_READ, PORT_WRITE, CS_MEMORY_READ, CS_MEMORY_WRITE, SS_MEMORY_READ, SS_MEMORY_WRITE, DS_MEMORY_READ, DS_MEMORY_WRITE, ES_MEMORY_READ, ES_MEMORY_WRITE, FS_MEMORY_READ, FS_MEMORY_WRITE, GS_MEMORY_READ, GS_MEMORY_WRITE, IDTR_MEMORY_READ, IDTR_MEMORY_WRITE, GDTR_MEMORY_READ, GDTR_MEMORY_WRITE, LDTR_MEMORY_READ, LDTR_MEMORY_WRITE, TSS_MEMORY_READ, TSS_MEMORY_WRITE, }; //decode tables public static final MICROCODE[] rotationTable = new MICROCODE[] { MICROCODE.FLAG_ROL_08, MICROCODE.FLAG_ROR_08, MICROCODE.FLAG_RCL_08, MICROCODE.FLAG_RCR_08, MICROCODE.FLAG_SHL_08, MICROCODE.FLAG_SHR_08, MICROCODE.FLAG_SHL_08, MICROCODE.FLAG_SAR_08, MICROCODE.FLAG_ROL_16, MICROCODE.FLAG_ROR_16, MICROCODE.FLAG_RCL_16, MICROCODE.FLAG_RCR_16, MICROCODE.FLAG_SHL_16, MICROCODE.FLAG_SHR_16, MICROCODE.FLAG_SHL_16, MICROCODE.FLAG_SAR_16, MICROCODE.OP_ROL_08, MICROCODE.OP_ROR_08, MICROCODE.OP_RCL_08, MICROCODE.OP_RCR_08, MICROCODE.OP_SHL, MICROCODE.OP_SHR, MICROCODE.OP_SHL, MICROCODE.OP_SAR_08, MICROCODE.OP_ROL_16_32, MICROCODE.OP_ROR_16_32, MICROCODE.OP_RCL_16_32, MICROCODE.OP_RCR_16_32, MICROCODE.OP_SHL, MICROCODE.OP_SHR, MICROCODE.OP_SHL, MICROCODE.OP_SAR_16_32 }; public static final int[][] inputTable0 = new int[][] { //effective byte {0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x84, 0x86, 0x8a, 0xfb6, 0xfbe, 0x80, 0x82, 0xc0, 0xfb0, 0xd0, 0xd2, 0xf6, 0xfe}, //effective word {0x01, 0x09, 0x11, 0x19, 0x21, 0x29, 0x31, 0x39, 0x85, 0x87, 0x8b, 0x81, 0xc1, 0x83, 0x69, 0x6b, 0xc4, 0xc5, 0xfb2, 0xfb4, 0xfb5, 0xfa4, 0xfac, 0xfa5, 0xfad, 0xfb1, 0xd1, 0xd3, 0xfb1, 0xff, 0xf7}, //register byte {0x88, 0x02, 0x0a, 0x12, 0x1a, 0x22, 0x2a, 0x32, 0x3a, 0xfc0}, //register word {0x89, 0x03, 0x0b, 0x13, 0x1b, 0x23, 0x2b, 0x33, 0x3b, 0xfaf, 0xfbc, 0xfbd, 0xfc1, 0xf40, 0xf41, 0xf42, 0xf43, 0xf44, 0xf45, 0xf46, 0xf47, 0xf48, 0xf49, 0xf4a, 0xf4b, 0xf4c, 0xf4d, 0xf4e, 0xf4f}, //immediate byte {0xc6, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xe4, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0xcd, 0xd4, 0xd5, 0xe0, 0xe1, 0xe2, 0xe3, 0xeb, 0xe5, 0xe6, 0xe7}, //immediate word {0xc7, 0x68, 0x6a, 0xe8, 0xe9, 0xf80, 0xf81, 0xf82, 0xf83, 0xf84, 0xf85, 0xf86, 0xf87, 0xf88, 0xf89, 0xf8a, 0xf8b, 0xf8c, 0xf8d, 0xf8e, 0xf8f, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf}, //AX {0x05, 0x0d, 0x15, 0x1d, 0x25, 0x2d, 0x35, 0x3d, 0xa9, 0x40, 0x48, 0x50, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0xa3, 0xab, 0xaf}, //AL {0x04, 0x0c, 0x14, 0x1c, 0x24, 0x2c, 0x34, 0x3c, 0xa8, 0xa2, 0xaa, 0xae},{}, //BX {0x43, 0x4b, 0x53},{},{}, //CX {0x41, 0x49, 0x51, 0xf30, 0xf32},{},{}, //DX {0x42, 0x4a, 0x52},{},{}, //SP {0x44, 0x4c, 0x54}, //BP {0x45, 0x4d, 0x55}, //SI {0x46, 0x4e, 0x56}, //DI {0x47, 0x4f, 0x57}, //CS {0x0e}, //SS {0x16}, //DS {0x1e}, //ES {0x06}, //FS {0xfa0}, //GS {0xfa8}, //flags {0x9c}, //special {0x9a, 0xea, 0xc8, 0x62, 0x8c, 0xa0, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, 0xac, 0xad, 0xfa3, 0xfab, 0xfb3, 0xfbb, 0x6e, 0x6f, 0xd7, 0xf00, 0xf01, 0xf20, 0xf21, 0xf22, 0xf23, 0xfba, 0xfc8, 0xfc9, 0xfca, 0xfcb, 0xfcc, 0xfcd, 0xfce, 0xfcf, 0x8d, 0xec, 0xed, 0xee, 0xef, 0x8e, 0xfb7, 0xfbf, 0x6c, 0x6d, 0xca, 0xc2} }; public static final int[][] inputTable1 = new int[][] { //effective byte {0x02, 0x0a, 0x12, 0x1a, 0x22, 0x2a, 0x32, 0x3a, 0xfc0}, //effective word {0x03, 0x0b, 0x13, 0x1b, 0x23, 0x2b, 0x33, 0x3b, 0xfaf, 0xfbc, 0xfbd, 0xfc1, 0xf40, 0xf41, 0xf42, 0xf43, 0xf44, 0xf45, 0xf46, 0xf47, 0xf48, 0xf49, 0xf4a, 0xf4b, 0xf4c, 0xf4d, 0xf4e, 0xf4f}, //register byte {0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x84, 0x86, 0xfb0}, //register word {0x01, 0x09, 0x11, 0x19, 0x21, 0x29, 0x31, 0x39, 0x85, 0x87, 0x62, 0xfa4, 0xfac, 0xfa5, 0xfad, 0xfb1}, //immediate byte {0x04, 0x0c, 0x14, 0x1c, 0x24, 0x2c, 0x34, 0x3c, 0xa8, 0x80, 0x82, 0xc0, 0xc1}, //immediate word {0x69, 0x6b, 0x05, 0x0d, 0x15, 0x1d, 0x25, 0x2d, 0x35, 0x3d, 0xa9, 0x81, 0x83}, //AX {0xef, 0xe7}, //AL {0xee, 0xe6},{}, //BX {0x93},{},{}, //CX {0x91}, //CL {0xd2, 0xd3},{}, //DX {0x92, 0xf30},{},{}, //SP {0x94}, //BP {0x95}, //SI {0x96}, //DI {0x97},{},{},{},{},{},{},{}, //special {0x9a, 0xea, 0xc8, 0xf6, 0xf7, 0x62, 0xc4, 0xc5, 0xfb2, 0xfb4, 0xfb5, 0xfba, 0xff, 0xd1, 0xd0, 0xf01, 0xfa3, 0xfab, 0xfb3, 0xfbb} }; public static final int[][] outputTable0 = new int[][] { //effective byte {0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x88, 0xc0, 0xc6, 0xfe, 0xf90, 0xf91, 0xf92, 0xf93, 0xf94, 0xf95, 0xf96, 0xf97, 0xf98, 0xf99, 0xf9a, 0xf9b, 0xf9c, 0xf9d, 0xf9e, 0xf9f, 0xfb0, 0xfc0, 0xd0, 0xd2}, //effective word {0x01, 0x09, 0x11, 0x19, 0x21, 0x29, 0x31, 0x89, 0x21, 0x29, 0x31, 0x89, 0xc7, 0xc1, 0x8f, 0xd1, 0xd3, 0x8c, 0xfa4, 0xfa5, 0xfac, 0xfad, 0xfc1, 0xfb1}, //register byte {0x86, 0x02, 0x0a, 0x12, 0x1a, 0x22, 0x2a, 0x32, 0x8a}, //register word {0x87, 0x03, 0x0b, 0x13, 0x1b, 0x23, 0x2b, 0x33, 0x69, 0x6b, 0x8b, 0x8d, 0xf40, 0xf41, 0xf42, 0xf43, 0xf44, 0xf45, 0xf46, 0xf47, 0xf48, 0xf49, 0xf4a, 0xf4b, 0xf4c, 0xf4d, 0xf4e, 0xf4f, 0xfaf, 0xfb6, 0xfb7, 0xfbc, 0xfbd, 0xfbe, 0xfbf, 0xfb2, 0xfb4, 0xfb5, 0x62, 0xc4, 0xc5},{},{}, //AX {0x05, 0x0d, 0x15, 0x1d, 0x25, 0x2d, 0x35, 0xb8, 0xe5, 0x40, 0x48, 0x58, 0xed, 0xa1}, //AL {0xec, 0x04, 0x0c, 0x14, 0x1c, 0x24, 0x2c, 0x34, 0xe4, 0xb0, 0xa0, 0xd6, 0xd7}, //AH {0xb4}, //BX {0x43, 0x4b, 0x5b, 0xbb, 0x93}, //BL {0xb3}, //BH {0xb7}, //CX {0x41, 0x49, 0x59, 0xb9, 0x91}, //CL {0xb1}, //CH {0xb5}, //DX {0x42, 0x4a, 0x5a, 0xba, 0x92}, //DL {0xb2}, //DH {0xb6}, //SP {0x44, 0x4c, 0x5c, 0xbc, 0x94}, //BP {0x45, 0x4d, 0x5d, 0xbd, 0x95}, //SI {0x46, 0x4e, 0x5e, 0xbe, 0x96}, //DI {0x47, 0x4f, 0x5f, 0xbf, 0x97},{}, //SS {0x17}, //DS {0x1f}, //ES {0x07}, //FS {0xfa1}, //GS {0xfa9}, //flags {0x9d}, //special {0x8e, 0xa2, 0xa3, 0xd0, 0xd1, 0xf6, 0xf7, 0xff, 0xf00, 0xf01, 0xf20, 0xf21, 0xf22, 0xf23, 0xf31, 0xf32, 0xfab, 0xfb3, 0xfbb, 0xfba, 0xfc8, 0xfc9, 0xfca, 0xfcb, 0xfcc, 0xfcd, 0xfce, 0xfcf, 0x80, 0x81, 0x82, 0x83} }; public static final int[][] outputTable1 = new int[][] { //effective byte {0x86}, //effective word {0x87}, {},{},{},{}, //AX {0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97}, {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}, //SS {0xfb2}, //DS {0xc5}, //ES {0xc4}, //FS {0xfb4}, //GS {0xfb5},{}, //special {0xf01, 0xf31, 0xf32} }; public static final MICROCODE[] operandRegisterTable = new MICROCODE[] { MICROCODE.LOAD0_AX, MICROCODE.LOAD0_AL, MICROCODE.LOAD0_AH, MICROCODE.LOAD0_BX, MICROCODE.LOAD0_BL, MICROCODE.LOAD0_BH, MICROCODE.LOAD0_CX, MICROCODE.LOAD0_CL, MICROCODE.LOAD0_CH, MICROCODE.LOAD0_DX, MICROCODE.LOAD0_DL, MICROCODE.LOAD0_DH, MICROCODE.LOAD0_SP, MICROCODE.LOAD0_BP, MICROCODE.LOAD0_SI, MICROCODE.LOAD0_DI, MICROCODE.LOAD0_CS, MICROCODE.LOAD0_SS, MICROCODE.LOAD0_DS, MICROCODE.LOAD0_ES, MICROCODE.LOAD0_FS, MICROCODE.LOAD0_GS, MICROCODE.LOAD0_FLAGS, MICROCODE.LOAD1_AX, MICROCODE.LOAD1_AL, MICROCODE.LOAD1_AH, MICROCODE.LOAD1_BX, MICROCODE.LOAD1_BL, MICROCODE.LOAD1_BH, MICROCODE.LOAD1_CX, MICROCODE.LOAD1_CL, MICROCODE.LOAD1_CH, MICROCODE.LOAD1_DX, MICROCODE.LOAD1_DL, MICROCODE.LOAD1_DH, MICROCODE.LOAD1_SP, MICROCODE.LOAD1_BP, MICROCODE.LOAD1_SI, MICROCODE.LOAD1_DI, MICROCODE.LOAD1_CS, MICROCODE.LOAD1_SS, MICROCODE.LOAD1_DS, MICROCODE.LOAD1_ES, MICROCODE.LOAD1_FS, MICROCODE.LOAD1_GS, MICROCODE.LOAD1_FLAGS, MICROCODE.STORE0_AX, MICROCODE.STORE0_AL, MICROCODE.STORE0_AH, MICROCODE.STORE0_BX, MICROCODE.STORE0_BL, MICROCODE.STORE0_BH, MICROCODE.STORE0_CX, MICROCODE.STORE0_CL, MICROCODE.STORE0_CH, MICROCODE.STORE0_DX, MICROCODE.STORE0_DL, MICROCODE.STORE0_DH, MICROCODE.STORE0_SP, MICROCODE.STORE0_BP, MICROCODE.STORE0_SI, MICROCODE.STORE0_DI, MICROCODE.STORE0_CS, MICROCODE.STORE0_SS, MICROCODE.STORE0_DS, MICROCODE.STORE0_ES, MICROCODE.STORE0_FS, MICROCODE.STORE0_GS, MICROCODE.STORE0_FLAGS, MICROCODE.STORE1_AX, MICROCODE.STORE1_AL, MICROCODE.STORE1_AH, MICROCODE.STORE1_BX, MICROCODE.STORE1_BL, MICROCODE.STORE1_BH, MICROCODE.STORE1_CX, MICROCODE.STORE1_CL, MICROCODE.STORE1_CH, MICROCODE.STORE1_DX, MICROCODE.STORE1_DL, MICROCODE.STORE1_DH, MICROCODE.STORE1_SP, MICROCODE.STORE1_BP, MICROCODE.STORE1_SI, MICROCODE.STORE1_DI, MICROCODE.STORE1_CS, MICROCODE.STORE1_SS, MICROCODE.STORE1_DS, MICROCODE.STORE1_ES, MICROCODE.STORE1_FS, MICROCODE.STORE1_GS, MICROCODE.STORE1_FLAGS }; public static final MICROCODE[] modrmRegisterTable = new MICROCODE[] { MICROCODE.LOAD0_AL, MICROCODE.LOAD0_CL, MICROCODE.LOAD0_DL, MICROCODE.LOAD0_BL, MICROCODE.LOAD0_AH, MICROCODE.LOAD0_CH, MICROCODE.LOAD0_DH, MICROCODE.LOAD0_BH, MICROCODE.LOAD0_MEM_BYTE, MICROCODE.LOAD1_AL, MICROCODE.LOAD1_CL, MICROCODE.LOAD1_DL, MICROCODE.LOAD1_BL, MICROCODE.LOAD1_AH, MICROCODE.LOAD1_CH, MICROCODE.LOAD1_DH, MICROCODE.LOAD1_BH, MICROCODE.LOAD1_MEM_BYTE, MICROCODE.STORE0_AL, MICROCODE.STORE0_CL, MICROCODE.STORE0_DL, MICROCODE.STORE0_BL, MICROCODE.STORE0_AH, MICROCODE.STORE0_CH, MICROCODE.STORE0_DH, MICROCODE.STORE0_BH, MICROCODE.STORE0_MEM_BYTE, MICROCODE.STORE1_AL, MICROCODE.STORE1_CL, MICROCODE.STORE1_DL, MICROCODE.STORE1_BL, MICROCODE.STORE1_AH, MICROCODE.STORE1_CH, MICROCODE.STORE1_DH, MICROCODE.STORE1_BH, MICROCODE.STORE1_MEM_BYTE, MICROCODE.LOAD0_AX, MICROCODE.LOAD0_CX, MICROCODE.LOAD0_DX, MICROCODE.LOAD0_BX, MICROCODE.LOAD0_SP, MICROCODE.LOAD0_BP, MICROCODE.LOAD0_SI, MICROCODE.LOAD0_DI, MICROCODE.LOAD0_MEM_WORD, MICROCODE.LOAD1_AX, MICROCODE.LOAD1_CX, MICROCODE.LOAD1_DX, MICROCODE.LOAD1_BX, MICROCODE.LOAD1_SP, MICROCODE.LOAD1_BP, MICROCODE.LOAD1_SI, MICROCODE.LOAD1_DI, MICROCODE.LOAD1_MEM_WORD, MICROCODE.STORE0_AX, MICROCODE.STORE0_CX, MICROCODE.STORE0_DX, MICROCODE.STORE0_BX, MICROCODE.STORE0_SP, MICROCODE.STORE0_BP, MICROCODE.STORE0_SI, MICROCODE.STORE0_DI, MICROCODE.STORE0_MEM_WORD, MICROCODE.STORE1_AX, MICROCODE.STORE1_CX, MICROCODE.STORE1_DX, MICROCODE.STORE1_BX, MICROCODE.STORE1_SP, MICROCODE.STORE1_BP, MICROCODE.STORE1_SI, MICROCODE.STORE1_DI, MICROCODE.STORE1_MEM_WORD, MICROCODE.LOAD0_EAX, MICROCODE.LOAD0_ECX, MICROCODE.LOAD0_EDX, MICROCODE.LOAD0_EBX, MICROCODE.LOAD0_ESP, MICROCODE.LOAD0_EBP, MICROCODE.LOAD0_ESI, MICROCODE.LOAD0_EDI, MICROCODE.LOAD0_MEM_DOUBLE, MICROCODE.LOAD1_EAX, MICROCODE.LOAD1_ECX, MICROCODE.LOAD1_EDX, MICROCODE.LOAD1_EBX, MICROCODE.LOAD1_ESP, MICROCODE.LOAD1_EBP, MICROCODE.LOAD1_ESI, MICROCODE.LOAD1_EDI, MICROCODE.LOAD1_MEM_DOUBLE, MICROCODE.STORE0_EAX, MICROCODE.STORE0_ECX, MICROCODE.STORE0_EDX, MICROCODE.STORE0_EBX, MICROCODE.STORE0_ESP, MICROCODE.STORE0_EBP, MICROCODE.STORE0_ESI, MICROCODE.STORE0_EDI, MICROCODE.STORE0_MEM_DOUBLE, MICROCODE.STORE1_EAX, MICROCODE.STORE1_ECX, MICROCODE.STORE1_EDX, MICROCODE.STORE1_EBX, MICROCODE.STORE1_ESP, MICROCODE.STORE1_EBP, MICROCODE.STORE1_ESI, MICROCODE.STORE1_EDI, MICROCODE.STORE1_MEM_DOUBLE }; //indexed by the opcode value //tells whether the instruction has a displacement, and if so, how many bytes //a displacement is an immediate added to the memory address public static final int[] hasDisplacementTable = new int[] { 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; //indexed by the opcode value //tells whether the opcode is followed by an immediate, and if so, how many bytes public static final int[] hasImmediateTable = new int[] { 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 2, 0, 0, 0, 1, 4, 3, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //this list, indexed by the opcode value, tells whether the opcode is followed by a MODR/M byte private static int[] modrmTable = new int[] { 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1, 1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0, 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1, 1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }; //this list, indexed by the opcode, tells whether the instruction has an SIB byte //the SIB is only relevent in 32-bit opcode mode private static int[] sibTable = new int[] { 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; //gives the flag changes when indexed by the opcode value public static final MICROCODE[] flagTable = new MICROCODE[] { MICROCODE.FLAG_ADD_08, MICROCODE.FLAG_ADD_16, MICROCODE.FLAG_ADD_08, MICROCODE.FLAG_ADD_16, MICROCODE.FLAG_ADD_08, MICROCODE.FLAG_ADD_16, //0-5 MICROCODE.FLAG_NONE, //6 MICROCODE.FLAG_NONE, //7 MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, //8-d MICROCODE.FLAG_NONE, //e MICROCODE.FLAG_BAD, //f MICROCODE.FLAG_ADC_08, MICROCODE.FLAG_ADC_16, MICROCODE.FLAG_ADC_08, MICROCODE.FLAG_ADC_16, MICROCODE.FLAG_ADC_08, MICROCODE.FLAG_ADC_16, //10-15 MICROCODE.FLAG_NONE, //16 MICROCODE.FLAG_NONE, //17 MICROCODE.FLAG_SBB_08, MICROCODE.FLAG_SBB_16, MICROCODE.FLAG_SBB_08, MICROCODE.FLAG_SBB_16, MICROCODE.FLAG_SBB_08, MICROCODE.FLAG_SBB_16, //18-1d MICROCODE.FLAG_NONE, //1e MICROCODE.FLAG_NONE, //1f MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, //20-25 MICROCODE.FLAG_BAD, //26 MICROCODE.FLAG_NONE, //27 MICROCODE.FLAG_SUB_08, //28 MICROCODE.FLAG_SUB_16, //29 MICROCODE.FLAG_SUB_08, //2a MICROCODE.FLAG_SUB_16, //2b MICROCODE.FLAG_SUB_08, //2c MICROCODE.FLAG_SUB_16, //2d MICROCODE.FLAG_BAD, //2e MICROCODE.FLAG_NONE, //2f MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, //30-35 MICROCODE.FLAG_BAD, //36 MICROCODE.FLAG_NONE, //37 MICROCODE.FLAG_SUB_08, //38 MICROCODE.FLAG_SUB_16, //39 MICROCODE.FLAG_SUB_08, //3a MICROCODE.FLAG_SUB_16, //3b MICROCODE.FLAG_SUB_08, //3c MICROCODE.FLAG_SUB_16, //3d MICROCODE.FLAG_BAD, //3e MICROCODE.FLAG_NONE, //3f MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, MICROCODE.FLAG_INC_16, //40-47 MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, MICROCODE.FLAG_DEC_16, //48-4f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //50-57 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //58-5b MICROCODE.FLAG_NONE, //5c MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //5d-5f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //60-63 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //64-7f MICROCODE.FLAG_80_82, MICROCODE.FLAG_81_83, MICROCODE.FLAG_80_82, MICROCODE.FLAG_81_83, //80-83 MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, //84-85 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //86-8e MICROCODE.FLAG_NONE, //8f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //90-a5 MICROCODE.FLAG_REP_SUB_08, MICROCODE.FLAG_REP_SUB_16, //a6-a7 MICROCODE.FLAG_BITWISE_08, MICROCODE.FLAG_BITWISE_16, //a8-a9 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //aa-ad MICROCODE.FLAG_REP_SUB_08, MICROCODE.FLAG_REP_SUB_16, //ae-af MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //b0-bf MICROCODE.FLAG_ROTATE_08, MICROCODE.FLAG_ROTATE_16, //c0-c1 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //c2-ce MICROCODE.STORE0_FLAGS, //cf MICROCODE.FLAG_ROTATE_08, MICROCODE.FLAG_ROTATE_16, MICROCODE.FLAG_ROTATE_08, MICROCODE.FLAG_ROTATE_16, //d0-d3 MICROCODE.FLAG_BITWISE_08, //d4 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //d5-d7 MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, MICROCODE.FLAG_FLOAT_NOP, //d8-df MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //e0-ef MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f0-f3 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //f4-f5 MICROCODE.FLAG_F6, MICROCODE.FLAG_F7, //f6-f7 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //f8-fd MICROCODE.FLAG_FE, MICROCODE.FLAG_FF, //fe-ff MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f00-f05 MICROCODE.FLAG_NONE, //f06 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f07-f08 MICROCODE.FLAG_NONE, //f09 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f0a-f1f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //f20-f23 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f24-f2f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //f30-f32 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f33-f3f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //f40-f4f MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //f50-f7f MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //f80-fa0 MICROCODE.FLAG_NONE, //fa1 MICROCODE.FLAG_NONE, //fa2 MICROCODE.FLAG_NONE, MICROCODE.FLAG_SHL_16, MICROCODE.FLAG_SHL_16, //fa4-fa5 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //fa6-fa7 MICROCODE.FLAG_NONE, //fa8 MICROCODE.FLAG_NONE, //fa9 MICROCODE.FLAG_BAD, //faa MICROCODE.FLAG_NONE, //fab MICROCODE.FLAG_SHR_16, MICROCODE.FLAG_SHR_16, //fac-fad MICROCODE.FLAG_BAD, //fae MICROCODE.FLAG_NONE, //faf MICROCODE.FLAG_UNIMPLEMENTED, MICROCODE.FLAG_UNIMPLEMENTED, //fb0-fb1 MICROCODE.FLAG_NONE, //fb2 MICROCODE.FLAG_NONE, //fb3 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //fb4-fb7 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //fb8-fb9 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //fba-fbb MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //fbc-fbf MICROCODE.FLAG_ADD_08, MICROCODE.FLAG_ADD_16, //fc0-fc1 MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, //fc2-fc7 MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, MICROCODE.FLAG_NONE, //fc8-fcf MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD, MICROCODE.FLAG_BAD //fd0-fdf }; //gives the opcode microcode when indexed by the opcode value public static final MICROCODE[] opcodeTable = new MICROCODE[] { MICROCODE.OP_ADD, MICROCODE.OP_ADD, MICROCODE.OP_ADD, MICROCODE.OP_ADD, MICROCODE.OP_ADD, MICROCODE.OP_ADD, //0x00-0x05 MICROCODE.OP_PUSH, //0x06 MICROCODE.OP_POP, //0x07 MICROCODE.OP_OR, MICROCODE.OP_OR, MICROCODE.OP_OR, MICROCODE.OP_OR, MICROCODE.OP_OR, MICROCODE.OP_OR, //0x08-0x0d MICROCODE.OP_PUSH, //0xe MICROCODE.OP_BAD, //0xe-0xf MICROCODE.OP_ADC, MICROCODE.OP_ADC, MICROCODE.OP_ADC, MICROCODE.OP_ADC, MICROCODE.OP_ADC, MICROCODE.OP_ADC, //0x10-0x15 MICROCODE.OP_PUSH, //0x16 MICROCODE.OP_POP, //0x17 MICROCODE.OP_SBB, MICROCODE.OP_SBB, MICROCODE.OP_SBB, MICROCODE.OP_SBB, MICROCODE.OP_SBB, MICROCODE.OP_SBB, //0x18-0x1d MICROCODE.OP_PUSH, //0x1e MICROCODE.OP_POP, //0x1f MICROCODE.OP_AND, MICROCODE.OP_AND, MICROCODE.OP_AND, MICROCODE.OP_AND, MICROCODE.OP_AND, MICROCODE.OP_AND, //0x20-0x25 MICROCODE.OP_BAD, //0x26 MICROCODE.OP_DAA, //0x27 MICROCODE.OP_SUB, MICROCODE.OP_SUB, MICROCODE.OP_SUB, MICROCODE.OP_SUB, MICROCODE.OP_SUB, MICROCODE.OP_SUB, //0x28-0x2d MICROCODE.OP_BAD, //0x2e MICROCODE.OP_DAS, //0x2f MICROCODE.OP_XOR, MICROCODE.OP_XOR, MICROCODE.OP_XOR, MICROCODE.OP_XOR, MICROCODE.OP_XOR, MICROCODE.OP_XOR, //0x30-0x35 MICROCODE.OP_BAD, //0x36 MICROCODE.OP_AAA, //0x37 MICROCODE.OP_CMP, MICROCODE.OP_CMP, MICROCODE.OP_CMP, MICROCODE.OP_CMP, MICROCODE.OP_CMP, MICROCODE.OP_CMP, //0x38-0x3d MICROCODE.OP_BAD, //0x3e MICROCODE.OP_AAS, //0x3f MICROCODE.OP_INC, MICROCODE.OP_INC, MICROCODE.OP_INC, MICROCODE.OP_INC, MICROCODE.OP_INC, MICROCODE.OP_INC, MICROCODE.OP_INC, MICROCODE.OP_INC, //0x40-0x47 MICROCODE.OP_DEC, MICROCODE.OP_DEC, MICROCODE.OP_DEC, MICROCODE.OP_DEC, MICROCODE.OP_DEC, MICROCODE.OP_DEC, MICROCODE.OP_DEC, MICROCODE.OP_DEC, //0x48-0x4f MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, MICROCODE.OP_PUSH, //0x50-0x57 MICROCODE.OP_POP, MICROCODE.OP_POP, MICROCODE.OP_POP, MICROCODE.OP_POP, MICROCODE.OP_POP, MICROCODE.OP_POP, MICROCODE.OP_POP, MICROCODE.OP_POP, //0x58-0x5f MICROCODE.OP_PUSHA, //0x60 MICROCODE.OP_POPA, //0x61 MICROCODE.OP_BOUND, //0x62 MICROCODE.OP_MOV, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0x63-0x67 MICROCODE.OP_PUSH, //0x68 MICROCODE.OP_IMUL_16_32, //0x69 MICROCODE.OP_PUSH, //0x6a MICROCODE.OP_IMUL_16_32, //0x6b MICROCODE.OP_INSB, //0x6c MICROCODE.OP_INSW, //0x6d MICROCODE.OP_OUTSB, //0x6e MICROCODE.OP_OUTSW, //0x6f MICROCODE.OP_JO, MICROCODE.OP_JNO, MICROCODE.OP_JC, MICROCODE.OP_JNC, MICROCODE.OP_JZ, MICROCODE.OP_JNZ, MICROCODE.OP_JNA, MICROCODE.OP_JA, MICROCODE.OP_JS, MICROCODE.OP_JNS, MICROCODE.OP_JP, MICROCODE.OP_JNP, MICROCODE.OP_JL, MICROCODE.OP_JNL, MICROCODE.OP_JNG, MICROCODE.OP_JG, //0x70-0x7f MICROCODE.OP_80_83, MICROCODE.OP_80_83, MICROCODE.OP_80_83, MICROCODE.OP_80_83, //0x80-0x83 MICROCODE.OP_TEST, MICROCODE.OP_TEST, //0x84-0x85 MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0x86-0x8e MICROCODE.OP_POP, //0x8f MICROCODE.OP_NOP, //0x90 MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0x91-0x97 MICROCODE.OP_CBW, //0x98 MICROCODE.OP_CWD, //0x99 MICROCODE.OP_CALL_FAR, //0x9a MICROCODE.OP_FLOAT_NOP, //0x9b MICROCODE.OP_PUSHF, //0x9c MICROCODE.OP_POPF, //0x9d MICROCODE.OP_SAHF, //0x9e MICROCODE.OP_LAHF, //0x9f MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0xa0-0xa3 MICROCODE.OP_MOVSB, //0xa4 MICROCODE.OP_MOVSW, //0xa5 MICROCODE.OP_CMPSB, //0xa6 MICROCODE.OP_CMPSW, //0xa7 MICROCODE.OP_TEST, MICROCODE.OP_TEST, //0xa8-0xa9 MICROCODE.OP_STOSB, //0xaa MICROCODE.OP_STOSW, //0xab MICROCODE.OP_LODSB, //0xac MICROCODE.OP_LODSW, //0xad MICROCODE.OP_SCASB, //0xae MICROCODE.OP_SCASW, //0xaf MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0xb0-0xbf MICROCODE.OP_ROTATE_08, //0xc0 MICROCODE.OP_ROTATE_16_32, //0xc1 MICROCODE.OP_RET_IW, //0xc2 MICROCODE.OP_RET, //0xc3 MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0xc4-0xc7 MICROCODE.OP_ENTER, //0xc8 MICROCODE.OP_LEAVE, //0xc9 MICROCODE.OP_RET_FAR_IW, //0xca MICROCODE.OP_RET_FAR, //0xcb MICROCODE.OP_INT3, //0xcc MICROCODE.OP_INT, //0xcd MICROCODE.OP_INT0, //0xce MICROCODE.OP_IRET, //0xcf MICROCODE.OP_ROTATE_08, //0xd0 MICROCODE.OP_ROTATE_16_32, //0xd1 MICROCODE.OP_ROTATE_08, //0xd2 MICROCODE.OP_ROTATE_16_32, //0xd3 MICROCODE.OP_AAM, //0xd4 MICROCODE.OP_AAD, //0xd5 MICROCODE.OP_SALC, //0xd6 MICROCODE.OP_MOV, //0xd7 MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, MICROCODE.OP_FLOAT_NOP, //0xd8-0xdf MICROCODE.OP_LOOPNZ_CX, MICROCODE.OP_LOOPZ_CX, MICROCODE.OP_LOOP_CX, MICROCODE.OP_JCXZ, //0xe0-0xe3 MICROCODE.OP_IN_08, MICROCODE.OP_IN_16_32, //0xe4-0xe5 MICROCODE.OP_OUT_08, MICROCODE.OP_OUT_16_32, //0xe6-0xe7 MICROCODE.OP_CALL, //0xe8 MICROCODE.OP_JMP_16_32, //0xe9 MICROCODE.OP_JMP_FAR, //0xea MICROCODE.OP_JMP_08, //0xeb MICROCODE.OP_IN_08, MICROCODE.OP_IN_16_32, //0xec-0xed MICROCODE.OP_OUT_08, MICROCODE.OP_OUT_16_32, //0xee-0xef MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf0-0xf3 MICROCODE.OP_HALT, //0xf4 MICROCODE.OP_CMC, //0xf5 MICROCODE.OP_F6, MICROCODE.OP_F7, //0xf6-f7 MICROCODE.OP_CLC, MICROCODE.OP_STC, MICROCODE.OP_CLI, MICROCODE.OP_STI, MICROCODE.OP_CLD, MICROCODE.OP_STD, //0xf8-0xfd MICROCODE.OP_FE, MICROCODE.OP_FF, //0xfe-0xff MICROCODE.OP_F00, MICROCODE.OP_F01, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf00-0xf05 MICROCODE.OP_CLTS, //0xf06 MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf07-0xf08 MICROCODE.OP_NOP, //0xf09 MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf0a-0xf1e MICROCODE.OP_NOP, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0xf1f-0xf23 MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf20-0xf2f MICROCODE.OP_UNIMPLEMENTED, //0xf30 MICROCODE.OP_RDTSC, //0xf31 MICROCODE.OP_UNIMPLEMENTED, //0xf32 MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf33-0xf3f MICROCODE.OP_CMOVO, MICROCODE.OP_CMOVNO, MICROCODE.OP_CMOVC, MICROCODE.OP_CMOVNC, MICROCODE.OP_CMOVZ, MICROCODE.OP_CMOVNZ, MICROCODE.OP_CMOVNA, MICROCODE.OP_CMOVA, MICROCODE.OP_CMOVS, MICROCODE.OP_CMOVNS, MICROCODE.OP_CMOVP, MICROCODE.OP_CMOVNP, MICROCODE.OP_CMOVL, MICROCODE.OP_CMOVNL, MICROCODE.OP_CMOVNG, MICROCODE.OP_CMOVG, //0xf40-0xf4f MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xf50-0xf7f MICROCODE.OP_JO_16_32, MICROCODE.OP_JNO_16_32, MICROCODE.OP_JC_16_32, MICROCODE.OP_JNC_16_32, MICROCODE.OP_JZ_16_32, MICROCODE.OP_JNZ_16_32, MICROCODE.OP_JNA_16_32, MICROCODE.OP_JA_16_32, MICROCODE.OP_JS_16_32, MICROCODE.OP_JNS_16_32, MICROCODE.OP_JP_16_32, MICROCODE.OP_JNP_16_32, MICROCODE.OP_JL_16_32, MICROCODE.OP_JNL_16_32, MICROCODE.OP_JNG_16_32, MICROCODE.OP_JG_16_32, //0xf80-0xf8f MICROCODE.OP_SETO, MICROCODE.OP_SETNO, MICROCODE.OP_SETC, MICROCODE.OP_SETNC, MICROCODE.OP_SETZ, MICROCODE.OP_SETNZ, MICROCODE.OP_SETNA, MICROCODE.OP_SETA, MICROCODE.OP_SETS, MICROCODE.OP_SETNS, MICROCODE.OP_SETP, MICROCODE.OP_SETNP, MICROCODE.OP_SETL, MICROCODE.OP_SETNL, MICROCODE.OP_SETNG, MICROCODE.OP_SETG, //0xf90-0xf9f MICROCODE.OP_PUSH, //0xfa0 MICROCODE.OP_POP, //0xfa1 MICROCODE.OP_CPUID, //0xfa2 MICROCODE.OP_BT_16_32, //0xfa3 MICROCODE.OP_SHLD_16_32, MICROCODE.OP_SHLD_16_32, //0xfa4-0xfa5 MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xfa6-0xfa7 MICROCODE.OP_PUSH, //0xfa8 MICROCODE.OP_POP, //0xfa9 MICROCODE.OP_BAD, //0xfaa MICROCODE.OP_BTS_16_32, //0xfab MICROCODE.OP_SHRD_16_32, MICROCODE.OP_SHRD_16_32, //0xfac-0xfad MICROCODE.OP_BAD, MICROCODE.OP_IMUL_16_32, //0xfae-0xfaf MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, //0xfb0-0xfb1 MICROCODE.OP_MOV, //0xfb2 MICROCODE.OP_BTR_16_32, //0xfb3 MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, MICROCODE.OP_MOV, //0xfb4-0xfb7 MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_UNIMPLEMENTED, //0xfb8-0xfba MICROCODE.OP_BTC_16_32, //0xfbb MICROCODE.OP_BSF, //0xfbc MICROCODE.OP_BSR, //0xfbd MICROCODE.OP_SIGN_EXTEND, //0xfbe MICROCODE.OP_SIGN_EXTEND_16_32, //0xfbf MICROCODE.OP_ADD, MICROCODE.OP_ADD, //0xfc0-0xfc1 MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, //0xfc2-0xfc7 MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, MICROCODE.OP_UNIMPLEMENTED, //0xfc8-0xfcf MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD, MICROCODE.OP_BAD //0xfd0-0xfff }; }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
9ccbc288a0913f892d5c4c652e23db1b4473d8a8
4e83c6b2a8a5b59cd28bcbd0a33c1544b5f222b2
/src/main/java/trex/examples/RuleR1.java
323c8e64e4a845f6cfa4ffa314538388c511f52c
[]
no_license
BehnamKhazael/T-Rex
e936078f326e98d51aebe81572f4aca5bf2cb277
7ea747e731ac43de267e6a7046728c80883e7e64
refs/heads/master
2022-12-11T06:28:56.440014
2020-09-16T05:46:54
2020-09-16T05:46:55
295,935,868
1
0
null
null
null
null
UTF-8
Java
false
false
9,030
java
package trex.examples; import trex.common.*; import trex.marshalling.Marshaller; import trex.packets.PubPkt; import trex.packets.RulePkt; import trex.packets.SubPkt; import java.util.ArrayList; import java.util.concurrent.TimeUnit; import static trex.common.Consts.AggregateFun.AVG; import static trex.common.Consts.CompKind.EACH_WITHIN; import static trex.common.Consts.ConstraintOp.*; import static trex.common.Consts.StateType.AGG; import static trex.common.Consts.StateType.STATE; import static trex.common.Consts.ValType.FLOAT; import static trex.common.Consts.ValType.INT; import static trex.common.Consts.ValType.STRING; import static trex.examples.RuleR0.EVENT_FIRE; import static trex.examples.RuleR0.EVENT_SMOKE; import static trex.examples.RuleR0.EVENT_TEMP; /** * Created by sony on 2/10/2020. * * * Rule R1: * * define Fire(area: string, measuredTemp: int) * from Smoke(area=$a) and * each Temp(area=$a and value>45) within 5 min. from Smoke * where area=Smoke.area and measuredTemp=Temp.value * * char RuleR0::ATTR_TEMPVALUE[]= "value"; char RuleR0::ATTR_AREA[]= "area"; char RuleR0::ATTR_MEASUREDTEMP[]= "measuredTemp"; char RuleR0::AREA_GARDEN[]= "garden"; char RuleR0::AREA_OFFICE[]= "office"; char RuleR0::AREA_TOILET[]= "toilet"; * */ public class RuleR1 { public RulePkt buildRule(){ RulePkt rule= new RulePkt(false); int indexPredSmoke= 0; int indexPredTemp= 1; Long fiveMin = 1000L*60L*5L; // Smoke root predicate // Fake constraint as a temporary workaround to an engine's bug // FIXME remove workaround when bug fixed Constraint fakeConstr[] = new Constraint[1]; fakeConstr[0] = new Constraint(); // fakeConstr[1] = new Constraint(); fakeConstr[0].setName("area"); fakeConstr[0].setValType(STRING); fakeConstr[0].setOp(IN); fakeConstr[0].setStringVal(""); rule.addRootPredicate(EVENT_SMOKE, fakeConstr, 1); // Temp predicate // Constraint: Temp.value > 45 Constraint tempConstr[] = new Constraint[2]; tempConstr[0] = new Constraint(); tempConstr[0].setName("value"); tempConstr[0].setValType(INT); tempConstr[0].setOp(GT); tempConstr[0].setIntVal(20); tempConstr[1] = new Constraint(); tempConstr[1].setName("accuracy"); tempConstr[1].setValType(INT); tempConstr[1].setOp(LT); tempConstr[1].setIntVal(5); rule.addPredicate(EVENT_TEMP, tempConstr, 2, indexPredSmoke, fiveMin, EACH_WITHIN); // Parameter: Smoke.area=Temp.area rule.addParameterBetweenStates(indexPredSmoke, "area", indexPredTemp, "area"); // Fire template EventTemplate fireTemplate= new EventTemplate(EVENT_FIRE); // Area attribute in template OpTree areaOpTree= new OpTree(new RulePktValueReference(indexPredSmoke, STATE, "area"), STRING); fireTemplate.addAttribute("area", areaOpTree); // MeasuredTemp attribute in template OpTree measuredTempOpTree= new OpTree(new RulePktValueReference(indexPredTemp, STATE, "value"), INT); fireTemplate.addAttribute("measuredtemp", measuredTempOpTree); rule.setEventTemplate(fireTemplate); return rule; } public SubPkt buildSubscription() { Constraint constr[] = new Constraint[1]; // Area constraint constr[0] = new Constraint(); constr[0].setName("area"); constr[0].setValType(STRING); constr[0].setOp(EQ); constr[0].setStringVal("office"); return new SubPkt(EVENT_FIRE, constr, 1); } public ArrayList<byte[]> buildPublication(){ // Temp event Attribute tempAttr[] = new Attribute[3]; tempAttr[0] = new Attribute(); tempAttr[1] = new Attribute(); tempAttr[2] = new Attribute(); // Value attribute tempAttr[0].setName("value"); tempAttr[0].setValType(INT); tempAttr[0].setIntVal(44); // Area attribute tempAttr[1].setName("area"); tempAttr[1].setValType(STRING); tempAttr[1].setStringVal("office"); tempAttr[2].setName("accuracy"); tempAttr[2].setValType(INT); tempAttr[2].setIntVal(1); PubPkt tempPubPkt= new PubPkt(EVENT_TEMP, tempAttr, 3); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } // Smoke event // Area attribute Attribute smokeAttr[] = new Attribute[1]; smokeAttr[0] = new Attribute(); smokeAttr[0].setName("area"); smokeAttr[0].setValType(STRING); smokeAttr[0].setStringVal("office"); PubPkt smokePubPkt= new PubPkt(EVENT_SMOKE, smokeAttr, 1); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } // Temp event Attribute tempAttr2[] = new Attribute[3]; tempAttr2[0] = new Attribute(); tempAttr2[1] = new Attribute(); tempAttr2[2] = new Attribute(); // Value attribute tempAttr2[0].setName("value"); tempAttr2[0].setValType(INT); tempAttr2[0].setIntVal(50); // Area attribute tempAttr2[1].setName("area"); tempAttr2[1].setValType(STRING); tempAttr2[1].setStringVal("office"); tempAttr2[2].setName("accuracy"); tempAttr2[2].setValType(INT); tempAttr2[2].setIntVal(1); PubPkt tempPubPkt2= new PubPkt(EVENT_TEMP, tempAttr2, 3); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } // Temp event Attribute tempAttr3[] = new Attribute[3]; tempAttr3[0] = new Attribute(); tempAttr3[1] = new Attribute(); tempAttr3[2] = new Attribute(); // Value attribute tempAttr3[0].setName("value"); tempAttr3[0].setValType(INT); tempAttr3[0].setIntVal(80); // Area attribute tempAttr3[1].setName("area"); tempAttr3[1].setValType(STRING); tempAttr3[1].setStringVal("office"); tempAttr3[2].setName("accuracy"); tempAttr3[2].setValType(INT); tempAttr3[2].setIntVal(1); PubPkt tempPubPkt3= new PubPkt(EVENT_TEMP, tempAttr3, 3); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } // Temp event Attribute tempAttr4[] = new Attribute[3]; tempAttr4[0] = new Attribute(); tempAttr4[1] = new Attribute(); tempAttr4[2] = new Attribute(); // Value attribute tempAttr4[0].setName("value"); tempAttr4[0].setValType(INT); tempAttr4[0].setIntVal(88); // Area attribute tempAttr4[1].setName("area"); tempAttr4[1].setValType(STRING); tempAttr4[1].setStringVal("office"); tempAttr4[2].setName("accuracy"); tempAttr4[2].setValType(INT); tempAttr4[2].setIntVal(1); PubPkt tempPubPkt4= new PubPkt(EVENT_TEMP, tempAttr4, 3); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } // Smoke event // Area attribute Attribute smokeAttr2[] = new Attribute[1]; smokeAttr2[0] = new Attribute(); smokeAttr2[0].setName("area"); smokeAttr2[0].setValType(STRING); smokeAttr2[0].setStringVal("office"); PubPkt smokePubPkt2= new PubPkt(EVENT_SMOKE, smokeAttr2, 1); try { TimeUnit.SECONDS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } // Smoke event // Area attribute Attribute smokeAttr3[] = new Attribute[1]; smokeAttr2[0] = new Attribute(); smokeAttr2[0].setName("area"); smokeAttr2[0].setValType(STRING); smokeAttr2[0].setStringVal("office"); PubPkt smokePubPkt3= new PubPkt(EVENT_SMOKE, smokeAttr2, 1); ArrayList<PubPkt> pubPkts = new ArrayList<>(); ArrayList<byte[]> pubPktsm = new ArrayList<>(); //pubPktsm.add(Marshaller.marshal(smokePubPkt)); pubPktsm.add(Marshaller.marshal(tempPubPkt)); pubPktsm.add(Marshaller.marshal(tempPubPkt2)); pubPktsm.add(Marshaller.marshal(smokePubPkt)); pubPktsm.add(Marshaller.marshal(tempPubPkt3)); pubPktsm.add(Marshaller.marshal(smokePubPkt3)); pubPktsm.add(Marshaller.marshal(tempPubPkt4)); pubPktsm.add(Marshaller.marshal(smokePubPkt2)); pubPkts.add(smokePubPkt); pubPkts.add(tempPubPkt); pubPkts.add(tempPubPkt2); pubPkts.add(smokePubPkt); pubPkts.add(tempPubPkt3); pubPkts.add(tempPubPkt4); pubPkts.add(smokePubPkt2); return pubPktsm; } }
[ "behnam_khazael@yahoo.com" ]
behnam_khazael@yahoo.com
c19d909446cdcf14339cdf1f2e8341245cadb94c
7c1985ddebb92bb651a9bb9d34f59dd0f02ade42
/oaManSystem/src/com/in/service/LeaveService.java
b784b99d6d5645e861450bdd792b1686061de911
[]
no_license
accp-in/accpin
58fd7939216b4fe66a0864bc49e59705c7ae5a12
3e990072c06f966e38170b3f75b3987cc557ff04
refs/heads/master
2021-01-23T10:03:26.927411
2014-09-29T11:49:31
2014-09-29T11:49:31
null
0
0
null
null
null
null
GB18030
Java
false
false
811
java
package com.in.service; import java.util.List; import java.util.Map; import com.in.entity.Leave; /** * 请假表 * */ public interface LeaveService { //添加请假信息 public void addLeave(Leave levave); //修改请假信息 public void updateLeave(Leave levave); //删除请假信息 public void deleteLeave(Integer id); //根据ID查找对象 public Leave findById(Integer id); //查询数据行数 public int findAll(); //Map public Map<String, Object> allByPage(String name,int pageNo, int pageSize,String hql,String[] paramNames,Object[] values); //分页查询(根据那么查询) public List<Leave> findByList(String name,int pageNo, int pageSize,String hql,String[] paramNames,Object[] values); }
[ "kalven@outlook.com" ]
kalven@outlook.com
ea1becddbaf5ac2b14b80f2c5038392ff61b3c30
0a77007c133d2d2f0203602daf06c2471327eba8
/src/JavaAlgorithms/Main.java
b7e14b668bad87497699401b5813dd08affd5226
[]
no_license
Dragonxero/ChallengeOneAlgorithmEveryDay
0367940e12d2f11aaabd10afe9ab8b85fb32823c
c31fc48e8ffb1e29d1cfdca72c8571015f55cf5e
refs/heads/master
2021-01-21T15:49:45.792841
2016-07-27T07:09:23
2016-07-27T07:09:23
null
0
0
null
null
null
null
UTF-8
Java
false
false
12,832
java
package JavaAlgorithms; import JavaAlgorithms.Algorithms.*; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Scanner; /** * Hey!! This is a list of algorithms. Originally, these algorithms are from FreeCodeCamp.com where you * need to code them in Javascript. I will convert them to Java. */ public class Main { public static void main(String[] args) { int option; while (true) { Scanner reader = new Scanner (System.in); menu(); try { option = reader.nextInt(); } catch (InputMismatchException ex) { System.out.println("\nJust numbers, pls\n"); continue; } switch (option) { case 1: System.out.println("The Chunkey Monkey algorithm takes an array and a chunk parameter"); System.out.println("to split the array into a multidimensional one."); System.out.println("\nThis is the array that is using:"); System.out.println("[1, 2, 3, 4, 6]"); System.out.println("The chunk parameter is: 2\n"); System.out.println("And this is the result:"); int[] arr = new int[] {1, 2, 3, 4, 5, 6}; ChunkeyMonkey chunkey = new ChunkeyMonkey(arr, 2); ArrayList<int[]> chunkeyArr = chunkey.doChunkey(); for (int[] item : chunkeyArr) System.out.print(Arrays.toString(item) + " "); System.out.print("\n"); break; case 2: System.out.println("The Mutations algorithm takes two Strings. The second parameter is"); System.out.println("the letters that I want to know if the first string contains."); System.out.print("\nEnter the first String: "); String[] parameters = new String[2]; reader.nextLine(); parameters[0] = reader.nextLine(); System.out.print("And the second, pls: "); parameters[1] = reader.nextLine(); Mutations mut = new Mutations(parameters); System.out.println("The result is: " + mut.checkMutation()); break; case 3: System.out.println("\nThe algorithm takes two arguments: The first is the numbers that You have"); System.out.println("and the second is those You want to seek to destroy them in the first arguments."); System.out.println("\nEnter the firsts numbers:"); ArrayList<Integer> arr1 = new ArrayList<>(); reader.nextLine(); for (String token; (token = reader.findInLine("[0-9]+")) != null;) arr1.add(Integer.valueOf(token)); System.out.println("Now, enter the numbers that you want to destroy:"); ArrayList<Integer> arr2 = new ArrayList<>(); reader.nextLine(); for (String token; (token = reader.findInLine("[0-9]+")) != null;) arr2.add(Integer.valueOf(token)); SeekAndDestroy sd = new SeekAndDestroy(arr1, arr2); System.out.println("\nResult:"); System.out.println(sd.doDestroy().toString() + "\n"); break; case 4: System.out.println("Returns the lowest index at which a value (second argument) should be inserted into an array"); System.out.println("(first argument). The returned value is a number."); System.out.println("\nEnter some numbers separated with spaces:"); reader.nextLine(); ArrayList<Double> listOfNumbers = new ArrayList<>(); for (String token; (token = reader.findInLine("[0-9]+(\\.\\d+)?")) != null;) listOfNumbers.add(Double.valueOf(token)); System.out.println("Enter the number that you want to insert:"); reader.nextLine(); double number = 0; for (String token; (token = reader.findInLine("[0-9]+(\\.\\d+)?")) != null;) number = Double.parseDouble(token); WhereDoIBelong wdib = new WhereDoIBelong(listOfNumbers, number); System.out.println("\nResult: " + wdib.getIndexToIns()); break; case 5: DiffTwoArrays dta = new DiffTwoArrays(); dta.showAlg(reader); break; case 6: SearchAndReplace sr = new SearchAndReplace(); sr.showAlg(reader); break; case 7: PigLatin pl = new PigLatin(); pl.showAlg(reader); break; case 8: SpinalCase sc = new SpinalCase(); sc.showAlg(reader); break; case 9: RomanNumeralConverter rnc = new RomanNumeralConverter(); rnc.showAlg(); break; case 10: FibonacciOddSum fos = new FibonacciOddSum(); fos.showAlg(reader); break; case 11: SumAllPrimes sap = new SumAllPrimes(); sap.showAlg(reader); break; case 12: SmallestCommonMultiple scm = new SmallestCommonMultiple(); scm.showAlg(reader); break; case 13: FriendlyNumbers fn = new FriendlyNumbers(); fn.showAlg(reader); break; case 14: NetPresentValue npv = new NetPresentValue(); npv.showAlg(reader); break; case 15: HarmonicMean hm = new HarmonicMean(); hm.showAlg(reader); break; case 16: FoodMachine fm = new FoodMachine(); fm.showAlg(reader); break; case 17: SquareRoot sq = new SquareRoot(); sq.showAlg(reader); break; case 18: TruncateAString ts = new TruncateAString(); ts.showAlg(reader); break; case 19: ConfirmTheEnding ce = new ConfirmTheEnding(); ce.showAlg(reader); break; case 20: FactorializeANumber fan = new FactorializeANumber(); fan.showAlg(reader); break; case 21: FindersKeepers fk = new FindersKeepers(); fk.showAlg(reader); break; case 22: RepeatAStringRepeatAString rsrs = new RepeatAStringRepeatAString(); rsrs.showAlg(reader); break; case 23: SumAllNumbersInARange saniar = new SumAllNumbersInARange(); saniar.showAlg(reader); break; case 24: BinaryAgents ba = new BinaryAgents(); ba.showAlg(reader); break; case 25: Palindromes p = new Palindromes(); p.showAlg(reader); break; case 26: TitleCaseASentence tcas = new TitleCaseASentence(); tcas.showAlg(reader); break; case 27: SlasherFlick sf = new SlasherFlick(); sf.showAlg(reader); break; case 28: RoleTheDice rtd = new RoleTheDice(); rtd.showAlg(reader); break; case 29: HTMLEntriesConverter htmlec = new HTMLEntriesConverter(); htmlec.showAlg(reader); break; case 30: Pythagoras py = new Pythagoras(); py.showAlg(reader); break; case 31: CollatzConjecture cc = new CollatzConjecture(); cc.showAlg(reader); break; case 32: SaintStackoverflow ss = new SaintStackoverflow(); ss.showAlg(reader); break; case 33: String outro = "/**\n" + " * Thanks for check my work. I really appreciate that.\n" + " *\n" + " * Don't forget to visit my profile on GitHub and LinkedIN!\n" + " * Github: https://github.com/Naturalsoul\n" + " * LinkedIN: https://cl.linkedin.com/in/rauleduardoc\n" + " *\n" + " * Good Bye!\n" + " */"; System.out.println("\n" + outro); System.exit(0); break; } } } private static void menu () { String intro = "/**\n" + " * Author: Naturalsoul\n" + " *\n" + " * It has been interesting doing this challenge.\n" + " * Some days I really felt unmotivated but I preferred to think that I'm\n" + " * more than those bad feelings and thoughts. That the only real failure is\n" + " * when I give up 'cause I always can continue and those \"bad things\"\n" + " * are just another ingredient of success.\n" + " *\n" + " * I hope these algorithms and challenge can help and motivate you to do things and to grow.\n" + " *\n" + " * My profile on Github: https://github.com/Naturalsoul\n" + " * My profile on LinkedIN: https://cl.linkedin.com/in/rauleduardoc\n" + " */"; System.out.println(intro + "\n"); System.out.println("--------------------"); System.out.println("Hi!! :D. Choose an algorithm!"); System.out.println("1) Chunkey Monkey."); System.out.println("2) Mutations."); System.out.println("3) Seek and Destroy."); System.out.println("4) Where Do I Belong."); System.out.println("5) Diff Two Arrays."); System.out.println("6) Search And Replace."); System.out.println("7) Pig Latin."); System.out.println("8) Spinal Case."); System.out.println("9) Roman Numeral Converter."); System.out.println("10) Fibonacci's Odd Sum."); System.out.println("11) Sum All Primes."); System.out.println("12) Smallest Common Multiple."); System.out.println("13) Friendly Numbers."); System.out.println("14) Net Present Values."); System.out.println("15) Harmonic Mean."); System.out.println("16) Food Machine."); System.out.println("17) Square Root."); System.out.println("18) Truncate a String."); System.out.println("19) Confirm The Ending."); System.out.println("20) Factorialize a Number."); System.out.println("21) Finders Keepers."); System.out.println("22) Repeat a String Repeat a String."); System.out.println("23) Sum All Numbers In A Range."); System.out.println("24) Binary Agents."); System.out.println("25) Palindromes."); System.out.println("26) Title Case a Sentence."); System.out.println("27) Slasher Flick."); System.out.println("28) RoleTheDice."); System.out.println("29) HTML Entries Converter."); System.out.println("30) Pythagoras."); System.out.println("31) Collatz Conjecture."); System.out.println("32) Saint Stackoverflow."); System.out.println("33) Thanks for the algorithms. Good Bye!!"); System.out.println("--------------------"); System.out.print("Choose an option: "); } }
[ "raul.d.carrasco@outlook.com" ]
raul.d.carrasco@outlook.com
29c6d99edb60fd7a40feec7a95e48e8d64476f9d
afa3842152755199fc3813d8f9a72541382b9f3e
/src/main/java/com/kraytech/restdemo/repositories/domain/Medico.java
2ef17a656e04a6ed4bc7eeb912a3cf878dd6ec42
[]
no_license
kjrg56/hosprest
77ed9d08678b2272adde52e4f3f79b746965aec5
05ec18e7d75618a0638d7d6d08ac9accc6b26d6c
refs/heads/master
2020-12-21T23:04:11.510467
2020-09-16T05:12:33
2020-09-16T05:12:33
236,592,857
0
0
null
null
null
null
UTF-8
Java
false
false
603
java
package com.kraytech.restdemo.repositories.domain; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import lombok.Data; @Data @Entity public class Medico { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String nombres; private String apellidos; private String telefono; public Medico() { } public Medico(String nombres, String apellidos, String telefono) { this.nombres = nombres; this.apellidos = apellidos; this.telefono = telefono; } }
[ "Kevin Raymundo" ]
Kevin Raymundo
626b4e890f3da97e2b32fb84ec54bdd11c6f406f
9b80a515194b84fe1e995511c7ddc232cb9b0a01
/clink-appsdk/android/demo/TOSClientLibDemo/online_service/threepart/src/main/java/com/org/gzuliyujiang/filepicker/contract/OnPathClickedListener.java
9178c3baf1fceb53fb75befb120b3032649cfdad
[ "Apache-2.0" ]
permissive
ti-net/clink-sdk
e5f17050c37d26d215b11f6ff19d30f23cf7cc9b
cb918ee1bb5b108159d3d9bae788dd9d9fd2a486
refs/heads/master
2023-08-18T21:44:35.676263
2023-08-17T12:22:13
2023-08-17T12:22:13
200,053,531
12
10
Apache-2.0
2023-09-13T06:09:42
2019-08-01T13:13:27
Objective-C
UTF-8
Java
false
false
1,006
java
/* * Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> * * The software is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * http://license.coscl.org.cn/MulanPSL2 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. */ package com.org.gzuliyujiang.filepicker.contract; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.org.gzuliyujiang.filepicker.adapter.ViewHolder; /** * @author 贵州山野羡民(1032694760@qq.com) * @since 2021/6/10 20:15 */ public interface OnPathClickedListener { void onPathClicked(RecyclerView.Adapter<ViewHolder> adapter, int position, @NonNull String path); }
[ "gyb_1314@126.com" ]
gyb_1314@126.com
d042835f3948c9bcdf5bdfcce94881be16221ef3
36dae58d1e0256fec216762fd48351b82ca3070e
/src/com/vebora/oauth2/cache/services/YoutubeService.java
a737ec8e9a07897d66db6454e93c36922884b57e
[]
no_license
arikanorh/repo2
78d19b32fe43a3ec276c1239f58cebfd7b1c0d4a
4fb760095bcbfca096c1feb2c3bbcefdee359df0
refs/heads/master
2016-08-12T04:01:42.070068
2016-03-22T19:49:02
2016-03-22T19:49:02
54,468,487
0
0
null
2016-03-22T19:01:37
2016-03-22T11:06:50
Java
UTF-8
Java
false
false
1,364
java
package com.vebora.oauth2.cache.services; import java.io.IOException; import java.util.List; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.googleapis.util.Utils; import com.google.api.services.youtube.YouTube; import com.google.api.services.youtube.model.Subscription; import com.google.api.services.youtube.model.SubscriptionListResponse; import com.vebora.oauth2.main.user.UserCredentialStore; public class YoutubeService { private static final Long NUMBER_OF_VIDEOS_RETURNED = 25L; public YoutubeService() { } public static void getSomething(String userId) throws IOException { GoogleCredential credential = UserCredentialStore.getUserCredential(userId); YouTube youTube = new YouTube.Builder(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory(), credential).build(); YouTube.Subscriptions.List search = youTube.subscriptions().list("snippet"); // To increase efficiency, only retrieve the fields that the // application uses. search.setMine(true); // search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)"); search.setMaxResults(NUMBER_OF_VIDEOS_RETURNED); SubscriptionListResponse searchResponse = search.execute(); List<Subscription> searchResultList = searchResponse.getItems(); System.out.println(searchResultList); } }
[ "arikanorh@gmail.com" ]
arikanorh@gmail.com
1873fc68caee9c6647862804bf4c829033a564f3
9282591635f3cf5a640800f2b643cd57048ed29f
/app/src/main/java/com/android/p2pflowernet/project/view/fragments/mine/setting/feedback/FeedBackPopupWindow.java
15ed25d22dba532cc3a36b980f4794afc493d6e9
[]
no_license
AHGZ/B2CFlowerNetProject
de5dcbf2cbb67809b00f86639d592309d84b3283
b1556c4b633fa7c0c1463af94db9f91285070714
refs/heads/master
2020-03-09T17:27:14.889919
2018-04-10T09:36:33
2018-04-10T09:36:33
128,908,791
1
0
null
null
null
null
UTF-8
Java
false
false
3,380
java
package com.android.p2pflowernet.project.view.fragments.mine.setting.feedback; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView; import com.android.p2pflowernet.project.R; /** * Created by caishen on 2017/11/24. * by-- */ public class FeedBackPopupWindow extends PopupWindow { private FragmentActivity mContext; private View view; public FeedBackPopupWindow(FragmentActivity activity, String tvType, String tvReply, String etFeedback, String loginName) { this.mContext = activity; this.view = LayoutInflater.from(mContext).inflate(R.layout.feedback_popup_window, null); Button btn_cancle = (Button) view.findViewById(R.id.btn_cancle); TextView tv_reply = (TextView) view.findViewById(R.id.tv_reply); TextView tv_num_text = (TextView) view.findViewById(R.id.tv_num_text); TextView tv_type = (TextView) view.findViewById(R.id.tv_type); EditText et_feedback = (EditText) view.findViewById(R.id.et_feedback); TextView tv_login_name = (TextView) view.findViewById(R.id.tv_login_name); tv_login_name.setText(loginName); tv_type.setText(tvType); tv_num_text.setText(etFeedback.length() + "/100字"); tv_reply.setText(tvReply); et_feedback.setText(etFeedback); btn_cancle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); // 设置外部可点击 this.setOutsideTouchable(true); // mMenuView添加OnTouchListener监听判断获取触屏位置如果在选择框外面则销毁弹出框 this.view.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { int height = view.findViewById(R.id.id_pop_layout).getTop(); int y = (int) event.getY(); if (event.getAction() == MotionEvent.ACTION_UP) { if (y < height) { dismiss(); } } return true; } }); /* 设置弹出窗口特征 */ // 设置视图 this.setContentView(this.view); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight(); // 设置弹出窗体的宽和高 this.setHeight(height * 2 / 3); this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT); // 设置弹出窗体可点击 this.setFocusable(true); // 实例化一个ColorDrawable颜色为半透明 ColorDrawable dw = new ColorDrawable(0xb0000000); // 设置弹出窗体的背景 this.setBackgroundDrawable(dw); // 设置弹出窗体显示时的动画,从底部向上弹出 this.setAnimationStyle(R.style.take_photo_anim); } }
[ "18911005030@163.com" ]
18911005030@163.com
548838d8d2315fb54cffc45561f32a7accc8d261
64137d25e00a5591a9cbdafd16daf00b10368f7e
/src/test/java/com/shanhaihen/rabbitdemo/SpringBootRabbitMQTest.java
655f5169c5bcf4bdc1b3761265d44147e4d33836
[]
no_license
shanhaihen/rabbitmq-demo
a272454eb3b57c59fd487d27f1bda6ed1ee84b50
d5f8680c58e86a2aed92c0bf8dbdb0405a7aacfa
refs/heads/main
2023-02-04T02:12:36.900048
2020-12-28T09:32:19
2020-12-28T09:32:19
323,837,555
0
0
null
null
null
null
UTF-8
Java
false
false
2,037
java
package com.shanhaihen.rabbitdemo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = RabbitDemoApplication.class) @RunWith(SpringRunner.class) public class SpringBootRabbitMQTest { @Autowired private RabbitTemplate rabbitTemplate; /** * topic 动态路由 订阅模式 */ @Test public void topicTest() { rabbitTemplate.convertAndSend("topic1", "user", "topic模型发送的[user]消息"); rabbitTemplate.convertAndSend("topic1", "user.save", "topic模型发送的[user.save]消息"); rabbitTemplate.convertAndSend("topic1", "user.save.query", "topic 模型发送的[user.save.query]消息"); rabbitTemplate.convertAndSend("topic1", "order", "topic模型发送的[order]消息"); } /** * route 路由模式 */ @Test public void routeTest() { rabbitTemplate.convertAndSend("route1", "info", "route1 模型发送的[info]消息"); rabbitTemplate.convertAndSend("route1", "error", "route1 模型发送的[error]消息"); } /** * fanout 广播 * * @throws InterruptedException */ @Test public void fanOutTest() { for (int i = 0; i < 10; i++) { rabbitTemplate.convertAndSend("fanout1", "", i + "fanout 模型发送的消息"); } } /** * 生产者不创建队列 */ @Test public void simpleQueueTest() { rabbitTemplate.convertAndSend("hello", "hello world"); } /** * 生产者不创建队列 */ @Test public void workQueueTest() { for (int i = 0; i < 10; i++) { System.out.println("=================>>>::" + i); rabbitTemplate.convertAndSend("spring_work1", i + "hello world"); } } }
[ "jingrunp@163.com" ]
jingrunp@163.com
c69b08e2fb7c34efd64fa74ccbaec92ae37c1aee
246bd3fbfadb1864c30bfdb20990474161b52df1
/read-n-characters-given-read4-ii.java
da8447f9be4db4ac95e34243e71d80ef684b737b
[]
no_license
renmengfei/leetcode
8200b155477b43da8b701c102a422e9a4127ea47
f263d32a4e49c5249d655baee7c7b1aeb481f0c5
refs/heads/master
2020-04-06T06:58:58.286956
2019-07-10T06:55:34
2019-07-10T06:55:34
19,768,032
0
0
null
2019-07-10T06:55:35
2014-05-14T05:52:09
Java
UTF-8
Java
false
false
659
java
public class Solution extends Reader4 { char[] buffer = new char[4]; int offset=0; int buffersize = 0; public int read(char[] buf, int n) { int result = 0; boolean eof = false; while(!eof && result <n){ //empty if(buffersize==0){ buffersize = read4(buffer); if(buffersize<4) eof = true; } int bytes = Math.min(buffersize, n-result); System.arraycopy(buffer,offset,buf,result,bytes); offset = (offset+bytes)%4; result+=bytes; buffersize-=bytes; } return result; } }
[ "mengfei@yahoo-inc.com" ]
mengfei@yahoo-inc.com
c97230ee3c19c618d159e5aabde3cf16653e0f15
079dc9d52c65c121662ebd016184eeb16fc36769
/bitcamp-assignment-04/src/main/java/bitcamp/assignment/repository/MemberRepository.java
4f741ec7694676cb524ac457933412d3f5a07006
[]
no_license
humonidtyphoon/bitcamp-cloud-computing
b3807072378bb6eb8e19b731f3415cb330763ba1
e23f2c8cd0e2094c7723015ddaf7541c85233398
refs/heads/master
2021-05-16T23:43:55.553888
2018-09-04T10:51:11
2018-09-04T10:51:11
null
0
0
null
null
null
null
UTF-8
Java
false
false
239
java
package bitcamp.assignment.repository; import java.util.Map; import bitcamp.assignment.domain.Member; public interface MemberRepository { int insert(Member member); Member findByEmailAndPassword(Map<String,Object> params); }
[ "somony9292@gmail.com" ]
somony9292@gmail.com
fdeb4a7d1a72eb8a46952d0f497d0067976d070a
af38ec4ba73a2a0fe662f2cfad7bb82afb7a1d8c
/app/src/main/java/com/uzair/chatmodulewithfirebase/SharedPrefHelper.java
b89ab1dd23e8be155282b0c1cfbb7c7c25dba8ed
[]
no_license
uzairmughal3397/chatModuleWithFirestore
b7bcb3b90645000aaeb1b557a50a9646edf9a096
de12b7f034803d750c67d86e730077ee9516029f
refs/heads/main
2023-02-18T12:26:46.727602
2021-01-17T11:16:04
2021-01-17T11:16:04
324,099,046
0
0
null
null
null
null
UTF-8
Java
false
false
1,552
java
package com.uzair.chatmodulewithfirebase; import android.content.Context; import android.content.SharedPreferences; public class SharedPrefHelper { private static final int MODE = 0; public SharedPrefHelper() { } private static SharedPreferences getPreferences(Context context) { return context.getSharedPreferences("", 0); } private static SharedPreferences.Editor getEditor(Context context) { return getPreferences(context).edit(); } public static void writeInteger(Context context, String str, int i) { getEditor(context).putInt(str, i).commit(); } public static int readInteger(Context context, String str) { return getPreferences(context).getInt(str, 0); } public static void writeString(Context context, String str, String str2) { getEditor(context).putString(str, str2).commit(); } public static String readString(Context context, String str) { return getPreferences(context).getString(str, null); } public static boolean checkContain(Context context, String str) { return getPreferences(context).contains(str); } public static void clearAll(Context context) { getEditor(context).clear().commit(); } public static void writeBoolean(Context context, String str, boolean z) { getPreferences(context).edit().putBoolean(str, z).apply(); } public static boolean readBoolean(Context context, String str) { return getPreferences(context).getBoolean(str, false); } }
[ "uzairmughal3397@gmail.com" ]
uzairmughal3397@gmail.com
54d3fe5c277214cdff558f27d63bc1fc46065ff4
2d46cff448051266819b8fb9abfec58627381834
/src/test/java/de/zalando/buildstatus/BuildStatusMonitorTest.java
cb55a83220900952ca676d13845499d1f2718f42
[ "MIT" ]
permissive
cjander/build-status-traffic-light
19f1a82c1b5d92fc191a8b8550a22324eb98b3f7
d30486e017413a9dbc4405c2ca040d9d0522df6d
refs/heads/master
2021-01-11T07:24:01.635564
2016-09-12T15:45:21
2016-09-12T15:45:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,519
java
package de.zalando.buildstatus; import de.zalando.buildstatus.display.Display; import de.zalando.buildstatus.http.SimpleHttpClient; import de.zalando.buildstatus.job.JenkinsJob; import de.zalando.buildstatus.job.Job; import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockserver.integration.ClientAndServer; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; public class BuildStatusMonitorTest { private final String jenkinsJobRedJson; private final String jenkinsJobYellowJson; private final String jenkinsJobBlueJson; private final String jenkinsJobRedAnimatedJson; private final String jenkinsJobBlueAnimatedJson; private final String jenkinsJobYellowAnimatedJson; private ClientAndServer mockServer; @Mock private Display display; private BuildStatusMonitor monitor; private int port= 8082; public BuildStatusMonitorTest() throws IOException { jenkinsJobRedJson = IOUtils.toString(this.getClass().getResourceAsStream("/jenkinsapi-job-red.json")); jenkinsJobYellowJson = IOUtils.toString(this.getClass().getResourceAsStream("/jenkinsapi-job-yellow.json")); jenkinsJobBlueJson = IOUtils.toString(this.getClass().getResourceAsStream("/jenkinsapi-job-blue.json")); jenkinsJobRedAnimatedJson = IOUtils.toString( this.getClass().getResourceAsStream("/jenkinsapi-job-red_anime.json")); jenkinsJobBlueAnimatedJson = IOUtils.toString( this.getClass().getResourceAsStream("/jenkinsapi-job-blue_anime.json")); jenkinsJobYellowAnimatedJson = IOUtils.toString( this.getClass().getResourceAsStream("/jenkinsapi-job-yellow_anime.json")); } @Before public void setup() { MockitoAnnotations.initMocks(this); mockServer = new ClientAndServer(port); monitor = new BuildStatusMonitor(display, new SimpleHttpClient()); } @After public void tearDown() { mockServer.stop(); } @Test public void ifJenkinsJobIsRedIndicatorShouldDisplayFailed() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobRedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } private Collection<Job> createJobsListFromJson(String... json) { List<Job> jobs = new ArrayList<>(json.length); int i = 0; for(String s : json) { String jobName = "job" + i++; configureJenkinsJob(jobName, s); jobs.add(new JenkinsJob("http://localhost:" + port +"/", jobName, "user", "password", true)); } return jobs; } private void configureJenkinsJob(String jobId, String body) { mockServer .when(request() .withMethod("GET") .withPath("/job/" + jobId + "/api/json")) .respond(response() .withStatusCode(200) .withHeader("Content-Type", "application/json") .withBody(body) ); } @Test public void ifJenkinsJobIsYellowIndicatorShouldDisplayUnstable() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobYellowJson)); Mockito.verify(display, Mockito.times(1)).displayUnstable(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifJenkinsJobIsBlueIndicatorShouldDisplaySuccess() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobBlueJson)); Mockito.verify(display, Mockito.times(1)).displaySuccess(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifAtLeastOneJobIsFailedIndicatorShouldDisplayFailure() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobBlueJson, jenkinsJobRedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifAtLeastOneJobIsUnstableIndicatorShouldDisplayUnstable() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobBlueJson, jenkinsJobYellowJson)); Mockito.verify(display, Mockito.times(1)).displayUnstable(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifThereAreUnstableAndFailedJobsIndicatorShouldDisplayFailed() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobRedJson, jenkinsJobYellowJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifAllJobsAreSuccessIndicatorShouldDisplaySuccess() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobBlueJson, jenkinsJobBlueJson)); Mockito.verify(display, Mockito.times(1)).displaySuccess(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifJenkinsJobIsBlueAnimatedIndicatorShouldDisplaySuccess() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobBlueAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displaySuccess(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifJenkinsJobIsRedAnimatedIndicatorShouldDisplayFailure() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobRedAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void ifJenkinsJobIsYellowAnimatedIndicatorShouldDisplayUnstable() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobRedAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void successBlinkingStatusShouldOverrideNonBlinkingStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobBlueJson, jenkinsJobBlueAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displaySuccess(); Mockito.verifyNoMoreInteractions(display); } @Test public void unstableBlinkingStatusShouldOverrideNonBlinkingStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobYellowJson, jenkinsJobYellowAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displayUnstable(); Mockito.verifyNoMoreInteractions(display); } @Test public void failureBlinkingStatusShouldOverrideNonBlinkingStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobRedJson, jenkinsJobRedAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void failureBlinkingStatusShouldOverrideSuccessStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobRedAnimatedJson, jenkinsJobBlueJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void failureBlinkingStatusShouldOverrideUnstableStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobYellowJson, jenkinsJobRedAnimatedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void unstableBlinkingStatusShouldNotOverrideFailedStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobYellowAnimatedJson, jenkinsJobRedJson)); Mockito.verify(display, Mockito.times(1)).displayFailure(); Mockito.verifyNoMoreInteractions(display); } @Test public void unstableBlinkingStatusShouldOverrideSuccessStatus() throws Exception { monitor.updateDisplay(createJobsListFromJson(jenkinsJobYellowAnimatedJson, jenkinsJobBlueJson)); Mockito.verify(display, Mockito.times(1)).displayUnstable(); Mockito.verifyNoMoreInteractions(display); } }
[ "julian.heise@zalando.de" ]
julian.heise@zalando.de
9c335a4f5e721629ef6176cda024606ad05f9825
800391064d513694784e8d41c67b934fc9f885f3
/src/com/jdon/util/ClassUtil.java
b949ad0e51be634ba58903f9d49c2467b737ae17
[ "Apache-2.0" ]
permissive
aduan/jdonframework
3322088502205706de66398bcfe31e74402539cb
1a4ef2db995f9a851e387746eb8466a3189a283a
refs/heads/master
2021-01-18T08:56:26.212888
2013-04-27T06:07:33
2013-04-27T06:07:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,504
java
/* * Copyright 2003-2009 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.jdon.util; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class ClassUtil { public static Class[] getParentAllInterfaces(Class pojoClass) { Class[] interfaces = null; try { List interfacesL = new ArrayList(); while (pojoClass != null) { for (int i = 0; i < pojoClass.getInterfaces().length; i++) { Class ifc = pojoClass.getInterfaces()[i]; // not add jdk interface if (!ifc.getName().startsWith("java.")) interfacesL.add(ifc); } pojoClass = pojoClass.getSuperclass(); } if (interfacesL.size() == 0) { throw new Exception(); } interfaces = (Class[]) interfacesL.toArray(new Class[interfacesL.size()]); } catch (Exception e) { } return interfaces; } public static Class[] getAllInterfaces(Class clazz) { if (clazz == null) { return new Class[0]; } List<Class> classList = new ArrayList<Class>(); while (clazz != null) { Class[] interfaces = clazz.getInterfaces(); for (Class interf : interfaces) { if (!classList.contains(interf)) { classList.add(interf); } Class[] superInterfaces = getAllInterfaces(interf); for (Class superIntf : superInterfaces) { if (!classList.contains(superIntf)) { classList.add(superIntf); } } } clazz = clazz.getSuperclass(); } return classList.toArray(new Class[classList.size()]); } public static Field[] getAllDecaredFields(Class clazz) { List<Field> fields = new ArrayList<Field>(); // fields.addAll(Arrays.asList(clazz.getDeclaredFields())); Class[] superClasses = getAllSuperclasses(clazz); for (Class superClass : superClasses) { fields.addAll(Arrays.asList(superClass.getDeclaredFields())); } return fields.toArray(new Field[fields.size()]); } public static Class finddAnnotationForMethod(Class clazz, Class annotationClass) { Class[] superClasses = getAllSuperclasses(clazz); if (superClasses != null) for (Class superClass : superClasses) { if (superClass.isAnnotationPresent(annotationClass)) { return superClass; } } superClasses = getParentAllInterfaces(clazz); if (superClasses != null) for (Class superClass : superClasses) { if (superClass.isAnnotationPresent(annotationClass)) { return superClass; } } return null; } public static Method finddAnnotationForMethod(Method m, Class annotationClass) { try { Class[] superClasses = getAllSuperclasses(m.getDeclaringClass()); if (superClasses != null) for (Class superClass : superClasses) { for (Method ms : superClass.getDeclaredMethods()) { if (ms.isAnnotationPresent(annotationClass)) { if (ms.getName() == m.getName()) { return ms; } } } } superClasses = getParentAllInterfaces(m.getDeclaringClass()); if (superClasses != null) for (Class superClass : superClasses) { for (Method ms : superClass.getDeclaredMethods()) { if (ms.isAnnotationPresent(annotationClass)) { if (ms.getName() == m.getName()) { return ms; } } } } } catch (SecurityException e) { e.printStackTrace(); } return null; } public static Method[] getAllDecaredMethods(Class clazz) { List<Method> methods = new ArrayList<Method>(); // fields.addAll(Arrays.asList(clazz.getDeclaredFields())); Class[] superClasses = getAllSuperclasses(clazz); for (Class superClass : superClasses) { methods.addAll(Arrays.asList(superClass.getDeclaredMethods())); } // superClasses = getParentAllInterfaces(clazz); // for (Class superClass : superClasses) { // methods.addAll(Arrays.asList(superClass.getDeclaredMethods())); // } return methods.toArray(new Method[methods.size()]); } public static Class[] getAllSuperclasses(Class cls) { if (cls == null) { return new Class[0]; } List<Class> classList = new ArrayList<Class>(); Class superClass = cls; while (superClass != null && !Object.class.equals(superClass) && !Class.class.equals(superClass)) { classList.add(superClass); superClass = superClass.getSuperclass(); } return classList.toArray(new Class[classList.size()]); } public static Field getDecaredField(Class clazz, String name) throws NoSuchFieldException { Field field = null; Class[] superClasses = getAllSuperclasses(clazz); for (Class superClass : superClasses) { try { field = superClass.getDeclaredField(name); break; } catch (NoSuchFieldException e) { // ignore } } if (field == null) { throw new NoSuchFieldException("No such declared field " + name + " in " + clazz); } return field; } }
[ "banq@163.com" ]
banq@163.com
23177aa6c647103ac4193756ab2410d240fd8144
5ce9f7f8ab8d6d5b492e64b7cb3f2e4a34a69ae1
/src/com/learning/module/Customer.java
cdd1cf724e09ba28615bc68ac643a2e195643764
[]
no_license
MayuriMusalgaonkar/gl-development
c37de0f5999f80687db97643bb4ca949aa297200
f8c5506c5bb29469a61a7158b7ace7893e6b4420
refs/heads/master
2023-07-15T09:45:15.617478
2021-08-23T16:24:26
2021-08-23T16:24:26
394,716,131
0
0
null
null
null
null
UTF-8
Java
false
false
953
java
package com.learning.module; public class Customer { private String password; private int bankAccountNo; private int balance; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public int getBankAccountNo() { return bankAccountNo; } public void setBankAccountNo(int bankAccountNo) { this.bankAccountNo = bankAccountNo; } public int getBalance() { return balance; } public void setBalance(int balance) { this.balance = balance; } public Customer(String password, int bankAccountNo) { this.password = password; this.bankAccountNo = bankAccountNo; } public Customer(String password, int bankAccountNo,int balance) { this.password = password; this.bankAccountNo = bankAccountNo; this.balance=balance; } }
[ "mayuridafne5@gmail.com" ]
mayuridafne5@gmail.com
70fdc3a1196f8a5639f358b1f999ca333d44df71
2d65fe9c26ea9ae354bd28028083f9cfe71d0579
/app/src/main/java/com/example/xxovek/salesman_tracker1/admin/routes/ShowRoutesFragment.java
5e4cd8451ccbe98eb5f8ebc097da95233936824b
[]
no_license
rockstarsantosh1994/Salesman_tracker1
937400c507b748c31a5e1b5d230c627e86f27c63
39e38365babf33f12a451622029480e9862a1b77
refs/heads/master
2020-06-22T20:22:13.390225
2019-08-09T06:39:49
2019-08-09T06:39:49
195,234,964
0
0
null
null
null
null
UTF-8
Java
false
false
12,679
java
package com.example.xxovek.salesman_tracker1.admin.routes; import android.content.Context; import android.content.DialogInterface; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AlertDialog; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; import com.example.xxovek.salesman_tracker1.ConfigUrls; import com.example.xxovek.salesman_tracker1.R; import com.example.xxovek.salesman_tracker1.admin.addshopsonroute.AddRouteForShopsFragment; import com.example.xxovek.salesman_tracker1.admin.tabs.AddShopOnRoutesTab; import com.example.xxovek.salesman_tracker1.admin.tabs.RoutesFragmentTab; import com.example.xxovek.salesman_tracker1.user.MyRecyclerViewAdapter; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ShowRoutesFragment extends Fragment implements MyRecyclerViewAdapter.ItemClickListener{ RecyclerView recyclerView; public int i; public MyRecyclerViewAdapter adapter; Button button77; String n [] ; String a=""; List<String> al = new ArrayList<String>(); List<String> al1 = new ArrayList<String>(); List<String> al2 = new ArrayList<String>(); List<String> al3 = new ArrayList<String>(); List<String> al4 = new ArrayList<String>(); List<String> al5 = new ArrayList<String>(); public String st_assignid; private String cid="3"; public ShowRoutesFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_show_route_details, container, false); recyclerView = view.findViewById(R.id.admin_show_recycle_id); final String LOGIN_URL = "http://track.xxovek.com/src/display_routes"; //Creating a string request StringRequest stringRequest = new StringRequest(Request.Method.POST, ConfigUrls.DISPLAY_ROUTE, new Response.Listener<String>() { @Override public void onResponse(String response) { //If we are getting success from server if(TextUtils.isEmpty(response)){ //Creating a shared preference //.makeText(ShowRoutesFragment.this.getContext(), "No Shops"+response.toString(), //.LENGTH_LONG).show(); }else{ JSONArray json_data = null; try { json_data = new JSONArray(response); int len = json_data.length(); //.makeText(getContext(), response.toString(), //.LENGTH_SHORT).show(); for(int i=0; i<json_data.length();i++){ JSONObject json = json_data.getJSONObject(i); al1.add((json.getString("RouteId"))); al2.add("Src: ".concat(json.getString("source"))); al3.add("Dest: ".concat(json.getString("dest"))); al4.add("Created At : ".concat(json.getString("creattime"))); al5.add("Updated At : ".concat(json.getString("updatetime"))); // st_assignid =(json.getString("status")); // a= a + "Age : "+json.getString("c_phone")+"\n"; //j= j + "Job : "+json.getString("Job")+"\n"; } // ////.makeText(getContext(), n.toString(), //.LENGTH_SHORT).show(); String result1 = response.replace("\"", ""); result1 = result1.replaceAll("[\\[\\]\\(\\)]", ""); String str[] = result1.split(","); //.makeText(getContext(), al.toString(), //.LENGTH_SHORT).show(); //.makeText(getContext(), al2.toString(), //.LENGTH_SHORT).show(); //al = Arrays.asList(n); final RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); adapter = new MyRecyclerViewAdapter(getContext(), al1,al2,al3,al4,al5,al5,al3,al2,al1,al1,"2"); adapter.setClickListener(ShowRoutesFragment.this); recyclerView.setAdapter(adapter); recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); } catch (JSONException e) { e.printStackTrace(); } } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { //You can handle error here if you want } }){ @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String,String> params = new HashMap<>(); //Adding parameters to request params.put("admin_id", cid); //returning parameter return params; } }; //Adding the string request to the queue RequestQueue requestQueue = Volley.newRequestQueue(getContext()); requestQueue.add(stringRequest); return view; } @Override public void onItemClick(View view, int position) { int id=view.getId(); String user_id1 = adapter.getItem(position); String source = adapter.getItem2(position); String dest = adapter.getItem3(position); // //.makeText(getContext(), "getitem is " + user_id1.toString() + " on row number " + position, //.LENGTH_SHORT).show(); //.makeText(getContext(), "On Item Clicked"+id, //.LENGTH_SHORT).show(); switch (id){ case R.id.ib_edit:Fragment fragment = new AddRoutesFragment(); FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Bundle data = new Bundle();//Use bundle to pass data data.putString("data", user_id1); data.putString("source", source); data.putString("dest", dest); fragment.setArguments(data); fragmentTransaction.replace(R.id.main_container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); break; case R.id.ib_delete: final String st_delid= adapter.getItem(position); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setIcon(android.R.drawable.ic_lock_power_off); builder.setTitle("Delete"); builder.setMessage("Do you really want to delete?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //.makeText(getContext(), "st_delid\n"+st_delid, //.LENGTH_SHORT).show(); StringRequest stringRequest = new StringRequest(Request.Method.POST, ConfigUrls.REMOVE_DETAILS, new Response.Listener<String>() { @Override public void onResponse(String response) { //If we are getting success from server if(TextUtils.isEmpty(response)){ //Creating a shared preference //.makeText(getContext(), "Unable to delete product data"+response.toString(), //.LENGTH_LONG).show(); }else{ //.makeText(getContext(), "Customer Deleted Successfully"+response, //.LENGTH_SHORT).show(); Log.d("mytag", "onResponse:REMOVE_DETAILS "+response); Fragment fragment = new RoutesFragmentTab(); FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.main_container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); adapter.notifyDataSetChanged(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { //You can handle error here if you want } }){ @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String,String> params = new HashMap<>(); //Adding parameters to request String tblname="RouteMaster"; String colname="RouteId"; params.put("id", st_delid); params.put("tblName", tblname); params.put("colName", colname); // params.put("password", password); Log.d("mytag", "\ngetParams: ID "+st_delid+"\ntblname "+tblname+"\ncolname "+colname); //returning parameter return params; } }; //Adding the string request to the queue RequestQueue requestQueue = Volley.newRequestQueue(getContext()); requestQueue.add(stringRequest); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //.makeText(getContext(), "Delete Operation Cancelled", //.LENGTH_SHORT).show(); } }); AlertDialog dialog = builder.create(); dialog.show(); break; } // Intent intent = new Intent(getContext(), Clientsinfo.class); // startActivity(intent); } }
[ "santoshpardeshi1994@gmail.com" ]
santoshpardeshi1994@gmail.com
cf8bdf58a32c4cbd9fdab941e6fcd26cf047ec9b
f4bb30d1ba864dfcc2a6b2e646f740693760a973
/javaenhance/src/cn/itcast/day3/MyAdvice.java
c5523efb20ec5ed66436a2050968faec7c7fa175
[]
no_license
zhaoccx/JavaBase
762e3a075aec5e369774fb4937692614fcca8c66
152d71eec8b7af444a2c5fc410a6bdbb3b576d4f
refs/heads/master
2020-12-13T07:45:35.219768
2017-10-25T13:04:37
2017-10-25T13:04:37
26,492,779
0
0
null
null
null
null
UTF-8
Java
false
false
529
java
package cn.itcast.day3; import java.lang.reflect.Method; public class MyAdvice implements Advice { long beginTime = 0; @Override public void afterMethod(Method method) { System.out.println("从传智播客毕业上班啦!"); long endTime = System.currentTimeMillis(); System.out.println(method.getName() + " running time of " + (endTime - beginTime)); } @Override public void beforeMethod(Method method) { System.out.println("到传智播客来学习啦!"); beginTime = System.currentTimeMillis(); } }
[ "zhaoccx@hotmail.com" ]
zhaoccx@hotmail.com
be67a350b0c9593451c62109af1de0e934e797d9
e9ad092dfc4efe87fe49e3d3083482311f765731
/dans-wicket/src/main/java/nl/knaw/dans/common/wicket/behavior/IncludeJsOrCssBehavior.java
3b49bf6c873766fb0bab81d47c308759bdd18d1c
[ "Apache-2.0" ]
permissive
DANS-KNAW/dccd-legacy-libs
e0f863cc5953dcceb9b91d4eb6ffdd0d37831bbb
687d2e434359ad80af0b192748475ec4a76529c4
refs/heads/master
2021-01-01T19:35:17.114074
2019-09-03T13:58:30
2019-09-03T13:58:30
37,195,178
0
1
Apache-2.0
2020-10-13T06:53:30
2015-06-10T12:15:06
Java
UTF-8
Java
false
false
3,032
java
/******************************************************************************* * Copyright 2015 DANS - Data Archiving and Networked Services * * 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 nl.knaw.dans.common.wicket.behavior; import org.apache.wicket.ResourceReference; import org.apache.wicket.behavior.AbstractBehavior; import org.apache.wicket.markup.html.IHeaderResponse; import org.apache.wicket.markup.html.resources.CompressedResourceReference; /** * <p> * Behavior that adds an included css or JS resource to component (e.g., a page). The scope is a class in * the same package as where the resource resides. Typically, the scope is the class object of a wicket * page or panel and the resource is CSS- or JavaScript file that is included in the source code in the * same package as the class. The HTML-template of the class can then refer to the resource without a * prefixed path. * </p> * <p> * Example: * * <pre> * JAVA FILE: * * public class MyPage extends Page { * * public MyPage() { * add(new IncludeResourceBehavior(MyPage.class, "myjavascript.js"); * // ... etc * * HTML-TEMPLATE MyPage.html: * * &lt;html&gt; * &lt;head&gt; * &lt;script type="text/javascript" src="myjavascript.js"&gt; * * &lt;-- etc --&gt; * </pre> */ public class IncludeJsOrCssBehavior extends AbstractBehavior { private static final long serialVersionUID = 5261628952131156563L; private final Class<?> scope; private final String resource; public IncludeJsOrCssBehavior(Class<?> scope, String resource) { if (!resource.endsWith(".js") && !resource.endsWith(".css")) { throw new IllegalArgumentException("Only JavaScript or CSS resources can be rendered"); } this.scope = scope; this.resource = resource; } @Override public void renderHead(IHeaderResponse response) { final ResourceReference ref = new CompressedResourceReference(scope, resource); if (resource.endsWith(".js")) { response.renderJavascriptReference(ref); } else if (resource.endsWith(".css")) { response.renderCSSReference(ref); } else { throw new RuntimeException("Only know how to render JavaScript or CSS references"); } } }
[ "jan.van.mansum@dans.knaw.nl" ]
jan.van.mansum@dans.knaw.nl
af017ae72eae805a7e9adaa6a5d53e834feee09c
850b06f040ae8445d6f5d21e881ff43cd3f8788c
/src/main/java/ru/kolyasnikovkv/discussion1c/util/HttpUtil.java
b3cce931adac75c9bfcfe88573636782757955fe
[]
no_license
KolyasnikovKV/1CDiscussion
675bde1aa070804825f104e1f8064297873d0fdb
a39b57114877a337883be63ea57a8a428171d152
refs/heads/master
2022-09-30T19:19:16.221953
2020-03-18T08:26:01
2020-03-18T08:26:01
248,157,272
0
0
null
2022-09-01T23:21:39
2020-03-18T06:40:02
Java
UTF-8
Java
false
false
1,658
java
package ru.kolyasnikovkv.discussion1c.util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * Created by tomoya. * Copyright (c) 2018, All Rights Reserved. * https://yiiu.co */ public class HttpUtil { public static boolean isApiRequest(HttpServletRequest request) { return request.getHeader("Accept") == null || !request.getHeader("Accept").contains("text/html"); } // 根据请求接收的类型定义不同的响应方式 // 判断请求对象request里的header里accept字段接收类型 // 如果是 text/html 则响应一段js,这里要将response对象的响应内容类型也设置成 text/javascript // 如果是 application/json 则响应一串json,response 对象的响应内容类型要设置成 application/json // 因为响应内容描述是中文,所以都要带上 ;charset=utf-8 否则会有乱码 // 写注释真累费劲。。 public static void responseWrite(HttpServletRequest request, HttpServletResponse response) throws IOException { if (!HttpUtil.isApiRequest(request)) { response.setContentType("text/html;charset=utf-8"); response.getWriter().write("<script>alert('请先登录!');window.history.go(-1);</script>"); } else /*if (accept.contains("application/json"))*/ { response.setContentType("application/json;charset=utf-8"); Result result = new Result(); result.setCode(201); result.setDescription("请先登录"); response.getWriter().write(JsonUtil.objectToJson(result)); } } }
[ "1c81@mail.ru" ]
1c81@mail.ru
517d272cc885257299930b5bf11e18d71d3d44c8
49b4cb79c910a17525b59d4b497a09fa28a9e3a8
/parserValidCheck/src/main/java/com/ke/css/cimp/fwb/fwb7/Rule_Hid_Goods_data_Identifier_S.java
11eda4b5085f914a04f3f6747fd7e727e49b921e
[]
no_license
ganzijo/koreanair
a7d750b62cec2647bfb2bed4ca1bf8648d9a447d
e980fb11bc4b8defae62c9d88e5c70a659bef436
refs/heads/master
2021-04-26T22:04:17.478461
2018-03-06T05:59:32
2018-03-06T05:59:32
124,018,887
0
0
null
null
null
null
UTF-8
Java
false
false
2,359
java
package com.ke.css.cimp.fwb.fwb7; /* ----------------------------------------------------------------------------- * Rule_Hid_Goods_data_Identifier_S.java * ----------------------------------------------------------------------------- * * Producer : com.parse2.aparse.Parser 2.5 * Produced : Tue Mar 06 10:38:08 KST 2018 * * ----------------------------------------------------------------------------- */ import java.util.ArrayList; final public class Rule_Hid_Goods_data_Identifier_S extends Rule { public Rule_Hid_Goods_data_Identifier_S(String spelling, ArrayList<Rule> rules) { super(spelling, rules); } public Object accept(Visitor visitor) { return visitor.visit(this); } public static Rule_Hid_Goods_data_Identifier_S parse(ParserContext context) { context.push("Hid_Goods_data_Identifier_S"); boolean parsed = true; int s0 = context.index; ParserAlternative a0 = new ParserAlternative(s0); ArrayList<ParserAlternative> as1 = new ArrayList<ParserAlternative>(); parsed = false; { int s1 = context.index; ParserAlternative a1 = new ParserAlternative(s1); parsed = true; if (parsed) { boolean f1 = true; int c1 = 0; for (int i1 = 0; i1 < 1 && f1; i1++) { Rule rule = Terminal_StringValue.parse(context, "S"); if ((f1 = rule != null)) { a1.add(rule, context.index); c1++; } } parsed = c1 == 1; } if (parsed) { as1.add(a1); } context.index = s1; } ParserAlternative b = ParserAlternative.getBest(as1); parsed = b != null; if (parsed) { a0.add(b.rules, b.end); context.index = b.end; } Rule rule = null; if (parsed) { rule = new Rule_Hid_Goods_data_Identifier_S(context.text.substring(a0.start, a0.end), a0.rules); } else { context.index = s0; } context.pop("Hid_Goods_data_Identifier_S", parsed); return (Rule_Hid_Goods_data_Identifier_S)rule; } } /* ----------------------------------------------------------------------------- * eof * ----------------------------------------------------------------------------- */
[ "wrjo@wrjo-PC" ]
wrjo@wrjo-PC
11e315c624dccee40e69e57caa1c4898335b7ec1
0fcdd676181754b9f93081b597fac5c4c62bcda6
/p0261intentfilter/src/main/java/ru/startandroid/p0261intentfilter/ActivityTime.java
d71c75f23742af27d4474f3f865df0809d1483c5
[]
no_license
vladislawovk/AndroidLessons
3ff622b3e2ec2a063d9f4c0dd39fcfcd4193b159
1ea6bd67d789c55d8da8ef5add7f202c0c4e003c
refs/heads/master
2023-02-20T04:37:10.211928
2021-01-25T11:02:20
2021-01-25T11:02:20
322,619,068
1
0
null
null
null
null
UTF-8
Java
false
false
669
java
package ru.startandroid.p0261intentfilter; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import java.sql.Date; import java.text.SimpleDateFormat; public class ActivityTime extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_time); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); String time = sdf.format(new Date(System.currentTimeMillis())); TextView tvTime = (TextView) findViewById(R.id.tvTime); tvTime.setText(time); } }
[ "vladislawovk@gmail.com" ]
vladislawovk@gmail.com
2c7984d314dd286d28d3d69d8a853e2d5dfe1a9c
391df28a26a8115dec2686c30f9c9c8c47123401
/ManyToOne/src/main/java/com/bridgelabz/ManyToOne/App.java
ac6652a9a83da1096aab4a8c472449d682f00eaa
[]
no_license
sujitchincholkar/Hibernate
c7d05e8be8de78e94a665ac8c3bb4cd90c5d6d57
4b547c545173a0af8dce0fd0a2c011c191edd2bb
refs/heads/master
2021-07-18T14:19:38.010311
2017-10-27T12:51:49
2017-10-27T12:51:49
107,673,581
0
0
null
null
null
null
UTF-8
Java
false
false
911
java
package com.bridgelabz.ManyToOne; import java.util.Scanner; import com.bridgelabz.ManyToOne.EmployeDao; public class App { public static void main( String[] args ) { Scanner scanner=new Scanner(System.in); int choice; String continueLoop="y"; while(continueLoop.equals("y")) { System.out.println("Enter choice \n1.Add \n2.update \n3.Delete"); choice=scanner.nextInt(); switch(choice) { case 1: EmployeDao.addEmployee(); break; case 2: EmployeDao.updateEmployee(); break; case 3: EmployeDao.deleteEmployee(); break; default: System.out.println("wrong choice "); } System.out.println("Do you want to continue[Y/N]"); continueLoop=scanner.next(); } } }
[ "chincholkarsujit@gmail.com" ]
chincholkarsujit@gmail.com
393eb7d3bfe93b93e042cd949295cb7dc5fb2aa1
abeecfef5a3cd8fbfdeea0b81ef918710d5141a0
/class02/src/androidTest/java/com/ourdreamit/batch002class02/ExampleInstrumentedTest.java
1af289943bdfad2318b40504f6c3a8d1bebb0ffd
[]
no_license
anismizicse/Android_Batch_Two_Master
2a9c3fd4707a47aff0cc78f9d397167f828e8cc5
2182c360188b56a59857b6fcd28c1175efad9166
refs/heads/master
2020-12-04T03:46:43.627368
2020-01-18T15:29:50
2020-01-18T15:29:50
231,596,627
0
0
null
null
null
null
UTF-8
Java
false
false
776
java
package com.ourdreamit.batch002class02; import android.content.Context; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.ourdreamit.batch002class02", appContext.getPackageName()); } }
[ "anismizicse@gmail.com" ]
anismizicse@gmail.com
12a157aaf647cdbceacee9ccbb0881eb72788f56
f9aeff9ad09c6b8d5b94b3550659791e39d40080
/Itsc1212/src/Post3.java
ca8deeeb7064d5a9c2183d36801e34de125b0df3
[]
no_license
rameshkoirala210/Java
cdb32759ffdeb3b225f76f943e98ba77ddc45925
ef3266baa72b4c9f3508dd5159ee05a9311050c9
refs/heads/master
2023-03-26T23:31:25.701140
2021-03-26T17:30:59
2021-03-26T17:30:59
254,694,057
0
0
null
null
null
null
UTF-8
Java
false
false
2,461
java
import java.util.*; //By Ramesh Koirala //Verson 1? //Date: 2/18/2020 // public class Post3 { public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.println("ID001"); System.out.println("Would you like to pick a card? Y/N");//ask user quwstion String card = a.next();//saving it as string if (card.equals("Y")) {//if user input is Y int faceValue = (int) ( Math.random() * 13 + 1);//getting random number int suit = (int) ( Math.random() * 3);//random suit System.out.print("you got a "); if(faceValue == 1) {//another if statement System.out.print("Ace "); if(suit == 0) {//if statement to get suit System.out.print("of Hearts"); }else if(suit == 1) { System.out.print("of Dimonds"); }else if(suit == 2) { System.out.print("of Clubs"); }else if(suit == 3) { System.out.print("of Spades"); } }else if(faceValue > 1 || faceValue < 11) {//if face value is greater then 1 and less then 11 System.out.print(faceValue ); if(suit == 0) {//if statement to get suit System.out.print(" of Hearts "); }else if(suit == 1) { System.out.print(" of Dimonds "); }else if(suit == 2) { System.out.print(" of Clubs "); }else if(suit == 3) { System.out.print(" of Spades "); } }if(faceValue == 11) {//if its 11 System.out.print("Jack "); if(suit == 0) {//if statement to get suit System.out.print("of Hearts"); }else if(suit == 1) { System.out.print("of Dimonds"); }else if(suit == 2) { System.out.print("of Clubs"); }else if(suit == 3) { System.out.print("of Spades"); } }if(faceValue == 12) {//if its 12 System.out.print("Queen "); if(suit == 0) {//if statement to get suit System.out.print("of Hearts"); }else if(suit == 1) { System.out.print("of Dimonds"); }else if(suit == 2) { System.out.print("of Clubs"); }else if(suit == 3) { System.out.print("of Spades"); } }if(faceValue == 13) {//if its 13 System.out.print("King "); if(suit == 0) {//if statement to get suit System.out.print("of Hearts"); }else if(suit == 1) { System.out.print("of Dimonds"); }else if(suit == 2) { System.out.print("of Clubs"); }else if(suit == 3) { System.out.print("of Spades"); } } }else{ System.out.print("Bye"); } } }
[ "rameshkoirala210@gmail.com" ]
rameshkoirala210@gmail.com
ccfc596936c432f6e32c7ef55e44ed902b9ed880
fba8af31d5d36d8a6cf0c341faed98b6cd5ec0cb
/src/main/java/com/alipay/api/response/AlipayEcardEduCardGetResponse.java
d1ce77ac03b8fa5858523b550f4b0ad11a54b52e
[ "Apache-2.0" ]
permissive
planesweep/alipay-sdk-java-all
b60ea1437e3377582bd08c61f942018891ce7762
637edbcc5ed137c2b55064521f24b675c3080e37
refs/heads/master
2020-12-12T09:23:19.133661
2020-01-09T11:04:31
2020-01-09T11:04:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,270
java
package com.alipay.api.response; import java.util.List; import com.alipay.api.internal.mapping.ApiField; import com.alipay.api.internal.mapping.ApiListField; import com.alipay.api.domain.EduOneCardDepositCardQueryResult; import com.alipay.api.AlipayResponse; /** * ALIPAY API: alipay.ecard.edu.card.get response. * * @author auto create * @since 1.0, 2019-03-08 15:29:11 */ public class AlipayEcardEduCardGetResponse extends AlipayResponse { private static final long serialVersionUID = 3142436285679687952L; /** * 用户是否首次充值标记 */ @ApiField("first_deposit_flag") private Boolean firstDepositFlag; /** * 校园一卡通历史充值卡信息查询结果对象 */ @ApiListField("onecard") @ApiField("edu_one_card_deposit_card_query_result") private List<EduOneCardDepositCardQueryResult> onecard; public void setFirstDepositFlag(Boolean firstDepositFlag) { this.firstDepositFlag = firstDepositFlag; } public Boolean getFirstDepositFlag( ) { return this.firstDepositFlag; } public void setOnecard(List<EduOneCardDepositCardQueryResult> onecard) { this.onecard = onecard; } public List<EduOneCardDepositCardQueryResult> getOnecard( ) { return this.onecard; } }
[ "ben.zy@antfin.com" ]
ben.zy@antfin.com
04cb89a5f39c23c632edec64be3f015d9469934a
b73129ae663d18693c7a220ebb41a3f56b7c2c69
/code/Ch10/Old/Image/Example2/Example2c.java
bf82a2489abf4ea5c4b6a13d01d9299230bbcfb5
[]
no_license
cse2016hy/cse2016hy.github.io
eb5f2c09a08a696cf05a2c25e86952123bdbccce
5617358a457be01dfa666cebea878255cbff3427
refs/heads/master
2022-11-29T12:59:43.869584
2022-11-28T02:08:38
2022-11-28T02:08:38
146,400,368
9
18
null
null
null
null
UTF-8
Java
false
false
201
java
/** Example2c starts the application */ public class Example2c { public static void main(String[] args) { Counterl model = new Counterl(0); Frame2c view = new Frame2c(model); } }
[ "highest416@naver.com" ]
highest416@naver.com
97356a5672719070a1413c561ab9137b82ae6175
804247bd22eb0424df9527dd24b3126efd58ffb3
/src/main/java/module-info.java
ed8d2d7d8963c7e2d1e6d15403126f68e6a2b09b
[ "Apache-2.0" ]
permissive
stelesoft/FortiFY
8596651b8b1b345c1d8a103c38b4f2e01a2c0bea
db9e7d88cf41f4fd277604589253b615239856d9
refs/heads/master
2023-01-03T11:52:56.221671
2020-10-18T23:20:19
2020-10-18T23:20:19
291,571,980
0
1
Apache-2.0
2020-10-18T23:19:36
2020-08-30T23:49:34
null
UTF-8
Java
false
false
895
java
/* * Copyright 2020 Stelesoft.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. */ /** * Base module for the FortiFY library. */ module FortiFY { // Module dependencies requires javafx.base; requires javafx.controls; requires javafx.graphics; // Expose module contents to the outside world exports com.stelesoft.fortify; }
[ "stele@stelesoft.com" ]
stele@stelesoft.com
4d5c276638063462e2abce0eb18ea6f3a91b7de1
cb5310ae9cb5a81c191a3e2f358b94f463b2fa6b
/cocoatouch/src/main/java/org/robovm/apple/uikit/UISplitViewControllerDelegateAdapter.java
1eac073bd790d09bacda8ac028b0e019ad83d801
[ "Apache-2.0" ]
permissive
jiangwh/robovm
a3da6d97083eab70ddeb4942d5bafa82d231aec2
a58b3a1928a60ea132b41cd0e51fae5550e224f5
refs/heads/master
2020-12-25T04:47:23.403516
2014-07-17T00:35:34
2014-07-17T00:35:34
21,945,788
1
0
null
null
null
null
UTF-8
Java
false
false
3,428
java
/* * Copyright (C) 2014 Trillian Mobile AB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.robovm.apple.uikit; /*<imports>*/ import java.io.*; import java.nio.*; import java.util.*; import org.robovm.objc.*; import org.robovm.objc.annotation.*; import org.robovm.objc.block.*; import org.robovm.rt.*; import org.robovm.rt.bro.*; import org.robovm.rt.bro.annotation.*; import org.robovm.rt.bro.ptr.*; import org.robovm.apple.foundation.*; import org.robovm.apple.coreanimation.*; import org.robovm.apple.coregraphics.*; import org.robovm.apple.coredata.*; import org.robovm.apple.coreimage.*; /*</imports>*/ /*<javadoc>*/ /*</javadoc>*/ /*<annotations>*//*</annotations>*/ /*<visibility>*/public/*</visibility>*/ class /*<name>*/UISplitViewControllerDelegateAdapter/*</name>*/ extends /*<extends>*/NSObject/*</extends>*/ /*<implements>*/implements UISplitViewControllerDelegate/*</implements>*/ { /*<ptr>*/ /*</ptr>*/ /*<bind>*/ /*</bind>*/ /*<constants>*//*</constants>*/ /*<constructors>*//*</constructors>*/ /*<properties>*/ /*</properties>*/ /*<members>*//*</members>*/ /*<methods>*/ @NotImplemented("splitViewController:willHideViewController:withBarButtonItem:forPopoverController:") public void willHideViewController(UISplitViewController svc, UIViewController aViewController, UIBarButtonItem barButtonItem, UIPopoverController pc) { throw new UnsupportedOperationException(); } @NotImplemented("splitViewController:willShowViewController:invalidatingBarButtonItem:") public void willShowViewController(UISplitViewController svc, UIViewController aViewController, UIBarButtonItem barButtonItem) { throw new UnsupportedOperationException(); } @NotImplemented("splitViewController:popoverController:willPresentViewController:") public void willPresentViewController(UISplitViewController svc, UIPopoverController pc, UIViewController aViewController) { throw new UnsupportedOperationException(); } /** * @since Available in iOS 5.0 and later. */ @NotImplemented("splitViewController:shouldHideViewController:inOrientation:") public boolean shouldHideViewController(UISplitViewController svc, UIViewController vc, UIInterfaceOrientation orientation) { throw new UnsupportedOperationException(); } /** * @since Available in iOS 7.0 and later. */ @NotImplemented("splitViewControllerSupportedInterfaceOrientations:") public @MachineSizedUInt long getSupportedInterfaceOrientations(UISplitViewController splitViewController) { throw new UnsupportedOperationException(); } /** * @since Available in iOS 7.0 and later. */ @NotImplemented("splitViewControllerPreferredInterfaceOrientationForPresentation:") public UIInterfaceOrientation name(UISplitViewController splitViewController) { throw new UnsupportedOperationException(); } /*</methods>*/ }
[ "niklas@therning.org" ]
niklas@therning.org
f5cb0ae9c4826e14b534ce07713280e16ca34cba
ee0a1fc029ce62881f25a510e99e12be0d2600e0
/app/src/main/java/com/cartoony/fragment/SettingFragment.java
c24fdab736c7e9723db332bf5489c491882e4e6b
[]
no_license
softinsolutions/AllInOneVideo_V1.9
975035b114a5fb9fda6698e096d3f3ca79171f48
33931c406213eeed9319946f56c369dcd3463104
refs/heads/master
2022-12-14T23:09:19.347861
2020-08-25T10:41:16
2020-08-25T10:41:16
289,996,780
0
0
null
null
null
null
UTF-8
Java
false
false
5,562
java
package com.cartoony.fragment; import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatDelegate; import androidx.fragment.app.Fragment; import androidx.appcompat.widget.SwitchCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.LinearLayout; import com.onesignal.OneSignal; import com.cartoony.allinonevideo.ActivityAboutUs; import com.cartoony.allinonevideo.ActivityPrivacy; import com.cartoony.allinonevideo.MyApplication; import com.cartoony.allinonevideo.R; public class SettingFragment extends Fragment { MyApplication MyApp; SwitchCompat notificationSwitch,notificationSwitchMode; LinearLayout lytAbout, lytPrivacy, lytMoreApp, layRateApp,layShareApp; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.fragment_setting, container, false); MyApp = MyApplication.getInstance(); notificationSwitch = rootView.findViewById(R.id.switch_notification); lytAbout = rootView.findViewById(R.id.lytAbout); lytPrivacy = rootView.findViewById(R.id.lytPrivacy); lytMoreApp = rootView.findViewById(R.id.lytMoreApp); layRateApp = rootView.findViewById(R.id.lytRateApp); layShareApp=rootView.findViewById(R.id.lytShareApp); notificationSwitch.setChecked(MyApp.getNotification()); notificationSwitchMode=rootView.findViewById(R.id.switch_notification_night); if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) notificationSwitchMode.setChecked(true); notificationSwitchMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { MyApplication.getInstance().setIsNightModeEnabled(isChecked); MyApplication.getInstance().onCreate(); Intent intent = requireActivity().getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); requireActivity().finish(); startActivity(intent); } }); layRateApp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("market://details?id=" + requireActivity().getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); // To count with Play market backstack, After pressing back button, // to taken back to our application, we need to add following flags to intent. goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + requireActivity().getPackageName()))); } } }); notificationSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { MyApp.saveIsNotification(isChecked); OneSignal.setSubscription(isChecked); } }); lytAbout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent_ab = new Intent(requireActivity(), ActivityAboutUs.class); startActivity(intent_ab); } }); lytPrivacy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent_pri = new Intent(requireActivity(), ActivityPrivacy.class); startActivity(intent_pri); } }); lytMoreApp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.play_more_apps)))); } }); layShareApp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_msg) + "\n" + "https://play.google.com/store/apps/details?id=" + getActivity().getPackageName()); sendIntent.setType("text/plain"); startActivity(sendIntent); } }); return rootView; } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Add your menu entries here super.onCreateOptionsMenu(menu, inflater); menu.clear(); } }
[ "Softinsolutions4@gmail.com" ]
Softinsolutions4@gmail.com
8eeb1ebad6e6f9649a00a4fc7f0e286d0d2ba853
29c749118a2bf2925451c72f1750ff1f2e245301
/test/GameTest.java
3620e2229a3e325f9a81440ef09f4fa421b77a06
[]
no_license
fletterman/practica
22db32867e6eeec4137854a6cb47e13b074d8e9d
96b6e75287c4e0577e764fb3ea7d803ae3fd0d65
refs/heads/main
2023-03-31T23:36:46.601465
2021-04-07T21:50:23
2021-04-07T21:50:23
334,987,204
0
0
null
null
null
null
UTF-8
Java
false
false
3,593
java
import practicum_6A.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.time.LocalDate; import static org.junit.jupiter.api.Assertions.*; class GameTest { private Game game1JrOud; private int ditJaar; @BeforeEach public void init(){ ditJaar = LocalDate.now().getYear(); game1JrOud = new Game("Mario Kart", ditJaar-1, 50.0); } //region Tests met huidigeWaarde() @Test public void testHuidigeWaardeNwPrijsNa0Jr(){ Game game0JrOud = new Game("Mario Kart", ditJaar, 50.0); assertEquals(50.0, Math.round(game0JrOud.huidigeWaarde() * 100)/100d, "Huidige waarde na 0 jr niet correct."); } @Test public void testHuidigeWaardeNwPrijsNa1Jr(){ assertEquals(35.0, Math.round(game1JrOud.huidigeWaarde() * 100)/100d, "Huidige waarde na 1 jr niet correct."); } @Test public void testHuidigeWaardeNwPrijsNa5Jr(){ Game game5JrOud = new Game("Mario Kart", ditJaar-5, 50.0); assertEquals(8.4, Math.round(game5JrOud.huidigeWaarde() * 100)/100d, "Huidige waarde na 5 jr niet correct."); } @Test public void testHuidigeWaardeGratisGameNa0Jr(){ Game gratisGame0JrOud = new Game("Mario Kart Free", ditJaar, 0.0); assertEquals(0.0, Math.round(gratisGame0JrOud.huidigeWaarde() * 100)/100d, "Huidige waarde gratis game na 0 jr niet correct."); } @Test public void testHuidigeWaardeGratisGameNa5Jr(){ Game gratisGame5JrOud = new Game("Mario Kart Free", ditJaar-5, 0.0); assertEquals(0.0, Math.round(gratisGame5JrOud.huidigeWaarde() * 100)/100d, "Huidige waarde gratis game na 5 jr niet correct."); } //endregion //region Tests met equals() @Test public void testGameEqualsZelfdeGame() { Game zelfdeGame1JrOud = new Game("Mario Kart", ditJaar-1, 50.0); assertTrue(game1JrOud.equals(zelfdeGame1JrOud), "equals() geeft false bij vgl. met zelfde game"); } @Test public void testGameEqualsSelf() { assertTrue(game1JrOud.equals(game1JrOud), "equals() geeft false bij vgl. met zichzelf"); } @Test public void testGameNotEqualsString() { assertFalse(game1JrOud.equals("testString"), "equals() geeft true bij vgl. tussen game en String"); } @Test public void testGameNotEqualsGameAndereNaam() { Game otherGame1JrOud = new Game("Zelda", ditJaar-1, 35.0); assertFalse(game1JrOud.equals(otherGame1JrOud), "equals() geeft true bij vgl. met game met andere naam"); } @Test public void testGameNotEqualsGameAnderJaar() { Game game5JrOud = new Game("Mario Kart", ditJaar-5, 50.0); assertFalse(game1JrOud.equals(game5JrOud), "equals() geeft true bij vgl. met game met ander releaseJaar"); } @Test public void testGameEqualsGameAndereNwPrijs() { Game duurdereGame1JrOud = new Game("Mario Kart", ditJaar-1, 59.95); assertTrue(game1JrOud.equals(duurdereGame1JrOud), "equals() geeft false bij vgl. met zelfde game met andere nieuwprijs"); } @Test public void testGameNotEqualsGameHeelAndereGame() { Game heelAndereGame = new Game("Zelda", ditJaar-2, 41.95); assertFalse(game1JrOud.equals(heelAndereGame), "equals() geeft true bij vgl. met heel andere game"); } //endregion @Test public void testToString(){ assertEquals("Mario Kart, uitgegeven in " + (ditJaar-1) + "; nieuwprijs: €50,00 nu voor: €35,00", game1JrOud.toString(), "toString() geeft niet de juiste tekst terug."); } }
[ "stijn.castrop@me.com" ]
stijn.castrop@me.com