answer
stringlengths 17
10.2M
|
|---|
package com.hf.resreader;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Spinner;
import android.widget.TextView;
public class MainActivity extends Activity {
private static final String TAG = "ResReader";
private static final String TYPE_INTEGER = "integer";
private static final String TYPE_BOOLEAN = "bool";
private static final String TYPE_STRING = "string";
private static final String[] TYPES = {
TYPE_INTEGER,
TYPE_BOOLEAN,
TYPE_STRING
};
private static final String INTERNAL_PKG = "com.android.internal";
private static final String[] NATIVE_PKGS = new String[]{
"android",
INTERNAL_PKG
};
private Spinner mType;
private AutoCompleteTextView mPkg;
private AutoCompleteTextView mKey;
private TextView mValue;
private TextView mResId;
private int mValueTypeIndex = 0;
private String mValueType;
private String mValuePkg;
private String mValueKey;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mType = (Spinner) findViewById(R.id.type);
mPkg = (AutoCompleteTextView) findViewById(R.id.pkg);
mKey = (AutoCompleteTextView) findViewById(R.id.key);
mValue = (TextView) findViewById(R.id.value);
mResId = (TextView) findViewById(R.id.resid);
// get pkg auto complete
setPkgAutoComplete();
mPkg.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus && updatePkgValue()) {
// key auto complete
setKeyAutoComplete();
}
}
});
mType.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
if (updateTypeValue()) {
setKeyAutoComplete();
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
if (updateTypeValue()) {
setKeyAutoComplete();
}
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.read) {
onReadClicked();
return true;
} else if (item.getItemId() == R.id.clear) {
onClearClicked();
return true;
}
return super.onOptionsItemSelected(item);
}
private void onReadClicked() {
updateTypeValue();
updatePkgValue();
updateKeyValue();
Context ctxt = getPkgContext(mValuePkg);
int resId = getResId(ctxt, mValuePkg, mValueType, mValueKey);
String value = getValueOfResId(ctxt, mValueType, resId);
mResId.setText(String.valueOf(resId));
mValue.setText(value);
}
private void onClearClicked() {
mValue.setText("");
mResId.setText("");
}
private boolean isNativePkg(String pkg) {
if (pkg == null || pkg.isEmpty()) {
return true;
}
for (String p : NATIVE_PKGS) {
if (p.equals(pkg)) {
return true;
}
}
return false;
}
private int getResId(Context context, String pkg, String type, String key) {
if (isNativePkg(pkg)) {
return getResId2(key, type, pkg);
}
return context.getResources().getIdentifier(key, type, pkg);
}
private int getResId2(String key, String type, String pkg) {
int resId = -1;
try {
String clazzName = pkg + ".R$" + type;
Class<?> clazz = Class.forName(clazzName);
Field field = clazz.getField(key);
resId = field.getInt(null);
} catch (ClassNotFoundException e) {
Log.w(TAG, "getResId2()# ClassNotFoundException [pkg: " + pkg + ", type: " + type + ", key: " + key + "]", e);
} catch (NoSuchFieldException e) {
Log.w(TAG, "getResId2()# NoSuchFieldException [pkg: " + pkg + ", type: " + type + ", key: " + key + "]", e);
} catch (IllegalAccessException e) {
Log.w(TAG, "getResId2()
} catch (IllegalArgumentException e) {
Log.w(TAG, "getResId2()
}
return resId;
}
private Context getPkgContext(String pkg) {
Context context;
if (isNativePkg(pkg)) {
context = this;
} else {
context = createContext(pkg);
if (context == null) {
context = this;
}
}
return context;
}
private String getValueOfResId(Context context, String type, int resId) {
if (resId > 0) {
if (TYPE_INTEGER.equals(type)) {
int iValue = context.getResources().getInteger(resId);
return String.valueOf(iValue);
} else if (TYPE_BOOLEAN.equals(type)) {
boolean bValue = context.getResources().getBoolean(resId);
return String.valueOf(bValue);
} else if (TYPE_STRING.equals(type)) {
return context.getResources().getString(resId);
}
}
return getResources().getString(R.string.err_not_found);
}
private List<String> getPackageList() {
ArrayList<String> list = new ArrayList<>();
PackageManager pm = getPackageManager();
List<PackageInfo> infos = pm.getInstalledPackages(0);
for (PackageInfo info : infos) {
list.add(info.packageName);
}
if (!list.contains(INTERNAL_PKG)) {
list.add(INTERNAL_PKG);
}
return list;
}
private Context createContext(String pkg) {
try {
return createPackageContext(pkg, Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
return null;
}
}
private boolean updateTypeValue() {
int index = mType.getSelectedItemPosition();
if (index != mValueTypeIndex) {
mValueTypeIndex = index;
mValueType = TYPES[mValueTypeIndex];
return true;
} else {
return false;
}
}
private boolean updatePkgValue() {
String value = mPkg.getText().toString().trim();
if (value.equals(mValuePkg)) {
return false;
} else {
mValuePkg = value;
return true;
}
}
private boolean updateKeyValue() {
String value = mKey.getText().toString().trim();
if (value.equals(mValueKey)) {
return false;
} else {
mValueKey = value;
return true;
}
}
private void setPkgAutoComplete() {
List<String> mPkgList = getPackageList();
mPkg.setAdapter(new ArrayAdapter<>(this,
R.layout.auto_complete_item, mPkgList));
}
private void setKeyAutoComplete() {
if (mValuePkg == null || mValuePkg.isEmpty() || mValueType == null
|| mValueType.isEmpty()) {
return;
}
List<String> keyList = getKeyList(mValueType, mValuePkg);
mKey.setAdapter(new ArrayAdapter<>(this,
R.layout.auto_complete_item, keyList));
}
private List<String> getKeyList(String type, String pkg) {
if (isNativePkg(pkg)) {
return getKeyListNative(type, pkg);
} else {
return new ArrayList<>();
}
}
private List<String> getKeyListNative(String type, String pkg) {
List<String> keyList = new ArrayList<>();
String clazzName = pkg + ".R$" + type;
try {
Class<?> clazz = Class.forName(clazzName);
Field[] fields = clazz.getFields();
// get key list
if (fields != null) {
for (Field field : fields) {
keyList.add(field.getName());
}
}
} catch (ClassNotFoundException e) {
Log.w(TAG, "getKeyList_Native()# class not found. [pkg: " + pkg + ", type: " + type + "]", e);
}
return keyList;
}
}
|
package com.sinyuk.yuk.data.shot;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.Spanned;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName;
import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.Default;
import com.litesuits.orm.db.annotation.Ignore;
import com.litesuits.orm.db.annotation.NotNull;
import com.litesuits.orm.db.annotation.PrimaryKey;
import com.litesuits.orm.db.annotation.Table;
import com.litesuits.orm.db.annotation.Unique;
import com.litesuits.orm.db.enums.AssignType;
import com.sinyuk.yuk.api.DribbleApi;
import com.sinyuk.yuk.data.team.Team;
import com.sinyuk.yuk.data.user.User;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Table("shot")
public class Shot implements Parcelable {
public static final String COL_TYPE = "type";
public static final String COL_INDEX = "fake_index";
/**
* It seems that a string = "" will be considered as NULL in liteOrm
*/
private final static String PLACE_HOLDER = " ";
@Default("others")
@Column(COL_TYPE)
private String type;
public void setType(String type) {
this.type = type;
}
@Column(COL_INDEX)
@PrimaryKey(AssignType.AUTO_INCREMENT)
private final int fakeIndex;
@NotNull
@Unique
@SerializedName("id")
private final int id;
@SerializedName("title")
private final String title;
@SerializedName("description")
private final String description;
@SerializedName("width")
private final int width;
@SerializedName("height")
private final int height;
@SerializedName("images")
@Ignore
private final Images images;
@SerializedName("views_count")
private final int viewsCount;
@SerializedName("likes_count")
private final int likesCount;
@SerializedName("comments_count")
private final int commentsCount;
@SerializedName("attachments_count")
private final int attachmentsCount;
@SerializedName("rebounds_count")
private final int reboundsCount;
@SerializedName("buckets_count")
private final int bucketsCount;
@SerializedName("created_at")
private final String createdAt;
@SerializedName("updated_at")
@Ignore
private final String updatedAt;
@SerializedName("html_url")
private final String htmlUrl;
@SerializedName("attachments_url")
private final String attachmentsUrl;
@SerializedName("buckets_url")
private final String bucketsUrl;
@SerializedName("comments_url")
private final String commentsUrl;
@SerializedName("likes_url")
private final String likesUrl;
@SerializedName("projects_url")
private final String projectsUrl;
@SerializedName("rebounds_url")
private final String reboundsUrl;
@SerializedName("animated")
private final boolean animated;
@SerializedName("tags")
@Ignore
private final List<String> tags;
@SerializedName("user")
@Ignore
private final User user;
@SerializedName("team")
@Ignore
private final Team team;
/**
* extras
*/
@Column("user_name")
private String username;
@Column("hidpi")
private String hidpi;
@Column("normal")
private String normal;
@Column("teaser")
private String teaser;
@Column("avatar_url")
private String avatarUrl;
@Column("playerOrTeam")
private String playerOrTeam;
@Column("pro")
private boolean pro;
@Ignore
private boolean hasFadedIn = false;
@Ignore
private Spanned parsedDescription;
public Shot(String type, int fakeIndex, int id, String title, String description, int width, int height, Images images, int viewsCount, int likesCount, int commentsCount, int attachmentsCount, int reboundsCount, int bucketsCount, String createdAt, String updatedAt, String htmlUrl, String attachmentsUrl, String bucketsUrl, String commentsUrl, String likesUrl, String projectsUrl, String reboundsUrl, boolean animated, List<String> tags, User user, Team team, String username, String hidpi, String normal, String teaser, String avatarUrl, String playerOrTeam, boolean pro, Spanned parsedDescription) {
this.type = type;
this.fakeIndex = fakeIndex;
this.id = id;
this.title = title;
this.description = description;
this.width = width;
this.height = height;
this.images = images;
this.viewsCount = viewsCount;
this.likesCount = likesCount;
this.commentsCount = commentsCount;
this.attachmentsCount = attachmentsCount;
this.reboundsCount = reboundsCount;
this.bucketsCount = bucketsCount;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.htmlUrl = htmlUrl;
this.attachmentsUrl = attachmentsUrl;
this.bucketsUrl = bucketsUrl;
this.commentsUrl = commentsUrl;
this.likesUrl = likesUrl;
this.projectsUrl = projectsUrl;
this.reboundsUrl = reboundsUrl;
this.animated = animated;
this.tags = tags;
this.user = user;
this.team = team;
this.username = username;
this.hidpi = hidpi;
this.normal = normal;
this.teaser = teaser;
this.avatarUrl = avatarUrl;
this.playerOrTeam = playerOrTeam;
this.pro = pro;
this.parsedDescription = parsedDescription;
}
public void addExtras(String username,
String hidpi,
String normal,
String teaser,
String avatarUrl,
String playerOrTeam,
boolean pro) {
this.username = checkNotNull(username, PLACE_HOLDER); // username
this.hidpi = checkNotNull(hidpi, PLACE_HOLDER);
this.normal = checkNotNull(normal, PLACE_HOLDER);
this.teaser = checkNotNull(teaser, PLACE_HOLDER);
this.avatarUrl = checkNotNull(avatarUrl, PLACE_HOLDER);
this.playerOrTeam = checkNotNull(playerOrTeam, PLACE_HOLDER);
this.pro = pro;
}
private String checkNotNull(String str, String placeholder) {
if (TextUtils.isEmpty(str)) {str = placeholder;}
return str;
}
public String bestQuality() {
return !TextUtils.isEmpty(hidpi) ? hidpi : normal;
}
public String normalQuality() {
return !TextUtils.isEmpty(normal) ? normal : teaser;
}
Date getCreatedDate(String createdAt) {
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DribbleApi.DATE_FORMAT);
try {
return simpleDateFormat.parse(createdAt);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
@Override
public int describeContents() { return 0; }
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.type);
dest.writeInt(this.fakeIndex);
dest.writeInt(this.id);
dest.writeString(this.title);
dest.writeString(this.description);
dest.writeInt(this.width);
dest.writeInt(this.height);
dest.writeParcelable(this.images, flags);
dest.writeInt(this.viewsCount);
dest.writeInt(this.likesCount);
dest.writeInt(this.commentsCount);
dest.writeInt(this.attachmentsCount);
dest.writeInt(this.reboundsCount);
dest.writeInt(this.bucketsCount);
dest.writeString(this.createdAt);
dest.writeString(this.updatedAt);
dest.writeString(this.htmlUrl);
dest.writeString(this.attachmentsUrl);
dest.writeString(this.bucketsUrl);
dest.writeString(this.commentsUrl);
dest.writeString(this.likesUrl);
dest.writeString(this.projectsUrl);
dest.writeString(this.reboundsUrl);
dest.writeByte(this.animated ? (byte) 1 : (byte) 0);
dest.writeStringList(this.tags);
dest.writeParcelable(this.user, flags);
dest.writeParcelable(this.team, flags);
dest.writeString(this.username);
dest.writeString(this.hidpi);
dest.writeString(this.normal);
dest.writeString(this.teaser);
dest.writeString(this.avatarUrl);
dest.writeString(this.playerOrTeam);
dest.writeByte(this.pro ? (byte) 1 : (byte) 0);
dest.writeByte(this.hasFadedIn ? (byte) 1 : (byte) 0);
}
protected Shot(Parcel in) {
this.type = in.readString();
this.fakeIndex = in.readInt();
this.id = in.readInt();
this.title = in.readString();
this.description = in.readString();
this.width = in.readInt();
this.height = in.readInt();
this.images = in.readParcelable(Images.class.getClassLoader());
this.viewsCount = in.readInt();
this.likesCount = in.readInt();
this.commentsCount = in.readInt();
this.attachmentsCount = in.readInt();
this.reboundsCount = in.readInt();
this.bucketsCount = in.readInt();
this.createdAt = in.readString();
this.updatedAt = in.readString();
this.htmlUrl = in.readString();
this.attachmentsUrl = in.readString();
this.bucketsUrl = in.readString();
this.commentsUrl = in.readString();
this.likesUrl = in.readString();
this.projectsUrl = in.readString();
this.reboundsUrl = in.readString();
this.animated = in.readByte() != 0;
this.tags = in.createStringArrayList();
this.user = in.readParcelable(User.class.getClassLoader());
this.team = in.readParcelable(Team.class.getClassLoader());
this.username = in.readString();
this.hidpi = in.readString();
this.normal = in.readString();
this.teaser = in.readString();
this.avatarUrl = in.readString();
this.playerOrTeam = in.readString();
this.pro = in.readByte() != 0;
this.hasFadedIn = in.readByte() != 0;
}
public static final Parcelable.Creator<Shot> CREATOR = new Parcelable.Creator<Shot>() {
@Override
public Shot createFromParcel(Parcel source) {return new Shot(source);}
@Override
public Shot[] newArray(int size) {return new Shot[size];}
};
public static String getColType() {
return COL_TYPE;
}
public static String getColIndex() {
return COL_INDEX;
}
public static String getPlaceHolder() {
return PLACE_HOLDER;
}
public String getType() {
return type;
}
public int getFakeIndex() {
return fakeIndex;
}
public int getId() {
return id;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public Images getImages() {
return images;
}
public int getViewsCount() {
return viewsCount;
}
public int getLikesCount() {
return likesCount;
}
public int getCommentsCount() {
return commentsCount;
}
public int getAttachmentsCount() {
return attachmentsCount;
}
public int getReboundsCount() {
return reboundsCount;
}
public int getBucketsCount() {
return bucketsCount;
}
public String getCreatedAt() {
return createdAt;
}
public String getUpdatedAt() {
return updatedAt;
}
public String getHtmlUrl() {
return htmlUrl;
}
public String getAttachmentsUrl() {
return attachmentsUrl;
}
public String getBucketsUrl() {
return bucketsUrl;
}
public String getCommentsUrl() {
return commentsUrl;
}
public String getLikesUrl() {
return likesUrl;
}
public String getProjectsUrl() {
return projectsUrl;
}
public String getReboundsUrl() {
return reboundsUrl;
}
public boolean isAnimated() {
return animated;
}
public List<String> getTags() {
return tags;
}
public User getUser() {
return user;
}
public Team getTeam() {
return team;
}
public String getUsername() {
return username;
}
public String getHidpi() {
return hidpi;
}
public String getNormal() {
return normal;
}
public String getTeaser() {
return teaser;
}
public String getAvatarUrl() {
return avatarUrl;
}
public String getPlayerOrTeam() {
return playerOrTeam;
}
public boolean isPro() {
return pro;
}
public boolean isHasFadedIn() {
return hasFadedIn;
}
public void setHasFadedIn(boolean hasFadedIn) {
this.hasFadedIn = hasFadedIn;
}
public Spanned getParsedDescription() {
return parsedDescription;
}
public static Creator<Shot> getCREATOR() {
return CREATOR;
}
}
|
package dateadog.dateadog;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
/**
* This class stores the user's profile information.
*/
public class UserProfile implements Serializable {
private String firstName;
private String lastName;
private String street;
private String email;
private String city;
private String state;
private String zip;
private String phone;
private String shelterId;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getShelterId() {
return shelterId;
}
public void setShelterId(String shelterId) {
this.shelterId = shelterId;
}
public boolean isComplete() {
return !(firstName.isEmpty() || lastName.isEmpty() || email.isEmpty()
|| street.isEmpty() || city.isEmpty() || state.isEmpty()
|| zip.isEmpty() || phone.isEmpty());
}
public JSONObject asJSONObject() {
JSONObject parameters = new JSONObject();
try {
parameters.put("fname", getFirstName());
parameters.put("lname", getLastName());
parameters.put("email", getEmail());
parameters.put("street", getStreet());
parameters.put("city", getCity());
parameters.put("state", getState());
parameters.put("zip", getZip());
parameters.put("phone", getPhone());
} catch (JSONException e) {
e.printStackTrace();
}
return parameters;
}
public UserProfile(String firstName, String lastName, String email, String street, String city, String state, String zip, String phone, String shelterId) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
this.phone = phone;
this.shelterId = shelterId;
}
/**
* Constructs and initializes an empty user profile (empty strings for each field).
*/
public UserProfile() {
this.firstName = "";
this.lastName = "";
this.email = "";
this.street = "";
this.city = "";
this.state = "";
this.zip = "";
this.phone = "";
this.shelterId = "";
}
/**
* Constructs and initializes a user profile using the fields of the given JSON object.
*
* @param json the JSON object containing the profile data
*/
public UserProfile(JSONObject json) {
try {
firstName = json.getString("fname");
lastName = json.getString("lname");
email = json.getString("email");
street = json.getString("street");
city = json.getString("city");
state = json.getString("state");
zip = json.getString("zip");
phone = json.getString("phone");
shelterId = json.getString("shelterid");
// Replace missing JSON values with empty string:
firstName = firstName.equals("null") ? "" : firstName;
lastName = lastName.equals("null") ? "" : lastName;
email = email.equals("null") ? "" : email;
street = street.equals("null") ? "" : street;
city = city.equals("null") ? "" : city;
state = state.equals("null") ? "" : state;
zip = zip.equals("null") ? "" : zip;
phone = phone.equals("null") ? "" : phone;
shelterId = shelterId.equals("null") ? "" : shelterId;
} catch (JSONException e) {
e.printStackTrace();
}
}
}
|
package org.wikipedia.util;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.Normalizer;
import java.util.Arrays;
import java.util.List;
public final class StringUtil {
private static final String CSV_DELIMITER = ",";
@NonNull
public static String listToCsv(@NonNull List<String> list) {
return TextUtils.join(CSV_DELIMITER, list);
}
/** @return Nonnull immutable list. */
@NonNull
public static List<String> csvToList(@NonNull String csv) {
return delimiterStringToList(csv, CSV_DELIMITER);
}
/** @return Nonnull immutable list. */
@NonNull
public static List<String> delimiterStringToList(@NonNull String delimitedString,
@NonNull String delimiter) {
return Arrays.asList(TextUtils.split(delimitedString, delimiter));
}
/**
* Creates an MD5 hash of the provided string and returns its ASCII representation
* @param s String to hash
* @return ASCII MD5 representation of the string passed in
*/
@NonNull public static String md5string(@NonNull String s) {
StringBuilder hexStr = new StringBuilder();
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(s.getBytes("utf-8"));
byte[] messageDigest = digest.digest();
final int maxByteVal = 0xFF;
for (byte b : messageDigest) {
hexStr.append(Integer.toHexString(maxByteVal & b));
}
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return hexStr.toString();
}
/**
* Remove leading and trailing whitespace from a CharSequence. This is useful after using
* the fromHtml() function to convert HTML to a CharSequence.
* @param str CharSequence to be trimmed.
* @return The trimmed CharSequence.
*/
@NonNull public static CharSequence strip(@Nullable CharSequence str) {
if (str == null || str.length() == 0) {
return "";
}
int len = str.length();
int start = 0;
int end = len - 1;
while (start < len && Character.isWhitespace(str.charAt(start))) {
start++;
}
while (end > 0 && Character.isWhitespace(str.charAt(end))) {
end
}
if (end > start) {
return str.subSequence(start, end + 1);
}
return "";
}
@NonNull
public static String intToHexStr(int i) {
return String.format("x%08x", i);
}
public static String addUnderscores(@NonNull String text) {
return text.replace(" ", "_");
}
public static String removeUnderscores(@NonNull String text) {
return text.replace("_", " ");
}
public static boolean hasSectionAnchor(@NonNull String text) {
return text.contains("
}
public static String removeSectionAnchor(String text) {
return text.substring(0, text.indexOf("
}
public static String sanitizeText(@NonNull String selectedText) {
return selectedText.replaceAll("\\[\\d+\\]", "")
.replaceAll("\\s*/[^/]+/;?\\s*", "")
.replaceAll("\\(\\s*;\\s*", "\\(") // (; -> ( hacky way for IPA remnants
.replaceAll("\\s{2,}", " ")
.trim();
}
// Compare two strings based on their normalized form, using the Unicode Normalization Form C.
// This should be used when comparing or verifying strings that will be exchanged between
// different platforms (iOS, desktop, etc) that may encode strings using inconsistent
// composition, especially for accents, diacritics, etc.
public static boolean normalizedEquals(@Nullable String str1, @Nullable String str2) {
if (str1 == null || str2 == null) {
return (str1 == null && str2 == null);
}
return Normalizer.normalize(str1, Normalizer.Form.NFC)
.equals(Normalizer.normalize(str2, Normalizer.Form.NFC));
}
/**
* @param source String that may contain HTML tags.
* @return returned Spanned string that may contain spans parsed from the HTML source.
*/
@NonNull public static Spanned fromHtml(@Nullable String source) {
if (source == null) {
return new SpannedString("");
}
if (!source.contains("<") && !source.contains("&
// If the string doesn't contain any hints of HTML tags, then skip the expensive
// processing that fromHtml() performs.
return new SpannedString(source);
}
source = source.replaceAll("‎", "\u200E")
.replaceAll("‏", "\u200F");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY);
} else {
//noinspection deprecation
return Html.fromHtml(source);
}
}
@NonNull
public static SpannableStringBuilder boldenSubstrings(@NonNull String text, @NonNull List<String> subStrings) {
SpannableStringBuilder sb = new SpannableStringBuilder(text);
for (String subString : subStrings) {
int index = text.toLowerCase().indexOf(subString.toLowerCase());
if (index != -1) {
sb.setSpan(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
? new TypefaceSpan("sans-serif-medium")
: new StyleSpan(android.graphics.Typeface.BOLD),
index, index + subString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
}
return sb;
}
private StringUtil() { }
}
|
package ui;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.StringTokenizer;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileFilter;
public class LabelingFrame extends JFrame implements ActionListener {
private static final long serialVersionUID = -2225603632488216748L;
private JPanel contentPane;
//Fields holding the two types of labels for labeling
private JTextField firstLabelField;
private JTextField secondLabelField;
//Field to hold the tweet text
private JTextArea tweetArea;
JLabel tweetTitlePanel;
//List iterator for moving thru tweets
private ListIterator<Tweet> tweetIterator;
//All the labelled tweets so far
private Set<Tweet> labelledTweets;
//Current tweet we are looking at
private Tweet currentTweet;
//Dummy tweet for beginning and ending
private Tweet defaultTweet;
JButton openFile, prev, next, delete, finish, firstLabel, secondLabel;
private JFileChooser fc;
private int curTweet, totalTweets;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
LabelingFrame frame = new LabelingFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public LabelingFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
Panel buttonPanel = new Panel();
contentPane.add(buttonPanel, BorderLayout.SOUTH);
openFile = new JButton("Open File");
openFile.addActionListener(this);
buttonPanel.add(openFile);
prev = new JButton("Previous");
prev.addActionListener(this);
buttonPanel.add(prev);
next = new JButton("Next");
next.addActionListener(this);
buttonPanel.add(next);
// delete = new JButton("Delete");
// delete.addActionListener(this);
// buttonPanel.add(delete);
finish = new JButton("Finish");
finish.addActionListener(this);
buttonPanel.add(finish);
JLabel Title = new JLabel("Labler");
Title.setFont(new Font("Tahoma", Font.PLAIN, 32));
Title.setHorizontalAlignment(SwingConstants.CENTER);
contentPane.add(Title, BorderLayout.NORTH);
Panel labelPanel = new Panel();
contentPane.add(labelPanel, BorderLayout.CENTER);
labelPanel.setLayout(new BorderLayout(0, 0));
tweetArea = new JTextArea();
tweetArea.setLineWrap(true);
tweetArea.setWrapStyleWord(true);
tweetArea.setEditable(false);
labelPanel.add(tweetArea);
Panel labelOptionsPanel = new Panel();
labelPanel.add(labelOptionsPanel, BorderLayout.SOUTH);
firstLabel = new JButton("Label as First");
firstLabel.addActionListener(this);
labelOptionsPanel.add(firstLabel);
secondLabel = new JButton("Label as Second");
secondLabel.addActionListener(this);
labelOptionsPanel.add(secondLabel);
Panel setLabelsPanel = new Panel();
labelPanel.add(setLabelsPanel, BorderLayout.EAST);
GridBagLayout gbl_setLabelsPanel = new GridBagLayout();
gbl_setLabelsPanel.columnWidths = new int[] {30, 30, 30};
gbl_setLabelsPanel.rowHeights = new int[] {30, 30, 30};
gbl_setLabelsPanel.columnWeights = new double[]{0.0, 1.0, 0.0};
gbl_setLabelsPanel.rowWeights = new double[]{0.0, 0.0, 0.0};
setLabelsPanel.setLayout(gbl_setLabelsPanel);
JLabel lblLabels = new JLabel("Labels");
GridBagConstraints gbc_lblLabels = new GridBagConstraints();
gbc_lblLabels.insets = new Insets(0, 0, 5, 5);
gbc_lblLabels.gridx = 1;
gbc_lblLabels.gridy = 0;
setLabelsPanel.add(lblLabels, gbc_lblLabels);
JLabel lblFirst = new JLabel("First: ");
GridBagConstraints gbc_lblFirst = new GridBagConstraints();
gbc_lblFirst.anchor = GridBagConstraints.EAST;
gbc_lblFirst.insets = new Insets(0, 0, 5, 5);
gbc_lblFirst.gridx = 0;
gbc_lblFirst.gridy = 1;
setLabelsPanel.add(lblFirst, gbc_lblFirst);
firstLabelField = new JTextField();
firstLabelField.setText("<Enter text>");
GridBagConstraints gbc_firstLabelField = new GridBagConstraints();
gbc_firstLabelField.insets = new Insets(0, 0, 5, 5);
gbc_firstLabelField.fill = GridBagConstraints.HORIZONTAL;
gbc_firstLabelField.gridx = 1;
gbc_firstLabelField.gridy = 1;
setLabelsPanel.add(firstLabelField, gbc_firstLabelField);
firstLabelField.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("Second:");
GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
gbc_lblNewLabel_1.insets = new Insets(0, 0, 0, 5);
gbc_lblNewLabel_1.gridx = 0;
gbc_lblNewLabel_1.gridy = 2;
setLabelsPanel.add(lblNewLabel_1, gbc_lblNewLabel_1);
secondLabelField = new JTextField();
secondLabelField.setText("<Enter text>");
GridBagConstraints gbc_secondLabelField = new GridBagConstraints();
gbc_secondLabelField.insets = new Insets(0, 0, 0, 5);
gbc_secondLabelField.fill = GridBagConstraints.HORIZONTAL;
gbc_secondLabelField.gridx = 1;
gbc_secondLabelField.gridy = 2;
setLabelsPanel.add(secondLabelField, gbc_secondLabelField);
secondLabelField.setColumns(10);
tweetTitlePanel = new JLabel("Tweet");
tweetTitlePanel.setHorizontalAlignment(SwingConstants.LEFT);
labelPanel.add(tweetTitlePanel, BorderLayout.NORTH);
fc = new JFileChooser();
fc.setFileFilter(new TweetFilter());
labelledTweets = new HashSet<Tweet>();
defaultTweet = new Tweet(0, "No more tweets!");
currentTweet = defaultTweet;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == openFile) {
this.loadFile();
if (tweetIterator != null) {
currentTweet = tweetIterator.next();
this.updateUi(currentTweet);
}
}
else if (e.getSource() == prev) {
if (tweetIterator != null && tweetIterator.hasPrevious()) {
currentTweet = tweetIterator.previous();
--curTweet;
this.updateUi(currentTweet);
}
else {
JOptionPane.showMessageDialog(this, "You can't do that!", "User Error",
JOptionPane.ERROR_MESSAGE);
}
}
else if (e.getSource() == next) {
if (tweetIterator != null && tweetIterator.hasNext()) {
currentTweet = tweetIterator.next();
++curTweet;
this.updateUi(currentTweet);
}
}
else if (e.getSource() == delete) {
try {
if (tweetIterator != null) {
tweetIterator.remove();
currentTweet = new Tweet(0, "Freshly Deleted!");
updateUi(currentTweet);
}
else {
JOptionPane.showMessageDialog(this, "You can't do that!", "User Error",
JOptionPane.ERROR_MESSAGE);
}
}
catch (IllegalStateException ise) {
JOptionPane.showMessageDialog(this, "You can't do that!", "User Error",
JOptionPane.ERROR_MESSAGE);
}
}
else if (e.getSource() == finish) {
this.saveAndQuit();
}
else if (e.getSource() == firstLabel || e.getSource() == secondLabel) {
if (currentTweet != null && !firstLabelField.getText().equals("<Enter text>")
&& !secondLabelField.getText().equals("<Enter text>")) {
currentTweet.label = (e.getSource() == firstLabel)
? firstLabelField.getText(): secondLabelField.getText();
boolean moveTwice = (labelledTweets.contains(currentTweet));
if(currentTweet != defaultTweet) {
labelledTweets.add(currentTweet);
System.out.println("Labelled tweet: " + currentTweet);
}
if (tweetIterator.hasNext()) {
currentTweet = tweetIterator.next();
++curTweet;
}
else {
JOptionPane.showMessageDialog(this, "That's all of them!", "Info",
JOptionPane.INFORMATION_MESSAGE);
currentTweet = defaultTweet;
}
//If we moved backwards thru the list we need to compensate
if (moveTwice && tweetIterator.hasNext()) {
currentTweet = tweetIterator.next();
}
updateUi(currentTweet);
}
else {
JOptionPane.showMessageDialog(this, "You need to set the labels!", "User Error",
JOptionPane.ERROR_MESSAGE);
}
}
}
private void saveAndQuit() {
int returnVal = fc.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
if (labelledTweets.size() != 0) {
this.saveTweets(fc.getSelectedFile());
}
System.exit(0);
}
}
private void saveTweets(File f) {
BufferedWriter bw;
try {
bw = new BufferedWriter(new FileWriter(f));
for (Tweet t: labelledTweets) {
bw.write(t.toString());
bw.newLine();
}
bw.flush();
bw.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Unable to save file :(", "IO Error",
JOptionPane.ERROR_MESSAGE);
}
}
private void updateUi(Tweet newTweet) {
tweetArea.setText(newTweet.text);
tweetTitlePanel.setText("Tweet number " + curTweet + " of " + totalTweets);
firstLabel.setText("Label as: " + firstLabelField.getText());
secondLabel.setText("Label as: " + secondLabelField.getText());
}
public void loadFile() {
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String line = "";
int failedTweets = 0;
try {
BufferedReader br = new BufferedReader(new FileReader(file));
List<Tweet> tweets = new LinkedList<Tweet>();
while ((line = br.readLine()) != null) {
Tweet n = makeTweet(line);
if (n != null) {
tweets.add(n);
}
else {
++failedTweets;
}
}
br.close();
JOptionPane.showMessageDialog(this, "Successfully read: " + tweets.size() +
((tweets.size() != 1) ? " Tweets. " : " Tweet. ") + "Failed to read " + failedTweets +
((failedTweets != 1) ? " Tweets." : " Tweet"), "IO Error",
JOptionPane.INFORMATION_MESSAGE);
tweetIterator = tweets.listIterator();
totalTweets = tweets.size();
curTweet = 1;
} catch (IOException e) {
JOptionPane.showMessageDialog(this, "Unable to open file", "IO Error",
JOptionPane.ERROR_MESSAGE);
}
}
}
private Tweet makeTweet(String tweetText) {
try {
Tweet newTweet = new Tweet(tweetText);
return newTweet;
}
catch (NumberFormatException e) {
return null;
}
}
private class Tweet {
public long id;
public String text;
public String label;
public Tweet(long id, String text) {
this.id = id;
this.text = text;
this.label = "";
}
public Tweet(String tweet) {
StringTokenizer st = new StringTokenizer(tweet);
id = Long.parseLong(st.nextToken());
StringBuilder sb = new StringBuilder();
while (st.hasMoreTokens()) {
sb.append(st.nextToken());
sb.append(" ");
}
text = sb.toString();
}
@Override
public String toString() {
return label.toLowerCase() + " " + id + " " + text;
}
@Override
public int hashCode() {
long hash = 7;
hash = hash * 31 + id;
hash = hash * 31 + text.hashCode();
return (int) hash;
}
}
private class TweetFilter extends FileFilter {
@Override
public boolean accept(File f) {
String name = f.getName().toLowerCase();
return f.isDirectory() || name.endsWith(".txt") || name.endsWith(".dan")
|| name.endsWith(".brandon") || name.endsWith(".curtis");
}
@Override
public String getDescription() {
return "Allows files with txt, dan, brandon, or curtis extensions";
}
}
}
|
package dr.app.seqgen;
import dr.evolution.tree.Tree;
import dr.evolution.tree.NodeRef;
import dr.evolution.datatype.Microsatellite;
import dr.evolution.alignment.Alignment;
import dr.evolution.alignment.Patterns;
import dr.evolution.sequence.Sequence;
import dr.evolution.util.Taxa;
import dr.evomodel.sitemodel.SiteModel;
import dr.evomodel.sitemodel.GammaSiteModel;
import dr.evomodel.branchratemodel.BranchRateModel;
import dr.evomodel.substmodel.MicrosatelliteModel;
import dr.math.MathUtils;
/**
* @author Chieh-Hsi Wu
*
* Simulates a pattern of microsatellites given a tree and microsatellite model
*
*/
public class MicrosatelliteSimulator extends SequenceSimulator{
private Taxa taxa;
private Microsatellite dataType;
public MicrosatelliteSimulator(
Microsatellite dataType,
Taxa taxa,
Tree tree,
MicrosatelliteModel msatModel,
BranchRateModel branchRateModel){
this(dataType, taxa, tree, new GammaSiteModel(msatModel), branchRateModel);
}
public MicrosatelliteSimulator(
Microsatellite dataType,
Taxa taxa,
Tree tree,
SiteModel siteModel,
BranchRateModel branchRateModel) {
super(tree, siteModel, branchRateModel, 1);
this.dataType = dataType;
this.taxa = taxa;
}
/**
* Convert integer representation of microsatellite length to string.
*/
Sequence intArray2Sequence(int [] seq, NodeRef node) {
String sSeq = ""+seq[0];
return new Sequence(m_tree.getNodeTaxon(node), sSeq);
} // intArray2Sequence
/**
* Convert an alignment to a pattern
*/
public Patterns simulateMsatPattern(){
Alignment align = simulate();
int[] pattern = new int[align.getTaxonCount()];
for(int i = 0; i < pattern.length; i++){
String taxonName = align.getSequence(i).getTaxon().getId();
int index = taxa.getTaxonIndex(taxonName);
pattern[index] = Integer.parseInt(align.getSequence(i).getSequenceString());
}
Patterns patterns = new Patterns(dataType,taxa);
patterns.addPattern(pattern);
for(int i = 0; i < pattern.length;i++){
System.out.print(pattern[i]+",");
}
System.out.println();
return patterns;
}
}
|
package emergencylanding.k.library.main;
import java.util.HashMap;
import emergencylanding.k.library.internalstate.Entity;
import emergencylanding.k.library.lwjgl.render.Render;
import emergencylanding.k.library.util.LUtils;
import emergencylanding.k.library.util.StackTraceInfo;
public abstract class KMain {
private static KMain insts = null;
private static Thread displayThread = null;
public abstract void onDisplayUpdate(int delta);
public abstract void init(String[] args);
public static void setInst(KMain inst) {
try {
LUtils.checkAccessor("emergencylanding.k.library.*",
StackTraceInfo.getInvokingClassName());
} catch (Exception e) {
e.printStackTrace();
return;
}
KMain.insts = inst;
}
public static KMain getInst() {
return KMain.insts;
}
public static void setDisplayThread(Thread t) {
try {
LUtils.checkAccessor("emergencylanding.k.library.*",
StackTraceInfo.getInvokingClassName());
} catch (Exception e) {
e.printStackTrace();
return;
}
KMain.displayThread = t;
System.err.println("Dispaly thread set");
}
public static Thread getDisplayThread() {
return KMain.displayThread;
}
public abstract void registerRenders(
HashMap<Class<? extends Entity>, Render<? extends Entity>> classToRender);
}
|
package test.SRA;
import automata.sra.*;
import automata.sfa.*;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test;
import org.sat4j.specs.TimeoutException;
import theory.characters.CharPred;
import theory.characters.StdCharPred;
import theory.intervals.UnaryCharIntervalSolver;
import java.util.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestSRAExperiments {
@Test
public void testSSNParserSRA() throws TimeoutException {
assertTrue(SSNParser.accepts(validName1, ba));
assertTrue(SSNParser.accepts(validName2, ba));
assertFalse(SSNParser.accepts(invalidName1, ba));
assertFalse(SSNParser.accepts(invalidName2, ba));
assertFalse(SSNParser.accepts(invalidName3, ba));
}
@Test
public void testSSNSimulation() throws TimeoutException {
assertTrue(SRA.canSimulate(SSNParser, SSNParserFirst, ba, false, Long.MAX_VALUE));
assertTrue(SRA.canSimulate(SSNParser, SSNParserLast, ba, false, Long.MAX_VALUE));
}
@Test
public void testSSNSFA() throws TimeoutException {
assertTrue(SSNParserSFA.accepts(validName1, ba));
assertTrue(SSNParserSFA.accepts(validName2, ba));
assertFalse(SSNParserSFA.accepts(invalidName1, ba));
assertFalse(SSNParserSFA.accepts(invalidName2, ba));
assertFalse(SSNParserSFA.accepts(invalidName3, ba));
}
@Test
public void testSSNFirstSFA() throws TimeoutException {
assertTrue(SSNParserFirstSFA.accepts(validName1, ba));
assertTrue(SSNParserFirstSFA.accepts(validName2, ba));
}
@Test
public void testSSNLastSFA() throws TimeoutException {
assertTrue(SSNParserLastSFA.accepts(validName1, ba));
assertTrue(SSNParserLastSFA.accepts(validName2, ba));
}
@Test
public void testSSNInclusion() throws TimeoutException {
assertTrue(SSNParserFirst.languageIncludes(SSNParser, ba, Long.MAX_VALUE));
assertTrue(SSNParserLast.languageIncludes(SSNParser, ba, Long.MAX_VALUE));
}
@Test
public void testSSNEquivalence() throws TimeoutException {
assertTrue(SSNParserFirst.isLanguageEquivalent(SSNParserFirst, ba, Long.MAX_VALUE));
assertTrue(SSNParserLast.isLanguageEquivalent(SSNParserLast, ba, Long.MAX_VALUE));
}
@Test
public void testSSNParserMSRAtoSRA() throws TimeoutException {
SRA<CharPred, Character> toSRA = SSNParser.toSingleValuedSRA(ba, Long.MAX_VALUE);
assertTrue(toSRA.accepts(validName1, ba));
assertTrue(toSRA.accepts(validName2, ba));
assertFalse(toSRA.accepts(invalidName1, ba));
assertFalse(toSRA.accepts(invalidName2, ba));
assertFalse(toSRA.accepts(invalidName3, ba));
}
@Test
public void testXMLParserSRA() throws TimeoutException {
boolean check = XMLParserSRA.createDotFile("xml", "");
assertTrue(check);
assertTrue(XMLParserSRA.accepts(validXML1, ba));
assertTrue(XMLParserSRA.accepts(validXML2, ba));
assertTrue(XMLParserSRA.accepts(validXML3, ba));
assertTrue(XMLParserSRA.accepts(validXML4, ba));
assertTrue(XMLParserSRA.accepts(validXML5, ba));
assertTrue(XMLParserSRA.accepts(validXML6, ba));
assertTrue(XMLParserSRA.accepts(validXML7, ba));
assertFalse(XMLParserSRA.accepts(invalidXML1, ba));
assertFalse(XMLParserSRA.accepts(invalidXML2, ba));
assertFalse(XMLParserSRA.accepts(invalidXML3, ba));
assertFalse(XMLParserSRA.accepts(invalidXML4, ba));
assertFalse(XMLParserSRA.accepts(invalidXML5, ba));
assertFalse(XMLParserSRA.accepts(invalidXML6, ba));
assertFalse(XMLParserSRA.accepts(invalidXML7, ba));
}
@Test
public void testIPPacketParserSRASingleValued() throws TimeoutException {
SRA<CharPred, Character> IP2PacketParserSRASS = IP2PacketParserSRA.toSingleValuedSRA(ba, Long.MAX_VALUE);
SRA<CharPred, Character> IP3PacketParserSRASS = IP3PacketParserSRA.toSingleValuedSRA(ba, Long.MAX_VALUE);
SRA<CharPred, Character> IP4PacketParserSRASS = IP4PacketParserSRA.toSingleValuedSRA(ba, Long.MAX_VALUE);
assertTrue(IP3PacketParserSRASS.accepts(validIPPacket1, ba));
assertTrue(IP4PacketParserSRASS.accepts(validIPPacket1, ba));
assertTrue(IP2PacketParserSRASS.accepts(validIPPacket2, ba));
assertTrue(IP3PacketParserSRASS.accepts(validIPPacket2, ba));
assertTrue(IP4PacketParserSRASS.accepts(validIPPacket2, ba));
assertTrue(IP2PacketParserSRASS.accepts(validIPPacket3, ba));
assertTrue(IP3PacketParserSRASS.accepts(validIPPacket3, ba));
assertTrue(IP4PacketParserSRASS.accepts(validIPPacket3, ba));
assertFalse(IP2PacketParserSRASS.accepts(invalidIPPacket1, ba));
assertFalse(IP3PacketParserSRASS.accepts(invalidIPPacket1, ba));
assertFalse(IP4PacketParserSRASS.accepts(invalidIPPacket1, ba));
assertFalse(IP2PacketParserSRASS.accepts(invalidIPPacket2, ba));
assertFalse(IP3PacketParserSRASS.accepts(invalidIPPacket2, ba));
assertFalse(IP4PacketParserSRASS.accepts(invalidIPPacket2, ba));
assertFalse(IP2PacketParserSRASS.accepts(invalidIPPacket3, ba));
assertFalse(IP3PacketParserSRASS.accepts(invalidIPPacket3, ba));
assertFalse(IP4PacketParserSRASS.accepts(invalidIPPacket3, ba));
assertTrue(IP2PacketParserSRASS.accepts(dependentIPPacket1, ba));
assertTrue(IP3PacketParserSRASS.accepts(dependentIPPacket1, ba));
assertTrue(IP4PacketParserSRASS.accepts(dependentIPPacket1, ba));
}
@Test
public void testIPPacketParserSRASingleValuedComplete() throws TimeoutException {
SRA<CharPred, Character> IP2PacketParserSRASS = IP2PacketParserSRA.toSingleValuedSRA(ba, Long.MAX_VALUE);
SRA<CharPred, Character> IP3PacketParserSRASS = IP3PacketParserSRA.toSingleValuedSRA(ba, Long.MAX_VALUE);
SRA<CharPred, Character> IP4PacketParserSRASS = IP4PacketParserSRA.toSingleValuedSRA(ba, Long.MAX_VALUE);
IP2PacketParserSRASS.complete(ba);
IP3PacketParserSRASS.complete(ba);
IP4PacketParserSRASS.complete(ba);
assertTrue(IP3PacketParserSRASS.accepts(validIPPacket1, ba));
assertTrue(IP4PacketParserSRASS.accepts(validIPPacket1, ba));
assertTrue(IP2PacketParserSRASS.accepts(validIPPacket2, ba));
assertTrue(IP3PacketParserSRASS.accepts(validIPPacket2, ba));
assertTrue(IP4PacketParserSRASS.accepts(validIPPacket2, ba));
assertTrue(IP2PacketParserSRASS.accepts(validIPPacket3, ba));
assertTrue(IP3PacketParserSRASS.accepts(validIPPacket3, ba));
assertTrue(IP4PacketParserSRASS.accepts(validIPPacket3, ba));
assertFalse(IP2PacketParserSRASS.accepts(invalidIPPacket1, ba));
assertFalse(IP3PacketParserSRASS.accepts(invalidIPPacket1, ba));
assertFalse(IP4PacketParserSRASS.accepts(invalidIPPacket1, ba));
assertFalse(IP2PacketParserSRASS.accepts(invalidIPPacket2, ba));
assertFalse(IP3PacketParserSRASS.accepts(invalidIPPacket2, ba));
assertFalse(IP4PacketParserSRASS.accepts(invalidIPPacket2, ba));
assertFalse(IP2PacketParserSRASS.accepts(invalidIPPacket3, ba));
assertFalse(IP3PacketParserSRASS.accepts(invalidIPPacket3, ba));
assertFalse(IP4PacketParserSRASS.accepts(invalidIPPacket3, ba));
assertTrue(IP2PacketParserSRASS.accepts(dependentIPPacket1, ba));
assertTrue(IP3PacketParserSRASS.accepts(dependentIPPacket1, ba));
assertTrue(IP4PacketParserSRASS.accepts(dependentIPPacket1, ba));
}
@Test
public void testIPPacketParserSRA() throws TimeoutException {
assertTrue(IP2PacketParserSRA.accepts(validIPPacket1, ba));
assertTrue(IP3PacketParserSRA.accepts(validIPPacket1, ba));
assertTrue(IP4PacketParserSRA.accepts(validIPPacket1, ba));
assertTrue(IP6PacketParserSRA.accepts(validIPPacket1, ba));
assertTrue(IP9PacketParserSRA.accepts(validIPPacket1, ba));
assertTrue(IP2PacketParserSRA.accepts(validIPPacket2, ba));
assertTrue(IP3PacketParserSRA.accepts(validIPPacket2, ba));
assertTrue(IP4PacketParserSRA.accepts(validIPPacket2, ba));
assertTrue(IP6PacketParserSRA.accepts(validIPPacket2, ba));
assertTrue(IP9PacketParserSRA.accepts(validIPPacket2, ba));
assertTrue(IP2PacketParserSRA.accepts(validIPPacket3, ba));
assertTrue(IP3PacketParserSRA.accepts(validIPPacket3, ba));
assertTrue(IP4PacketParserSRA.accepts(validIPPacket3, ba));
assertTrue(IP6PacketParserSRA.accepts(validIPPacket3, ba));
assertTrue(IP9PacketParserSRA.accepts(validIPPacket3, ba));
assertFalse(IP2PacketParserSRA.accepts(invalidIPPacket1, ba));
assertFalse(IP3PacketParserSRA.accepts(invalidIPPacket1, ba));
assertFalse(IP4PacketParserSRA.accepts(invalidIPPacket1, ba));
assertFalse(IP6PacketParserSRA.accepts(invalidIPPacket1, ba));
assertFalse(IP9PacketParserSRA.accepts(invalidIPPacket1, ba));
assertFalse(IP2PacketParserSRA.accepts(invalidIPPacket2, ba));
assertFalse(IP3PacketParserSRA.accepts(invalidIPPacket2, ba));
assertFalse(IP4PacketParserSRA.accepts(invalidIPPacket2, ba));
assertFalse(IP6PacketParserSRA.accepts(invalidIPPacket2, ba));
assertFalse(IP9PacketParserSRA.accepts(invalidIPPacket2, ba));
assertFalse(IP2PacketParserSRA.accepts(invalidIPPacket3, ba));
assertFalse(IP3PacketParserSRA.accepts(invalidIPPacket3, ba));
assertFalse(IP4PacketParserSRA.accepts(invalidIPPacket3, ba));
assertFalse(IP6PacketParserSRA.accepts(invalidIPPacket3, ba));
assertFalse(IP9PacketParserSRA.accepts(invalidIPPacket3, ba));
assertTrue(IP2PacketParserSRA.accepts(dependentIPPacket1, ba));
assertTrue(IP3PacketParserSRA.accepts(dependentIPPacket1, ba));
assertTrue(IP4PacketParserSRA.accepts(dependentIPPacket1, ba));
assertTrue(IP6PacketParserSRA.accepts(dependentIPPacket1, ba));
assertFalse(IP9PacketParserSRA.accepts(dependentIPPacket1, ba));
}
@Test
public void testPP2Equivalence() throws TimeoutException {
assertFalse(productParserC2.isLanguageEquivalent(productParserCL2, ba, Long.MAX_VALUE));
}
@Test
public void testPP3Equivalence() throws TimeoutException {
assertFalse(productParserC3.isLanguageEquivalent(productParserCL3, ba, Long.MAX_VALUE));
}
@Test
public void testPP4Equivalence() throws TimeoutException {
assertFalse(productParserC4.isLanguageEquivalent(productParserCL4, ba, Long.MAX_VALUE));
}
@Test
public void testPP6Equivalence() throws TimeoutException {
assertFalse(productParserC6.isLanguageEquivalent(productParserCL6, ba, Long.MAX_VALUE));
}
@Test
public void testPP9Equivalence() throws TimeoutException {
assertFalse(productParserC9.isLanguageEquivalent(productParserCL9, ba, Long.MAX_VALUE));
}
@Test
public void testPPC2Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserC2, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL2Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserCL2, ba, Long.MAX_VALUE));
}
@Test
public void testPPC3Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserC3, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL3Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserCL3, ba, Long.MAX_VALUE));
}
@Test
public void testPPC4Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserC4, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL4Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserCL4, ba, Long.MAX_VALUE));
}
@Test
public void testPPC6Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserC6, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL6Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserCL6, ba, Long.MAX_VALUE));
}
@Test
public void testPPC9Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserC9, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL9Emptiness() throws TimeoutException {
assertFalse(SRA.isLanguageEmpty(productParserCL9, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL2Inclusion() throws TimeoutException {
assertFalse(productParserCL2.languageIncludes(productParserC2, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL3Inclusion() throws TimeoutException {
assertFalse(productParserCL3.languageIncludes(productParserC3, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL4Inclusion() throws TimeoutException {
assertFalse(productParserCL4.languageIncludes(productParserC4, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL6Inclusion() throws TimeoutException {
assertFalse(productParserCL6.languageIncludes(productParserC6, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL9Inclusion() throws TimeoutException {
assertFalse(productParserCL9.languageIncludes(productParserC9, ba, Long.MAX_VALUE));
}
@Test
public void testPPC2Inclusion() throws TimeoutException {
assertTrue(productParserC2.languageIncludes(productParserCL2, ba, Long.MAX_VALUE));
}
@Test
public void testPPC3Inclusion() throws TimeoutException {
assertTrue(productParserC3.languageIncludes(productParserCL3, ba, Long.MAX_VALUE));
}
@Test
public void testPPC4Inclusion() throws TimeoutException {
assertTrue(productParserC9.languageIncludes(productParserCL9, ba, Long.MAX_VALUE));
}
@Test
public void testPPC6Inclusion() throws TimeoutException {
assertTrue(productParserC6.languageIncludes(productParserCL6, ba, Long.MAX_VALUE));
}
@Test
public void testPPC9Inclusion() throws TimeoutException {
assertTrue(productParserC9.languageIncludes(productParserCL9, ba, Long.MAX_VALUE));
}
@Test
public void testPPC2Equivalence() throws TimeoutException {
assertTrue(productParserC2.isLanguageEquivalent(productParserC2, ba, Long.MAX_VALUE));
}
@Test
public void testPPC3Equivalence() throws TimeoutException {
assertTrue(productParserC3.isLanguageEquivalent(productParserC3, ba, Long.MAX_VALUE));
}
@Test
public void testPPC4Equivalence() throws TimeoutException {
assertTrue(productParserC4.isLanguageEquivalent(productParserC4, ba, Long.MAX_VALUE));
}
@Test
public void testPPC6Equivalence() throws TimeoutException {
assertTrue(productParserC6.isLanguageEquivalent(productParserC6, ba, Long.MAX_VALUE));
}
@Test
public void testPPC9Equivalence() throws TimeoutException {
assertTrue(productParserC9.isLanguageEquivalent(productParserC9, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL2Equivalence() throws TimeoutException {
assertTrue(productParserCL2.isLanguageEquivalent(productParserCL2, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL3Equivalence() throws TimeoutException {
assertTrue(productParserCL3.isLanguageEquivalent(productParserCL3, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL4Equivalence() throws TimeoutException {
assertTrue(productParserCL4.isLanguageEquivalent(productParserCL4, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL6Equivalence() throws TimeoutException {
assertTrue(productParserCL6.isLanguageEquivalent(productParserCL6, ba, Long.MAX_VALUE));
}
@Test
public void testPPCL9Equivalence() throws TimeoutException {
assertTrue(productParserCL9.isLanguageEquivalent(productParserCL9, ba, Long.MAX_VALUE));
}
@Test
public void testPPAcceptanceC2PP1() throws TimeoutException {
List<Character> valid2PP = lOfS("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste"); // accepted by PPC2 and PPCL2
assertTrue(productParserC2.accepts(valid2PP, ba));
}
@Test
public void testPPAcceptanceC2PP10() throws TimeoutException {
List<Character> valid2PP10 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 10);
assertTrue(productParserC2.accepts(valid2PP10, ba));
}
@Test
public void testPPAcceptanceC2PP100000() throws TimeoutException {
List<Character> valid2PP100000 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 100000);
assertTrue(productParserC2.accepts(valid2PP100000, ba));
}
@Test
public void testPPAcceptanceC2PP1000000() throws TimeoutException {
List<Character> valid2PP1000000 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 1000000);
assertTrue(productParserC2.accepts(valid2PP1000000, ba));
}
@Test
public void testPPAcceptanceC2PP10000000() throws TimeoutException {
List<Character> valid2PP10000000 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 10000000);
assertTrue(productParserC2.accepts(valid2PP10000000, ba));
}
@Test
public void testPPAcceptanceCL2PP1() throws TimeoutException {
List<Character> valid2PP = lOfS("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste"); // accepted by PPC2 and PPCL2
assertTrue(productParserCL2.accepts(valid2PP, ba));
}
@Test
public void testPPAcceptanceCL2PP10() throws TimeoutException {
List<Character> valid2PP10 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 10);
assertTrue(productParserCL2.accepts(valid2PP10, ba));
}
@Test
public void testPPAcceptanceCL2PP100000() throws TimeoutException {
List<Character> valid2PP100000 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 100000);
assertTrue(productParserCL2.accepts(valid2PP100000, ba));
}
@Test
public void testPPAcceptanceCL2PP1000000() throws TimeoutException {
List<Character> valid2PP1000000 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 1000000);
assertTrue(productParserCL2.accepts(valid2PP1000000, ba));
}
@Test
public void testPPAcceptanceCL2PP10000000() throws TimeoutException {
List<Character> valid2PP10000000 = getPPTestStrings("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 10000000);
assertTrue(productParserCL2.accepts(valid2PP10000000, ba));
}
@Test
public void testPPAcceptanceC3PP1() throws TimeoutException {
List<Character> valid3PP = lOfS("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste"); // accepted by PPC3 and PPCL3
assertTrue(productParserC3.accepts(valid3PP, ba));
}
@Test
public void testPPAcceptanceC3PP10() throws TimeoutException {
List<Character> valid3PP10 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 10);
assertTrue(productParserC3.accepts(valid3PP10, ba));
}
@Test
public void testPPAcceptanceC3PP100000() throws TimeoutException {
List<Character> valid3PP100000 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 100000);
assertTrue(productParserC3.accepts(valid3PP100000, ba));
}
@Test
public void testPPAcceptanceC3PP1000000() throws TimeoutException {
List<Character> valid3PP1000000 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 1000000);
assertTrue(productParserC3.accepts(valid3PP1000000, ba));
}
@Test
public void testPPAcceptanceC3PP10000000() throws TimeoutException {
List<Character> valid3PP10000000 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 10000000);
assertTrue(productParserC3.accepts(valid3PP10000000, ba));
}
@Test
public void testPPAcceptanceCL3PP1() throws TimeoutException {
List<Character> valid3PP = lOfS("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste"); // accepted by PPC3 and PPCL3
assertTrue(productParserCL3.accepts(valid3PP, ba));
}
@Test
public void testPPAcceptanceCL3PP10() throws TimeoutException {
List<Character> valid3PP10 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 10);
assertTrue(productParserCL3.accepts(valid3PP10, ba));
}
@Test
public void testPPAcceptanceCL3PP100000() throws TimeoutException {
List<Character> valid3PP100000 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 100000);
assertTrue(productParserCL3.accepts(valid3PP100000, ba));
}
@Test
public void testPPAcceptanceCL3PP1000000() throws TimeoutException {
List<Character> valid3PP1000000 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 1000000);
assertTrue(productParserCL3.accepts(valid3PP1000000, ba));
}
@Test
public void testPPAcceptanceCL3PP10000000() throws TimeoutException {
List<Character> valid3PP10000000 = getPPTestStrings("C:X4a L:4 D:toothbrush C:X4a L:4 D:toothpaste", 10000000);
assertTrue(productParserCL3.accepts(valid3PP10000000, ba));
}
@Test
public void testPPAcceptanceC4PP1() throws TimeoutException {
List<Character> valid4PP = lOfS("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste"); // accepted by PPC4 and PPCL4
assertTrue(productParserC4.accepts(valid4PP, ba));
}
@Test
public void testPPAcceptanceC4PP10() throws TimeoutException {
List<Character> valid4PP10 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 10);
assertTrue(productParserC4.accepts(valid4PP10, ba));
}
@Test
public void testPPAcceptanceC4PP100000() throws TimeoutException {
List<Character> valid4PP100000 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 100000);
assertTrue(productParserC4.accepts(valid4PP100000, ba));
}
@Test
public void testPPAcceptanceC4PP1000000() throws TimeoutException {
List<Character> valid4PP1000000 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 1000000);
assertTrue(productParserC4.accepts(valid4PP1000000, ba));
}
@Test
public void testPPAcceptanceC4PP10000000() throws TimeoutException {
List<Character> valid4PP10000000 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 10000000);
assertTrue(productParserC4.accepts(valid4PP10000000, ba));
}
@Test
public void testPPAcceptanceCL4PP1() throws TimeoutException {
List<Character> valid4PP = lOfS("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste"); // accepted by PPC4 and PPCL4
assertTrue(productParserCL4.accepts(valid4PP, ba));
}
@Test
public void testPPAcceptanceCL4PP10() throws TimeoutException {
List<Character> valid4PP10 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 10);
assertTrue(productParserCL4.accepts(valid4PP10, ba));
}
@Test
public void testPPAcceptanceCL4PP100000() throws TimeoutException {
List<Character> valid4PP100000 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 100000);
assertTrue(productParserCL4.accepts(valid4PP100000, ba));
}
@Test
public void testPPAcceptanceCL4PP1000000() throws TimeoutException {
List<Character> valid4PP1000000 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 1000000);
assertTrue(productParserCL4.accepts(valid4PP1000000, ba));
}
@Test
public void testPPAcceptanceCL4PP10000000() throws TimeoutException {
List<Character> valid4PP10000000 = getPPTestStrings("C:X4aB L:4 D:toothbrush C:X4aB L:4 D:toothpaste", 10000000);
assertTrue(productParserCL4.accepts(valid4PP10000000, ba));
}
@Test
public void testPPAcceptanceC6PP1() throws TimeoutException {
List<Character> valid6PP = lOfS("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste"); // accepted by PPC6 and PPCL6
assertTrue(productParserC6.accepts(valid6PP, ba));
}
@Test
public void testPPAcceptanceC6PP10() throws TimeoutException {
List<Character> valid6PP10 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 10);
assertTrue(productParserC6.accepts(valid6PP10, ba));
}
@Test
public void testPPAcceptanceC6PP100000() throws TimeoutException {
List<Character> valid6PP100000 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 100000);
assertTrue(productParserC6.accepts(valid6PP100000, ba));
}
@Test
public void testPPAcceptanceC6PP1000000() throws TimeoutException {
List<Character> valid6PP1000000 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 1000000);
assertTrue(productParserC6.accepts(valid6PP1000000, ba));
}
@Test
public void testPPAcceptanceC6PP10000000() throws TimeoutException {
List<Character> valid6PP10000000 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 10000000);
assertTrue(productParserC6.accepts(valid6PP10000000, ba));
}
@Test
public void testPPAcceptanceCL6PP1() throws TimeoutException {
List<Character> valid6PP = lOfS("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste"); // accepted by PPC6 and PPCL6
assertTrue(productParserCL6.accepts(valid6PP, ba));
}
@Test
public void testPPAcceptanceCL6PP10() throws TimeoutException {
List<Character> valid6PP10 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 10);
assertTrue(productParserCL6.accepts(valid6PP10, ba));
}
@Test
public void testPPAcceptanceCL6PP100000() throws TimeoutException {
List<Character> valid6PP100000 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 100000);
assertTrue(productParserCL6.accepts(valid6PP100000, ba));
}
@Test
public void testPPAcceptanceCL6PP1000000() throws TimeoutException {
List<Character> valid6PP1000000 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 1000000);
assertTrue(productParserCL6.accepts(valid6PP1000000, ba));
}
@Test
public void testPPAcceptanceCL6PP10000000() throws TimeoutException {
List<Character> valid6PP10000000 = getPPTestStrings("C:X4aB@y L:4 D:toothbrush C:X4aB@y L:4 D:toothpaste", 10000000);
assertTrue(productParserCL6.accepts(valid6PP10000000, ba));
}
@Test
public void testPPAcceptanceC9PP1() throws TimeoutException {
List<Character> valid9PP = lOfS("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste"); // accepted by PPC9 and PPCL9
assertTrue(productParserC9.accepts(valid9PP, ba));
}
@Test
public void testPPAcceptanceC9PP10() throws TimeoutException {
List<Character> valid9PP10 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 10);
assertTrue(productParserC9.accepts(valid9PP10, ba));
}
@Test
public void testPPAcceptanceC9PP100000() throws TimeoutException {
List<Character> valid9PP100000 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 100000);
assertTrue(productParserC9.accepts(valid9PP100000, ba));
}
@Test
public void testPPAcceptanceC9PP1000000() throws TimeoutException {
List<Character> valid9PP1000000 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 1000000);
assertTrue(productParserC9.accepts(valid9PP1000000, ba));
}
@Test
public void testPPAcceptanceC9PP10000000() throws TimeoutException {
List<Character> valid9PP10000000 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 10000000);
assertTrue(productParserC9.accepts(valid9PP10000000, ba));
}
@Test
public void testPPAcceptanceCL9PP1() throws TimeoutException {
List<Character> valid9PP = lOfS("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste"); // accepted by PPC9 and PPCL9
assertTrue(productParserCL9.accepts(valid9PP, ba));
}
@Test
public void testPPAcceptanceCL9PP10() throws TimeoutException {
List<Character> valid9PP10 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 10);
assertTrue(productParserCL9.accepts(valid9PP10, ba));
}
@Test
public void testPPAcceptanceCL9PP100000() throws TimeoutException {
List<Character> valid9PP100000 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 100000);
assertTrue(productParserCL9.accepts(valid9PP100000, ba));
}
@Test
public void testPPAcceptanceCL9PP1000000() throws TimeoutException {
List<Character> valid9PP1000000 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 1000000);
assertTrue(productParserCL9.accepts(valid9PP1000000, ba));
}
@Test
public void testPPAcceptanceCL9PP10000000() throws TimeoutException {
List<Character> valid9PP10000000 = getPPTestStrings("C:X4aB@y%z[ L:4 D:toothbrush C:X4aB@y%z[ L:4 D:toothpaste", 10000000);
assertTrue(productParserCL9.accepts(valid9PP10000000, ba));
}
@Test
public void testPPAcceptanceJavaRegex() {
String valid2PP100Str = getPPTestString("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 100);
Matcher m = CL2PPRegex.matcher(valid2PP100Str);
assertTrue(m.find());
}
@Test
public void testPPAcceptanceJavaRegexOverflow() {
String valid2PP1000Str = getPPTestString("C:X4 L:4 D:toothbrush C:X4 L:4 D:toothpaste", 1000);
Matcher m = CL2PPRegex.matcher(valid2PP1000Str);
assertTrue(m.find());
}
@Test
public void testSFAEquivalence3And2() throws TimeoutException {
assertFalse(IP2PacketParserSimplifiedSFA.isHopcroftKarpEquivalentTo(IP3PacketParserSimplifiedSFA, ba));
}
@Test
public void testSFAEquivalence4In3() throws TimeoutException {
assertFalse(IP3PacketParserSimplifiedSFA.isHopcroftKarpEquivalentTo(IP4PacketParserSimplifiedSFA, ba));
}
@Test
public void testSRAInclusion3In2() throws TimeoutException {
assertTrue(IP2PacketParserSimplifiedSRA.languageIncludes(IP3PacketParserSimplifiedSRA, ba, Long.MAX_VALUE));
}
@Test
public void testSRAInclusion4In3() throws TimeoutException {
assertTrue(IP3PacketParserSimplifiedSRA.languageIncludes(IP4PacketParserSimplifiedSRA, ba, Long.MAX_VALUE));
}
@Test
public void testSRAInclusion6In4() throws TimeoutException {
assertTrue(IP4PacketParserSimplifiedSRA.languageIncludes(IP6PacketParserSimplifiedSRA, ba, Long.MAX_VALUE));
}
@Test
public void testSRAInclusion9In6() throws TimeoutException {
assertTrue(IP6PacketParserSimplifiedSRA.languageIncludes(IP9PacketParserSimplifiedSRA, ba, Long.MAX_VALUE));
}
// Predicates
private UnaryCharIntervalSolver ba = new UnaryCharIntervalSolver();
private CharPred alpha = StdCharPred.ALPHA;
private CharPred num = StdCharPred.NUM;
private CharPred alphaNum = StdCharPred.ALPHA_NUM;
private CharPred lowerAlpha = StdCharPred.LOWER_ALPHA;
private CharPred upperAlpha = StdCharPred.UPPER_ALPHA;
private CharPred dot = new CharPred('.');
private CharPred comma = new CharPred(',');
private CharPred space = new CharPred(' ');
private CharPred open = new CharPred('<');
private CharPred close = new CharPred('>');
private CharPred slash = new CharPred('/');
// SSN test strings
private List<Character> validName1 = lOfS("Tiago, Ferreira, TF"); // accepted by SSNParser
private List<Character> validName2 = lOfS("Thomas, Thomson, TT"); // accepted by SSNParser
private List<Character> invalidName1 = lOfS("Tiago, Ferreira, TA"); // not accepted by SSNParser
private List<Character> invalidName2 = lOfS("Tiago, Ferreira, AA"); // not accepted by SSNParser
private List<Character> invalidName3 = lOfS("Tiago, Ferreira, A"); // not accepted by SSNParser
// Regex pattern
Pattern CL2PPRegex = Pattern.compile("C:(.{2}) L:(.) D:[^\\s]+( C:\\1 L:\\2 D:[^\\s]+)+");
// XML test strings
private List<Character> validXML1 = lOfS("<A></A>"); // accepted by XMLParser
private List<Character> validXML2 = lOfS("<AB></AB>"); // accepted by XMLParser
private List<Character> validXML3 = lOfS("<BB></BB>"); // accepted by XMLParser
private List<Character> validXML4 = lOfS("<ABB></ABB>"); // accepted by XMLParser
private List<Character> validXML5 = lOfS("<ABA></ABA>"); // accepted by XMLParser
private List<Character> validXML6 = lOfS("<AAB></AAB>"); // accepted by XMLParser
private List<Character> validXML7 = lOfS("<ABC></ABC>"); // accepted by XMLParser
private List<Character> invalidXML1 = lOfS("<A></>"); // not accepted by XMLParser
private List<Character> invalidXML2 = lOfS("<A><AB/>"); // not accepted by XMLParser
private List<Character> invalidXML3 = lOfS("<></A>"); // not accepted by XMLParser
private List<Character> invalidXML4 = lOfS("<A><A>"); // not accepted by XMLParser
private List<Character> invalidXML5 = lOfS("<AA></AB>"); // not accepted by XMLParser
private List<Character> invalidXML6 = lOfS("<AAA></CCC>"); // not accepted by XMLParser
private List<Character> invalidXML7 = lOfS("<ABA></ABC>"); // not accepted by XMLParser
// IP Packet test strings
private List<Character> validIPPacket1 = lOfS("srcip:192.168.123.192 prt:40 dstip:192.168.123.224 prt:50 pload:'hello'"); // accepted by IP9PacketParser
// private List<Character> validIPPacketSimplified1 = lOfS("s:192.168.123.192 p:40 d:192.168.123.224 p:50 p:'hello'"); // accepted by IP2PacketParserSimplified
private List<Character> validIPPacket2 = lOfS("srcip:192.168.123.122 prt:40 dstip:192.168.123.124 prt:5 pload:'hello123'"); // accepted by IP9PacketParser
private List<Character> validIPPacket3 = lOfS("srcip:192.148.123.122 prt:40 dstip:192.148.123.124 prt:5 pload:'hello123'"); // accepted by IP9PacketParser
private List<Character> invalidIPPacket1 = lOfS("srcip:12.168.123.122 prt:40 dstip:192.168.123.124 prt:5 pload:'hello123'"); // not accepted by either
private List<Character> invalidIPPacket2 = lOfS("srcip:192.148.123.122 prt:40 dstip:192.148.123.124 prt:5 plad:'hello123'"); // not accepted by either
private List<Character> invalidIPPacket3 = lOfS("srcip:192.148.123.122 dstip:192.148.123.124 prt:5 pload:'hello123'"); // not accepted by either
private List<Character> dependentIPPacket1 = lOfS("srcip:192.148.125.122 prt:40 dstip:192.148.123.124 prt:5 pload:'hello123'"); // accepted by IP6PacketParser but not IP9PacketParser
// Automata
private SRA<CharPred, Character> SSNParser = getSSNParser(ba);
private SFA<CharPred, Character> SSNParserSFA = getSSNParserSFA(ba);
private SRA<CharPred, Character> SSNParserFirst = getSSNParserFirst(ba);
private SFA<CharPred, Character> SSNParserFirstSFA = getSSNParserFirstSFA(ba);
private SRA<CharPred, Character> SSNParserLast = getSSNParserLast(ba);
private SFA<CharPred, Character> SSNParserLastSFA = getSSNParserLastSFA(ba);
private SRA<CharPred, Character> XMLParserSRA = getXMLParserSRA(ba);
private SRA<CharPred, Character> productParserC2 = getProductParserC2(ba);
private SRA<CharPred, Character> productParserCL2 = getProductParserCL2(ba);
private SRA<CharPred, Character> productParserC3 = getProductParserC3(ba);
private SRA<CharPred, Character> productParserCL3 = getProductParserCL3(ba);
private SRA<CharPred, Character> productParserC4 = getProductParserC4(ba);
private SRA<CharPred, Character> productParserCL4 = getProductParserCL4(ba);
private SRA<CharPred, Character> productParserC6 = getProductParserC6(ba);
private SRA<CharPred, Character> productParserCL6 = getProductParserCL6(ba);
private SRA<CharPred, Character> productParserC9 = getProductParserC9(ba);
private SRA<CharPred, Character> productParserCL9 = getProductParserCL9(ba);
// private SFA<CharPred, Character> productParserSFA = getProductParserSFA(ba); // Intractable.
private SRA<CharPred, Character> IP2PacketParserSRA = getIP2PacketParserSRA(ba);
private SRA<CharPred, Character> IP2PacketParserSimplifiedSRA = getIP2PacketParserSimplifiedSRA(ba);
private SFA<CharPred, Character> IP2PacketParserSimplifiedSFA = getIP2PacketParserSimplifiedSFA(ba);
private SRA<CharPred, Character> IP3PacketParserSRA = getIP3PacketParserSRA(ba);
private SRA<CharPred, Character> IP3PacketParserSimplifiedSRA = getIP3PacketParserSimplifiedSRA(ba);
private SFA<CharPred, Character> IP3PacketParserSimplifiedSFA = getIP3PacketParserSimplifiedSFA(ba);
private SRA<CharPred, Character> IP4PacketParserSRA = getIP4PacketParserSRA(ba);
private SRA<CharPred, Character> IP4PacketParserSimplifiedSRA = getIP4PacketParserSimplifiedSRA(ba);
private SFA<CharPred, Character> IP4PacketParserSimplifiedSFA = getIP4PacketParserSimplifiedSFA(ba);
private SRA<CharPred, Character> IP6PacketParserSRA = getIP6PacketParserSRA(ba);
private SRA<CharPred, Character> IP6PacketParserSimplifiedSRA = getIP6PacketParserSimplifiedSRA(ba);
private SRA<CharPred, Character> IP9PacketParserSRA = getIP9PacketParserSRA(ba);
private SRA<CharPred, Character> IP9PacketParserSimplifiedSRA = getIP9PacketParserSimplifiedSRA(ba);
private SRA<CharPred, Character> getSSNParser(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
// Read first initial and store it in register 0
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, upperAlpha, 0));
// Read an unbound number of lowercase letters for the rest of the first name.
// Dispose of them on the dummy register (2)
transitions.add(new SRAStoreMove<CharPred, Character>(1, 1, lowerAlpha, 2));
// Read a comma and dispose of it on register (2)
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, comma, 2));
// Read an unbound number of spaces.
transitions.add(new SRAStoreMove<CharPred, Character>(2, 2, space, 2));
// Read the second initial and store it in register 1
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, upperAlpha, 1));
// Read an unbound number of lowercase letters for the rest of the last name.
// Dispose of them on the dummy register (2)
transitions.add(new SRAStoreMove<CharPred, Character>(3, 3, lowerAlpha, 2));
// Read a comma and dispose of it on register (2)
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, comma, 2));
// Read an unbound number of spaces.
transitions.add(new SRAStoreMove<CharPred, Character>(4, 4, space, 2));
// Read the first initial and compare it to register 0
transitions.add(new SRACheckMove<CharPred, Character>(4, 5, upperAlpha, 0));
// Read the second initial and compare it to register 1
transitions.add(new SRACheckMove<CharPred, Character>(5, 6, upperAlpha, 1));
try {
return SRA.MkSRA(transitions, 0, Arrays.asList(6), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SFA<CharPred, Character> getSSNParserSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
List<Integer> finalStates = new LinkedList<Integer>();
Character firstInitial = upperAlpha.intervals.get(0).left;
Character firstEnd = upperAlpha.intervals.get(0).right;
for (int firstCounter = 0; firstInitial < firstEnd; firstCounter++, firstInitial++) {
transitions.add(new SFAInputMove<CharPred, Character>(0, (firstCounter * 185) + 1, new CharPred(firstInitial)));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + 1, (firstCounter * 185) + 1, lowerAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + 1, (firstCounter * 185) + 2, comma));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + 2, (firstCounter * 185) + 3, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + 3, (firstCounter * 185) + 3, space));
Character secondInitial = upperAlpha.intervals.get(0).left;
Character secondEnd = upperAlpha.intervals.get(0).right;
for (int secondCounter = 0; secondInitial < secondEnd; secondCounter++, secondInitial++) {
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + 3, (firstCounter * 185) + (secondCounter * 7) + 4, new CharPred(secondInitial)));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + (secondCounter * 7) + 4, (firstCounter * 185) + (secondCounter * 7) + 4, lowerAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + (secondCounter * 7) + 4, (firstCounter * 185) + (secondCounter * 7) + 5, comma));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + (secondCounter * 7) + 5, (firstCounter * 185) + (secondCounter * 7) + 6, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + (secondCounter * 7) + 6, (firstCounter * 185) + (secondCounter * 7) + 6, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + (secondCounter * 7) + 6, (firstCounter * 185) + (secondCounter * 7) + 7, new CharPred(firstInitial)));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 185) + (secondCounter * 7) + 7, (firstCounter * 185) + (secondCounter * 7) + 8, new CharPred(secondInitial)));
finalStates.add((firstCounter * 185) + (secondCounter * 7) + 8);
}
}
try {
return SFA.MkSFA(transitions, 0, finalStates, ba, false, false);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getSSNParserFirst(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
// Read the first initial and store it in register 0
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, upperAlpha, 0));
// Read an unbound number of lowercase characters
transitions.add(new SRAStoreMove<CharPred, Character>(1, 1, lowerAlpha, 1));
// Read a comma
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, comma, 1));
// Read an unbound number of spaces
transitions.add(new SRAStoreMove<CharPred, Character>(2, 2, space, 1));
// Read a different second initial or a repeated second initial and store it in 1
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, upperAlpha, 1));
// Read an unbound number of lowercase characters
transitions.add(new SRAStoreMove<>(3, 3, lowerAlpha,1));
// Read a comma
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, comma, 1));
// Read an unbound number of spaces
transitions.add(new SRAStoreMove<CharPred, Character>(4, 4, space, 1));
// Read a capital that matches both registers or a capital that matches the first register
transitions.add(new SRACheckMove<CharPred, Character>(4, 5, upperAlpha, 0));
// Read a second capital
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, upperAlpha, 1));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(6), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SFA<CharPred, Character> getSSNParserFirstSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
List<Integer> finalStates = new LinkedList<Integer>();
Character firstInitial = upperAlpha.intervals.get(0).left;
Character firstEnd = upperAlpha.intervals.get(0).right;
for (int firstCounter = 0; firstInitial < firstEnd; firstCounter++, firstInitial++) {
transitions.add(new SFAInputMove<CharPred, Character>(0, (firstCounter * 9) + 1, new CharPred(firstInitial)));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 1, (firstCounter * 9) + 1, lowerAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 1, (firstCounter * 9) + 2, comma));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 2, (firstCounter * 9) + 3, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 3, (firstCounter * 9) + 3, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 3, (firstCounter * 9) + 4, upperAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 4, (firstCounter * 9) + 4, lowerAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 4, (firstCounter * 9) + 5, comma));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 5, (firstCounter * 9) + 6, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 6, (firstCounter * 9) + 6, space));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 6, (firstCounter * 9) + 7, new CharPred(firstInitial)));
transitions.add(new SFAInputMove<CharPred, Character>((firstCounter * 9) + 7, (firstCounter * 9) + 8, upperAlpha));
finalStates.add((firstCounter * 9) + 8);
}
try {
return SFA.MkSFA(transitions, 0, finalStates, ba, false, false);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getSSNParserLast(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
// Read the first initial and store it in register 0
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, upperAlpha, 1));
// Read an unbound number of lowercase characters
transitions.add(new SRAStoreMove<CharPred, Character>(1, 1, lowerAlpha, 1));
// Read a comma
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, comma, 1));
// Read an unbound number of spaces
transitions.add(new SRAStoreMove<CharPred, Character>(2, 2, space, 1));
// Read a different second initial or a repeated second initial and store it in 1
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, upperAlpha, 0));
// Read an unbound number of lowercase characters
transitions.add(new SRAStoreMove<>(3, 3, lowerAlpha,1));
// Read a comma
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, comma, 1));
// Read an unbound number of spaces
transitions.add(new SRAStoreMove<CharPred, Character>(4, 4, space, 1));
// Read a capital
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, upperAlpha, 1));
// Read a capital that matches both registers or a capital that matches the first register
transitions.add(new SRACheckMove<CharPred, Character>(5, 6, upperAlpha, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(6), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SFA<CharPred, Character> getSSNParserLastSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
List<Integer> finalStates = new LinkedList<Integer>();
transitions.add(new SFAInputMove<CharPred, Character>(0, 1, upperAlpha));
transitions.add(new SFAInputMove<CharPred, Character>(1, 1, lowerAlpha));
transitions.add(new SFAInputMove<CharPred, Character>(1, 2, comma));
transitions.add(new SFAInputMove<CharPred, Character>(2, 3, space));
transitions.add(new SFAInputMove<CharPred, Character>(3, 3, space));
Character secondInitial = upperAlpha.intervals.get(0).left;
Character secondEnd = upperAlpha.intervals.get(0).right;
for (int secondCounter = 0; secondInitial < secondEnd; secondCounter++, secondInitial++) {
transitions.add(new SFAInputMove<CharPred, Character>(3, (secondCounter * 7) + 4, new CharPred(secondInitial)));
transitions.add(new SFAInputMove<CharPred, Character>((secondCounter * 7) + 4, (secondCounter * 7) + 4, lowerAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((secondCounter * 7) + 4, (secondCounter * 7) + 5, comma));
transitions.add(new SFAInputMove<CharPred, Character>((secondCounter * 7) + 5, (secondCounter * 7) + 6, space));
transitions.add(new SFAInputMove<CharPred, Character>((secondCounter * 7) + 6, (secondCounter * 7) + 6, space));
transitions.add(new SFAInputMove<CharPred, Character>((secondCounter * 7) + 6, (secondCounter * 7) + 7, upperAlpha));
transitions.add(new SFAInputMove<CharPred, Character>((secondCounter * 7) + 7, (secondCounter * 7) + 8, new CharPred(secondInitial)));
finalStates.add((secondCounter * 7) + 8);
}
try {
return SFA.MkSFA(transitions, 0, finalStates, ba, false, false);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserC2(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 12, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(15, 16, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(16, 17, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(22, 23, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 25, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 13, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(25), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserCL2(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, alphaNum, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 12, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(15, 16, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(16, 17, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(20, 21, alphaNum, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(22, 23, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 25, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 13, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(25), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserC3(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 13, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(16, 17, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(17, 18, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(18, 19, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(22, 23, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 14, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(27), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserCL3(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, alphaNum, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 13, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(16, 17, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(17, 18, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(18, 19, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, alphaNum, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 14, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(27), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserC4(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 14, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(17, 18, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(18, 19, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(19, 20, ba.MkNot(space), 3));
transitions.add(new SRACheckMove<CharPred, Character>(20, 21, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(22, 23, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 29, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 15, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(29), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserCL4(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, alphaNum, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 14, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(17, 18, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(18, 19, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(19, 20, ba.MkNot(space), 3));
transitions.add(new SRACheckMove<CharPred, Character>(20, 21, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(22, 23, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(24, 25, alphaNum, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 29, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 15, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(29), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserC6(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, ba.MkNot(space), 5));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, ba.MkNot(space), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 16, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(19, 20, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(20, 21, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, ba.MkNot(space), 3));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, ba.MkNot(space), 4));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, ba.MkNot(space), 5));
transitions.add(new SRACheckMove<CharPred, Character>(24, 25, ba.MkNot(space), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 30, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(30, 31, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 33, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 17, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(33), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserCL6(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, ba.MkNot(space), 5));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, ba.MkNot(space), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, alphaNum, 7));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 16, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(19, 20, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(20, 21, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, ba.MkNot(space), 3));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, ba.MkNot(space), 4));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, ba.MkNot(space), 5));
transitions.add(new SRACheckMove<CharPred, Character>(24, 25, ba.MkNot(space), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(28, 29, alphaNum, 7));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 30, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(30, 31, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 33, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 17, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(33), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserC9(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, ba.MkNot(space), 5));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, ba.MkNot(space), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, ba.MkNot(space), 7));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, ba.MkNot(space), 8));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, ba.MkNot(space), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 19, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(24, 25, ba.MkNot(space), 3));
transitions.add(new SRACheckMove<CharPred, Character>(25, 26, ba.MkNot(space), 4));
transitions.add(new SRACheckMove<CharPred, Character>(26, 27, ba.MkNot(space), 5));
transitions.add(new SRACheckMove<CharPred, Character>(27, 28, ba.MkNot(space), 6));
transitions.add(new SRACheckMove<CharPred, Character>(28, 29, ba.MkNot(space), 7));
transitions.add(new SRACheckMove<CharPred, Character>(29, 30, ba.MkNot(space), 8));
transitions.add(new SRACheckMove<CharPred, Character>(30, 31, ba.MkNot(space), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(38, 39, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 39, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 20, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(39), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getProductParserCL9(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, ba.MkNot(space), 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, ba.MkNot(space), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, ba.MkNot(space), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, ba.MkNot(space), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, ba.MkNot(space), 5));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, ba.MkNot(space), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, ba.MkNot(space), 7));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, ba.MkNot(space), 8));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, ba.MkNot(space), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 19, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, new CharPred('C'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, new CharPred(':'), 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, ba.MkNot(space), 1));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, ba.MkNot(space), 2));
transitions.add(new SRACheckMove<CharPred, Character>(24, 25, ba.MkNot(space), 3));
transitions.add(new SRACheckMove<CharPred, Character>(25, 26, ba.MkNot(space), 4));
transitions.add(new SRACheckMove<CharPred, Character>(26, 27, ba.MkNot(space), 5));
transitions.add(new SRACheckMove<CharPred, Character>(27, 28, ba.MkNot(space), 6));
transitions.add(new SRACheckMove<CharPred, Character>(28, 29, ba.MkNot(space), 7));
transitions.add(new SRACheckMove<CharPred, Character>(29, 30, ba.MkNot(space), 8));
transitions.add(new SRACheckMove<CharPred, Character>(30, 31, ba.MkNot(space), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, new CharPred('L'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, alphaNum, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, space, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, new CharPred('D'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, new CharPred(':'), 0));
transitions.add(new SRAStoreMove<CharPred, Character>(38, 39, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 39, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 20, space, 0));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(39), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private List<Character> getPPTestStrings(String original, int repetitions) {
int startIndex = original.indexOf(' ', original.indexOf(' ', original.indexOf(' ') + 1) + 1);
if (startIndex != -1) {
String repetition = original.substring(startIndex);
StringBuilder sb = new StringBuilder();
sb.append(original);
for (int index = 0; index < repetitions; index++)
sb.append(repetition);
return lOfS(sb.toString());
}
return null;
}
private String getPPTestString(String original, int repetitions) {
int startIndex = original.indexOf(' ', original.indexOf(' ', original.indexOf(' ') + 1) + 1);
if (startIndex != -1) {
String repetition = original.substring(startIndex);
StringBuilder sb = new StringBuilder();
sb.append(original);
for (int index = 0; index < repetitions; index++)
sb.append(repetition);
return sb.toString();
}
return null;
}
private SFA<CharPred, Character> getProductParserSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
transitions.add(new SFAInputMove<CharPred, Character>(0, 1, new CharPred('C')));
transitions.add(new SFAInputMove<CharPred, Character>(1, 2, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(2, 3, space));
for (ImmutablePair<Character, Character> firstInterval : ba.MkNot(space).intervals) {
Character firstStart = firstInterval.left;
Character firstEnd = firstInterval.right;
for (int firstCounter = 0; firstStart < firstEnd; firstCounter++, firstStart++) {
transitions.add(new SFAInputMove<CharPred, Character>(3, 4 + (firstCounter * 4), new CharPred(firstStart)));
for (ImmutablePair<Character, Character> secondInterval : ba.MkNot(space).intervals) {
Character secondStart = secondInterval.left;
Character secondEnd = secondInterval.right;
for (int secondCounter = 0; secondStart < secondEnd; secondCounter++, secondStart++) {
transitions.add(new SFAInputMove<CharPred, Character>(4 + (firstCounter * 4), 4 + (firstCounter * 4) + (secondCounter * 2) + 1, new CharPred(secondStart)));
for (ImmutablePair<Character, Character> thirdInterval : ba.MkNot(space).intervals) {
Character thirdStart = thirdInterval.left;
Character thirdEnd = thirdInterval.right;
for (int thirdCounter = 0; thirdStart < thirdEnd; thirdCounter++, thirdStart++) {
transitions.add(new SFAInputMove<CharPred, Character>(4 + (firstCounter * 4) + (secondCounter * 2) + 1, 4 + (firstCounter * 4) + (secondCounter * 2) + thirdCounter + 2, new CharPred(thirdStart)));
}
}
}
}
}
}
// transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, space, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, new CharPred('L'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, new CharPred(':'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, alphaNum, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, space, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, new CharPred('D'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, new CharPred(':'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, alpha, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(14, 14, alpha, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, space, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, new CharPred('C'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, new CharPred(':'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 3));
// transitions.add(new SRACheckMove<CharPred, Character>(18, 19, ba.MkNot(space), 0));
// transitions.add(new SRACheckMove<CharPred, Character>(19, 20, ba.MkNot(space), 1));
// transitions.add(new SRACheckMove<CharPred, Character>(20, 21, ba.MkNot(space), 2));
// transitions.add(new SRAStoreMove<CharPred, Character>(21, 22, new CharPred('L'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(22, 23, new CharPred(':'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, alphaNum, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, space, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, new CharPred('D'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, new CharPred(':'), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, alpha, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, alpha, 3));
try {
return SFA.MkSFA(transitions, 0, Collections.singleton(3), ba, false, false);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getSmallXMLParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList('<', '>', '/', null, null, null));
Integer garbageReg = registers.size() - 1;
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
// Read opening character
transitions.add(new SRACheckMove<CharPred, Character>(0, 1, open, 0));
// Read tag
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, alpha, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, alpha, 4));
// Read closing character
transitions.add(new SRACheckMove<CharPred, Character>(2, 5, close, 1));
transitions.add(new SRACheckMove<CharPred, Character>(3, 5, close, 1));
transitions.add(new SRACheckMove<CharPred, Character>(4, 5, close, 1));
// Read any content (or not)
transitions.add(new SRAStoreMove<CharPred, Character>(5, 5, alphaNum, garbageReg));
// Read opening character and slash
transitions.add(new SRACheckMove<CharPred, Character>(5, 6, open, 0));
transitions.add(new SRACheckMove<CharPred, Character>(6, 7, slash, 2));
// Read repeated tag (AAA, BBB, ...)
transitions.add(new SRACheckMove<CharPred, Character>(7, 8, alpha, 3));
transitions.add(new SRACheckMove<CharPred, Character>(8, 9, alpha, 4));
// Read closing character
transitions.add(new SRACheckMove<CharPred, Character>(8, 11, close, 1));
transitions.add(new SRACheckMove<CharPred, Character>(9, 11, close, 1));
transitions.add(new SRACheckMove<CharPred, Character>(10, 11, close, 1));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(11), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getXMLParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
// Read opening character
transitions.add(new SRAStoreMove<CharPred, Character>(0, 1, open, 3));
// Read tag
transitions.add(new SRAStoreMove<CharPred, Character>(1, 2, alpha, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, alpha, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, alpha, 2));
// Read closing character
transitions.add(new SRAStoreMove<CharPred, Character>(2, 5, close, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 5, close, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, close, 3));
// Read any content (or not)
transitions.add(new SRAStoreMove<CharPred, Character>(5, 5, alphaNum, 3));
// Read opening character and slash
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, open, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, slash, 3));
// Read repeated tag (AAA, BBB, ...)
transitions.add(new SRACheckMove<CharPred, Character>(7, 8, alpha, 0));
transitions.add(new SRACheckMove<CharPred, Character>(8, 9, alpha, 1));
transitions.add(new SRACheckMove<CharPred, Character>(9, 10, alpha, 2));
// Read closing character
transitions.add(new SRAStoreMove<CharPred, Character>(8, 11, close, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 11, close, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, close, 3));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(11), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP2PacketParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "srcip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("srcip:".charAt(index)), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, num, 2));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 21, index + 22, new CharPred(" prt:".charAt(index)), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, num, 2));
for (int index = 0; index < " dstip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 27, index + 28, new CharPred(" dstip:".charAt(index)), 2));
transitions.add(new SRACheckMove<CharPred, Character>(34, 35, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(35, 36, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(38, 39, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 40, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(43, 44, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(44, 45, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(45, 46, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(46, 47, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(47, 48, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(48, 49, num, 2));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 49, index + 50, new CharPred(" prt:".charAt(index)), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(54, 55, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(55, 55, num, 2));
for (int index = 0; index < " pload:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 55, index + 56, new CharPred(" pload:".charAt(index)), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(62, 63, new CharPred('\''), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(63, 64, alphaNum, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 64, alphaNum, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 65, new CharPred('\''), 2));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(65), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP2PacketParserSimplifiedSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "s:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("s:".charAt(index)), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 18, ba.MkOr(new CharPred(':'), alphaNum), 2));
for (int index = 0; index < " d:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 18, index + 19, new CharPred(" d:".charAt(index)), 2));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(23, 24, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 30, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(30, 31, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, dot, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, space, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 37, ba.MkOr(new CharPred(':'), alphaNum), 2));
for (int index = 0; index < " p:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 37, index + 38, new CharPred(" p:".charAt(index)), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, new CharPred('\''), 2));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, alphaNum, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 42, alphaNum, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, new CharPred('\''), 2));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(43), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SFA<CharPred, Character> getIP2PacketParserSimplifiedSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
LinkedList<Integer> finalStates = new LinkedList<Integer>();
transitions.add(new SFAInputMove<CharPred, Character>(0, 1, new CharPred('s')));
transitions.add(new SFAInputMove<CharPred, Character>(1, 2, new CharPred(':')));
for (Integer firstDigit = 0; firstDigit < 10; firstDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(2, (firstDigit * 401) + 3, new CharPred(firstDigit.toString().charAt(0))));
for (Integer secondDigit = 0; secondDigit < 10; secondDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401), 3 + (firstDigit * 401) + (secondDigit * 40) + 1, new CharPred(secondDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 1, 3 + (firstDigit * 401) + (secondDigit * 40) + 2, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 2, 3 + (firstDigit * 401) + (secondDigit * 40) + 3, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 3, 3 + (firstDigit * 401) + (secondDigit * 40) + 4, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 4, 3 + (firstDigit * 401) + (secondDigit * 40) + 5, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 5, 3 + (firstDigit * 401) + (secondDigit * 40) + 6, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 6, 3 + (firstDigit * 401) + (secondDigit * 40) + 7, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 7, 3 + (firstDigit * 401) + (secondDigit * 40) + 8, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 8, 3 + (firstDigit * 401) + (secondDigit * 40) + 9, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 9, 3 + (firstDigit * 401) + (secondDigit * 40) + 10, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 10, 3 + (firstDigit * 401) + (secondDigit * 40) + 11, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 11, 3 + (firstDigit * 401) + (secondDigit * 40) + 12, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 12, 3 + (firstDigit * 401) + (secondDigit * 40) + 13, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 13, 3 + (firstDigit * 401) + (secondDigit * 40) + 14, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 14, 3 + (firstDigit * 401) + (secondDigit * 40) + 15, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 15, 3 + (firstDigit * 401) + (secondDigit * 40) + 15, ba.MkOr(new CharPred(':'), alphaNum)));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 15, 3 + (firstDigit * 401) + (secondDigit * 40) + 16, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 16, 3 + (firstDigit * 401) + (secondDigit * 40) + 17, new CharPred('d')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 17, 3 + (firstDigit * 401) + (secondDigit * 40) + 18, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 18, 3 + (firstDigit * 401) + (secondDigit * 40) + 19, new CharPred(firstDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 19, 3 + (firstDigit * 401) + (secondDigit * 40) + 20, new CharPred(secondDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 20, 3 + (firstDigit * 401) + (secondDigit * 40) + 21, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 21, 3 + (firstDigit * 401) + (secondDigit * 40) + 22, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 22, 3 + (firstDigit * 401) + (secondDigit * 40) + 23, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 23, 3 + (firstDigit * 401) + (secondDigit * 40) + 24, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 24, 3 + (firstDigit * 401) + (secondDigit * 40) + 25, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 25, 3 + (firstDigit * 401) + (secondDigit * 40) + 26, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 26, 3 + (firstDigit * 401) + (secondDigit * 40) + 27, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 27, 3 + (firstDigit * 401) + (secondDigit * 40) + 28, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 28, 3 + (firstDigit * 401) + (secondDigit * 40) + 29, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 29, 3 + (firstDigit * 401) + (secondDigit * 40) + 30, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 30, 3 + (firstDigit * 401) + (secondDigit * 40) + 31, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 31, 3 + (firstDigit * 401) + (secondDigit * 40) + 32, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 32, 3 + (firstDigit * 401) + (secondDigit * 40) + 33, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 33, 3 + (firstDigit * 401) + (secondDigit * 40) + 34, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 34, 3 + (firstDigit * 401) + (secondDigit * 40) + 34, ba.MkOr(new CharPred(':'), alphaNum)));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 34, 3 + (firstDigit * 401) + (secondDigit * 40) + 35, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 35, 3 + (firstDigit * 401) + (secondDigit * 40) + 36, new CharPred('p')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 36, 3 + (firstDigit * 401) + (secondDigit * 40) + 37, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 37, 3 + (firstDigit * 401) + (secondDigit * 40) + 38, new CharPred('\'')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 38, 3 + (firstDigit * 401) + (secondDigit * 40) + 39, alphaNum));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 39, 3 + (firstDigit * 401) + (secondDigit * 40) + 39, alphaNum));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 401) + (secondDigit * 40) + 39, 3 + (firstDigit * 401) + (secondDigit * 40) + 40, new CharPred('\'')));
finalStates.add(3 + (firstDigit * 401) + (secondDigit * 40) + 40);
}
}
try {
return SFA.MkSFA(transitions, 0,finalStates, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP3PacketParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "srcip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("srcip:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, num, 3));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 21, index + 22, new CharPred(" prt:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, num, 3));
for (int index = 0; index < " dstip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 27, index + 28, new CharPred(" dstip:".charAt(index)), 3));
transitions.add(new SRACheckMove<CharPred, Character>(34, 35, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(35, 36, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(36, 37, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(38, 39, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 40, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(43, 44, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(44, 45, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(45, 46, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(46, 47, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(47, 48, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(48, 49, num, 3));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 49, index + 50, new CharPred(" prt:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(54, 55, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(55, 55, num, 3));
for (int index = 0; index < " pload:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 55, index + 56, new CharPred(" pload:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(62, 63, new CharPred('\''), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(63, 64, alphaNum, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 64, alphaNum, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 65, new CharPred('\''), 3));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(65), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP3PacketParserSimplifiedSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "s:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("s:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 18, ba.MkOr(new CharPred(':'), alphaNum), 3));
for (int index = 0; index < " d:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 18, index + 19, new CharPred(" d:".charAt(index)), 3));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(25, 26, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 30, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(30, 31, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, dot, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, space, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 37, ba.MkOr(new CharPred(':'), alphaNum), 3));
for (int index = 0; index < " p:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 37, index + 38, new CharPred(" p:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, new CharPred('\''), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, alphaNum, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 42, alphaNum, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, new CharPred('\''), 3));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(43), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SFA<CharPred, Character> getIP3PacketParserSimplifiedSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
LinkedList<Integer> finalStates = new LinkedList<Integer>();
transitions.add(new SFAInputMove<CharPred, Character>(0, 1, new CharPred('s')));
transitions.add(new SFAInputMove<CharPred, Character>(1, 2, new CharPred(':')));
for (Integer firstDigit = 0; firstDigit < 10; firstDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(2, (firstDigit * 4329) + 3, new CharPred(firstDigit.toString().charAt(0))));
for (Integer secondDigit = 0; secondDigit < 10; secondDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329), 3 + (firstDigit * 4329) + (secondDigit * 429) + 1, new CharPred(secondDigit.toString().charAt(0))));
for (Integer thirdDigit = 0; thirdDigit < 10; thirdDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + 1, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 2, new CharPred(thirdDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 2, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 3, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 3, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 4, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 4, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 5, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 5, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 6, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 6, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 7, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 7, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 8, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 8, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 9, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 9, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 10, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 10, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 11, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 11, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 12, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 12, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 13, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 13, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 14, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 14, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 15, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 15, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 15, ba.MkOr(new CharPred(':'), alphaNum)));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 15, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 16, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 16, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 17, new CharPred('d')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 17, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 18, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 18, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 19, new CharPred(firstDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 19, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 20, new CharPred(secondDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 20, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 21, new CharPred(thirdDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 21, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 22, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 22, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 23, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 23, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 24, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 24, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 25, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 25, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 26, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 26, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 27, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 27, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 28, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 28, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 29, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 29, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 30, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 30, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 31, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 31, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 32, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 32, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 33, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 33, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 34, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 34, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 34, ba.MkOr(new CharPred(':'), alphaNum)));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 34, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 35, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 35, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 36, new CharPred('p')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 36, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 37, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 37, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 38, new CharPred('\'')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 38, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 39, alphaNum));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 39, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 39, alphaNum));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 39, 3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 40, new CharPred('\'')));
finalStates.add(3 + (firstDigit * 4329) + (secondDigit * 429) + (thirdDigit * 39) + 40);
}
}
}
try {
return SFA.MkSFA(transitions, 0, finalStates, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getSmallIP3PacketParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "s:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("s:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, num, 2));
// transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, dot, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, num, 3));
for (int index = 0; index < " p:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 5, index + 6, new CharPred(" p:".charAt(index)), 3));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 9, num, 3));
for (int index = 0; index < " d:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 9, index + 10, new CharPred(" d:".charAt(index)), 3));
transitions.add(new SRACheckMove<CharPred, Character>(12, 13, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(13, 14, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(14, 15, num, 2));
// transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, dot, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(38, 39, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(39, 40, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, dot, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(43, 44, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(44, 45, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(45, 46, dot, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(46, 47, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(47, 48, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(48, 49, num, 3));
// for (int index = 0; index < " prt:".length(); index++)
// transitions.add(new SRAStoreMove<CharPred, Character>(index + 49, index + 50, new CharPred(" prt:".charAt(index)), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(54, 55, num, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(55, 55, num, 3));
// for (int index = 0; index < " pload:".length(); index++)
// transitions.add(new SRAStoreMove<CharPred, Character>(index + 55, index + 56, new CharPred(" pload:".charAt(index)), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(62, 63, new CharPred('\''), 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(63, 64, alphaNum, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(64, 64, alphaNum, 3));
// transitions.add(new SRAStoreMove<CharPred, Character>(64, 65, new CharPred('\''), 3));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(15), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP4PacketParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "srcip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("srcip:".charAt(index)), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, num, 4));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 21, index + 22, new CharPred(" prt:".charAt(index)), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, num, 4));
for (int index = 0; index < " dstip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 27, index + 28, new CharPred(" dstip:".charAt(index)), 4));
transitions.add(new SRACheckMove<CharPred, Character>(34, 35, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(35, 36, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(36, 37, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, dot, 4));
transitions.add(new SRACheckMove<CharPred, Character>(38, 39, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(39, 40, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(43, 44, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(44, 45, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(45, 46, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(46, 47, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(47, 48, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(48, 49, num, 4));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 49, index + 50, new CharPred(" prt:".charAt(index)), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(54, 55, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(55, 55, num, 4));
for (int index = 0; index < " pload:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 55, index + 56, new CharPred(" pload:".charAt(index)), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(62, 63, new CharPred('\''), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(63, 64, alphaNum, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 64, alphaNum, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 65, new CharPred('\''), 4));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(65), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP4PacketParserSimplifiedSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "s:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("s:".charAt(index)), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 18, ba.MkOr(new CharPred(':'), alphaNum), 4));
for (int index = 0; index < " d:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 18, index + 19, new CharPred(" d:".charAt(index)), 4));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, dot, 4));
transitions.add(new SRACheckMove<CharPred, Character>(25, 26, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 28, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 30, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(30, 31, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, dot, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, space, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 37, ba.MkOr(new CharPred(':'), alphaNum), 4));
for (int index = 0; index < " p:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 37, index + 38, new CharPred(" p:".charAt(index)), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, new CharPred('\''), 4));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, alphaNum, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 42, alphaNum, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, new CharPred('\''), 4));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(43), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SFA<CharPred, Character> getIP4PacketParserSimplifiedSFA(UnaryCharIntervalSolver ba) {
Collection<SFAMove<CharPred, Character>> transitions = new LinkedList<SFAMove<CharPred, Character>>();
LinkedList<Integer> finalStates = new LinkedList<Integer>();
transitions.add(new SFAInputMove<CharPred, Character>(0, 1, new CharPred('s')));
transitions.add(new SFAInputMove<CharPred, Character>(1, 2, new CharPred(':')));
for (Integer firstDigit = 0; firstDigit < 10; firstDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(2, (firstDigit * 46287) + 3, new CharPred(firstDigit.toString().charAt(0))));
for (Integer secondDigit = 0; secondDigit < 10; secondDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287), 3 + (firstDigit * 46287) + (secondDigit * 4477) + 1, new CharPred(secondDigit.toString().charAt(0))));
for (Integer thirdDigit = 0; thirdDigit < 10; thirdDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + 1, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + 2, new CharPred(thirdDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + 2, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + 3, dot));
for (Integer fourthDigit = 0; fourthDigit < 10; fourthDigit++) {
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + 3, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 4, new CharPred(fourthDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 4, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 5, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 5, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 6, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 6, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 7, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 7, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 8, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 8, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 9, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 9, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 10, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 10, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 11, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 11, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 12, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 12, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 13, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 13, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 14, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 14, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 15, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 15, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 15, ba.MkOr(new CharPred(':'), alphaNum)));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 15, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 16, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 16, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 17, new CharPred('d')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 17, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 18, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 18, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 19, new CharPred(firstDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 19, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 20, new CharPred(secondDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 20, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 21, new CharPred(thirdDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 21, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 22, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 22, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 23, new CharPred(fourthDigit.toString().charAt(0))));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 23, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 24, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 24, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 25, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 25, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 26, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 26, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 27, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 27, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 28, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 28, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 29, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 29, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 30, dot));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 30, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 31, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 31, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 32, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 32, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 33, num));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 33, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 34, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 34, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 34, ba.MkOr(new CharPred(':'), alphaNum)));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 34, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 35, space));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 35, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 36, new CharPred('p')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 36, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 37, new CharPred(':')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 37, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 38, new CharPred('\'')));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 38, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 39, alphaNum));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 39, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 39, alphaNum));
transitions.add(new SFAInputMove<CharPred, Character>(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 39, 3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 40, new CharPred('\'')));
finalStates.add(3 + (firstDigit * 46287) + (secondDigit * 4477) + (thirdDigit * 444) + (fourthDigit * 37) + 40);
}
}
}
}
try {
return SFA.MkSFA(transitions, 0,finalStates, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP6PacketParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "srcip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("srcip:".charAt(index)), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, num, 6));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 21, index + 22, new CharPred(" prt:".charAt(index)), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, num, 6));
for (int index = 0; index < " dstip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 27, index + 28, new CharPred(" dstip:".charAt(index)), 6));
transitions.add(new SRACheckMove<CharPred, Character>(34, 35, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(35, 36, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(36, 37, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, dot, 6));
transitions.add(new SRACheckMove<CharPred, Character>(38, 39, num, 3));
transitions.add(new SRACheckMove<CharPred, Character>(39, 40, num, 4));
transitions.add(new SRACheckMove<CharPred, Character>(40, 41, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(43, 44, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(44, 45, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(45, 46, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(46, 47, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(47, 48, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(48, 49, num, 6));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 49, index + 50, new CharPred(" prt:".charAt(index)), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(54, 55, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(55, 55, num, 6));
for (int index = 0; index < " pload:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 55, index + 56, new CharPred(" pload:".charAt(index)), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(62, 63, new CharPred('\''), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(63, 64, alphaNum, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 64, alphaNum, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 65, new CharPred('\''), 6));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(65), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP6PacketParserSimplifiedSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "s:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("s:".charAt(index)), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 18, ba.MkOr(new CharPred(':'), alphaNum), 6));
for (int index = 0; index < " d:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 18, index + 19, new CharPred(" d:".charAt(index)), 6));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, dot, 6));
transitions.add(new SRACheckMove<CharPred, Character>(25, 26, num, 3));
transitions.add(new SRACheckMove<CharPred, Character>(26, 27, num, 4));
transitions.add(new SRACheckMove<CharPred, Character>(27, 28, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(29, 30, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(30, 31, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(31, 32, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, dot, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, space, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 37, ba.MkOr(new CharPred(':'), alphaNum), 6));
for (int index = 0; index < " p:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 37, index + 38, new CharPred(" p:".charAt(index)), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, new CharPred('\''), 6));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, alphaNum, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 42, alphaNum, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, new CharPred('\''), 6));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(43), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP9PacketParserSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "srcip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("srcip:".charAt(index)), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 7));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 8));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 19, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(19, 20, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(20, 21, num, 9));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 21, index + 22, new CharPred(" prt:".charAt(index)), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(26, 27, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(27, 27, num, 9));
for (int index = 0; index < " dstip:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 27, index + 28, new CharPred(" dstip:".charAt(index)), 9));
transitions.add(new SRACheckMove<CharPred, Character>(34, 35, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(35, 36, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(36, 37, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 38, dot, 9));
transitions.add(new SRACheckMove<CharPred, Character>(38, 39, num, 3));
transitions.add(new SRACheckMove<CharPred, Character>(39, 40, num, 4));
transitions.add(new SRACheckMove<CharPred, Character>(40, 41, num, 5));
transitions.add(new SRACheckMove<CharPred, Character>(41, 42, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, dot, 9));
transitions.add(new SRACheckMove<CharPred, Character>(42, 43, num, 6));
transitions.add(new SRACheckMove<CharPred, Character>(43, 44, num, 7));
transitions.add(new SRACheckMove<CharPred, Character>(44, 45, num, 8));
transitions.add(new SRAStoreMove<CharPred, Character>(45, 46, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(46, 47, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(47, 48, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(48, 49, num, 9));
for (int index = 0; index < " prt:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 49, index + 50, new CharPred(" prt:".charAt(index)), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(54, 55, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(55, 55, num, 9));
for (int index = 0; index < " pload:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 55, index + 56, new CharPred(" pload:".charAt(index)), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(62, 63, new CharPred('\''), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(63, 64, alphaNum, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 64, alphaNum, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(64, 65, new CharPred('\''), 9));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(65), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private SRA<CharPred, Character> getIP9PacketParserSimplifiedSRA(UnaryCharIntervalSolver ba) {
LinkedList<Character> registers = new LinkedList<Character>(Arrays.asList(null, null, null, null, null, null, null, null, null, null));
Collection<SRAMove<CharPred, Character>> transitions = new LinkedList<SRAMove<CharPred, Character>>();
for (int index = 0; index < "s:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index, index + 1, new CharPred("s:".charAt(index)), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(2, 3, num, 0));
transitions.add(new SRAStoreMove<CharPred, Character>(3, 4, num, 1));
transitions.add(new SRAStoreMove<CharPred, Character>(4, 5, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(5, 6, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(6, 7, num, 3));
transitions.add(new SRAStoreMove<CharPred, Character>(7, 8, num, 4));
transitions.add(new SRAStoreMove<CharPred, Character>(8, 9, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(9, 10, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(10, 11, num, 6));
transitions.add(new SRAStoreMove<CharPred, Character>(11, 12, num, 7));
transitions.add(new SRAStoreMove<CharPred, Character>(12, 13, num, 8));
transitions.add(new SRAStoreMove<CharPred, Character>(13, 14, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(14, 15, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(15, 16, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(16, 17, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(17, 18, space, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(18, 18, ba.MkOr(new CharPred(':'), alphaNum), 9));
for (int index = 0; index < " d:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 18, index + 19, new CharPred(" d:".charAt(index)), 9));
transitions.add(new SRACheckMove<CharPred, Character>(21, 22, num, 0));
transitions.add(new SRACheckMove<CharPred, Character>(22, 23, num, 1));
transitions.add(new SRACheckMove<CharPred, Character>(23, 24, num, 2));
transitions.add(new SRAStoreMove<CharPred, Character>(24, 25, dot, 9));
transitions.add(new SRACheckMove<CharPred, Character>(25, 26, num, 3));
transitions.add(new SRACheckMove<CharPred, Character>(26, 27, num, 4));
transitions.add(new SRACheckMove<CharPred, Character>(27, 28, num, 5));
transitions.add(new SRAStoreMove<CharPred, Character>(28, 29, dot, 9));
transitions.add(new SRACheckMove<CharPred, Character>(29, 30, num, 6));
transitions.add(new SRACheckMove<CharPred, Character>(30, 31, num, 7));
transitions.add(new SRACheckMove<CharPred, Character>(31, 32, num, 8));
transitions.add(new SRAStoreMove<CharPred, Character>(32, 33, dot, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(33, 34, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(34, 35, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(35, 36, num, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(36, 37, space, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(37, 37, ba.MkOr(new CharPred(':'), alphaNum), 9));
for (int index = 0; index < " p:".length(); index++)
transitions.add(new SRAStoreMove<CharPred, Character>(index + 37, index + 38, new CharPred(" p:".charAt(index)), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(40, 41, new CharPred('\''), 9));
transitions.add(new SRAStoreMove<CharPred, Character>(41, 42, alphaNum, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 42, alphaNum, 9));
transitions.add(new SRAStoreMove<CharPred, Character>(42, 43, new CharPred('\''), 9));
try {
return SRA.MkSRA(transitions, 0, Collections.singleton(43), registers, ba);
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
// Auxiliary methods
private List<Character> lOfS(String s) {
List<Character> l = new ArrayList<Character>();
char[] ca = s.toCharArray();
for (int i = 0; i < s.length(); i++)
l.add(ca[i]);
return l;
}
}
|
package Inventaris;
public class RekapRuang extends Sistem{
public RekapRuang(){
super();
}
@Override
String Review() {
// TODO Auto-generated method stub
Ruangan();
HitungLuasRuang();
HitungRasioRuangan();
AnalisisPdanJ();
AnalisisListrik();
AnalisisProyektor();
AnalisisLampu();
AnalisisKipasAngin();
AnalisisAC();
AnalisisInternet();
AnalisisCCTV();
AnalisisKondisiLantai();
AnalisisKondisiDinding();
AnalisisKondisiAtap();
AnalisisKondisiPintu();
AnalisisKondisiJendela();
AnalisisSirUdara();
AnalisisPencahayaan();
AnalisisKelmabapan();
AnalisisSuhu();
AnalisisKebisingan();
AnalisisBau();
AnalisisKebocoran();
AnalisisKerusakan();
AnalisisKeausan();
AnalisisKekokohan();
AnalisisKunciPintu();
AnalisisKunciJendela();
AnalisisKeamananRuang();
return Review();
}
@Override
String Ruangan() {
// TODO Auto-generated method stub
return Ruangan();
}
@Override
double HitungLuasRuang() {
// TODO Auto-generated method stub
return HitungLuasRuang();
}
@Override
double BentukRuang() {
// TODO Auto-generated method stub
return BentukRuang();
}
@Override
double HitungRasioRuangan() {
// TODO Auto-generated method stub
return HitungRasioRuangan();
}
@Override
String AnalisisPdanJ() {
// TODO Auto-generated method stub
return AnalisisPdanJ();
}
@Override
String AnalisisListrik() {
// TODO Auto-generated method stub
return AnalisisListrik();
}
@Override
String AnalisisProyektor() {
// TODO Auto-generated method stub
return AnalisisProyektor();
}
@Override
String AnalisisLampu() {
// TODO Auto-generated method stub
return AnalisisLampu();
}
@Override
String AnalisisKipasAngin() {
// TODO Auto-generated method stub
return AnalisisKipasAngin();
}
@Override
String AnalisisAC() {
// TODO Auto-generated method stub
return AnalisisAC();
}
@Override
String AnalisisInternet() {
// TODO Auto-generated method stub
return AnalisisInternet();
}
@Override
String AnalisisCCTV() {
// TODO Auto-generated method stub
return AnalisisCCTV();
}
@Override
String AnalisisKondisiLantai() {
// TODO Auto-generated method stub
return AnalisisKondisiLantai();
}
@Override
String AnalisisKondisiDinding() {
// TODO Auto-generated method stub
return AnalisisKondisiDinding();
}
@Override
String AnalisisKondisiAtap() {
// TODO Auto-generated method stub
return AnalisisKondisiAtap();
}
@Override
String AnalisisKondisiPintu() {
// TODO Auto-generated method stub
return AnalisisKondisiPintu();
}
@Override
String AnalisisKondisiJendela() {
// TODO Auto-generated method stub
return AnalisisKondisiJendela();
}
@Override
String AnalisisSirUdara() {
// TODO Auto-generated method stub
return AnalisisSirUdara();
}
@Override
String AnalisisPencahayaan() {
// TODO Auto-generated method stub
return AnalisisPencahayaan();
}
@Override
String AnalisisKelmabapan() {
// TODO Auto-generated method stub
return AnalisisKelmabapan();
}
@Override
String AnalisisSuhu() {
// TODO Auto-generated method stub
return AnalisisSuhu();
}
@Override
String AnalisisKebisingan() {
// TODO Auto-generated method stub
return AnalisisKebisingan();
}
@Override
String AnalisisBau() {
// TODO Auto-generated method stub
return AnalisisBau();
}
@Override
String AnalisisKebocoran() {
// TODO Auto-generated method stub
return AnalisisKebocoran();
}
@Override
String AnalisisKerusakan() {
// TODO Auto-generated method stub
return AnalisisKerusakan();
}
@Override
String AnalisisKeausan() {
// TODO Auto-generated method stub
return AnalisisKeausan();
}
@Override
String AnalisisKekokohan() {
// TODO Auto-generated method stub
return AnalisisKekokohan();
}
@Override
String AnalisisKunciPintu() {
// TODO Auto-generated method stub
return AnalisisKunciPintu();
}
@Override
String AnalisisKunciJendela() {
// TODO Auto-generated method stub
return AnalisisKunciJendela();
}
@Override
String AnalisisKeamananRuang() {
// TODO Auto-generated method stub
return AnalisisKeamananRuang();
}
}
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Game;
import Utilities.ImageCollection;
import Utilities.InputAdvance;
import Utilities.KeyBoard;
import Utilities.Mouse;
import Utilities.SoundBatch;
import Utilities.ViewScreen;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.sound.sampled.*;
import javax.swing.*;
/**
* This is the base class for all subsequent games. It will update and draw everything.
* It also has methods built in for playing sound clips and music.
* This class also automatically converts all key, Mouse, Mouse Motion, and Mouse Wheel events into state driven.
* All subsequent games should be extensions of this.
* @author Kyle Maximilian Dieter Sweeney
*/
public abstract class Game extends JPanel implements ActionListener, Runnable{
// <editor-fold defaultstate="collapsed" desc="Necessary Instance Variables">
private double startimeNano=System.nanoTime();
/**
* The View Screen, that is, the visible area of the game world
*/
protected ViewScreen viewScreen=new ViewScreen();
/**
* The collection into which Images are placed, and from where they are drawn
*/
protected ImageCollection batch = new ImageCollection(viewScreen,this);
private Timer timer;
private Timer updateTimer;
/**
* The game speed, or how many milliseconds waited between updates
*/
protected int gameSpeed=16;
protected boolean backgroundMusicFinished = false;
/**
* Represents the current state of the Keyboard
*/
protected KeyBoard keyboard;
/**
* Represents the current state of the Mouse
*/
protected Mouse mouse;
/**
* A sound handler for the game
*/
protected SoundBatch soundbatch=new SoundBatch();;
/**
* The window of the game itself. Only access in update or drawing methods
*/
public GameBase base=null;
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Constructor Method">
/**
* Constructs the game
*/
public Game() {
InitializeAndLoad();
UnloadContent();
keyboard=new KeyBoard();
mouse=Mouse.getCurrentInstance();
InputAdvance input=new Inputs();
addMouseListener(input);
addMouseMotionListener(input);
addMouseWheelListener(input);
addKeyListener(input);
timer = new Timer(gameSpeed, this);
updateTimer=new Timer(gameSpeed, new updateClass());
// imageTimer= new Timer(gameSpeed, new ActionListener(){
// @Override
// public void actionPerformed(ActionEvent e) {
// synchronized(new Object()){
// repaint();
// imageTimer.start();
timer.start();
updateTimer.start();
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Constructor Methods -to be implemented in child class">
/**
* Where items can be Initialized during the construction of the game
*/
public abstract void InitializeAndLoad();
/**
* Where content once needed by the constructor for making the game, but no longer needed, can be deleted.
*
* Also could be used to simply unload any other content not needed.
*/
public abstract void UnloadContent();
//</editor-fold>
// <editor-fold defaultstate="collapsed" desc="Update and Draw Methods">
/**
* Where all objects needing to be updated can be update at the rate of the game speed.
*
* Default game speed is 60 Hz or 60 times per second
*/
public abstract void Update();
/**
* Where all images are loaded into the batch
* @param g the graphics from the Game
*/
public abstract void Draw(Graphics g);
/**
* Adds another handy thread from which items can run
*/
@Override
public abstract void run();
// </editor-fold>
/**
* Returns the ImageColection used by the game
* @return the Image Collection used by the game
*/
public ImageCollection getImageCollection() {
return batch;
}
/**
* Runs the LoadContent(), Initialize() and UnloadContent() again.
*/
protected void reset(){
InitializeAndLoad();
UnloadContent();
}
/**
* Returns the amount of time elapsed since the start of the game. Result is in nanoseconds
* @return the amount of time, in nanoSeconds, since the start of the game
*/
protected double ElapsedGameSystemTimeNano(){
double currentTime=System.nanoTime();
return currentTime-startimeNano;
}
// <editor-fold defaultstate="collapsed" desc="InputClass">
/**
* the class which handles all input events
*/
protected class Inputs extends InputAdvance{
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
keyboard.setPressed(e);
}
@Override
public void keyReleased(KeyEvent e) {
keyboard.setRelease(e);
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
mouse.setButton(e);
}
@Override
public void mouseReleased(MouseEvent e) {
mouse.setRelease(e);
}
@Override
public void mouseEntered(MouseEvent e) {
mouse.mouseMoved(e);
}
@Override
public void mouseExited(MouseEvent e) {
mouse.mouseMoved(e);
}
@Override
public void mouseDragged(MouseEvent e) {
mouse.mouseMoved(e);
}
@Override
public void mouseMoved(MouseEvent e) {
mouse.mouseMoved(e);
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
mouse.mouseScroll(e);
}
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Untouchable Uethods">
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
BufferedImage buffer=new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D gr=buffer.createGraphics();
Draw(gr);
Drawer(gr);
g.drawImage(buffer, 0, 0, this);
g.dispose();
}
public void actionPerformed(ActionEvent e) {
try {
//Update();
RepaintCaller();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void RepaintCaller() {
soundbatch.Update();
repaint();
}
private void Drawer(Graphics g) {
batch.Render(g, base.theGUI);
}
// </editor-fold>
private class updateClass implements ActionListener{
public void actionPerformed(ActionEvent ae) {
try {
synchronized (this) {
Update();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
|
package net.time4j;
import net.time4j.base.MathUtils;
import net.time4j.base.ResourceLoader;
import net.time4j.base.TimeSource;
import net.time4j.base.UnixTime;
import net.time4j.engine.TimeSpan;
import net.time4j.format.NumberSymbolProvider;
import net.time4j.format.NumberSystem;
import net.time4j.format.NumberType;
import net.time4j.format.PluralCategory;
import net.time4j.format.PluralRules;
import net.time4j.format.TemporalFormatter;
import net.time4j.format.TextWidth;
import net.time4j.format.internal.SymbolProviderSPI;
import net.time4j.tz.TZID;
import net.time4j.tz.Timezone;
import net.time4j.tz.ZonalOffset;
import java.text.MessageFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAmount;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import static net.time4j.CalendarUnit.*;
import static net.time4j.ClockUnit.*;
/**
* <p>Enables formatted output as usually used in social media in different
* languages. </p>
*
* <p>Parsing is not included because there is no general solution for all
* locales. Instead users must keep the backing duration object and use it
* for printing. </p>
*
* @author Meno Hochschild
* @since 1.2
* @doctags.concurrency {immutable}
*/
/*[deutsch]
* <p>Ermöglicht formatierte Ausgaben einer Dauer für soziale Medien
* ("social media style") in verschiedenen Sprachen. </p>
*
* <p>Der Rückweg der Interpretation (<i>parsing</i>) ist nicht enthalten,
* weil so nicht alle Sprachen unterstützt werden können. Stattdessen
* werden Anwender angehalten, das korrespondierende Dauer-Objekt im Hintergrund
* zu halten und es für die formatierte Ausgabe zu nutzen. </p>
*
* @author Meno Hochschild
* @since 1.2
* @doctags.concurrency {immutable}
*/
public final class PrettyTime {
private static final NumberSymbolProvider NUMBER_SYMBOLS;
static {
NumberSymbolProvider p = null;
int count = 0;
for (NumberSymbolProvider tmp : ResourceLoader.getInstance().services(NumberSymbolProvider.class)) {
int size = tmp.getAvailableLocales().length;
if (size >= count) {
p = tmp;
count = size;
}
}
if (p == null) {
p = SymbolProviderSPI.INSTANCE;
}
NUMBER_SYMBOLS = p;
}
private static final int MIO = 1000000;
private static final ConcurrentMap<Locale, PrettyTime> LANGUAGE_MAP = new ConcurrentHashMap<>();
private static final IsoUnit[] STD_UNITS;
private static final IsoUnit[] TSP_UNITS;
private static final Set<IsoUnit> SUPPORTED_UNITS;
private static final long START_1972;
static {
IsoUnit[] stdUnits = {YEARS, MONTHS, WEEKS, DAYS, HOURS, MINUTES, SECONDS};
STD_UNITS = stdUnits;
TSP_UNITS = new IsoUnit[]{YEARS, MONTHS, DAYS, HOURS, MINUTES, SECONDS};
Set<IsoUnit> tmp = new HashSet<>();
Collections.addAll(tmp, stdUnits);
tmp.add(NANOS);
SUPPORTED_UNITS = Collections.unmodifiableSet(tmp);
START_1972 = 2 * 365 * 86400L;
}
private final PluralRules rules;
private final Locale locale;
private final TimeSource<?> refClock;
private final char zeroDigit;
private final String minusSign;
private final IsoUnit emptyUnit;
private final boolean weekToDays;
private final boolean shortStyle;
private final String stdListSeparator;
private final String endListSeparator;
private PrettyTime(
Locale loc,
TimeSource<?> refClock,
char zeroDigit,
String minusSign,
IsoUnit emptyUnit,
boolean weekToDays,
boolean shortStyle,
String stdListSeparator,
String endListSeparator
) {
super();
if (emptyUnit == null) {
throw new NullPointerException("Missing zero time unit.");
} else if (refClock == null) {
throw new NullPointerException("Missing reference clock.");
}
// throws NPE if language == null
this.rules = PluralRules.of(loc, NumberType.CARDINALS);
this.locale = loc;
this.refClock = refClock;
this.zeroDigit = zeroDigit;
this.emptyUnit = emptyUnit;
this.minusSign = minusSign;
this.weekToDays = weekToDays;
this.shortStyle = shortStyle;
this.stdListSeparator = stdListSeparator;
this.endListSeparator = endListSeparator;
}
/**
* <p>Gets an instance of {@code PrettyTime} for given language,
* possibly cached. </p>
*
* @param locale the language an instance is searched for
* @return pretty time object for formatting durations or relative time
* @since 1.2
*/
/*[deutsch]
* <p>Liefert eine Instanz von {@code PrettyTime} für die angegebene
* Sprache, eventuell aus dem Cache. </p>
*
* @param locale the language an instance is searched for
* @return pretty time object for formatting durations or relative time
* @since 1.2
*/
public static PrettyTime of(Locale locale) {
PrettyTime ptime = LANGUAGE_MAP.get(locale);
if (ptime == null) {
ptime =
new PrettyTime(
locale,
SystemClock.INSTANCE,
NUMBER_SYMBOLS.getZeroDigit(locale),
NUMBER_SYMBOLS.getMinusSign(locale),
SECONDS,
false,
false,
null,
null);
PrettyTime old = LANGUAGE_MAP.putIfAbsent(locale, ptime);
if (old != null) {
ptime = old;
}
}
return ptime;
}
/**
* <p>Gets the language of this instance. </p>
*
* @return language
* @since 1.2
*/
/*[deutsch]
* <p>Liefert die Bezugssprache. </p>
*
* @return Spracheinstellung
* @since 1.2
*/
public Locale getLocale() {
return this.locale;
}
/**
* <p>Yields the reference clock for formatting of relative times. </p>
*
* @return reference clock or system clock if not yet specified
* @since 1.2
* @see #withReferenceClock(TimeSource)
* @see #printRelative(UnixTime, TZID)
* @see #printRelative(UnixTime, String)
*/
/*[deutsch]
* <p>Liefert die Bezugsuhr für formatierte Ausgaben der relativen
* Zeit. </p>
*
* @return Zeitquelle oder die Systemuhr, wenn noch nicht angegeben
* @since 1.2
* @see #withReferenceClock(TimeSource)
* @see #printRelative(UnixTime, TZID)
* @see #printRelative(UnixTime, String)
*/
public TimeSource<?> getReferenceClock() {
return this.refClock;
}
/**
* <p>Yields a changed copy of this instance with given reference
* clock. </p>
*
* @param clock new reference clock
* @return new instance of {@code PrettyTime} with changed reference clock
* @since 1.2
* @see #getReferenceClock()
* @see #printRelative(UnixTime, TZID)
* @see #printRelative(UnixTime, String)
*/
/*[deutsch]
* <p>Legt die Bezugszeit für relative Zeitangaben neu fest. </p>
*
* @param clock new reference clock
* @return new instance of {@code PrettyTime} with changed reference clock
* @since 1.2
* @see #getReferenceClock()
* @see #printRelative(UnixTime, TZID)
* @see #printRelative(UnixTime, String)
*/
public PrettyTime withReferenceClock(TimeSource<?> clock) {
return new PrettyTime(
this.locale,
clock,
this.zeroDigit,
this.minusSign,
this.emptyUnit,
this.weekToDays,
this.shortStyle,
this.stdListSeparator,
this.endListSeparator);
}
public PrettyTime withZeroDigit(NumberSystem numberSystem) {
if (numberSystem.isDecimal()) {
return this.withZeroDigit(numberSystem.getDigits().charAt(0));
} else {
throw new IllegalArgumentException("Number system is not decimal: " + numberSystem);
}
}
/**
* <p>Defines the localized zero digit. </p>
*
* <p>In most languages the zero digit is just ASCII-"0",
* but for example in arabic locales the digit can also be the char
* {@code U+0660}. By default Time4J will try to use the configuration
* of the module i18n or else the JDK-setting. This method can override
* it however. </p>
*
* @param zeroDigit localized zero digit
* @return changed copy of this instance
* @since 1.2
* @see java.text.DecimalFormatSymbols#getZeroDigit()
* @see net.time4j.format.NumberSymbolProvider#getZeroDigit(Locale)
*/
/*[deutsch]
* <p>Definiert die lokalisierte Nullziffer. </p>
*
* <p>In den meisten Sprachen ist die Nullziffer ASCII-"0",
* aber etwa im arabischen Sprachraum kann das Zeichen auch {@code U+0660}
* sein. Per Vorgabe wird Time4J versuchen, die Konfiguration des
* i18n-Moduls oder sonst die JDK-Einstellung zu verwenden. Diese
* Methode überschreibt jedoch den Standard. </p>
*
* @param zeroDigit localized zero digit
* @return changed copy of this instance
* @since 1.2
* @see java.text.DecimalFormatSymbols#getZeroDigit()
* @see net.time4j.format.NumberSymbolProvider#getZeroDigit(Locale)
*/
public PrettyTime withZeroDigit(char zeroDigit) {
if (this.zeroDigit == zeroDigit) {
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
zeroDigit,
this.minusSign,
this.emptyUnit,
this.weekToDays,
this.shortStyle,
this.stdListSeparator,
this.endListSeparator);
}
/**
* <p>Defines the localized minus sign. </p>
*
* <p>In most languages the minus sign is just {@code U+002D}. By default
* Time4J will try to use the configuration of the module i18n or else the
* JDK-setting. This method can override it however. Especially for arabic,
* it might make sense to first add a unicode marker (either LRM
* {@code U+200E} or RLM {@code U+200F}) in front of the minus sign
* in order to control the orientation in right-to-left-style. </p>
*
* @param minusSign localized minus sign (possibly with unicode markers)
* @return changed copy of this instance
* @since 2.1
* @see java.text.DecimalFormatSymbols#getMinusSign()
* @see net.time4j.format.NumberSymbolProvider#getMinusSign(Locale)
*/
/*[deutsch]
* <p>Definiert das lokalisierte Minuszeichen. </p>
*
* <p>In den meisten Sprachen ist es einfach das Zeichen {@code U+002D}.
* Per Vorgabe wird Time4J versuchen, die Konfiguration des
* i18n-Moduls oder sonst die JDK-Einstellung zu verwenden. Diese
* Methode überschreibt jedoch den Standard. Besonders für
* Arabisch kann es sinnvoll sein, vor dem eigentlichen Minuszeichen
* einen Unicode-Marker (entweder LRM {@code U+200E} oder RLM
* {@code U+200F}) einzufügen, um die Orientierung des Minuszeichens
* in der traditionellen Rechts-nach-links-Schreibweise zu
* kontrollieren. </p>
*
* @param minusSign localized minus sign (possibly with unicode markers)
* @return changed copy of this instance
* @since 2.1
* @see java.text.DecimalFormatSymbols#getMinusSign()
* @see net.time4j.format.NumberSymbolProvider#getMinusSign(Locale)
*/
public PrettyTime withMinusSign(String minusSign) {
if (minusSign.equals(this.minusSign)) { // NPE-check
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
minusSign,
this.emptyUnit,
this.weekToDays,
this.shortStyle,
this.stdListSeparator,
this.endListSeparator);
}
/**
* <p>Defines the time unit used for formatting an empty duration. </p>
*
* <p>Time4J uses seconds as default. This method can override the
* default however. </p>
*
* @param emptyUnit time unit for usage in an empty duration
* @return changed copy of this instance
* @since 1.2
* @see #print(Duration, TextWidth)
*/
/*[deutsch]
* <p>Definiert die Zeiteinheit für die Verwendung in der
* Formatierung einer leeren Dauer. </p>
*
* <p>Vorgabe ist die Sekundeneinheit. Diese Methode kann die Vorgabe
* jedoch überschreiben. </p>
*
* @param emptyUnit time unit for usage in an empty duration
* @return changed copy of this instance
* @since 1.2
* @see #print(Duration, TextWidth)
*/
public PrettyTime withEmptyUnit(CalendarUnit emptyUnit) {
if (this.emptyUnit.equals(emptyUnit)) {
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
this.minusSign,
emptyUnit,
this.weekToDays,
this.shortStyle,
this.stdListSeparator,
this.endListSeparator);
}
/**
* <p>Defines the time unit used for formatting an empty duration. </p>
*
* <p>Time4J uses seconds as default. This method can override the
* default however. </p>
*
* @param emptyUnit time unit for usage in an empty duration
* @return changed copy of this instance
* @since 1.2
* @see #print(Duration, TextWidth)
*/
/*[deutsch]
* <p>Definiert die Zeiteinheit für die Verwendung in der
* Formatierung einer leeren Dauer. </p>
*
* <p>Vorgabe ist die Sekundeneinheit. Diese Methode kann die Vorgabe
* jedoch überschreiben. </p>
*
* @param emptyUnit time unit for usage in an empty duration
* @return changed copy of this instance
* @since 1.2
* @see #print(Duration, TextWidth)
*/
public PrettyTime withEmptyUnit(ClockUnit emptyUnit) {
if (this.emptyUnit.equals(emptyUnit)) {
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
this.minusSign,
emptyUnit,
this.weekToDays,
this.shortStyle,
this.stdListSeparator,
this.endListSeparator);
}
/**
* <p>Determines that weeks will always be normalized to days. </p>
*
* @return changed copy of this instance
* @since 2.0
*/
/*[deutsch]
* <p>Legt fest, daß Wochen immer zu Tagen normalisiert werden. </p>
*
* @return changed copy of this instance
* @since 2.0
*/
public PrettyTime withWeeksToDays() {
if (this.weekToDays) {
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
this.minusSign,
this.emptyUnit,
true,
this.shortStyle,
this.stdListSeparator,
this.endListSeparator);
}
/**
* <p>Mandates the use of abbreviations as default style. </p>
*
* <p>All {@code print()}-methods with explicit {@code TextWidth}-parameters will ignore this
* setting however. This method is mainly relevant for printing relative times. </p>
*
* @return changed copy of this instance
* @since 3.6/4.4
*/
/*[deutsch]
* <p>Legt die Verwendung von Abkürzungen als Vorgabestil fest. </p>
*
* <p>Alle {@code print()}-Methoden mit einem expliziten {@code TextWidth}-Parameter ignorieren diese
* Einstellung. Diese Methode ist hauptsächlich für die Formatierung von relativen Zeitangaben
* von Bedeutung. </p>
*
* @return changed copy of this instance
* @since 3.6/4.4
*/
public PrettyTime withShortStyle() {
if (this.shortStyle) {
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
this.minusSign,
this.emptyUnit,
this.weekToDays,
true,
this.stdListSeparator,
this.endListSeparator);
}
/**
* <p>Mandates the use of given default list separator. </p>
*
* <p>Usually the locale specifies any list patterns for printing durations. However, this
* method allows customized list separators. Example: </p>
*
* <pre>
* assertThat(
* PrettyTime.of(Locale.US)
* .withDefaultListSeparator(" | ")
* .withLastListSeparator(" + ")
* .print(Duration.ofCalendarUnits(1, 2, 3), TextWidth.WIDE),
* is("1 year | 2 months + 3 days"));
* </pre>
*
* @param separator the separator characters between any duration items
* @return changed copy of this instance
* @see #withLastListSeparator(String)
* @since 5.2
*/
/*[deutsch]
* <p>Legt einen neuen Standard für die Listentrennzeichen fest. </p>
*
* <p>Normalerweise legt die angewandte {@code Locale} die verwendeten Listentrennzeichen fest.
* Diese Methode erlaubt benutzerdefinierte Listentrennzeichen. Beispiel: </p>
*
* <pre>
* assertThat(
* PrettyTime.of(Locale.US)
* .withDefaultListSeparator(" | ")
* .withLastListSeparator(" + ")
* .print(Duration.ofCalendarUnits(1, 2, 3), TextWidth.WIDE),
* is("1 year | 2 months + 3 days"));
* </pre>
*
* @param separator the separator characters between any duration items
* @return changed copy of this instance
* @see #withLastListSeparator(String)
* @since 5.2
*/
public PrettyTime withDefaultListSeparator(String separator) {
if (separator.equals(this.stdListSeparator)) { // includes NPE-check
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
this.minusSign,
this.emptyUnit,
this.weekToDays,
this.shortStyle,
separator,
this.endListSeparator);
}
/**
* <p>Mandates the use of given list separator at the last position. </p>
*
* <p><strong>Important:</strong> A default list separator must be specified
* otherwise this method will have no effect. </p>
*
* @param separator the separator characters between the last two duration items
* @return changed copy of this instance
* @see #withDefaultListSeparator(String)
* @since 5.2
*/
/*[deutsch]
* <p>Legt die Listentrennzeichen an der letzten Position fest. </p>
*
* <p><strong>Wichtig:</strong> Die Standardlistentrennzeichen müssen angegeben
* werden, damit diese Methode Wirkung zeigt. </p>
*
* @param separator the separator characters between the last two duration items
* @return changed copy of this instance
* @see #withDefaultListSeparator(String)
* @since 5.2
*/
public PrettyTime withLastListSeparator(String separator) {
if (separator.equals(this.endListSeparator)) { // includes NPE-check
return this;
}
return new PrettyTime(
this.locale,
this.refClock,
this.zeroDigit,
this.minusSign,
this.emptyUnit,
this.weekToDays,
this.shortStyle,
this.stdListSeparator,
separator);
}
/**
* <p>Determines the localized word for "yesterday". </p>
*
* @return String
* @since 3.43/4.38
*/
/*[deutsch]
* <p>Ermittelt das lokalisierte Wort für "gestern". </p>
*
* @return String
* @since 3.43/4.38
*/
public String printYesterday() {
return UnitPatterns.of(this.getLocale()).getYesterdayWord();
}
/**
* <p>Determines the localized word for "today". </p>
*
* @return String
* @since 3.24/4.20
*/
/*[deutsch]
* <p>Ermittelt das lokalisierte Wort für "heute". </p>
*
* @return String
* @since 3.24/4.20
*/
public String printToday() {
return UnitPatterns.of(this.getLocale()).getTodayWord();
}
/**
* <p>Determines the localized word for "tomorrow". </p>
*
* @return String
* @since 3.43/4.38
*/
/*[deutsch]
* <p>Ermittelt das lokalisierte Wort für "morgen". </p>
*
* @return String
* @since 3.43/4.38
*/
public String printTomorrow() {
return UnitPatterns.of(this.getLocale()).getTomorrowWord();
}
/**
* <p>Obtains the localized word for given last day-of-week if available. </p>
*
* @param weekday the last day of week
* @return localized word, maybe empty
* @since 5.1
*/
/*[deutsch]
* <p>Liefert das lokalisierte Wort für den angegebenen letzten Wochentag, falls verfügbar. </p>
*
* @param weekday the last day of week
* @return localized word, maybe empty
* @since 5.1
*/
public String printLast(Weekday weekday) {
return UnitPatterns.of(this.getLocale()).labelForLast(weekday);
}
/**
* <p>Obtains the localized word for given next day-of-week if available. </p>
*
* @param weekday the next day of week
* @return localized word, maybe empty
* @since 5.1
*/
/*[deutsch]
* <p>Liefert das lokalisierte Wort für den angegebenen nächsten Wochentag, falls verfügbar. </p>
*
* @param weekday the next day of week
* @return localized word, maybe empty
* @since 5.1
*/
public String printNext(Weekday weekday) {
return UnitPatterns.of(this.getLocale()).labelForNext(weekday);
}
/**
* <p>Formats given duration in calendar units. </p>
*
* <p>Note: Millennia, centuries and decades are automatically normalized
* to years while quarter-years are normalized to months. </p>
*
* @param amount count of units (quantity)
* @param unit calendar unit
* @param width text width (ABBREVIATED as synonym for SHORT)
* @return formatted output
* @since 1.2
* @see #print(Duration, TextWidth)
*/
/*[deutsch]
* <p>Formatiert die angegebene Dauer in kalendarischen Zeiteinheiten. </p>
*
* <p>Hinweis: Jahrtausende, Jahrhunderte und Dekaden werden automatisch
* zu Jahren normalisiert, während Quartale zu Monaten normalisiert
* werden. </p>
*
* @param amount Anzahl der Einheiten
* @param unit kalendarische Zeiteinheit
* @param width text width (ABBREVIATED as synonym for SHORT)
* @return formatierte Ausgabe
* @since 1.2
* @see #print(Duration, TextWidth)
*/
public String print(
long amount,
CalendarUnit unit,
TextWidth width
) {
UnitPatterns p = UnitPatterns.of(this.locale);
CalendarUnit u;
switch (unit) {
case MILLENNIA:
amount = MathUtils.safeMultiply(amount, 1000);
u = CalendarUnit.YEARS;
break;
case CENTURIES:
amount = MathUtils.safeMultiply(amount, 100);
u = CalendarUnit.YEARS;
break;
case DECADES:
amount = MathUtils.safeMultiply(amount, 10);
u = CalendarUnit.YEARS;
break;
case YEARS:
u = CalendarUnit.YEARS;
break;
case QUARTERS:
amount = MathUtils.safeMultiply(amount, 3);
u = CalendarUnit.MONTHS;
break;
case MONTHS:
u = CalendarUnit.MONTHS;
break;
case WEEKS:
if (this.weekToDays) {
amount = MathUtils.safeMultiply(amount, 7);
u = CalendarUnit.DAYS;
} else {
u = CalendarUnit.WEEKS;
}
break;
case DAYS:
u = CalendarUnit.DAYS;
break;
default:
throw new UnsupportedOperationException(unit.name());
}
String pattern = p.getPattern(width, this.getCategory(amount), u);
return this.format(pattern, amount);
}
/**
* <p>Formats given duration in clock units. </p>
*
* @param amount count of units (quantity)
* @param unit clock unit
* @param width text width (ABBREVIATED as synonym for SHORT)
* @return formatted output
* @since 1.2
* @see #print(Duration, TextWidth)
*/
/*[deutsch]
* <p>Formatiert die angegebene Dauer in Uhrzeiteinheiten. </p>
*
* @param amount Anzahl der Einheiten
* @param unit Uhrzeiteinheit
* @param width text width (ABBREVIATED as synonym for SHORT)
* @return formatierte Ausgabe
* @since 1.2
* @see #print(Duration, TextWidth)
*/
public String print(
long amount,
ClockUnit unit,
TextWidth width
) {
String pattern = UnitPatterns.of(this.locale).getPattern(width, this.getCategory(amount), unit);
return this.format(pattern, amount);
}
/**
* <p>Formats the total given duration. </p>
*
* <p>A localized output is only supported for the units
* {@link CalendarUnit#YEARS}, {@link CalendarUnit#MONTHS},
* {@link CalendarUnit#WEEKS}, {@link CalendarUnit#DAYS} and
* all {@link ClockUnit}-units. This method performs an internal
* normalization if any other unit is involved. </p>
*
* <p>Note: This method uses full words by default. If
* {@link #withShortStyle()} is called then abbreviations will be used. </p>
*
* @param duration object representing a duration which might contain several units and quantities
* @return formatted list output
* @since 3.6/4.4
*/
/*[deutsch]
* <p>Formatiert die gesamte angegebene Dauer. </p>
*
* <p>Eine lokalisierte Ausgabe ist nur für die Zeiteinheiten
* {@link CalendarUnit#YEARS}, {@link CalendarUnit#MONTHS},
* {@link CalendarUnit#WEEKS}, {@link CalendarUnit#DAYS} und
* alle {@link ClockUnit}-Instanzen vorhanden. Bei Bedarf werden
* andere Einheiten zu diesen normalisiert. </p>
*
* <p>Hinweis: Diese Methode verwendet standardmäß volle
* Wörter. Falls {@link #withShortStyle()} aufgerufen wurde, werden
* Abkürzungen verwendet. </p>
*
* @param duration object representing a duration which might contain several units and quantities
* @return formatted list output
* @since 3.6/4.4
*/
public String print(Duration<?> duration) {
TextWidth width = (this.shortStyle ? TextWidth.ABBREVIATED : TextWidth.WIDE);
return this.print(duration, width, false, Integer.MAX_VALUE);
}
public String print(TemporalAmount threeten) {
return this.print(Duration.from(threeten));
}
/**
* <p>Formats the total given duration. </p>
*
* <p>A localized output is only supported for the units
* {@link CalendarUnit#YEARS}, {@link CalendarUnit#MONTHS},
* {@link CalendarUnit#WEEKS}, {@link CalendarUnit#DAYS} and
* all {@link ClockUnit}-units. This method performs an internal
* normalization if any other unit is involved. </p>
*
* @param duration object representing a duration which might contain
* several units and quantities
* @param width text width (ABBREVIATED as synonym for SHORT)
* @return formatted list output
* @since 1.2
*/
/*[deutsch]
* <p>Formatiert die gesamte angegebene Dauer. </p>
*
* <p>Eine lokalisierte Ausgabe ist nur für die Zeiteinheiten
* {@link CalendarUnit#YEARS}, {@link CalendarUnit#MONTHS},
* {@link CalendarUnit#WEEKS}, {@link CalendarUnit#DAYS} und
* alle {@link ClockUnit}-Instanzen vorhanden. Bei Bedarf werden
* andere Einheiten zu diesen normalisiert. </p>
*
* @param duration object representing a duration which might contain
* several units and quantities
* @param width text width (ABBREVIATED as synonym for SHORT)
* @return formatted list output
* @since 1.2
*/
public String print(
Duration<?> duration,
TextWidth width
) {
return this.print(duration, width, false, Integer.MAX_VALUE);
}
public String print(
TemporalAmount threeten,
TextWidth width
) {
return this.print(Duration.from(threeten), width);
}
public String print(
Duration<?> duration,
TextWidth width,
boolean printZero,
int maxLength
) {
if (maxLength < 1) {
throw new IllegalArgumentException(
"Max length is invalid: " + maxLength);
}
// special case of empty duration
if (duration.isEmpty()) {
if (this.emptyUnit.isCalendrical()) {
CalendarUnit unit = CalendarUnit.class.cast(this.emptyUnit);
return this.print(0, unit, width);
} else {
ClockUnit unit = ClockUnit.class.cast(this.emptyUnit);
return this.print(0, unit, width);
}
}
// fill values-array from duration
boolean negative = duration.isNegative();
long[] values = new long[8];
pushDuration(values, duration, this.refClock, this.weekToDays);
// format duration items
List<Object> parts = new ArrayList<>();
int count = 0;
for (int i = 0; i < values.length; i++) {
if (
(count < maxLength)
&& (!this.weekToDays || (i != 2))
&& ((printZero && (count > 0)) || (values[i] > 0))
) {
IsoUnit unit = ((i == 7) ? NANOS : STD_UNITS[i]);
parts.add(this.format(values[i], unit, negative, width));
count++;
}
}
// duration is not empty here
assert (count > 0);
// special case of only one item
if (count == 1) {
return parts.get(0).toString();
}
// multiple items (count >= 2)
String listPattern;
if (this.stdListSeparator != null) {
String endSep = this.endListSeparator;
if (endSep == null) {
endSep = this.stdListSeparator;
}
StringBuilder sb = new StringBuilder();
sb.append("{0}");
int max = count - 1;
for (int i = 1; i < max; i++) {
sb.append(this.stdListSeparator);
sb.append('{');
sb.append(i);
sb.append('}');
}
sb.append(endSep);
sb.append('{');
sb.append(max);
sb.append('}');
listPattern = sb.toString();
} else {
listPattern = UnitPatterns.of(this.locale).getListPattern(width, count);
}
return MessageFormat.format(
listPattern,
parts.toArray(new Object[count]));
}
public String print(
TemporalAmount threeten,
TextWidth width,
boolean printZero,
int maxLength
) {
return this.print(Duration.from(threeten), width, printZero, maxLength);
}
/**
* <p>Formats given time point relative to the current time of
* {@link #getReferenceClock()} as duration in at most second
* precision or less - using the system timezone. </p>
*
* @param moment relative time point
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 3.4/4.3
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal
* Sekundengenauigkeit - bezüglich der Systemzeitzone. </p>
*
* @param moment relative time point
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 3.4/4.3
*/
public String printRelativeInStdTimezone(UnixTime moment) {
return this.printRelative(moment, Timezone.ofSystem(), TimeUnit.SECONDS);
}
/**
* <p>Formats given time point relative to the current time of
* {@link #getReferenceClock()} as duration in at most second
* precision or less. </p>
*
* <p>Example how to query for a coming leap second: </p>
*
* <pre>
* TimeSource<?> clock = () -> PlainTimestamp.of(2015, 6, 30, 23, 59, 54).atUTC();
* String remainingDurationInRealSeconds =
* PrettyTime.of(Locale.ENGLISH).withReferenceClock(clock).printRelative(
* PlainTimestamp.of(2015, 7, 1, 0, 0, 0).atUTC(),
* ZonalOffset.UTC);
* System.out.println(remainingDurationInRealSeconds); // in 7 seconds
* </pre>
*
* @param moment relative time point
* @param tzid time zone id for translating to a local duration
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 1.2
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal
* Sekundengenauigkeit. </p>
*
* <p>Beispiel, das zeigt, wie eine bevorstehende Schaltsekunde abgefragt werden kann: </p>
*
* <pre>
* TimeSource<?> clock = () -> PlainTimestamp.of(2015, 6, 30, 23, 59, 54).atUTC();
* String remainingDurationInRealSeconds =
* PrettyTime.of(Locale.ENGLISH).withReferenceClock(clock).printRelative(
* PlainTimestamp.of(2015, 7, 1, 0, 0, 0).atUTC(),
* ZonalOffset.UTC);
* System.out.println(remainingDurationInRealSeconds); // in 7 seconds
* </pre>
*
* @param moment relative time point
* @param tzid time zone id for translating to a local duration
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 1.2
*/
public String printRelative(
UnixTime moment,
TZID tzid
) {
return this.printRelative(moment, Timezone.of(tzid), TimeUnit.SECONDS);
}
/**
* <p>Formats given time point relative to the current time of
* {@link #getReferenceClock()} as duration in at most second
* precision or less. </p>
*
* @param moment relative time point
* @param tzid time zone id for translating to a local duration
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 1.2
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal
* Sekundengenauigkeit. </p>
*
* @param moment relative time point
* @param tzid time zone id for translating to a local duration
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 1.2
*/
public String printRelative(
UnixTime moment,
String tzid
) {
return this.printRelative(moment, Timezone.of(tzid), TimeUnit.SECONDS);
}
/**
* <p>Formats given threeten object relative to the current time of
* {@link #getReferenceClock()} as duration in at most second
* precision or less. </p>
*
* @param zdt relative time
* @return formatted output of relative time, either in past or in future
* @see #printRelative(Instant, ZoneId)
* @since 4.8
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt in JSR-310-Schreibweise relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal
* Sekundengenauigkeit. </p>
*
* @param zdt relative time
* @return formatted output of relative time, either in past or in future
* @see #printRelative(Instant, ZoneId)
* @since 4.8
*/
public String printRelative(ZonedDateTime zdt) {
return this.printRelative(zdt.toInstant(), zdt.getZone());
}
/**
* <p>Formats given time point relative to the current time of
* {@link #getReferenceClock()} as duration in at most second
* precision or less. </p>
*
* @param instant relative time point
* @param zoneId time zone id for translating to a local duration
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 4.8
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in maximal
* Sekundengenauigkeit. </p>
*
* @param instant relative time point
* @param zoneId time zone id for translating to a local duration
* @return formatted output of relative time, either in past or in future
* @see #printRelative(UnixTime, Timezone, TimeUnit)
* @since 4.8
*/
public String printRelative(
Instant instant,
ZoneId zoneId
) {
return this.printRelative(Moment.from(instant), Timezone.of(zoneId.getId()), TimeUnit.SECONDS);
}
/**
* <p>Formats given time point relative to the current time of {@link #getReferenceClock()}
* as duration in given precision or less. </p>
*
* <p>If day precision is given then output like "today", "yesterday",
* "tomorrow" or "last Wednesday" is possible. Example: </p>
*
* <pre>
* TimeSource<?> clock = () -> PlainTimestamp.of(2015, 8, 1, 10, 24, 5).atUTC();
* String durationInDays =
* PrettyTime.of(Locale.GERMAN).withReferenceClock(clock).printRelative(
* PlainTimestamp.of(2015, 8, 1, 17, 0).atUTC(),
* Timezone.of(EUROPE.BERLIN),
* TimeUnit.DAYS);
* System.out.println(durationInDays); // heute (german word for today)
* </pre>
*
* @param moment relative time point
* @param tz time zone for translating to a local duration
* @param precision maximum precision of relative time (not more than seconds)
* @return formatted output of relative time, either in past or in future
* @since 3.6/4.4
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in der angegebenen
* maximalen Genauigkeit. </p>
*
* <p>Wenn Tagesgenauigkeit angegeben ist, sind auch Ausgaben wie "heute", "gestern",
* "morgen" oder "letzten Mittwoch" möglich. Beispiel: </p>
*
* <pre>
* TimeSource<?> clock = () -> PlainTimestamp.of(2015, 8, 1, 10, 24, 5).atUTC();
* String durationInDays =
* PrettyTime.of(Locale.GERMAN).withReferenceClock(clock).printRelative(
* PlainTimestamp.of(2015, 8, 1, 17, 0).atUTC(),
* Timezone.of(EUROPE.BERLIN),
* TimeUnit.DAYS);
* System.out.println(durationInDays); // heute
* </pre>
*
* @param moment relative time point
* @param tz time zone for translating to a local duration
* @param precision maximum precision of relative time (not more than seconds)
* @return formatted output of relative time, either in past or in future
* @since 3.6/4.4
*/
public String printRelative(
UnixTime moment,
Timezone tz,
TimeUnit precision
) {
UnixTime ref = this.getReferenceClock().currentTime();
Moment t1 = Moment.from(ref);
Moment t2 = Moment.from(moment);
if (precision.compareTo(TimeUnit.SECONDS) <= 0) {
long delta = t1.until(t2, TimeUnit.SECONDS);
if (Math.abs(delta) < 60L) {
return this.printRelativeSeconds(t1, t2, delta);
}
}
return this.printRelativeTime(t1, t2, tz, precision, null, null);
}
/**
* <p>Formats given time point relative to the current time of {@link #getReferenceClock()}
* as duration in given precision or as absolute date-time. </p>
*
* <p>If the calculated duration in seconds is bigger than {@code maxdelta} then the absolute date-time
* will be printed else a relative expression will be used. </p>
*
* @param moment relative time point
* @param tz time zone for translating to a local duration
* @param precision maximum precision of relative time (not more than seconds)
* @param maxdelta maximum deviation of given moment from clock in posix seconds for relative printing
* @param formatter used for printing absolute time if the deviation is bigger than maxdelta
* @return formatted output of relative time, either in past or in future
* @since 3.6/4.4
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in der angegebenen
* maximalen Genauigkeit oder als absolute Datumszeit. </p>
*
* <p>Wenn die berechnete Dauer in Sekunden größer als {@code maxdelta} ist, wird
* die absolute Datumszeit formatiert, sonst wird ein relativer Ausdruck verwendet. </p>
*
* @param moment relative time point
* @param tz time zone for translating to a local duration
* @param precision maximum precision of relative time (not more than seconds)
* @param maxdelta maximum deviation of given moment from clock in posix seconds for relative printing
* @param formatter used for printing absolute time if the deviation is bigger than maxdelta
* @return formatted output of relative time, either in past or in future
* @since 3.6/4.4
*/
public String printRelativeOrDateTime(
UnixTime moment,
Timezone tz,
TimeUnit precision,
long maxdelta,
TemporalFormatter<Moment> formatter
) {
UnixTime ref = this.getReferenceClock().currentTime();
Moment t1 = Moment.from(ref);
Moment t2 = Moment.from(moment);
long delta = t1.until(t2, TimeUnit.SECONDS);
if (Math.abs(delta) > maxdelta) {
return formatter.format(t2);
} else if (
(precision.compareTo(TimeUnit.SECONDS) <= 0)
&& (Math.abs(delta) < 60L)
) {
return this.printRelativeSeconds(t1, t2, delta);
}
return this.printRelativeTime(t1, t2, tz, precision, null, null);
}
/**
* <p>Formats given time point relative to the current time of {@link #getReferenceClock()}
* as duration in given precision or as absolute date-time. </p>
*
* @param moment time point whose deviation from clock is to be printed
* @param tz time zone for translating to a local duration
* @param precision maximum precision of relative time (not more than seconds)
* @param maxRelativeUnit maximum time unit which will still be printed in a relative way
* @param formatter used for printing absolute time if the leading unit is bigger than maxRelativeUnit
* @return formatted output of relative time, either in past or in future
* @since 3.6/4.4
*/
/*[deutsch]
* <p>Formatiert den angegebenen Zeitpunkt relativ zur aktuellen Zeit
* der Referenzuhr {@link #getReferenceClock()} als Dauer in der angegebenen
* maximalen Genauigkeit oder als absolute Datumszeit. </p>
*
* @param moment time point whose deviation from clock is to be printed
* @param tz time zone for translating to a local duration
* @param precision maximum precision of relative time (not more than seconds)
* @param maxRelativeUnit maximum time unit which will still be printed in a relative way
* @param formatter used for printing absolute time if the leading unit is bigger than maxRelativeUnit
* @return formatted output of relative time, either in past or in future
* @since 3.6/4.4
*/
public String printRelativeOrDateTime(
UnixTime moment,
Timezone tz,
TimeUnit precision,
CalendarUnit maxRelativeUnit,
TemporalFormatter<Moment> formatter
) {
if (maxRelativeUnit == null) {
throw new NullPointerException("Missing max relative unit.");
}
UnixTime ref = this.getReferenceClock().currentTime();
Moment t1 = Moment.from(ref);
Moment t2 = Moment.from(moment);
long delta = t1.until(t2, TimeUnit.SECONDS);
if (
(precision.compareTo(TimeUnit.SECONDS) <= 0)
&& (Math.abs(delta) < 60L)
) {
return this.printRelativeSeconds(t1, t2, delta);
}
return this.printRelativeTime(t1, t2, tz, precision, maxRelativeUnit, formatter);
}
/**
* <p>Formats given date relative to the current date of {@link #getReferenceClock()}
* as duration or as absolute date. </p>
*
* @param date calendar date whose deviation from clock is to be printed
* @param tzid time zone identifier for getting current reference date
* @param maxRelativeUnit maximum calendar unit which will still be printed in a relative way
* @param formatter used for printing absolute date if the leading unit is bigger than maxRelativeUnit
* @return formatted output of relative date, either in past or in future
* @since 3.7/4.5
*/
/*[deutsch]
* <p>Formatiert das angegebene Datum relativ zum aktuellen Datum der Referenzuhr {@link #getReferenceClock()}
* als Dauer oder als absolute Datumszeit. </p>
*
* @param date calendar date whose deviation from clock is to be printed
* @param tzid time zone identifier for getting current reference date
* @param maxRelativeUnit maximum calendar unit which will still be printed in a relative way
* @param formatter used for printing absolute date if the leading unit is bigger than maxRelativeUnit
* @return formatted output of relative date, either in past or in future
* @since 3.7/4.5
*/
public String printRelativeOrDate(
PlainDate date,
TZID tzid,
CalendarUnit maxRelativeUnit,
TemporalFormatter<PlainDate> formatter
) {
if (maxRelativeUnit == null) {
throw new NullPointerException("Missing max relative unit.");
}
Moment refTime = Moment.from(this.getReferenceClock().currentTime());
PlainDate refDate = refTime.toZonalTimestamp(tzid).toDate();
Duration<CalendarUnit> duration;
if (this.weekToDays) {
duration = Duration.inYearsMonthsDays().between(refDate, date);
} else {
CalendarUnit[] stdUnits = {YEARS, MONTHS, WEEKS, DAYS};
duration = Duration.in(stdUnits).between(refDate, date);
}
if (duration.isEmpty()) {
return this.getEmptyRelativeString(TimeUnit.DAYS);
}
TimeSpan.Item<CalendarUnit> item = duration.getTotalLength().get(0);
long amount = item.getAmount();
CalendarUnit unit = item.getUnit();
if (Double.compare(unit.getLength(), maxRelativeUnit.getLength()) > 0) {
return formatter.format(date);
} else if (unit.equals(CalendarUnit.DAYS)) {
String replacement = this.getRelativeReplacement(date, duration.isNegative(), amount);
if (!replacement.isEmpty()) {
return replacement;
}
}
String pattern = (
duration.isNegative()
? this.getPastPattern(amount, unit)
: this.getFuturePattern(amount, unit));
return this.format(pattern, amount);
}
private String printRelativeSeconds(
Moment t1,
Moment t2,
long delta
) {
if (t1.getPosixTime() >= START_1972 && t2.getPosixTime() >= START_1972) {
delta = SI.SECONDS.between(t1, t2); // leap second correction
}
if (delta == 0) {
return UnitPatterns.of(this.locale).getNowWord();
}
long amount = Math.abs(delta);
String pattern = (
(delta < 0)
? this.getPastPattern(amount, ClockUnit.SECONDS)
: this.getFuturePattern(amount, ClockUnit.SECONDS));
return this.format(pattern, amount);
}
private String printRelativeTime(
Moment ref,
Moment moment,
Timezone tz,
TimeUnit precision,
CalendarUnit maxRelativeUnit,
TemporalFormatter<Moment> formatter
) {
PlainTimestamp start =
PlainTimestamp.from(
ref,
tz.getOffset(ref));
PlainTimestamp end =
PlainTimestamp.from(
moment,
tz.getOffset(moment));
IsoUnit[] units = (this.weekToDays ? TSP_UNITS : STD_UNITS);
Duration<IsoUnit> duration = Duration.in(tz, units).between(start, end);
if (duration.isEmpty()) {
return this.getEmptyRelativeString(precision);
}
TimeSpan.Item<IsoUnit> item = duration.getTotalLength().get(0);
long amount = item.getAmount();
IsoUnit unit = item.getUnit();
if (unit instanceof ClockUnit) {
if (5 - ((ClockUnit) unit).ordinal() < precision.ordinal()) {
return this.getEmptyRelativeString(precision);
}
} else if (
(maxRelativeUnit != null)
&& (Double.compare(unit.getLength(), maxRelativeUnit.getLength()) > 0)
) {
return formatter.format(moment);
} else if (unit.equals(CalendarUnit.DAYS)) {
String replacement = this.getRelativeReplacement(end.toDate(), duration.isNegative(), amount);
if (!replacement.isEmpty()) {
return replacement;
}
}
String pattern;
if (duration.isNegative()) {
if (unit.isCalendrical()) {
assert (unit instanceof CalendarUnit);
pattern = this.getPastPattern(amount, (CalendarUnit) unit);
} else {
assert (unit instanceof ClockUnit);
pattern = this.getPastPattern(amount, (ClockUnit) unit);
}
} else {
if (unit.isCalendrical()) {
assert (unit instanceof CalendarUnit);
pattern = this.getFuturePattern(amount, (CalendarUnit) unit);
} else {
assert (unit instanceof ClockUnit);
pattern = this.getFuturePattern(amount, (ClockUnit) unit);
}
}
return this.format(pattern, amount);
}
private String getRelativeReplacement(
PlainDate date,
boolean negative,
long amount
) {
if ((amount >= 1L) && (amount <= 7L)) {
UnitPatterns patterns = UnitPatterns.of(this.locale);
if (amount == 1L) {
return (negative ? patterns.getYesterdayWord() : patterns.getTomorrowWord());
} else {
Weekday dayOfWeek = date.getDayOfWeek();
return (negative ? patterns.labelForLast(dayOfWeek): patterns.labelForNext(dayOfWeek));
}
}
return "";
}
private String getEmptyRelativeString(TimeUnit precision) {
UnitPatterns patterns = UnitPatterns.of(this.locale);
if (precision.equals(TimeUnit.DAYS)) {
String replacement = patterns.getTodayWord();
if (!replacement.isEmpty()) {
return replacement;
}
}
return patterns.getNowWord();
}
private String getPastPattern(
long amount,
CalendarUnit unit
) {
UnitPatterns patterns = UnitPatterns.of(this.locale);
PluralCategory category = this.getCategory(amount);
return patterns.getPatternInPast(category, this.shortStyle, unit);
}
private String getFuturePattern(
long amount,
CalendarUnit unit
) {
UnitPatterns patterns = UnitPatterns.of(this.locale);
PluralCategory category = this.getCategory(amount);
return patterns.getPatternInFuture(category, this.shortStyle, unit);
}
private String getPastPattern(
long amount,
ClockUnit unit
) {
UnitPatterns patterns = UnitPatterns.of(this.locale);
PluralCategory category = this.getCategory(amount);
return patterns.getPatternInPast(category, this.shortStyle, unit);
}
private String getFuturePattern(
long amount,
ClockUnit unit
) {
UnitPatterns patterns = UnitPatterns.of(this.locale);
PluralCategory category = this.getCategory(amount);
return patterns.getPatternInFuture(category, this.shortStyle, unit);
}
private PluralCategory getCategory(long amount) {
return this.rules.getCategory(Math.abs(amount));
}
private static void pushDuration(
long[] values,
Duration<?> duration,
TimeSource<?> refClock,
boolean weekToDays
) {
int len = duration.getTotalLength().size();
for (int i = 0; i < len; i++) {
TimeSpan.Item<? extends IsoUnit> item =
duration.getTotalLength().get(i);
IsoUnit unit = item.getUnit();
long amount = item.getAmount();
if (unit instanceof CalendarUnit) {
push(values, CalendarUnit.class.cast(unit), amount, weekToDays);
} else if (unit instanceof ClockUnit) {
push(values, ClockUnit.class.cast(unit), amount);
} else if (unit instanceof OverflowUnit) {
push(
values,
OverflowUnit.class.cast(unit).getCalendarUnit(),
amount,
weekToDays);
} else if (unit.equals(CalendarUnit.weekBasedYears())) {
values[0] = MathUtils.safeAdd(amount, values[0]); // YEARS
} else { // approximated duration by normalization without nanos
Moment unix = Moment.from(refClock.currentTime());
PlainTimestamp start = unix.toZonalTimestamp(ZonalOffset.UTC);
PlainTimestamp end = start.plus(amount, unit);
IsoUnit[] units = (weekToDays ? TSP_UNITS : STD_UNITS);
Duration<?> part = Duration.in(units).between(start, end);
pushDuration(values, part, refClock, weekToDays);
}
}
}
private static void push(
long[] values,
CalendarUnit unit,
long amount,
boolean weekToDays
) {
int index;
switch (unit) {
case MILLENNIA:
amount = MathUtils.safeMultiply(amount, 1000);
index = 0; // YEARS
break;
case CENTURIES:
amount = MathUtils.safeMultiply(amount, 100);
index = 0; // YEARS
break;
case DECADES:
amount = MathUtils.safeMultiply(amount, 10);
index = 0; // YEARS
break;
case YEARS:
index = 0; // YEARS
break;
case QUARTERS:
amount = MathUtils.safeMultiply(amount, 3);
index = 1; // MONTHS
break;
case MONTHS:
index = 1; // MONTHS
break;
case WEEKS:
if (weekToDays) {
amount = MathUtils.safeMultiply(amount, 7);
index = 3; // DAYS
} else {
index = 2; // WEEKS
}
break;
case DAYS:
index = 3; // DAYS
break;
default:
throw new UnsupportedOperationException(unit.name());
}
values[index] = MathUtils.safeAdd(amount, values[index]);
}
private static void push(
long[] values,
ClockUnit unit,
long amount
) {
int index;
switch (unit) {
case HOURS:
index = 4;
break;
case MINUTES:
index = 5;
break;
case SECONDS:
index = 6;
break;
case MILLIS:
amount = MathUtils.safeMultiply(amount, MIO);
index = 7; // NANOS
break;
case MICROS:
amount = MathUtils.safeMultiply(amount, 1000);
index = 7; // NANOS
break;
case NANOS:
index = 7; // NANOS
break;
default:
throw new UnsupportedOperationException(unit.name());
}
values[index] = MathUtils.safeAdd(amount, values[index]);
}
private String format(
long amount,
IsoUnit unit,
boolean negative,
TextWidth width
) {
long value = amount;
if (negative) {
value = MathUtils.safeNegate(amount);
}
if (SUPPORTED_UNITS.contains(unit)) {
if (unit.isCalendrical()) {
CalendarUnit u = CalendarUnit.class.cast(unit);
return this.print(value, u, width);
} else {
ClockUnit u = ClockUnit.class.cast(unit);
if (u == NANOS) {
if ((amount % MIO) == 0) {
u = MILLIS;
value = value / MIO;
} else if ((amount % 1000) == 0) {
u = MICROS;
value = value / 1000;
}
}
return this.print(value, u, width);
}
}
throw new UnsupportedOperationException("Unknown unit: " + unit);
}
private String format(
String pattern,
long amount
) {
for (int i = 0, n = pattern.length(); i < n; i++) {
if (
(i < n - 2)
&& (pattern.charAt(i) == '{')
&& (pattern.charAt(i + 1) == '0')
&& (pattern.charAt(i + 2) == '}')
) {
StringBuilder sb = new StringBuilder(pattern);
sb.replace(i, i + 3, this.format(amount));
return sb.toString();
}
}
if (amount < 0) {
return this.minusSign + pattern;
}
return pattern;
}
private String format(long amount) {
String num = String.valueOf(Math.abs(amount));
char zero = this.zeroDigit;
StringBuilder sb = new StringBuilder();
if (amount < 0) {
sb.append(this.minusSign);
}
for (int i = 0, n = num.length(); i < n; i++) {
char c = num.charAt(i);
if (zero != '0') {
c = (char) (c + zero - '0');
}
sb.append(c);
}
return sb.toString();
}
}
|
package thaumcraft.api;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import thaumcraft.api.blocks.BlocksTC;
import thaumcraft.api.items.ItemsTC;
public class OreDictionaryEntries {
/**
* I included this in the API to make it simpler to see what items and blocks are ore dictionaried
*/
public static void initializeOreDictionary() {
OreDictionary.registerOre("oreAmber", new ItemStack(BlocksTC.oreAmber));
OreDictionary.registerOre("oreCinnabar", new ItemStack(BlocksTC.oreCinnabar));
OreDictionary.registerOre("oreQuartz", new ItemStack(BlocksTC.oreQuartz));
OreDictionary.registerOre("oreCrystalAir", new ItemStack(BlocksTC.crystalAir,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("oreCrystalEarth", new ItemStack(BlocksTC.crystalEarth,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("oreCrystalWater", new ItemStack(BlocksTC.crystalWater,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("oreCrystalFire", new ItemStack(BlocksTC.crystalFire,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("oreCrystalOrder", new ItemStack(BlocksTC.crystalOrder,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("oreCrystalEntropy", new ItemStack(BlocksTC.crystalEntropy,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("oreCrystalTaint", new ItemStack(BlocksTC.crystalTaint,1,OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("logWood", new ItemStack(BlocksTC.logGreatwood));
OreDictionary.registerOre("logWood", new ItemStack(BlocksTC.logSilverwood));
OreDictionary.registerOre("plankWood", new ItemStack(BlocksTC.plankGreatwood));
OreDictionary.registerOre("plankWood", new ItemStack(BlocksTC.plankSilverwood));
OreDictionary.registerOre("slabWood", new ItemStack(BlocksTC.slabGreatwood));
OreDictionary.registerOre("slabWood", new ItemStack(BlocksTC.slabSilverwood));
OreDictionary.registerOre("treeSapling", new ItemStack(BlocksTC.saplingGreatwood));
OreDictionary.registerOre("treeSapling", new ItemStack(BlocksTC.saplingSilverwood));
OreDictionary.registerOre("treeLeaves", new ItemStack(BlocksTC.leafGreatwood, 1, OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("treeLeaves", new ItemStack(BlocksTC.leafSilverwood, 1, OreDictionary.WILDCARD_VALUE));
for (Block b:BlocksTC.nitor.values())
OreDictionary.registerOre("nitor", new ItemStack(b));
OreDictionary.registerOre("gemAmber", new ItemStack(ItemsTC.amber));
OreDictionary.registerOre("quicksilver", new ItemStack(ItemsTC.quicksilver));
OreDictionary.registerOre("nuggetIron", new ItemStack(ItemsTC.nuggets,1,0));
OreDictionary.registerOre("nuggetCopper", new ItemStack(ItemsTC.nuggets,1,1));
OreDictionary.registerOre("nuggetTin", new ItemStack(ItemsTC.nuggets,1,2));
OreDictionary.registerOre("nuggetSilver", new ItemStack(ItemsTC.nuggets,1,3));
OreDictionary.registerOre("nuggetLead", new ItemStack(ItemsTC.nuggets,1,4));
OreDictionary.registerOre("nuggetQuicksilver", new ItemStack(ItemsTC.nuggets,1,5));
OreDictionary.registerOre("nuggetThaumium", new ItemStack(ItemsTC.nuggets,1,6));
OreDictionary.registerOre("nuggetVoid", new ItemStack(ItemsTC.nuggets,1,7));
OreDictionary.registerOre("nuggetBrass", new ItemStack(ItemsTC.nuggets,1,8));
OreDictionary.registerOre("nuggetQuartz", new ItemStack(ItemsTC.nuggets,1,9));
OreDictionary.registerOre("nuggetMeat", new ItemStack(ItemsTC.chunks,1,0));
OreDictionary.registerOre("nuggetMeat", new ItemStack(ItemsTC.chunks,1,1));
OreDictionary.registerOre("nuggetMeat", new ItemStack(ItemsTC.chunks,1,2));
OreDictionary.registerOre("nuggetMeat", new ItemStack(ItemsTC.chunks,1,3));
OreDictionary.registerOre("nuggetMeat", new ItemStack(ItemsTC.chunks,1,4));
OreDictionary.registerOre("nuggetMeat", new ItemStack(ItemsTC.chunks,1,5));
OreDictionary.registerOre("ingotThaumium", new ItemStack(ItemsTC.ingots,1,0));
OreDictionary.registerOre("ingotVoid", new ItemStack(ItemsTC.ingots,1,1));
OreDictionary.registerOre("ingotBrass", new ItemStack(ItemsTC.ingots,1,2));
OreDictionary.registerOre("blockThaumium", new ItemStack(BlocksTC.metalBlockThaumium,1,0));
OreDictionary.registerOre("blockVoid", new ItemStack(BlocksTC.metalBlockVoid,1,1));
OreDictionary.registerOre("blockBrass", new ItemStack(BlocksTC.metalBlockBrass,1,4));
OreDictionary.registerOre("plateIron", new ItemStack(ItemsTC.plate,1,1));
OreDictionary.registerOre("plateBrass", new ItemStack(ItemsTC.plate,1,0));
OreDictionary.registerOre("plateThaumium", new ItemStack(ItemsTC.plate,1,2));
OreDictionary.registerOre("plateVoid", new ItemStack(ItemsTC.plate,1,3));
OreDictionary.registerOre("clusterIron", new ItemStack(ItemsTC.clusters,1,0));
OreDictionary.registerOre("clusterGold", new ItemStack(ItemsTC.clusters,1,1));
OreDictionary.registerOre("clusterCopper", new ItemStack(ItemsTC.clusters,1,2));
OreDictionary.registerOre("clusterTin", new ItemStack(ItemsTC.clusters,1,3));
OreDictionary.registerOre("clusterSilver", new ItemStack(ItemsTC.clusters,1,4));
OreDictionary.registerOre("clusterLead", new ItemStack(ItemsTC.clusters,1,5));
OreDictionary.registerOre("clusterCinnabar", new ItemStack(ItemsTC.clusters,1,6));
OreDictionary.registerOre("clusterQuartz", new ItemStack(ItemsTC.clusters,1,7));
// for mod recipe compatibility
OreDictionary.registerOre("trapdoorWood", new ItemStack(Blocks.TRAPDOOR));
}
}
|
package watchdogtest;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* Activator for the test plugin.
*/
public class Activator extends AbstractUIPlugin {
/**
* The plug-in ID
*/
public static final String PLUGIN_ID = "WatchDogTest"; //$NON-NLS-1$
/** The shared instance */
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/**
* Initialize plugin.
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/**
* Stop plugin.
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
|
package jade.domain.mobility;
import jade.util.leap.Iterator;
import jade.util.leap.List;
import jade.util.leap.ArrayList;
import jade.util.leap.Map;
import jade.util.leap.HashMap;
import jade.core.AID;
import jade.core.Location;
import jade.core.ContainerID;
import jade.content.onto.*;
import jade.content.schema.*;
import jade.domain.JADEAgentManagement.*;
/**
@author Giovanni Rimassa - Universita` di Parma
@version $Date$ $Revision$
*/
/**
This class represents the ontology used for JADE mobility. There is
only a single instance of this class.
@see jade.domain.MobilityOntology#getInstance()
*/
public class MobilityOntology extends Ontology implements MobilityVocabulary {
public static final String NAME = "jade-mobility-ontology";
private static Ontology theInstance = new MobilityOntology();
public static Ontology getInstance() {
return theInstance;
}
private MobilityOntology() {
super(NAME, JADEManagementOntology.getInstance());
try{
// Adds the roles of the basic ontology (ACTION, AID,...)
add(new ConceptSchema(MOBILE_AGENT_DESCRIPTION), MobileAgentDescription.class);
add(new ConceptSchema(MOBILE_AGENT_PROFILE), MobileAgentProfile.class);
add(new ConceptSchema(MOBILE_AGENT_SYSTEM), MobileAgentSystem.class);
add(new ConceptSchema(MOBILE_AGENT_LANGUAGE), MobileAgentLanguage.class);
add(new ConceptSchema(MOBILE_AGENT_OS), MobileAgentOS.class);
add(new AgentActionSchema(CLONE), CloneAction.class);
add(new AgentActionSchema(MOVE), MoveAction.class);
ConceptSchema cs = (ConceptSchema)getSchema(MOBILE_AGENT_DESCRIPTION);
cs.add(MOBILE_AGENT_DESCRIPTION_NAME, (ConceptSchema)getSchema(BasicOntology.AID));
cs.add(MOBILE_AGENT_DESCRIPTION_DESTINATION, (ConceptSchema)getSchema(LOCATION));
cs.add(MOBILE_AGENT_DESCRIPTION_AGENT_PROFILE, (ConceptSchema)getSchema(MOBILE_AGENT_PROFILE), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_DESCRIPTION_AGENT_VERSION, (PrimitiveSchema)getSchema(BasicOntology.STRING), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_DESCRIPTION_SIGNATURE, (PrimitiveSchema)getSchema(BasicOntology.STRING), ObjectSchema.OPTIONAL);
cs = (ConceptSchema)getSchema(MOBILE_AGENT_PROFILE);
cs.add(MOBILE_AGENT_PROFILE_SYSTEM, (ConceptSchema)getSchema(MOBILE_AGENT_SYSTEM), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_PROFILE_LANGUAGE, (ConceptSchema)getSchema(MOBILE_AGENT_LANGUAGE), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_PROFILE_OS, (ConceptSchema)getSchema(MOBILE_AGENT_OS));
cs = (ConceptSchema)getSchema(MOBILE_AGENT_SYSTEM);
cs.add(MOBILE_AGENT_SYSTEM_NAME, (PrimitiveSchema)getSchema(BasicOntology.STRING));
cs.add(MOBILE_AGENT_SYSTEM_MAJOR_VERSION, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
cs.add(MOBILE_AGENT_SYSTEM_MINOR_VERSION, (PrimitiveSchema)getSchema(BasicOntology.INTEGER), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_SYSTEM_DEPENDENCIES, (PrimitiveSchema)getSchema(BasicOntology.STRING), ObjectSchema.OPTIONAL);
cs = (ConceptSchema)getSchema(MOBILE_AGENT_LANGUAGE);
cs.add(MOBILE_AGENT_LANGUAGE_NAME, (PrimitiveSchema)getSchema(BasicOntology.STRING));
cs.add(MOBILE_AGENT_LANGUAGE_MAJOR_VERSION, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
cs.add(MOBILE_AGENT_LANGUAGE_MINOR_VERSION, (PrimitiveSchema)getSchema(BasicOntology.INTEGER), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_LANGUAGE_DEPENDENCIES, (PrimitiveSchema)getSchema(BasicOntology.STRING), ObjectSchema.OPTIONAL);
cs = (ConceptSchema)getSchema(MOBILE_AGENT_OS);
cs.add(MOBILE_AGENT_OS_NAME, (PrimitiveSchema)getSchema(BasicOntology.STRING));
cs.add(MOBILE_AGENT_OS_MAJOR_VERSION, (PrimitiveSchema)getSchema(BasicOntology.INTEGER));
cs.add(MOBILE_AGENT_OS_MINOR_VERSION, (PrimitiveSchema)getSchema(BasicOntology.INTEGER), ObjectSchema.OPTIONAL);
cs.add(MOBILE_AGENT_OS_DEPENDENCIES, (PrimitiveSchema)getSchema(BasicOntology.STRING), ObjectSchema.OPTIONAL);
AgentActionSchema as = (AgentActionSchema)getSchema(MOVE);
as.add(MOVE_MOBILE_AGENT_DESCRIPTION, (ConceptSchema)getSchema(MOBILE_AGENT_DESCRIPTION));
as = (AgentActionSchema)getSchema(CLONE);
as.addSuperSchema((AgentActionSchema)getSchema(MOVE));
//as.add(CLONE_MOBILE_AGENT_DESCRIPTION, (ConceptSchema)getSchema(MOBILE_AGENT_DESCRIPTION));
as.add(CLONE_NEW_NAME, (PrimitiveSchema)getSchema(BasicOntology.STRING));
}
catch(OntologyException oe) {
oe.printStackTrace();
}
}
}
|
package common.i18n;
import io.sphere.sdk.models.Base;
import org.apache.commons.lang3.StringUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
import play.Logger;
import javax.annotation.Nullable;
import java.io.InputStream;
import java.util.*;
import static java.util.Collections.emptyMap;
import static java.util.Objects.requireNonNull;
/**
* Resolves the i18n messages using YAML files defined in a webjar located in the classpath.
*/
public final class YamlI18nResolver extends Base implements I18nResolver {
private final Map<String, Map> yamlMap = new HashMap<>();
private YamlI18nResolver(final String filepath, final List<Locale> locales, final List<String> bundles) {
requireNonNull(filepath);
requireNonNull(locales);
requireNonNull(bundles);
for (final Locale locale : locales) {
buildYamlMap(filepath, bundles, locale);
}
Logger.debug("Yaml i18n resolver: Loaded {} from filepath '{}'", yamlMap.keySet(), filepath);
}
@Override
public Optional<String> get(final String bundle, final String key, final Locale locale, final Object... args) {
// TODO Work with the arguments (replace arguments, pluralize)
final Map yamlContent = getYamlContent(bundle, locale);
final String[] pathSegments = StringUtils.split(key, '.');
return get(yamlContent, pathSegments, 0);
}
@Override
public String toString() {
return "YamlI18nResolver{" +
"supportedLanguageBundles=" + yamlMap.keySet() +
'}';
}
public static YamlI18nResolver of(final String filepath, final List<Locale> locales, final List<String> bundles) {
return new YamlI18nResolver(filepath, locales, bundles);
}
private Optional<String> get(final Map yamlContent, final String[] pathSegments, final int index) {
Optional<String> message = Optional.empty();
if (index < pathSegments.length) {
final Object yamlEntry = yamlContent.get(pathSegments[index]);
if (yamlEntry instanceof String) {
message = Optional.of((String) yamlEntry);
} else if (yamlEntry instanceof Map) {
message = get((Map) yamlEntry, pathSegments, index + 1);
}
}
return message;
}
private void buildYamlMap(final String filepath, final List<String> bundles, final Locale locale) {
for (final String bundle : bundles) {
try {
final String yamlKey = buildYamlKey(locale.toLanguageTag(), bundle);
final Map yamlContent = loadYamlContent(filepath, locale, bundle);
if (yamlContent != null) {
yamlMap.put(yamlKey, yamlContent);
}
} catch (final YAMLException e){
Logger.warn("Yaml i18n resolver: Failed to load bundle '{}' for locale '{}' in filepath '{}'", bundle, locale, filepath);
}
}
}
private Map getYamlContent(final String bundle, final Locale locale) {
final String yamlKey = buildYamlKey(locale.toLanguageTag(), bundle);
return yamlMap.getOrDefault(yamlKey, emptyMap());
}
@Nullable
private static Map loadYamlContent(final String filepath, final Locale locale, final String bundle) throws YAMLException {
final String path = String.format("%s/%s/%s.yaml", filepath, locale.toLanguageTag(), bundle);
final InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
return (Map) new Yaml().load(resourceAsStream);
}
private static String buildYamlKey(final String languageTag, final String bundle) {
return languageTag + "/" + bundle;
}
}
|
package com.threerings.gwt.ui;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Widget;
/**
* Extends {@link FlexTable} with a number of extremely useful utility methods.
*/
public class SmartTable extends FlexTable
{
public SmartTable ()
{
}
public SmartTable (int cellPadding, int cellSpacing)
{
setCellPadding(cellPadding);
setCellSpacing(cellSpacing);
}
public SmartTable (String styleName, int cellPadding, int cellSpacing)
{
setStyleName(styleName);
setCellPadding(cellPadding);
setCellSpacing(cellSpacing);
}
/**
* Sets the text in the specified cell, with the specified style and column span.
*
* @param text an object whose string value will be displayed.
*/
public void setText (int row, int column, Object text, int colSpan, String... styles)
{
setText(row, column, String.valueOf(text));
if (colSpan > 0) {
getFlexCellFormatter().setColSpan(row, column, colSpan);
}
setStyleNames(row, column, styles);
}
/**
* Sets the HTML in the specified cell, with the specified style and column span.
*/
public void setHTML (int row, int column, String text, int colSpan, String... styles)
{
setHTML(row, column, text);
if (colSpan > 0) {
getFlexCellFormatter().setColSpan(row, column, colSpan);
}
setStyleNames(row, column, styles);
}
/**
* Sets the widget in the specified cell, with the specified style and column span.
*/
public void setWidget (int row, int column, Widget widget, int colSpan, String... styles)
{
setWidget(row, column, widget);
if (colSpan > 0) {
getFlexCellFormatter().setColSpan(row, column, colSpan);
}
setStyleNames(row, column, styles);
}
/**
* Adds text to the bottom row of this table in column zero, with the specified column span and
* style.
*
* @param text an object whose string value will be displayed.
*
* @return the row to which the text was added.
*/
public int addText (Object text, int colSpan, String... styles)
{
int row = getRowCount();
setText(row, 0, text, colSpan, styles);
return row;
}
/**
* Adds a widget to the bottom row of this table in column zero, with the specified column span
* and style.
*
* @return the row to which the widget was added.
*/
public int addWidget (Widget widget, int colSpan, String... styles)
{
int row = getRowCount();
setWidget(row, 0, widget, colSpan, styles);
return row;
}
/**
* Configures the specified style names on the specified row and column. The first style is set
* as the primary style and additional styles are added onto that.
*/
public void setStyleNames (int row, int column, String... styles)
{
int idx = 0;
for (String style : styles) {
if (idx++ == 0) {
getFlexCellFormatter().setStyleName(row, column, style);
} else {
getFlexCellFormatter().addStyleName(row, column, style);
}
}
}
}
|
// Narya library - tools for developing networked games
// This library is free software; you can redistribute it and/or modify it
// (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// You should have received a copy of the GNU Lesser General Public
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.io;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.RandomAccess;
/**
* Code to read and write basic object types (like arrays of primitives,
* {@link Integer} instances, {@link Double} instances, etc.).
*/
public class BasicStreamers
{
/** An array of types for all of the basic streamers. */
public static Class[] BSTREAMER_TYPES = {
Boolean.class,
Byte.class,
Short.class,
Character.class,
Integer.class,
Long.class,
Float.class,
Double.class,
String.class,
boolean[].class,
byte[].class,
short[].class,
char[].class,
int[].class,
long[].class,
float[].class,
double[].class,
Object[].class,
List.class,
ArrayList.class,
};
/** An array of instances of all of the basic streamers. */
public static Streamer[] BSTREAMER_INSTANCES = {
new BooleanStreamer(),
new ByteStreamer(),
new ShortStreamer(),
new CharacterStreamer(),
new IntegerStreamer(),
new LongStreamer(),
new FloatStreamer(),
new DoubleStreamer(),
new StringStreamer(),
new BooleanArrayStreamer(),
new ByteArrayStreamer(),
new ShortArrayStreamer(),
new CharArrayStreamer(),
new IntArrayStreamer(),
new LongArrayStreamer(),
new FloatArrayStreamer(),
new DoubleArrayStreamer(),
new ObjectArrayStreamer(),
new ListStreamer(),
new ListStreamer(),
};
/** Streams {@link Boolean} instances. */
public static class BooleanStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Boolean.valueOf(in.readBoolean());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeBoolean(((Boolean)object).booleanValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Byte} instances. */
public static class ByteStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Byte.valueOf(in.readByte());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeByte(((Byte)object).byteValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Short} instances. */
public static class ShortStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Short.valueOf(in.readShort());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeShort(((Short)object).shortValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Character} instances. */
public static class CharacterStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Character.valueOf(in.readChar());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeChar(((Character)object).charValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Integer} instances. */
public static class IntegerStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Integer.valueOf(in.readInt());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeInt(((Integer)object).intValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Long} instances. */
public static class LongStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Long.valueOf(in.readLong());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeLong(((Long)object).longValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Float} instances. */
public static class FloatStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Float.valueOf(in.readFloat());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeFloat(((Float)object).floatValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link Double} instances. */
public static class DoubleStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return Double.valueOf(in.readDouble());
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeDouble(((Double)object).doubleValue());
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams {@link String} instances. */
public static class StringStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return in.readUTF();
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
out.writeUTF((String)object);
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
// nothing to do here
}
}
/** Streams arrays of booleans. */
public static class BooleanArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new boolean[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
boolean[] value = (boolean[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeBoolean(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
boolean[] value = (boolean[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readBoolean();
}
}
}
/** Streams arrays of bytes. */
public static class ByteArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new byte[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
byte[] value = (byte[])object;
int ecount = value.length;
out.writeInt(ecount);
out.write(value);
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
byte[] value = (byte[])object;
int remain = value.length, offset = 0, read;
while (remain > 0) {
if ((read = in.read(value, offset, remain)) > 0) {
remain -= read;
offset += read;
} else {
throw new EOFException();
}
}
}
}
/** Streams arrays of shorts. */
public static class ShortArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new short[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
short[] value = (short[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeShort(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
short[] value = (short[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readShort();
}
}
}
/** Streams arrays of chars. */
public static class CharArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new char[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
char[] value = (char[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeChar(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
char[] value = (char[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readChar();
}
}
}
/** Streams arrays of ints. */
public static class IntArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new int[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
int[] value = (int[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeInt(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
int[] value = (int[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readInt();
}
}
}
/** Streams arrays of longs. */
public static class LongArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new long[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
long[] value = (long[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeLong(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
long[] value = (long[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readLong();
}
}
}
/** Streams arrays of floats. */
public static class FloatArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new float[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
float[] value = (float[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeFloat(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
float[] value = (float[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readFloat();
}
}
}
/** Streams arrays of doubles. */
public static class DoubleArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new double[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
double[] value = (double[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeDouble(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
double[] value = (double[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readDouble();
}
}
}
/** Streams arrays of Object instances. */
public static class ObjectArrayStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new Object[in.readInt()];
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
Object[] value = (Object[])object;
int ecount = value.length;
out.writeInt(ecount);
for (int ii = 0; ii < ecount; ii++) {
out.writeObject(value[ii]);
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
Object[] value = (Object[])object;
int ecount = value.length;
for (int ii = 0; ii < ecount; ii++) {
value[ii] = in.readObject();
}
}
}
/** Streams {@link List} instances. */
public static class ListStreamer extends Streamer
{
// documentation inherited
public Object createObject (ObjectInputStream in)
throws IOException
{
return new ArrayList(0); // minimally sized
// (We thought about using a ThreadLocal to assist here...
// we could read the length of the list here and construct
// the ArrayList with the right size, and then read the
// length out of the ThreadLocal down in readObject(). Instead,
// we simply create a 0-length list here, which generates
// minimal garbage when we ensureCapacity() down in readObject.)
}
// documentation inherited
public void writeObject (
Object object, ObjectOutputStream out, boolean useWriter)
throws IOException
{
List list = (List)object;
int ecount = list.size();
out.writeInt(ecount);
if (list instanceof RandomAccess) {
// if RandomAccess, it's faster and less garbagey this way
for (int ii = 0; ii < ecount; ii++) {
out.writeObject(list.get(ii));
}
} else {
// if not RandomAccess, go ahead and make an Iterator...
for (Object o : list) {
out.writeObject(o);
}
}
}
// documentation inherited
public void readObject (
Object object, ObjectInputStream in, boolean useReader)
throws IOException, ClassNotFoundException
{
@SuppressWarnings("unchecked") ArrayList<Object> value =
(ArrayList<Object>)object;
int ecount = in.readInt();
value.ensureCapacity(ecount); // resize the array once
for (int ii = 0; ii < ecount; ii++) {
value.add(in.readObject());
}
}
}
}
|
package org.apache.commons.chain;
import java.io.Serializable;
import java.util.Map;
public interface Context {
/**
* <p>Return an implementation of <code>java.util.Map</code> that
* applications can use to manipulate a general purpose collection
* of key-value pairs that maintain the state information associated
* with the processing of the transaction that is represented by
* this {@link Context} instance.</p>
*
* @return The state information for this context as a Map
*/
public Map getAttributes();
}
|
package jmetest.sound.openal;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.logging.Level;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import jmetest.sound.fsound.NextButtonHandler;
import com.jme.sound.openAL.SoundSystem;
import com.jme.util.LoggingSystem;
/**
* @author Arman
*/
public class TestStreamPlayer {
public static void main(String[] args) throws Exception{
SoundSystem.init(null, SoundSystem.OUTPUT_DEFAULT);
final JFrame frame=new JFrame();
final JButton open=new JButton("Select directory");
frame.getContentPane().add(open);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
open.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
final JFileChooser fileChooser=new JFileChooser();;
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.showOpenDialog(null);
((JButton)e.getSource()).setEnabled(false);
try {
new Thread(new Runnable(){public void run(){try {
startPlayer(frame, open,fileChooser.getSelectedFile());
} catch (Exception e) {
System.exit(-1);
}}}).start();
} catch (Exception e1) {
System.exit(-1);
}
}
});
frame.setSize(300, 100);
frame.show();
}
protected static void startPlayer(JFrame frame, JButton button, File dir) throws Exception{
JButton next=new JButton(">>");
NextButtonHandler nextHandler=new NextButtonHandler();
next.addActionListener(nextHandler);
frame.getContentPane().add(next);
String[] list=null;
int[] clip=null;
if(dir !=null && dir.isDirectory()){
list=dir.list();
}else{
System.exit(-1);
}
ArrayList valid=null;
ArrayList songs=null;
if(list !=null && list.length>0){
valid=new ArrayList();
songs=new ArrayList();
}
else{
LoggingSystem.getLogger().log(Level.INFO,"The path entered does not contain any file");
LoggingSystem.getLogger().log(Level.INFO,dir.getAbsolutePath());
System.exit(-1);
}
for(int a=0; a<list.length; a++){
int nb=SoundSystem.createStream(dir.getAbsolutePath()+File.separator+list[a], false);
if(SoundSystem.isStreamOpened(nb)){
valid.add(new Integer(nb));
songs.add(list[a]);
}
}
int nbStream=valid.size();
if(nbStream>0){
System.out.print("Found "+nbStream+" playable songs in this directory");
for(int a=0; a<nbStream; a++){
int music=((Integer)valid.get(a)).intValue();
int lgth=(int)SoundSystem.getStreamLength(music);
SoundSystem.playStream(music);
//SoundSystem.setStreamLooping(music, true);
while(!(lgth <=0)){
button.setText("Playing "+(String)songs.get(a)+" "+(lgth/1000/60)+" m "+(lgth/1000%60)+"s");
frame.repaint();
button.repaint();
frame.pack();
Thread.sleep(1000);
if(nextHandler.isPressed()){
lgth=0;
nextHandler.setPressed(false);
}
lgth-=1000;
}
}
}
}
}
class NextButtonHandler implements ActionListener{
private boolean pressed;
public void actionPerformed(ActionEvent arg0) {
pressed=true;
}
public boolean isPressed() {
return pressed;
}
public void setPressed(boolean pressed) {
this.pressed = pressed;
}
}
|
package lbms.plugins.mldht.kad;
import static the8472.bencode.Utils.buf2ary;
import java.nio.ByteBuffer;
import java.security.InvalidKeyException;
import java.security.Signature;
import java.security.SignatureException;
import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import lbms.plugins.mldht.kad.messages.PutRequest;
import net.i2p.crypto.eddsa.EdDSAEngine;
import net.i2p.crypto.eddsa.EdDSAPublicKey;
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable;
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec;
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;
import the8472.bencode.BEncoder;
public class GenericStorage {
public static final long EXPIRATION_INTERVAL_SECONDS = 2*60*60;
public static class StorageItem {
public StorageItem(PutRequest req) {
expirationDate = System.currentTimeMillis() + EXPIRATION_INTERVAL_SECONDS*1000;
value = buf2ary(req.rawValue());
if(req.getPubkey() != null) {
sequenceNumber = req.getSequenceNumber();
signature = req.getSignature();
salt = req.getSalt();
pubkey = req.getPubkey();
} else {
pubkey = null;
salt = null;
}
}
long expirationDate;
long sequenceNumber = -1;
byte[] signature;
final byte[] pubkey;
final byte[] salt;
byte[] value;
public boolean mutable() {
return pubkey != null;
}
static final EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("ed25519-sha-512");
public boolean validateSig() {
try {
Signature sig = new EdDSAEngine();
sig.initVerify(new EdDSAPublicKey(new EdDSAPublicKeySpec(pubkey, spec)));
// ("4:salt" length-of-salt ":" salt) "3:seqi" seq "e1:v" len ":" and the encoded value
Map<String, Object> p = new TreeMap<>();
if(salt != null)
p.put("salt", salt);
p.put("seq", sequenceNumber);
p.put("v", new BEncoder.RawData(ByteBuffer.wrap(value)));
ByteBuffer buf = new BEncoder().encode(p, 1500);
// trim d ... e
buf.position(buf.position() + 1);
buf.limit(buf.limit() - 1);
sig.update(buf);
return sig.verify(signature);
} catch (InvalidKeyException | SignatureException e) {
return false;
}
}
}
ConcurrentHashMap<Key, StorageItem> items = new ConcurrentHashMap<>();
enum UpdateResult {
SUCCESS,
IMMUTABLE_SUBSTITUTION_FAIL,
SIG_FAIL,
CAS_FAIL,
SEQ_FAIL;
}
public UpdateResult putOrUpdate(Key k, StorageItem newItem, long expected) {
if(newItem.mutable() && !newItem.validateSig())
return UpdateResult.SIG_FAIL;
while(true) {
StorageItem oldItem = items.putIfAbsent(k, newItem);
if(oldItem == null)
return UpdateResult.SUCCESS;
if(oldItem.mutable()) {
if(!newItem.mutable())
return UpdateResult.IMMUTABLE_SUBSTITUTION_FAIL;
if(newItem.sequenceNumber < oldItem.sequenceNumber)
return UpdateResult.SEQ_FAIL;
if(expected >= 0 && oldItem.sequenceNumber >= 0 && oldItem.sequenceNumber != expected)
return UpdateResult.CAS_FAIL;
}
if(items.replace(k, oldItem, newItem))
break;
}
return UpdateResult.SUCCESS;
}
public Optional<StorageItem> get(Key k) {
return Optional.ofNullable(items.get(k));
}
public void cleanup() {
long now = System.currentTimeMillis();
items.entrySet().removeIf(entry -> {
return entry.getValue().expirationDate < now;
});
}
}
|
package annotators;
import org.apache.uima.UimaContext;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
import static org.apache.uima.fit.util.JCasUtil.select;
import types.Features;
import weka.classifiers.Classifier;
import weka.classifiers.meta.Bagging;
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Utils;
public class WekaModelBuilder extends JCasAnnotator_ImplBase {
Instances classifierData;
int indexClass = 7;
Classifier classifier;
@Override
public void initialize(UimaContext context)
throws ResourceInitializationException {
// TODO Auto-generated method stub
super.initialize(context);
Boolean nominalClassValue = false;
FastVector attributes = new FastVector();
attributes.addElement(new Attribute("TF"));
attributes.addElement(new Attribute("DF"));
attributes.addElement(new Attribute("IDF"));
attributes.addElement(new Attribute("TFxIDF"));
attributes.addElement(new Attribute("FirstOccurrence"));
attributes.addElement(new Attribute("LastOccurrence"));
attributes.addElement(new Attribute("Spread"));
// declare a class attribute :
if (nominalClassValue) {
FastVector vals = new FastVector(2);
vals.addElement("False");
vals.addElement("True");
attributes.addElement(new Attribute("Keyphrase?", vals));
} else {
attributes.addElement(new Attribute("Keyphrase?"));
}
classifierData = new Instances("ClassifierData", attributes, 0);
classifierData.setClassIndex(indexClass);
classifier = new Bagging();
}
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
for(Features f : select(jCas, Features.class))
{
double[] vals = {f.getTf(), f.getDf(), f.getIdf(), f.getTfidf(), f.getFirst_occurrence(), f.getLast_occurrence(), f.getSpread(), f.getClass_()};
classifierData.add(new Instance(1, vals));
}
}
@Override
public void collectionProcessComplete() throws AnalysisEngineProcessException {
// TODO Auto-generated method stub
super.collectionProcessComplete();
System.out.println("Collection Process Complete --> build model...");
try {
classifier.setOptions(Utils.splitOptions("-P 100 -S 1 -I 10 -W weka.classifiers.trees.M5P -- -U -M 7.0"));
} catch (Exception e) {
//TODO
System.out.println("Error while loading classifier options");
}
try {
classifier.buildClassifier(classifierData);
} catch (Exception e) {
//TODO
System.out.println("Error while building the classifier : " + e.getMessage());
}
System.out.println("Collection Process Complete --> saving model...");
//TODO dump model in file
try {
weka.core.SerializationHelper.write("target/m5p.model", classifier);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Model successfully saved to target/m5p.model");
}
}
|
package apollo.upload;
import apollo.maven.MavenDeployer;
import apollo.predicators.PomFilePredictor;
import apollo.xml_handlers.XmlReformer;
import com.google.inject.Inject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
public class MavenUploader implements Uploader {
private final PomFilePredictor pomFilePredictor;
private final MavenDeployer mavenDeployer;
private final XmlReformer xmlReformer;
private static final Logger logger = LogManager.getLogger(MavenUploader.class);
private static final int maxThreadNo = 8;
private static ExecutorService executor = Executors.newFixedThreadPool(maxThreadNo);
@Inject
public MavenUploader(PomFilePredictor pomFilePredictor, MavenDeployer mavenDeployer, XmlReformer xmlReformer) {
this.pomFilePredictor = pomFilePredictor;
this.mavenDeployer = mavenDeployer;
this.xmlReformer = xmlReformer;
}
@Override
public void uploadToRepository(Path pathToUpload) {
logger.info("Starting to upload artifacts from " + pathToUpload.toString());
try (Stream<Path> files = Files.walk(pathToUpload)){
files.filter(pomFilePredictor).filter(path -> {
try {
xmlReformer.prepareXmlToDeploy(path);
return true;
} catch (Exception e) {
logger.error("Error uploading " + path + " : " + e);
return false;
}
}).forEach(path -> {
Runnable uploadThread = new MavenUploadThread(mavenDeployer, path);
executor.submit(uploadThread);
});
} catch (IOException e) {
throw new UncheckedIOException(e);
}
executor.shutdown();
try {
if (executor.awaitTermination(5, TimeUnit.DAYS)) {
logger.info("Executor service has shut down");
}
} catch (InterruptedException e) {
logger.info("Executor service interrupted");
}
}
}
|
package main.java.bschecker.gui;
import java.io.File;
import org.fxmisc.richtext.StyleClassedTextArea;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Dialog;
import main.java.bschecker.bluesheets.Bluesheet;
import main.java.bschecker.bluesheets.Bluesheets;
import main.java.bschecker.util.Error;
import main.java.bschecker.util.ErrorList;
import main.java.bschecker.util.TextImport;
import main.java.bschecker.util.UtilityMethods;
/**
* This is the class that connects the GUI with the rest of the program.
*
* @author Luke Giacalone
* @author JeremiahDeGreeff
*/
public class GUIController {
@FXML
private StyleClassedTextArea essayBox;
@FXML
private StyleClassedTextArea errorBox;
@FXML
private StyleClassedTextArea noteBox;
@FXML
private CheckMenuItem menuBluesheet1;
@FXML
private CheckMenuItem menuBluesheet2;
@FXML
private CheckMenuItem menuBluesheet3;
@FXML
private CheckMenuItem menuBluesheet4;
@FXML
private CheckMenuItem menuBluesheet5;
@FXML
private CheckMenuItem menuBluesheet6;
@FXML
private CheckMenuItem menuBluesheet7;
@FXML
private CheckMenuItem menuBluesheet8;
@FXML
private CheckMenuItem menuBluesheet9;
@FXML
private CheckMenuItem menuBluesheet10;
@FXML
private CheckMenuItem menuBluesheet11;
@FXML
private CheckMenuItem menuBluesheet12;
@FXML
private CheckMenuItem menuBluesheet13;
@FXML
private CheckMenuItem menuBluesheet14;
/**
* The method that will be called when the analyze button is clicked
*/
@FXML
private void analyzeButtonClick() {
Dialog<ButtonType> d = new Dialog<ButtonType>();
d.setTitle("Analyzing");
d.setContentText("BSChecker is analyzing your essay.");
d.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL);
d.show();
String text = essayBox.getText();
essayBox.setStyleClass(0, essayBox.getLength(), null);
text = UtilityMethods.replaceInvalidChars(text);
if(text.charAt(text.length() - 1) != '\n')
text += "\n";
essayBox.replaceText(text);
errors = Bluesheet.findAllErrors(text);
d.close();
if(errors.size() == 0)
errorBox.replaceText("No Error Found!");
else {
currError = 0;
//highlight all the errors
for(Error error : errors)
essayBox.setStyleClass(error.getStartIndex(), error.getEndIndex() + 1, "light-red");
//put first error in sentenceBox and corresponding thing in errorBox
displayError();
}
}
/**
* The method that will be called when the left arrow is clicked
*/
@FXML
private void leftArrowClick() {
if(errors.size() != 0) {
previousError();
}
}
/**
* The method that will be called when the right arrow is clicked
*/
@FXML
private void rightArrowClick() {
if(errors.size() != 0) {
nextError();
}
}
/**
* The method that will be called when the File->Open is clicked. It takes the file and puts the contents into the essay box.
*/
@FXML
private void menuOpenClick() {
file = TextImport.chooseFile();
if(file == null)
return;
String text = TextImport.openFile(file);
if(text == null)
return;
essayBox.replaceText(text);
}
/**
* The method that will be called when the File->Save is clicked
*/
@FXML
private void menuSaveClick() {
if(file != null && !TextImport.saveText(file, essayBox.getText())) {
Alert a = new Alert(Alert.AlertType.ERROR);
a.setTitle("Saving Error");
a.setContentText("There was an error in saving your file. It may be in use or moved from its original location.");
a.showAndWait();
}
}
/**
* The method that will be called when the File->Save As is clicked
*/
@FXML
private void menuSaveAsClick() {
TextImport.saveAs(essayBox.getText());
}
/**
* The method that will be called when the Edit->Undo is clicked
*/
@FXML
private void menuUndoClick() {
/* EDIT->UNDO ACTION */
}
/**
* The method that will be called when the Edit->Redo is clicked
*/
@FXML
private void menuRedoClick() {
/* EDIT->REDO ACTION */
}
/**
* The method that will be called when the Edit->Cut is clicked
*/
@FXML
private void menuCutClick() {
String temp = essayBox.getSelectedText();
if(!temp.equals("")) {
clipboard = temp;
essayBox.deleteText(essayBox.getSelection());
}
}
/**
* The method that will be called when the Edit->Copy is clicked
*/
@FXML
private void menuCopyClick() {
String temp = essayBox.getSelectedText();
if(!temp.equals(""))
clipboard = temp;
}
/**
* The method that will be called when the Edit->Paste is clicked
*/
@FXML
private void menuPasteClick() {
essayBox.insertText(essayBox.getSelection().getEnd(), clipboard);
}
/**
* The method that will be called when the Edit->Select All is clicked
*/
@FXML
private void menuSelectAllClick() {essayBox.selectAll();}
/**
* The method that will be called when the View->Next Error is clicked
*/
@FXML
private void menuNextErrorClick() {rightArrowClick();}
/**
* The method that will be called when the View->Previous Error is clicked
*/
@FXML
private void menuPreviousErrorClick() {leftArrowClick();}
/**
* The method that will be called when the Bluesheets->Past Tense (1) is clicked
*/
@FXML
private void menuBluesheet1Click() {menuBluesheetClick(1);}
/**
* The method that will be called when the Bluesheets->Incomplete Sentence (2) is clicked
*/
@FXML
private void menuBluesheet2Click() {menuBluesheetClick(2);}
/**
* The method that will be called when the Bluesheets->First/Second Person (3) is clicked
*/
@FXML
private void menuBluesheet3Click() {menuBluesheetClick(3);}
/**
* The method that will be called when the Bluesheets->Vague This/Which (4) is clicked
*/
@FXML
private void menuBluesheet4Click() {menuBluesheetClick(4);}
/**
* The method that will be called when the Bluesheets->Subject-Verb Disagreement (5) is clicked
*/
@FXML
private void menuBluesheet5Click() {menuBluesheetClick(5);}
/**
* The method that will be called when the Bluesheets->Pronoun Case (6) is clicked
*/
@FXML
private void menuBluesheet6Click() {menuBluesheetClick(6);}
/**
* The method that will be called when the Bluesheets->Ambiguous Pronoun (7) is clicked
*/
@FXML
private void menuBluesheet7Click() {menuBluesheetClick(7);}
/**
* The method that will be called when the Bluesheets->Apostrophe Error (8) is clicked
*/
@FXML
private void menuBluesheet8Click() {menuBluesheetClick(8);}
/**
* The method that will be called when the Bluesheets->Passive Voice (9) is clicked
*/
@FXML
private void menuBluesheet9Click() {menuBluesheetClick(9);}
/**
* The method that will be called when the Bluesheets->Dangling Modifier (10) is clicked
*/
@FXML
private void menuBluesheet10Click() {menuBluesheetClick(10);}
/**
* The method that will be called when the Bluesheets->Faulty Parallelism (11) is clicked
*/
@FXML
private void menuBluesheet11Click() {menuBluesheetClick(11);}
/**
* The method that will be called when the Bluesheets->Progressive Tense (12) is clicked
*/
@FXML
private void menuBluesheet12Click() {menuBluesheetClick(12);}
/**
* The method that will be called when the Bluesheets->Gerund Possesive (13) is clicked
*/
@FXML
private void menuBluesheet13Click() {menuBluesheetClick(13);}
/**
* The method that will be called when the Bluesheets->Quotation Form (14) is clicked
*/
@FXML
private void menuBluesheet14Click() {menuBluesheetClick(14);}
/**
* The method that will be called when the Help->About is clicked
*/
@FXML
private void menuAboutClick() {
/* HELP->ABOUT ACTION */
}
private int currError = 0;
private ErrorList errors;
private File file;
private String clipboard = "";
/**
* This method sets default "empty" text for the Text Areas
*/
public void setDefaultText() {
essayBox.replaceText("Insert Essay Here");
errorBox.replaceText("No Error Selected");
noteBox.replaceText("No Error Selected");
}
/**
* loads the settings into the checkedMenuItems for each bluesheet
* @param settings a boolean array of settings for each bluesheet as found in the Bluesheets enum
*/
public void loadSettings(boolean[] settings) {
for(int i = 0; i < settings.length; i++)
getMenuBluesheet(i + 1).setSelected(settings[i]);
}
/**
* accessor for a bluesheet's CheckMenuItem based on its number
* @param number the number of the bluesheet
* @return the CheckMenuItem for that bluesheet's setting
*/
private CheckMenuItem getMenuBluesheet(int number) {
switch(number) {
case 1: return menuBluesheet1;
case 2: return menuBluesheet2;
case 3: return menuBluesheet3;
case 4: return menuBluesheet4;
case 5: return menuBluesheet5;
case 6: return menuBluesheet6;
case 7: return menuBluesheet7;
case 8: return menuBluesheet8;
case 9: return menuBluesheet9;
case 10: return menuBluesheet10;
case 11: return menuBluesheet11;
case 12: return menuBluesheet12;
case 13: return menuBluesheet13;
case 14: return menuBluesheet14;
default: return null;
}
}
/**
* a method to be called whenever a bluesheet CheckMenuItem is clicked
* it reverses the setting in the bluesheets Enum and gives a warning if the bluesheet is not fully available
* @param number the number of the bluesheet which was clicked
*/
private void menuBluesheetClick(int number) {
Bluesheets.reverseSetting(number);
if(Bluesheets.getBluesheetFromNum(number).getAvailabilityWarning() != null && getMenuBluesheet(number).isSelected()) {
Alert a = new Alert(AlertType.WARNING);
a.setTitle("Warning");
a.setHeaderText(null);
a.setContentText(Bluesheets.getBluesheetFromNum(number).getAvailabilityWarning());
a.showAndWait();
}
}
/**
* Updates the selected text to the next error.
*/
private void nextError() {
resetCurrentColor();
currError++;
if(currError >= errors.size()) {
Alert a = new Alert(Alert.AlertType.INFORMATION);
a.setContentText("Searching from beginning of passage.");
a.setHeaderText("Search Complete");
a.setTitle("Notice");
a.showAndWait();
currError = 0;
}
displayError();
}
/**
* Updates the selected text to the previous error.
*/
private void previousError() {
resetCurrentColor();
currError
if(currError < 0) {
Alert a = new Alert(Alert.AlertType.INFORMATION);
a.setContentText("Searching from end of passage.");
a.setHeaderText("Search Complete");
a.setTitle("Notice");
a.showAndWait();
currError = errors.size() - 1;
}
displayError();
}
/**
* Displays the current error.
*/
private void displayError() {
essayBox.positionCaret(errors.get(currError).getStartIndex());
essayBox.setStyleClass(errors.get(currError).getStartIndex(), errors.get(currError).getEndIndex() + 1, "dark-red");
Bluesheets b = Bluesheets.getBluesheetFromNum(errors.get(currError).getBluesheetNumber());
errorBox.replaceText(b.getName() + "\n\n" + b.getDescription() + "\n\n" + b.getExample());
noteBox.replaceText(errors.get(currError).getNote().equals("") ? "No note was found for this error." : errors.get(currError).getNote());
}
/**
* Resets the color of the current error to the lighter color
*/
private void resetCurrentColor() {
essayBox.setStyleClass(errors.get(currError).getStartIndex(), errors.get(currError).getEndIndex() + 1, "light-red");
}
}
|
package com.alibaba.ttl;
import com.alibaba.ttl.spi.TtlEnhanced;
import com.alibaba.ttl.spi.TtlWrapper;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.function.*;
import static com.alibaba.ttl.TransmittableThreadLocal.Transmitter.*;
/**
* Util methods for TTL Wrapper: wrap common {@code Functional Interface}.
* <p>
* <b><i>Note:</i></b>
* <ul>
* <li>all methods is {@code null}-safe, when input parameter is {@code null}, return {@code null}.</li>
* <li>all wrap method skip wrap (aka. just return input parameter), when input parameter is already wrapped.</li>
* </ul>
*
* @author Jerry Lee (oldratlee at gmail dot com)
* @author huangfei1101 (fei.hf at alibaba-inc dot com)
* @see TtlRunnable
* @see TtlCallable
* @see TtlUnwrap
* @see TtlWrapper
* @since 2.11.4
*/
public class TtlWrappers {
/**
* wrap {@link Supplier} to TTL wrapper.
*
* @param supplier input {@link Supplier}
* @return Wrapped {@link Supplier}
* @see TtlUnwrap#unwrap(Object)
* @since 2.12.4
*/
@Nullable
public static <T> Supplier<T> wrapSupplier(@Nullable Supplier<T> supplier) {
if (supplier == null) return null;
else if (supplier instanceof TtlEnhanced) return supplier;
else return new TtlSupplier<T>(supplier);
}
/**
* wrap {@link Supplier} to TTL wrapper.
*
* @param supplier input {@link Supplier}
* @return Wrapped {@link Supplier}
* @see TtlUnwrap#unwrap(Object)
* @since 2.11.4
* @deprecated overload methods using the same name {@code wrap} is not readable
* and have the type inference problems in some case;
* so use {@link TtlWrappers#wrapSupplier(Supplier)} instead.
*/
@Deprecated
@Nullable
public static <T> Supplier<T> wrap(@Nullable Supplier<T> supplier) {
return wrapSupplier(supplier);
}
private static class TtlSupplier<T> implements Supplier<T>, TtlWrapper<Supplier<T>>, TtlEnhanced {
final Supplier<T> supplier;
final Object captured;
TtlSupplier(@NonNull Supplier<T> supplier) {
this.supplier = supplier;
this.captured = capture();
}
@Override
public T get() {
final Object backup = replay(captured);
try {
return supplier.get();
} finally {
restore(backup);
}
}
@NonNull
@Override
public Supplier<T> unwrap() {
return supplier;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TtlSupplier<?> that = (TtlSupplier<?>) o;
return supplier.equals(that.supplier);
}
@Override
public int hashCode() {
return supplier.hashCode();
}
@Override
public String toString() {
return this.getClass().getName() + " - " + supplier.toString();
}
}
/**
* wrap {@link Consumer} to TTL wrapper.
*
* @param consumer input {@link Consumer}
* @return Wrapped {@link Consumer}
* @see TtlUnwrap#unwrap(Object)
* @since 2.12.4
*/
@Nullable
public static <T> Consumer<T> wrapConsumer(@Nullable Consumer<T> consumer) {
if (consumer == null) return null;
else if (consumer instanceof TtlEnhanced) return consumer;
else return new TtlConsumer<T>(consumer);
}
/**
* wrap {@link Consumer} to TTL wrapper.
*
* @param consumer input {@link Consumer}
* @return Wrapped {@link Consumer}
* @see TtlUnwrap#unwrap(Object)
* @since 2.11.4
* @deprecated overload methods using the same name {@code wrap} is not readable
* and have the type inference problems in some case;
* so use {@link TtlWrappers#wrapConsumer(java.util.function.Consumer)} instead.
*/
@Deprecated
@Nullable
public static <T> Consumer<T> wrap(@Nullable Consumer<T> consumer) {
return wrapConsumer(consumer);
}
private static class TtlConsumer<T> implements Consumer<T>, TtlWrapper<Consumer<T>>, TtlEnhanced {
final Consumer<T> consumer;
final Object captured;
TtlConsumer(@NonNull Consumer<T> consumer) {
this.consumer = consumer;
this.captured = capture();
}
@Override
public void accept(T t) {
final Object backup = replay(captured);
try {
consumer.accept(t);
} finally {
restore(backup);
}
}
@NonNull
@Override
public Consumer<T> unwrap() {
return consumer;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TtlConsumer<?> that = (TtlConsumer<?>) o;
return consumer.equals(that.consumer);
}
@Override
public int hashCode() {
return consumer.hashCode();
}
@Override
public String toString() {
return this.getClass().getName() + " - " + consumer.toString();
}
}
/**
* wrap {@link BiConsumer} to TTL wrapper.
*
* @param consumer input {@link BiConsumer}
* @return Wrapped {@link BiConsumer}
* @see TtlUnwrap#unwrap(Object)
* @since 2.12.4
*/
@Nullable
public static <T, U> BiConsumer<T, U> wrapBiConsumer(@Nullable BiConsumer<T, U> consumer) {
if (consumer == null) return null;
else if (consumer instanceof TtlEnhanced) return consumer;
else return new TtlBiConsumer<T, U>(consumer);
}
/**
* wrap input {@link BiConsumer} to TTL wrapper.
*
* @param consumer input {@link BiConsumer}
* @return Wrapped {@link BiConsumer}
* @see TtlUnwrap#unwrap(Object)
* @since 2.11.4
* @deprecated overload methods using the same name {@code wrap} is not readable
* and have the type inference problems in some case;
* so use {@link TtlWrappers#wrapBiConsumer(BiConsumer)} instead.
*/
@Deprecated
@Nullable
public static <T, U> BiConsumer<T, U> wrap(@Nullable BiConsumer<T, U> consumer) {
return wrapBiConsumer(consumer);
}
private static class TtlBiConsumer<T, U> implements BiConsumer<T, U>, TtlWrapper<BiConsumer<T, U>>, TtlEnhanced {
final BiConsumer<T, U> consumer;
final Object captured;
TtlBiConsumer(@NonNull BiConsumer<T, U> consumer) {
this.consumer = consumer;
this.captured = capture();
}
@Override
public void accept(T t, U u) {
final Object backup = replay(captured);
try {
consumer.accept(t, u);
} finally {
restore(backup);
}
}
@NonNull
@Override
public BiConsumer<T, U> unwrap() {
return consumer;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TtlBiConsumer<?, ?> that = (TtlBiConsumer<?, ?>) o;
return consumer.equals(that.consumer);
}
@Override
public int hashCode() {
return consumer.hashCode();
}
@Override
public String toString() {
return this.getClass().getName() + " - " + consumer.toString();
}
}
/**
* wrap {@link Function} to TTL wrapper.
*
* @param fn input {@link Function}
* @return Wrapped {@link Function}
* @see TtlUnwrap#unwrap(Object)
* @since 2.12.4
*/
@Nullable
public static <T, R> Function<T, R> wrapFunction(@Nullable Function<T, R> fn) {
if (fn == null) return null;
else if (fn instanceof TtlEnhanced) return fn;
else return new TtlFunction<T, R>(fn);
}
/**
* wrap {@link Function} to TTL wrapper.
*
* @param fn input {@link Function}
* @return Wrapped {@link Function}
* @see TtlUnwrap#unwrap(Object)
* @since 2.11.4
* @deprecated overload methods using the same name {@code wrap} is not readable
* and have the type inference problems in some case;
* so use {@link TtlWrappers#wrapFunction(Function)} instead.
*/
@Deprecated
@Nullable
public static <T, R> Function<T, R> wrap(@Nullable Function<T, R> fn) {
return wrapFunction(fn);
}
private static class TtlFunction<T, R> implements Function<T, R>, TtlWrapper<Function<T, R>>, TtlEnhanced {
final Function<T, R> fn;
final Object captured;
TtlFunction(@NonNull Function<T, R> fn) {
this.fn = fn;
this.captured = capture();
}
@Override
public R apply(T t) {
final Object backup = replay(captured);
try {
return fn.apply(t);
} finally {
restore(backup);
}
}
@NonNull
@Override
public Function<T, R> unwrap() {
return fn;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TtlFunction<?, ?> that = (TtlFunction<?, ?>) o;
return fn.equals(that.fn);
}
@Override
public int hashCode() {
return fn.hashCode();
}
@Override
public String toString() {
return this.getClass().getName() + " - " + fn.toString();
}
}
/**
* wrap {@link BiFunction} to TTL wrapper.
*
* @param fn input {@link BiFunction}
* @return Wrapped {@link BiFunction}
* @see TtlUnwrap#unwrap(Object)
* @since 2.12.4
*/
@Nullable
public static <T, U, R> BiFunction<T, U, R> wrapBiFunction(@Nullable BiFunction<T, U, R> fn) {
if (fn == null) return null;
else if (fn instanceof TtlEnhanced) return fn;
else return new TtlBiFunction<T, U, R>(fn);
}
/**
* wrap {@link BiFunction} to TTL wrapper.
*
* @param fn input {@link BiFunction}
* @return Wrapped {@link BiFunction}
* @see TtlUnwrap#unwrap(Object)
* @since 2.11.4
* @deprecated overload methods using the same name {@code wrap} is not readable
* and have the type inference problems in some case;
* so use {@link TtlWrappers#wrapBiFunction(BiFunction)} instead.
*/
@Deprecated
@Nullable
public static <T, U, R> BiFunction<T, U, R> wrap(@Nullable BiFunction<T, U, R> fn) {
return wrapBiFunction(fn);
}
private static class TtlBiFunction<T, U, R> implements BiFunction<T, U, R>, TtlWrapper<BiFunction<T, U, R>>, TtlEnhanced {
final BiFunction<T, U, R> fn;
final Object captured;
TtlBiFunction(@NonNull BiFunction<T, U, R> fn) {
this.fn = fn;
this.captured = capture();
}
@Override
public R apply(T t, U u) {
final Object backup = replay(captured);
try {
return fn.apply(t, u);
} finally {
restore(backup);
}
}
@NonNull
@Override
public BiFunction<T, U, R> unwrap() {
return fn;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TtlBiFunction<?, ?, ?> that = (TtlBiFunction<?, ?, ?>) o;
return fn.equals(that.fn);
}
@Override
public int hashCode() {
return fn.hashCode();
}
@Override
public String toString() {
return this.getClass().getName() + " - " + fn.toString();
}
}
private TtlWrappers() {
throw new InstantiationError("Must not instantiate this class");
}
}
|
package com.github.mjvesa.spil;
import javax.servlet.annotation.WebServlet;
import java.lang.StringBuffer;
import java.util.Properties;
import java.net.URL;
import java.nio.file.FileSystems;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.UI;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
import jscheme.JScheme;
import com.github.mjvesa.spil.WatchDir;
@Push
@Theme("base")
@Widgetset("com.vaadin.DefaultWidgetSet")
public class MyUI extends UI {
private String sourceDir;
private Button evalButton;
@Override
protected void init(VaadinRequest vaadinRequest) {
loadProps();
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSizeFull();
final VerticalLayout outputLayout = new VerticalLayout();
outputLayout.setSizeFull();
Button eval = new Button("Eval", event -> {
outputLayout.removeAllComponents();
final JScheme js = new JScheme();
js.eval("(begin " + loadBuffer() + ")");
js.call("main", outputLayout);
});
evalButton = eval;
eval.setClickShortcut(KeyCode.R, ModifierKey.CTRL);
VerticalLayout mainLayout =
new VerticalLayout(outputLayout, eval);
mainLayout.setSizeFull();
mainLayout.setExpandRatio(outputLayout, 1);
setContent(mainLayout);
new Thread() {
public void run() {
try {
new WatchDir(FileSystems.getDefault().getPath(sourceDir), true, () -> {
MyUI.this.access( new Runnable() {
public void run() {
evalButton.click();
}
});
}).processEvents();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
private String loadBuffer() {
StringBuffer sb = new StringBuffer();
try {
FileReader fr = new FileReader(new File(sourceDir + "main.scm"));
char[] chars = new char[100];
while (fr.ready()) {
int count = fr.read(chars);
sb.append(chars, 0, count);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
private void loadProps() {
try {
URL propsURL = getClass().getClassLoader().getResource("spil.properties");
Properties props = new Properties();
FileInputStream in = new FileInputStream(propsURL.getPath());
props.load(in);
in.close();
sourceDir = props.getProperty("PROJECT_DIR");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
|
package com.gmail.nossr50.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Furnace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
import org.bukkit.entity.NPC;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryEvent;
import org.bukkit.inventory.FurnaceInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.util.player.UserManager;
public final class Misc {
private static Random random = new Random();
public static final int TIME_CONVERSION_FACTOR = 1000;
public static final int TICK_CONVERSION_FACTOR = 20;
public static final long PLAYER_DATABASE_COOLDOWN_MILLIS = 1750;
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
// Sound Pitches & Volumes from CB
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values
public static final float FIZZ_VOLUME = 0.5F;
public static final float POP_VOLUME = 0.2F;
public static final float BAT_VOLUME = 1.0F;
public static final float BAT_PITCH = 0.6F;
public static final float GHAST_VOLUME = 1.0F;
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always
private Misc() {};
public static float getFizzPitch() {
return 2.6F + (getRandom().nextFloat() - getRandom().nextFloat()) * 0.8F;
}
public static float getPopPitch() {
return ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F;
}
public static float getGhastPitch() {
return (getRandom().nextFloat() - getRandom().nextFloat()) * 0.2F + 1.0F;
}
public static boolean isNPCEntity(Entity entity) {
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || (mcMMO.isCombatTagEnabled() && entity instanceof HumanEntity && ((HumanEntity) entity).getName().contains("PvpLogger")) || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
}
/**
* Get the upgrade tier of the item in hand.
*
* @param inHand The item to check the tier of
* @return the tier of the item
*/
public static int getTier(ItemStack inHand) {
int tier = 0;
if (ItemUtils.isWoodTool(inHand)) {
tier = 1;
}
else if (ItemUtils.isStoneTool(inHand)) {
tier = 2;
}
else if (ItemUtils.isIronTool(inHand)) {
tier = 3;
}
else if (ItemUtils.isGoldTool(inHand)) {
tier = 1;
}
else if (ItemUtils.isDiamondTool(inHand)) {
tier = 4;
}
else if (ModUtils.isCustomTool(inHand)) {
tier = ModUtils.getToolFromItemStack(inHand).getTier();
}
return tier;
}
/**
* Determine if two locations are near each other.
*
* @param first The first location
* @param second The second location
* @param maxDistance The max distance apart
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
*/
public static boolean isNear(Location first, Location second, double maxDistance) {
if (first.getWorld() != second.getWorld()) {
return false;
}
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
}
public static void dropItems(Location location, Collection<ItemStack> drops) {
for (ItemStack drop : drops) {
dropItem(location, drop);
}
}
/**
* Drop items at a given location.
*
* @param location The location to drop the items at
* @param is The items to drop
* @param quantity The amount of items to drop
*/
public static void dropItems(Location location, ItemStack is, int quantity) {
for (int i = 0; i < quantity; i++) {
dropItem(location, is);
}
}
/**
* Randomly drop an item at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param chance The percentage chance for the item to drop
*/
public static void randomDropItem(Location location, ItemStack is, double chance) {
if (random.nextInt(100) < chance) {
dropItem(location, is);
}
}
/**
* Drop items with random quantity at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param quantity The amount of items to drop
*/
public static void randomDropItems(Location location, ItemStack is, int quantity) {
int dropCount = random.nextInt(quantity + 1);
if (dropCount > 0) {
is.setAmount(dropCount);
dropItem(location, is);
}
}
public static void randomDropItems(Location location, Collection<ItemStack> drops, double chance) {
for (ItemStack item : drops) {
randomDropItem(location, item, chance);
}
}
/**
* Drop an item at a given location.
*
* @param location The location to drop the item at
* @param itemStack The item to drop
* @return Dropped Item entity or null if invalid or cancelled
*/
public static Item dropItem(Location location, ItemStack itemStack) {
if (itemStack.getType() == Material.AIR) {
return null;
}
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
return location.getWorld().dropItemNaturally(location, itemStack);
}
public static void profileCleanup(String playerName) {
UserManager.remove(playerName);
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player != null) {
UserManager.addUser(player);
}
}
public static void printProgress(int convertedUsers, int progressInterval, long startMillis) {
if ((convertedUsers % progressInterval) == 0) {
mcMMO.p.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR)));
}
}
public static void resendChunkRadiusAt(Player player, int radius) {
Chunk chunk = player.getLocation().getChunk();
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
for (int x = chunkX - radius; x < chunkX + radius; x++) {
for (int z = chunkZ - radius; z < chunkZ + radius; z++) {
player.getWorld().refreshChunk(x, z);
}
}
}
public static Block processInventoryOpenorCloseEvent(InventoryEvent event) {
Inventory inventory = event.getInventory();
if (!(inventory instanceof FurnaceInventory)) {
return null;
}
Furnace furnace = (Furnace) inventory.getHolder();
if (furnace == null || furnace.getBurnTime() != 0) {
return null;
}
return furnace.getBlock();
}
public static Player getPlayerFromFurnace(Block furnaceBlock) {
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
if (metadata.isEmpty()) {
return null;
}
return mcMMO.p.getServer().getPlayerExact(metadata.get(0).asString());
}
public static ItemStack getSmeltingFromFurnace(Block furnaceBlock) {
BlockState furnaceState = furnaceBlock.getState();
if (!(furnaceState instanceof Furnace)) {
return null;
}
return ((Furnace) furnaceState).getInventory().getSmelting();
}
public static ItemStack getResultFromFurnace(Block furnaceBlock) {
BlockState furnaceState = furnaceBlock.getState();
if (!(furnaceState instanceof Furnace)) {
return null;
}
return ((Furnace) furnaceState).getInventory().getResult();
}
/**
* Attempts to match any player names with the given name, and returns a list of all possibly matches.
*
* This list is not sorted in any particular order.
* If an exact match is found, the returned list will only contain a single result.
*
* @param partialName Name to match
* @return List of all possible names
*/
public static List<String> matchPlayer(String partialName) {
List<String> matchedPlayers = new ArrayList<String>();
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
String playerName = offlinePlayer.getName();
if (partialName.equalsIgnoreCase(playerName)) {
// Exact match
matchedPlayers.clear();
matchedPlayers.add(playerName);
break;
}
if (playerName.toLowerCase().contains(partialName.toLowerCase())) {
// Partial match
matchedPlayers.add(playerName);
}
}
return matchedPlayers;
}
/**
* Get a matched player name if one was found in the database.
*
* @param partialName Name to match
*
* @return Matched name or {@code partialName} if no match was found
*/
public static String getMatchedPlayerName(String partialName) {
if (Config.getInstance().getMatchOfflinePlayers()) {
List<String> matches = matchPlayer(partialName);
if (matches.size() == 1) {
partialName = matches.get(0);
}
}
else {
Player player = mcMMO.p.getServer().getPlayer(partialName);
if (player != null) {
partialName = player.getName();
}
}
return partialName;
}
public static Random getRandom() {
return random;
}
}
|
package com.rampatra.arrays;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* Given an array ar[] of n numbers and
* another number x, determine whether or not there
* exists two elements in ar[] whose sum is exactly x.
*
* @author rampatra
* @since 5/18/15
*/
public class PairSum {
/**
* Using sorting. If we use Merge Sort or Heap Sort
* then (-)(nlogn) in worst case. If we use Quick Sort
* then O(n^2) in worst case.
*
* @param ar
* @param sum
* @return
*/
static boolean pairSum(int[] ar, int sum) {
Arrays.sort(ar);
int len = ar.length;
for (int i = 0, j = len - 1; i < j; ) {
if (ar[i] + ar[j] == sum) {
return true;
} else if (ar[i] + ar[j] < sum) { // approach towards larger elements
i++;
} else { // approach towards smaller elements
j
}
}
return false;
}
/**
* Using hashmap in O(n) time.
*
* @param ar
* @param sum
* @param numSet
* @return
*/
static boolean pairSum(int[] ar, int sum, Set<Integer> numSet) {
for (int i = 0; i < ar.length; i++) {
if (numSet.contains(sum - ar[i])) {
return true;
}
numSet.add(ar[i]);
}
return false;
}
public static void main(String a[]) {
System.out.println(pairSum(new int[]{-3, 4, -6, 1, 1}, -2));
System.out.println(pairSum(new int[]{-3, 4, -6, 1, 1}, 5));
System.out.println(pairSum(new int[]{-3, 4, -6, 1, 1}, 0));
System.out.println("
System.out.println(pairSum(new int[]{-3, 4, -6, 1, 1}, -2, new HashSet<>()));
System.out.println(pairSum(new int[]{-3, 4, -6, 1, 1}, 5, new HashSet<>()));
System.out.println(pairSum(new int[]{-3, 4, -6, 1, 1}, 0, new HashSet<>()));
}
}
|
package com.twiki.tools;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.twiki.helper.AppStringUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.pdfbox.multipdf.Splitter;
import org.apache.pdfbox.pdmodel.PDDocument;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class PDFSplitter {
public static void splitPage(File pdfIn, Map<Integer, String> rangePages, File pdfOutFolder) throws IOException {
if (!pdfOutFolder.exists() || pdfOutFolder.isFile()) {
throw new IOException("Folder is not existed");
}
List<Integer> indexPages = Lists.newArrayList(rangePages.keySet());
Collections.sort(indexPages);
String name = AppStringUtils.slugify(FilenameUtils.getBaseName(pdfIn.getName()));
File bookFolder = new File(pdfOutFolder, name);
bookFolder.mkdir();
PDDocument document = PDDocument.load(pdfIn);
Splitter splitter = new Splitter() {
protected boolean splitAtPage(int pageNumber) {
return indexPages.contains(pageNumber);
}
};
List<PDDocument> splittedDocuments = splitter.split(document);
for (PDDocument pdDocument : splittedDocuments) {
int index = splittedDocuments.indexOf(pdDocument);
int fromPage = index == 0 ? 0 : indexPages.get(index - 1);
int toPage = (index == splittedDocuments.size() - 1) ? document.getNumberOfPages() : indexPages.get(index);
// String filename = String.format("%02d_%s_%s-%s_%s.pdf", index, name, fromPage + 1, toPage, rangePages.get(indexPages.get(index)));
String filename = String.format("%02d_%s", index, rangePages.get(indexPages.get(index)));
// String filename = String.format("%s.pdf", rangePages.get(indexPages.get(index)));
pdDocument.save(new File(bookFolder, AppStringUtils.slugify(filename) + ".pdf"));
}
}
public static void main(String[] args) throws IOException {
File pdfIn = new File("D:\\books\\english\\Writing Academic English, 4th Edition.pdf");
ImmutableMap<Integer, String> indexs = ImmutableMap.<Integer, String>builder()
.put(7, "Table of Content")
.put(10, "Preface")
.put(1 + 10, "PART I_WRITING A PARAGRAPH")
.put(17 + 10, "Chapter 1_Paragraph Structure")
.put(38 + 10, "Chapter 2_Unity and Coherence")
.put(54 + 10, "Chapter 3_Supporting Details Facts, Quotations, and Statistics")
.put(55 + 10, "Part II_ WRITING AN ESSAY")
.put(80 + 10, "Chapter 4_From Paragraph to Essay")
.put(93 + 10, "Chapter 5_Chronological Order Process Essays")
.put(110 + 10, "Chapter 6_Cause,Effect essays")
.put(126 + 10, "Chapter 7_Comparison,Contrast Essay")
.put(141 + 10, "Chapter 8_Paraphrase and Summary")
.put(160 + 10, "Chapter 9_Argumentative Essay")
.put(161 + 10, "Part III_SENTENCE STRUCTURE")
.put(178 + 10, "Chapter 10_Types of Sentences")
.put(193 + 10, "Chapter 11_Using Parallel Structures and Fixing Sentence Problems")
.put(209 + 10, "Chapter 12_Noun Clauses")
.put(229 + 10, "Chapter 13_Adverb Clauses")
.put(249 + 10, "Chapter 14_Adjective Clauses")
.put(264 + 10, "Chapter 15_Participial Phrases")
.put(279 + 10, "Appendix A_ The Process of Academic Writing")
.put(290 + 10, "Appendix B_Punctuation Rules")
.put(299 + 10, "Appendix C_Charts of Connecting Words and Transition Signals")
.put(302 + 10, "Appendix D_Editing Symbols")
.put(312 + 10, "Appendix E_Research and Documentation of Sources")
.put(330 + 10, "Appendix F_Self-Editing and Peer-Editing Worksheets")
.put(345, "Index and Credit")
.build();
splitPage(pdfIn, indexs, new File("D:\\books\\english"));
}
}
|
package com.zandero.rest;
import com.zandero.rest.context.ContextProvider;
import com.zandero.rest.context.ContextProviderFactory;
import com.zandero.rest.data.*;
import com.zandero.rest.exception.*;
import com.zandero.rest.injection.InjectionProvider;
import com.zandero.rest.reader.ReaderFactory;
import com.zandero.rest.reader.ValueReader;
import com.zandero.rest.writer.GenericResponseWriter;
import com.zandero.rest.writer.HttpResponseWriter;
import com.zandero.rest.writer.NotFoundResponseWriter;
import com.zandero.rest.writer.WriterFactory;
import com.zandero.utils.Assert;
import com.zandero.utils.extra.ValidatingUtils;
import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.auth.User;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.Session;
import io.vertx.ext.web.handler.BodyHandler;
import io.vertx.ext.web.handler.CookieHandler;
import io.vertx.ext.web.handler.CorsHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Builds up a vert.x route based on JAX-RS annotation provided in given class
*/
public class RestRouter {
private final static Logger log = LoggerFactory.getLogger(RestRouter.class);
private static final WriterFactory writers = new WriterFactory();
private static final ReaderFactory readers = new ReaderFactory();
private static final ExceptionHandlerFactory handlers = new ExceptionHandlerFactory();
private static final ContextProviderFactory providers = new ContextProviderFactory();
private static InjectionProvider injectionProvider;
/**
* Searches for annotations to register routes ...
*
* @param vertx Vert.X instance
* @param restApi instance to search for annotations
* @return Router new Router with routes as defined in {@code restApi} class
*/
public static Router register(Vertx vertx, Object... restApi) {
Assert.notNull(vertx, "Missing vertx!");
Router router = Router.router(vertx);
return register(router, restApi);
}
/**
* Searches for annotations to register routes ...
*
* @param restApi instance to search for annotations
* @param router to add additional routes from {@code restApi} class
* @return Router with routes as defined in {@code restApi} class
*/
public static Router register(Router router, Object... restApi) {
// TODO: split into smaller chucks
Assert.notNull(router, "Missing vertx router!");
Assert.isTrue(restApi != null && restApi.length > 0, "Missing REST API class object!");
assert restApi != null;
for (Object api : restApi) {
// check if api is an instance of a class or a class type
if (api instanceof Class) {
Class inspectApi = (Class) api;
try {
api = ClassFactory.newInstanceOf(inspectApi, injectionProvider, null);
}
catch (ClassFactoryException | ContextException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
Map<RouteDefinition, Method> definitions = AnnotationProcessor.get(api.getClass());
boolean bodyHandlerRegistered = false;
boolean cookieHandlerRegistered = false;
for (RouteDefinition definition : definitions.keySet()) {
// add BodyHandler in case request has a body ...
if (definition.requestHasBody() && !bodyHandlerRegistered) {
router.route().handler(BodyHandler.create());
bodyHandlerRegistered = true;
}
// add CookieHandler in case cookies are expected
if (definition.hasCookies() && !cookieHandlerRegistered) {
router.route().handler(CookieHandler.create());
cookieHandlerRegistered = true;
}
Method method = definitions.get(definition);
// add security check handler in front of regular route handler
if (definition.checkSecurity()) {
checkSecurity(router, definition);
}
// bind method execution
Route route;
if (definition.pathIsRegEx()) {
route = router.routeWithRegex(definition.getMethod(), definition.getRoutePath());
} else {
route = router.route(definition.getMethod(), definition.getRoutePath());
}
log.info("Registering route: " + definition);
if (definition.requestHasBody() && definition.getConsumes() != null) { // only register if request with body
for (MediaType item : definition.getConsumes()) {
route.consumes(MediaTypeHelper.getKey(item)); // ignore charset when binding
}
}
if (definition.getProduces() != null) {
for (MediaType item : definition.getProduces()) {
route.produces(MediaTypeHelper.getKey(item)); // ignore charset when binding
}
}
if (definition.getOrder() != 0) {
route.order(definition.getOrder());
}
// check body and reader compatibility beforehand
checkBodyReader(definition);
Method method = definitions.get(definition);
// bind handler // blocking or async
if (definition.isAsync()) {
Handler<RoutingContext> handler = getAsyncHandler(api, definition, method);
route.handler(handler);
} else {
try { // no way to know the accept content at this point
getWriter(injectionProvider, definition.getReturnType(), definition, null, null, GenericResponseWriter.class);
}
catch (ContextException | ClassFactoryException e) {
// not relevant at this point
}
}
Handler<RoutingContext> handler = getHandler(api, definition, method);
route.handler(handler);
}
}
return router;
}
public static void provide(Router output, Class<? extends ContextProvider> provider) {
try {
Class clazz = (Class) ClassFactory.getGenericType(provider);
ContextProvider instance = getContextProviders().getContextProvider(injectionProvider,
clazz,
provider,
null);
// set before other routes ...
output.route().order(Integer.MIN_VALUE).blockingHandler(getContextHandler(instance));
}
catch (ClassFactoryException | ContextException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
public static void provide(Router output, ContextProvider<?> provider) {
output.route().blockingHandler(getContextHandler(provider));
}
private static Handler<RoutingContext> getContextHandler(ContextProvider instance) {
return context -> {
if (instance != null) {
Object provided = instance.provide(context.request());
if (provided instanceof User) {
context.setUser((User) provided);
}
if (provided instanceof Session) {
context.setSession((Session) provided);
}
if (provided != null) {
context.data().put(ContextProviderFactory.getContextKey(provided), provided);
}
}
context.next();
};
}
@SuppressWarnings("unchecked")
public static void handler(Router output, Class<? extends Handler<RoutingContext>> handler) {
try {
Handler<RoutingContext> instance = (Handler<RoutingContext>) ClassFactory.newInstanceOf(handler, injectionProvider, null);
output.route().handler(instance);
}
catch (ClassFactoryException | ContextException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
/**
* Handles not found route for all requests
*
* @param router to add route to
* @param notFound handler
*/
public static void notFound(Router router, Class<? extends NotFoundResponseWriter> notFound) {
notFound(router, null, notFound);
}
/**
* Handles not found route for all requests
*
* @param router to add route to
* @param notFound handler
*/
public static void notFound(Router router, NotFoundResponseWriter notFound) {
notFound(router, null, notFound);
}
/**
* Handles not found route in case request path mathes given path prefix
*
* @param router to add route to
* @param path prefix
* @param notFound handler
*/
public static void notFound(Router router, String path, NotFoundResponseWriter notFound) {
Assert.notNull(router, "Missing router!");
Assert.notNull(notFound, "Missing not found handler!");
addLastHandler(router, path, getNotFoundHandler(notFound));
}
/**
* Handles not found route in case request path mathes given path prefix
*
* @param router to add route to
* @param path prefix
* @param notFound hander
*/
public static void notFound(Router router, String path, Class<? extends NotFoundResponseWriter> notFound) {
Assert.notNull(router, "Missing router!");
Assert.notNull(notFound, "Missing not found handler!");
addLastHandler(router, path, getNotFoundHandler(notFound));
}
private static void addLastHandler(Router router, String path, Handler<RoutingContext> notFoundHandler) {
if (path == null) {
router.route().last().handler(notFoundHandler);
} else {
if (!ValidatingUtils.isRegEx(path)) {
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.endsWith("/")) {
path = path + "/";
}
path = path.replaceAll("\\/", "\\\\/"); // escape path to be valid regEx
path = path + ".*";
}
router.routeWithRegex(path).last().handler(notFoundHandler);
}
}
/**
* @param router to add handler to
* @param allowedOriginPattern origin pattern
* @param allowCredentials allowed credentials
* @param maxAge in seconds
* @param allowedHeaders set of headers or null for none
* @param methods list of methods or empty for all
*/
public void enableCors(Router router,
String allowedOriginPattern,
boolean allowCredentials,
int maxAge,
Set<String> allowedHeaders,
HttpMethod... methods) {
CorsHandler handler = CorsHandler.create(allowedOriginPattern)
.allowCredentials(allowCredentials)
.maxAgeSeconds(maxAge);
if (methods == null || methods.length == 0) { // if not given than all
methods = HttpMethod.values();
}
for (HttpMethod method : methods) {
handler.allowedMethod(method);
}
handler.allowedHeaders(allowedHeaders);
router.route().handler(handler);
}
private static void checkBodyReader(RouteDefinition definition) {
if (!definition.requestHasBody() || !definition.hasBodyParameter()) {
return;
}
ValueReader bodyReader = readers.get(definition.getBodyParameter(), definition.getReader(), injectionProvider,
null,
definition.getConsumes());
if (bodyReader != null && definition.checkCompatibility()) {
Type readerType = ClassFactory.getGenericType(bodyReader.getClass());
MethodParameter bodyParameter = definition.getBodyParameter();
ClassFactory.checkIfCompatibleTypes(bodyParameter.getDataType(), readerType,
definition.toString().trim() + " - Parameter type: '" +
bodyParameter.getDataType() + "' not matching reader type: '" +
readerType + "' in: '" + bodyReader.getClass() + "'");
}
}
private static HttpResponseWriter getWriter(InjectionProvider injectionProvider,
Class returnType,
RouteDefinition definition,
MediaType acceptHeader,
RoutingContext context,
Class<? extends HttpResponseWriter> defaultTo) throws ContextException,
ClassFactoryException {
if (returnType == null) {
returnType = definition.getReturnType();
}
HttpResponseWriter writer = writers.getResponseWriter(returnType, definition, injectionProvider, context, acceptHeader);
if (writer == null) {
log.error("No writer could be provided. Falling back to " + defaultTo.getSimpleName() + " instead!");
return (HttpResponseWriter) ClassFactory.newInstanceOf(defaultTo);
}
if (definition.checkCompatibility() &&
ClassFactory.checkCompatibility(writer.getClass())) {
Type writerType = ClassFactory.getGenericType(writer.getClass());
ClassFactory.checkIfCompatibleTypes(returnType,
writerType,
definition.toString().trim() + " - Response type: '" +
returnType + "' not matching writer type: '" +
writerType + "' in: '" + writer.getClass() + "'");
}
//ContextProviderFactory.injectContext(writer, definition, context); // injects @Context if needed
return writer;
}
private static void checkSecurity(Router router, final RouteDefinition definition) {
Route route;
if (definition.pathIsRegEx()) {
route = router.routeWithRegex(definition.getMethod(), definition.getRoutePath());
} else {
route = router.route(definition.getMethod(), definition.getRoutePath());
}
route.order(definition.getOrder()); // same order as following handler
Handler<RoutingContext> securityHandler = getSecurityHandler(definition);
route.blockingHandler(securityHandler);
}
private static Handler<RoutingContext> getSecurityHandler(final RouteDefinition definition) {
return context -> {
boolean allowed = isAllowed(context.user(), definition);
if (allowed) {
context.next();
} else {
handleException(new ExecuteException(Response.Status.UNAUTHORIZED.getStatusCode(), "HTTP 401 Unauthorized"), context, definition);
}
};
}
private static boolean isAllowed(User user, RouteDefinition definition) {
if (definition.getPermitAll() != null) {
// allow all or deny all
return definition.getPermitAll();
}
if (user == null) {
return false; // no user present ... can't check
}
// check if given user is authorized for given role ...
List<Future> list = new ArrayList<>();
for (String role : definition.getRoles()) {
Future<Boolean> future = Future.future();
user.isAuthorized(role, future.completer());
list.add(future);
}
// compose multiple futures ... and return true if any of those return true
Future<CompositeFuture> output = Future.future();
CompositeFuture.all(list).setHandler(output.completer());
if (output.result() != null) {
for (int index = 0; index < output.result().size(); index++) {
if (output.result().succeeded(index)) {
Object result = output.result().resultAt(index);
if (result instanceof Boolean && ((Boolean) result)) {
return true;
}
}
}
}
return false;
}
private static Handler<RoutingContext> getHandler(final Object toInvoke, final RouteDefinition definition, final Method method) {
return context -> context.vertx().executeBlocking(
fut -> {
try {
Object[] args = ArgumentProvider.getArguments(method, definition, context, readers, providers, injectionProvider);
fut.complete(method.invoke(toInvoke, args));
}
catch (Exception e) {
fut.fail(e);
}
},
false,
res -> {
if (res.succeeded()) {
try {
Object result = res.result();
Class returnType = result != null ? result.getClass() : definition.getReturnType();
MediaType accept = MediaTypeHelper.valueOf(context.getAcceptableContentType());
HttpResponseWriter writer = getWriter(injectionProvider,
returnType,
definition,
accept,
context,
GenericResponseWriter.class);
produceResponse(res.result(), context, definition, writer);
}
catch (Exception e) {
handleException(e, context, definition);
}
} else {
handleException(res.cause(), context, definition);
}
}
);
}
private static Handler<RoutingContext> getAsyncHandler(final Object toInvoke, final RouteDefinition definition, final Method method) {
return context -> {
try {
Object[] args = ArgumentProvider.getArguments(method, definition, context, readers, providers, injectionProvider);
Object result = method.invoke(toInvoke, args);
if (result instanceof Future) {
Future<?> fut = (Future) result;
// wait for future to complete ... don't block vertx event bus in the mean time
fut.setHandler(handler -> {
if (fut.succeeded()) {
try {
Object futureResult = fut.result();
MediaType accept = MediaTypeHelper.valueOf(context.getAcceptableContentType());
HttpResponseWriter writer;
if (futureResult != null) { // get writer from result type otherwise we don't know
writer = getWriter(injectionProvider,
futureResult.getClass(),
definition,
accept,
context,
GenericResponseWriter.class);
} else { // due to limitations of Java generics we can't tell the type if response is null
Class<?> writerClass = definition.getWriter() == null ? GenericResponseWriter.class : definition.getWriter();
writer = (HttpResponseWriter) WriterFactory.newInstanceOf(writerClass);
}
produceResponse(futureResult, context, definition, writer);
}
catch (Exception e) {
handleException(e, context, definition);
}
} else {
handleException(fut.cause(), context, definition);
}
});
}
}
catch (Exception e) {
handleException(e, context, definition);
}
};
}
@SuppressWarnings("unchecked")
private static Handler<RoutingContext> getNotFoundHandler(Object notFoundWriter) {
return context -> {
try {
// fill up definition (response headers) from request
RouteDefinition definition = new RouteDefinition(context);
HttpResponseWriter writer;
if (notFoundWriter instanceof Class) {
writer = writers.getClassInstance((Class<? extends HttpResponseWriter>) notFoundWriter, injectionProvider, context);
} else {
writer = (HttpResponseWriter) notFoundWriter;
}
// TODO: XXX
//ContextProviderFactory.injectContext(writer, null, context);
produceResponse(null, context, definition, writer);
}
catch (Exception e) {
handleException(e, context, null);
}
};
}
@SuppressWarnings("unchecked")
private static void handleException(Throwable e, RoutingContext context, final RouteDefinition definition) {
log.error("Handling exception: ", e);
ExecuteException ex = getExecuteException(e);
// get appropriate exception handler/writer ...
ExceptionHandler handler;
try {
Class<? extends Throwable> clazz;
if (ex.getCause() == null) {
clazz = ex.getClass();
} else {
clazz = ex.getCause().getClass();
}
Class<? extends ExceptionHandler>[] exHandlers = null;
if (definition != null) {
exHandlers = definition.getExceptionHandlers();
}
handler = handlers.getExceptionHandler(clazz, exHandlers, injectionProvider, context);
}
catch (ClassFactoryException classException) {
// Can't provide exception handler ... rethrow
log.error("Can't provide exception handler!", classException);
// fall back to generic ...
handler = new GenericExceptionHandler();
ex = new ExecuteException(500, classException);
}
catch (ContextException contextException) {
// Can't provide @Context for handler ... rethrow
log.error("Can't provide @Context!", contextException);
// fall back to generic ...
handler = new GenericExceptionHandler();
ex = new ExecuteException(500, contextException);
}
HttpServerResponse response = context.response();
response.setStatusCode(ex.getStatusCode());
handler.addResponseHeaders(definition, response);
handler.write(ex.getCause(), context.request(), context.response());
// end response ...
if (!response.ended()) {
response.end();
}
}
private static ExecuteException getExecuteException(Throwable e) {
if (e instanceof ExecuteException) {
ExecuteException ex = (ExecuteException) e;
return new ExecuteException(ex.getStatusCode(), ex.getMessage(), ex);
}
// unwrap invoke exception ...
if (e instanceof IllegalAccessException || e instanceof InvocationTargetException) {
if (e.getCause() != null) {
return getExecuteException(e.getCause());
}
}
if (e instanceof IllegalArgumentException) {
return new ExecuteException(400, e);
}
return new ExecuteException(500, e);
}
@SuppressWarnings("unchecked")
private static void produceResponse(Object result, RoutingContext context, RouteDefinition definition, HttpResponseWriter writer) {
HttpServerResponse response = context.response();
HttpServerRequest request = context.request();
// add default response headers per definition
writer.addResponseHeaders(definition, response);
// write response and override headers if necessary
writer.write(result, request, response);
// finish if not finished by writer
// and is not an Async REST (Async RESTs must finish responses on their own)
if (!definition.isAsync() &&
!response.ended()) {
response.end();
}
}
public static WriterFactory getWriters() {
return writers;
}
public static ReaderFactory getReaders() {
return readers;
}
public static ExceptionHandlerFactory getExceptionHandlers() {
return handlers;
}
/**
* Registers a context provider for given type of class
*
* @param provider clazz type to be registered
*/
public static void addProvider(Class<? extends ContextProvider> provider) {
Class clazz = (Class) ClassFactory.getGenericType(provider);
providers.register(clazz, provider);
}
public static <T> void addProvider(Class<T> clazz, ContextProvider<T> provider) {
providers.register(clazz, provider);
}
public static ContextProviderFactory getContextProviders() {
return providers;
}
static void pushContext(RoutingContext context, Object object) {
Assert.notNull(context, "Missing context!");
Assert.notNull(object, "Can't push null into context!");
context.put(ContextProviderFactory.getContextKey(object), object);
}
/**
* Provide an injector to getInstance classes where needed
*
* @param provider to getInstance classes
*/
public static void injectWith(InjectionProvider provider) {
injectionProvider = provider;
}
/**
* Provide an injector to getInstance classes where needed
*
* @param provider to create to getInstance classes
*/
public static void injectWith(Class<InjectionProvider> provider) {
try {
injectionProvider = (InjectionProvider) ClassFactory.newInstanceOf(provider);
}
catch (ClassFactoryException e) {
throw new IllegalArgumentException(e);
}
}
}
|
package com.zierfisch.util;
import org.lwjgl.glfw.GLFWCursorPosCallback;
import static org.lwjgl.glfw.GLFW.*;
import org.lwjgl.glfw.GLFW;
public class MousePos extends GLFWCursorPosCallback{
private static double x = 0;
private static double y = 0;
private static double deltaX = 0;
private static double deltaY = 0;
public boolean focused = true;
@Override
public void invoke(long window, double xpos, double ypos) {
glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED);
if(focused){
deltaX = xpos - x;
deltaY = ypos - y;
}
x = xpos;
y = ypos;
}
public static double getXDelta(){
double temp = deltaX;
deltaX = 0;
return temp;
}
public static double getYDelta(){
double temp = deltaY;
deltaY = 0;
return temp;
}
}
|
package core.parsers;
import core.genome.Genome;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.TreeMap;
/**
* Parser for MetaData stored in .xlsx files.
*
* @author Arthur Breurkes.
* @version 1.0
* @since 23-05-2016.
*/
public final class MetaDataParser {
private static TreeMap<String, Genome> metadata = new TreeMap<>();
/**
* Class constructor
*/
private MetaDataParser() {
}
/**
* Reads a meta data file from disk.
*
* @param path The path to the meta data file.
*/
public static void readMetadataFromFile(String path) {
if (path != null && new File(path).exists()) {
try {
FileInputStream fileInputStream = new FileInputStream(path);
metadata = parse(fileInputStream);
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* Parses MetaData into a Treemap.
*
* @param stream an InputStream to read the xlsx sheet from.
* @return a TreeMap with genomes sorted on their name.
*/
public static TreeMap<String, Genome> parse(InputStream stream) {
TreeMap<String, Genome> metaMap = new TreeMap<>();
try {
XSSFWorkbook book = new XSSFWorkbook(stream);
XSSFSheet sheet = book.getSheetAt(0);
sheet.forEach(row -> {
parseRow(row, metaMap);
});
stream.close();
} catch (Exception e) {
e.printStackTrace();
}
return metaMap;
}
/**
* Return the lineage code belonging to a genome.
* <p>
* LINEAGE INT VALUES:
* 0 - Unknown.
* 1-7 - normal numeric.
* 8 - animal.
* 9 - B.
* 10 - CANETTII.
*
* @param s lineage string.
* @return lineage code.
*/
public static int detLineage(String s) {
if (s.equals("unknown")) {
return 0;
} else if (s.equals("LIN animal")) {
return 8;
} else if (s.equals("LIN B")) {
return 9;
} else if (s.equals("LIN CANETTII")) {
return 10;
} else {
return Integer.parseInt(s.replace("LIN ", ""));
}
}
/**
* Gets the meta data.
*
* @return The meta data.
*/
public static TreeMap<String, Genome> getMetadata() {
return metadata;
}
/**
* Method to parse a row.
* @param row the row to be parsed.
* @param metaMap map to put results in.
*/
public static void parseRow(Row row, TreeMap<String, Genome> metaMap) {
if (row.getCell(0) != null && row.getCell(0).getStringCellValue().contains("TKK")) {
String name = row.getCell(0).getStringCellValue();
Genome gen = new Genome(name);
for (int i = 1; i < 28; i++) {
switchRow1(i, row, gen);
switchRow2(i, row, gen);
metaMap.put(name, gen);
}
}
}
/**
* Check all columns of a row.
* @param i - index of column
* @param row - the row
* @param gen - genomes
*/
private static void switchRow1(int i, Row row, Genome gen) {
switch (i) {
case 1:
if (row.getCell(1).getCellType() == 0) {
gen.setAge((int) row.getCell(1).getNumericCellValue());
}
break;
case 2: gen.setSex(row.getCell(2).getStringCellValue());
break;
case 3: gen.setHiv(row.getCell(3).getStringCellValue());
break;
case 4: gen.setCohort(row.getCell(4).getStringCellValue());
break;
case 6: gen.setStudyDistrict(row.getCell(6).getStringCellValue());
break;
case 7: gen.setSpecimenType(row.getCell(7).getStringCellValue());
break;
case 8: gen.setSmearStatus(row.getCell(8).getStringCellValue());
break;
case 10: gen.setIsolation(row.getCell(10).getStringCellValue());
break;
case 11: gen.setPhenoDST(row.getCell(11).getStringCellValue());
break;
case 12: gen.setCapreomycin(row.getCell(12).getStringCellValue());
break;
case 13: gen.setEthambutol(row.getCell(13).getStringCellValue());
break;
default: break;
}
}
/**
* Check all columns of a row.
* @param i - index of column
* @param row - the row
* @param gen - genomes
*/
private static void switchRow2(int i, Row row, Genome gen) {
switch (i) {
case 14: gen.setEthionamide(row.getCell(14).getStringCellValue());
break;
case 16: gen.setIsoniazid(row.getCell(15).getStringCellValue());
break;
case 17: gen.setKanamycin(row.getCell(16).getStringCellValue());
break;
case 18: gen.setPyrazinamide(row.getCell(18).getStringCellValue());
break;
case 19: gen.setOfloxacin(row.getCell(19).getStringCellValue());
break;
case 20: gen.setRifampin(row.getCell(20).getStringCellValue());
break;
case 21: gen.setStreptomycin(row.getCell(21).getStringCellValue());
break;
case 22: gen.setSpoligotype(row.getCell(22).getStringCellValue());
break;
case 23: gen.setLineage(detLineage(row.getCell(23).getStringCellValue()));
break;
case 24: gen.setGenoDST(row.getCell(24).getStringCellValue());
break;
case 26: gen.setTf(row.getCell(26).getStringCellValue());
break;
default: break;
}
}
}
|
package cronapi.database;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
import org.eclipse.persistence.descriptors.DescriptorQueryManager;
import org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.security.core.GrantedAuthority;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializable;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.ser.SerializerCache.TypeKey;
import cronapi.RestClient;
import cronapi.SecurityBeanFilter;
import cronapi.Utils;
import cronapi.Var;
import cronapi.cloud.CloudFactory;
import cronapi.cloud.CloudManager;
import cronapi.i18n.Messages;
import cronapi.rest.security.CronappSecurity;
/**
* Class database manipulation, responsible for querying, inserting,
* updating and deleting database data procedurally, allowing paged
* navigation and setting page size.
*
* @author robson.ataide
* @version 1.0
* @since 2017-04-26
*
*/
public class DataSource implements JsonSerializable {
private String entity;
private String simpleEntity;
private Class domainClass;
private String filter;
private Var[] params;
private int pageSize;
private Page page;
private int index;
private int current;
private Pageable pageRequest;
private Object insertedElement = null;
private EntityManager customEntityManager;
private DataSourceFilter dsFilter;
private boolean multiTenant = true;
/**
* Init a datasource with a page size equals 100
*
* @param entity
* - full name of entitiy class like String
*/
public DataSource(String entity) {
this(entity, 100);
}
/**
* Init a datasource with a page size equals 100, and custom entity manager
*
* @param entity
* - full name of entitiy class like String
* @param entityManager
* - custom entity manager
*/
public DataSource(String entity, EntityManager entityManager) {
this(entity, 100);
this.customEntityManager = entityManager;
}
/**
* Init a datasource setting a page size
*
* @param entity
* - full name of entitiy class like String
* @param pageSize
* - page size of a Pageable object retrieved from repository
*/
public DataSource(String entity, int pageSize) {
this.entity = entity;
this.simpleEntity = entity.substring(entity.lastIndexOf(".") + 1);
this.pageSize = pageSize;
this.pageRequest = new PageRequest(0, pageSize);
// initialize dependencies and necessaries objects
this.instantiateRepository();
}
private EntityManager getEntityManager(Class domainClass) {
if(customEntityManager != null)
return customEntityManager;
else
return TransactionManager.getEntityManager(domainClass);
}
public Class getDomainClass() {
return domainClass;
}
public String getSimpleEntity() {
return simpleEntity;
}
public String getEntity() {
return entity;
}
/**
* Retrieve repository from entity
*
* @throws RuntimeException
* when repository not fount, entity passed not found or cast repository
*/
private void instantiateRepository() {
try {
domainClass = Class.forName(this.entity);
}
catch(ClassNotFoundException cnfex) {
throw new RuntimeException(cnfex);
}
}
private List<String> parseParams(String SQL) {
final String delims = " \n\r\t.(){},+:=!";
final String quots = "\'";
String token = "";
boolean isQuoted = false;
List<String> tokens = new LinkedList<>();
for(int i = 0; i < SQL.length(); i++) {
if(quots.indexOf(SQL.charAt(i)) != -1) {
isQuoted = token.length() == 0;
}
if(delims.indexOf(SQL.charAt(i)) == -1 || isQuoted) {
token += SQL.charAt(i);
}
else {
if(token.length() > 0) {
if(token.startsWith(":"))
tokens.add(token.substring(1));
token = "";
isQuoted = false;
}
if(SQL.charAt(i) == ':') {
token = ":";
}
}
}
if(token.length() > 0) {
if(token.startsWith(":"))
tokens.add(token.substring(1));
}
return tokens;
}
/**
* Retrieve objects from database using repository when filter is null or empty,
* if filter not null or is not empty, this method uses entityManager and create a
* jpql instruction.
*
* @return a array of Object
*/
public Object[] fetch() {
String jpql = this.filter;
Var[] params = this.params;
if(jpql == null) {
jpql = "select e from " + simpleEntity + " e";
}
boolean containsNoTenant = jpql.contains("/*notenant*/");
jpql = jpql.replace("/*notenant*/", "");
boolean disableMT = false;
if (!multiTenant || containsNoTenant) {
disableMT = true;
}
if(dsFilter != null) {
dsFilter.applyTo(domainClass, jpql, params);
params = dsFilter.getAppliedParams();
jpql = dsFilter.getAppliedJpql();
}
try {
EntityManager em = getEntityManager(domainClass);
for(EntityType type: em.getMetamodel().getEntities()) {
DescriptorQueryManager old = ((EntityTypeImpl) type).getDescriptor().getQueryManager();
if (CronappDescriptorQueryManager.needProxy(old)) {
((EntityTypeImpl) type).getDescriptor().setQueryManager(CronappDescriptorQueryManager.build(old));
}
}
if (disableMT) {
CronappDescriptorQueryManager.disableMultitenant();
}
TypedQuery<?> query = em.createQuery(jpql, domainClass);
int i = 0;
List<String> parsedParams = parseParams(jpql);
for(String param : parsedParams) {
Var p = null;
if(i <= params.length - 1) {
p = params[i];
}
if(p != null) {
if(p.getId() != null) {
query.setParameter(p.getId(), p.getObject(query.getParameter(p.getId()).getParameterType()));
}
else {
query.setParameter(param, p.getObject(query.getParameter(parsedParams.get(i)).getParameterType()));
}
}
else {
query.setParameter(param, null);
}
i++;
}
query.setFirstResult(this.pageRequest.getPageNumber() * this.pageRequest.getPageSize());
query.setMaxResults(this.pageRequest.getPageSize());
List<?> resultsInPage = query.getResultList();
this.page = new PageImpl(resultsInPage, this.pageRequest, 0);
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
finally {
if (disableMT) {
CronappDescriptorQueryManager.enableMultitenant();
}
}
// has data, moves cursor to first position
if(this.page.getNumberOfElements() > 0)
this.current = 0;
return this.page.getContent().toArray();
}
public EntityMetadata getMetadata() {
return new EntityMetadata(domainClass);
}
/**
* Create a new instance of entity and add a
* results and set current (index) for his position
*/
public void insert() {
try {
this.insertedElement = this.domainClass.newInstance();
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
public Object toObject(Map<?, ?> values) {
try {
Object insertedElement = this.domainClass.newInstance();
for(Object key : values.keySet()) {
updateField(insertedElement, key.toString(), values.get(key));
}
return insertedElement;
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
public void insert(Object value) {
try {
if(value instanceof Map) {
this.insertedElement = this.domainClass.newInstance();
Map<?, ?> values = (Map<?, ?>)value;
for(Object key : values.keySet()) {
try {
updateField(key.toString(), values.get(key));
}
catch(Exception e) {
}
}
}
else {
this.insertedElement = value;
}
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
public Object save() {
return save(true);
}
private void processCloudFields() {
Object toSave;
if(this.insertedElement != null)
toSave = this.insertedElement;
else
toSave = this.getObject();
List<String> fieldsAnnotationCloud = Utils.getFieldsWithAnnotationCloud(toSave, "dropbox");
List<String> fieldsIds = Utils.getFieldsWithAnnotationId(toSave);
if (fieldsAnnotationCloud.size() > 0) {
String dropAppAccessToken = Utils.getAnnotationCloud(toSave, fieldsAnnotationCloud.get(0)).value();
CloudManager cloudManager = CloudManager.newInstance().byID(fieldsIds.toArray(new String[0])).toFields(fieldsAnnotationCloud.toArray(new String[0]));
CloudFactory factory = cloudManager.byEntity(toSave).build();
factory.dropbox(dropAppAccessToken).upload();
factory.getFiles().forEach(f-> {
updateField(toSave, f.getFieldReference(), f.getFileDirectUrl());
});
}
}
/**
* Saves the object in the current index or a new object when has insertedElement
*/
public Object save(boolean returnCursorAfterInsert) {
try {
processCloudFields();
Object toSave;
EntityManager em = getEntityManager(domainClass);
em.getMetamodel().entity(domainClass);
if(!em.getTransaction().isActive()) {
em.getTransaction().begin();
}
if(this.insertedElement != null) {
toSave = this.insertedElement;
if(returnCursorAfterInsert)
this.insertedElement = null;
em.persist(toSave);
}
else
toSave = this.getObject();
Object saved = em.merge(toSave);
return saved;
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
public void delete(Var[] primaryKeys) {
insert();
int i = 0;
Var[] params = new Var[primaryKeys.length];
EntityManager em = getEntityManager(domainClass);
EntityType type = em.getMetamodel().entity(domainClass);
String jpql = " DELETE FROM " + entity.substring(entity.lastIndexOf(".") + 1) + " WHERE ";
List<TypeKey> keys = getKeys(type);
for(TypeKey key : keys) {
jpql += "" + key.name + " = :p" + i;
params[i] = Var.valueOf("p" + i, primaryKeys[i].getObject(key.field.getType().getJavaType()));
i++;
}
execute(jpql, params);
}
/**
* Removes the object in the current index
*/
public void delete() {
try {
Object toRemove = this.getObject();
EntityManager em = getEntityManager(domainClass);
if(!em.getTransaction().isActive()) {
em.getTransaction().begin();
}
// returns managed instance
toRemove = em.merge(toRemove);
em.remove(toRemove);
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
/**
* Update a field from object in the current index
*
* @param fieldName
* - attributte name in entity
* @param fieldValue
* - value that replaced or inserted in field name passed
*/
public void updateField(String fieldName, Object fieldValue) {
updateField(getObject(), fieldName, fieldValue);
}
private void updateField(Object obj, String fieldName, Object fieldValue) {
try {
boolean update = true;
if(RestClient.getRestClient().isFilteredEnabled()) {
update = SecurityBeanFilter.includeProperty(obj.getClass(), fieldName, null);
}
if(update) {
Method setMethod = Utils.findMethod(obj, "set" + fieldName);
if(setMethod != null) {
if(fieldValue instanceof Var) {
fieldValue = ((Var)fieldValue).getObject(setMethod.getParameterTypes()[0]);
}
else {
Var tVar = Var.valueOf(fieldValue);
fieldValue = tVar.getObject(setMethod.getParameterTypes()[0]);
}
setMethod.invoke(obj, fieldValue);
}
else {
throw new RuntimeException("Field " + fieldName + " not found");
}
}
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
/**
* Update fields from object in the current index
*
* @param fields
* - bidimensional array like fields
* sample: { {"name", "Paul"}, {"age", "21"} }
*
* @thows RuntimeException if a field is not accessible through a set method
*/
public void updateFields(Var ... fields) {
for(Var field : fields) {
updateField(field.getId(), field.getObject());
}
}
public void filter(Var data, Var[] extraParams) {
EntityManager em = getEntityManager(domainClass);
EntityType type = em.getMetamodel().entity(domainClass);
int i = 0;
String jpql = " select e FROM " + entity.substring(entity.lastIndexOf(".") + 1) + " e WHERE ";
Vector<Var> params = new Vector<>();
for(Object obj : type.getAttributes()) {
SingularAttribute field = (SingularAttribute)obj;
if(field.isId()) {
if(i > 0) {
jpql += " AND ";
}
jpql += "e." + field.getName() + " = :p" + i;
params.add(Var.valueOf("p" + i, data.getField(field.getName()).getObject(field.getType().getJavaType())));
i++;
}
}
if(extraParams != null) {
for(Var p : extraParams) {
jpql += "e." + p.getId() + " = :p" + i;
params.add(Var.valueOf("p" + i, p.getObject()));
i++;
}
}
Var[] arr = params.toArray(new Var[params.size()]);
filter(jpql, arr);
}
public void update(Var data) {
try {
List<String> fieldsByteHeaderSignature = cronapi.Utils.getFieldsWithAnnotationByteHeaderSignature(getObject());
LinkedList<String> fields = data.keySet();
for(String key : fields) {
if (!fieldsByteHeaderSignature.contains(key) || isFieldByteWithoutHeader(key, data.getField(key))) {
if(!key.equalsIgnoreCase(Class.class.getSimpleName())) {
this.updateField(key, data.getField(key));
}
}
}
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
private boolean isFieldByteWithoutHeader(String fieldName, Object fieldValue) {
boolean result = false;
if(fieldValue instanceof Var) {
if (((Var)fieldValue).getObject() == null)
return true;
else if (cronapi.util.StorageService.isTempFileJson(((Var)fieldValue).getObject().toString()))
return true;
}
Method setMethod = Utils.findMethod(getObject(), "set" + fieldName);
if (setMethod!=null) {
if(fieldValue instanceof Var) {
fieldValue = ((Var)fieldValue).getObject(setMethod.getParameterTypes()[0]);
}
else {
Var tVar = Var.valueOf(fieldValue);
fieldValue = tVar.getObject(setMethod.getParameterTypes()[0]);
}
Object header = cronapi.util.StorageService.getFileBytesMetadata((byte[])fieldValue);
result = (header == null);
}
return result;
}
/**
* Return object in current index
*
* @return Object from database in current position
*/
public Object getObject() {
if(this.insertedElement != null)
return this.insertedElement;
if(this.current < 0 || this.current > this.page.getContent().size() - 1)
return null;
return this.page.getContent().get(this.current);
}
/**
* Return field passed from object in current index
*
* @return Object value of field passed
* @thows RuntimeException if a field is not accessible through a set method
*/
public Object getObject(String fieldName) {
try {
Method getMethod = Utils.findMethod(getObject(), "get" + fieldName);
if(getMethod != null)
return getMethod.invoke(getObject());
return null;
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
/**
* Moves the index for next position, in pageable case,
* looking for next page and so on
*/
public void next() {
if(this.page.getNumberOfElements() > (this.current + 1))
this.current++;
else {
if(this.page.hasNext()) {
this.pageRequest = this.page.nextPageable();
this.fetch();
this.current = 0;
}
else {
this.current = -1;
}
}
}
/**
* Moves the index for next position, in pageable case,
* looking for next page and so on
*/
public void nextOnPage() {
this.current++;
}
/**
* Verify if can moves the index for next position,
* in pageable case, looking for next page and so on
*
* @return boolean true if has next, false else
*/
public boolean hasNext() {
if(this.page.getNumberOfElements() > (this.current + 1))
return true;
else {
if(this.page.hasNext()) {
return true;
}
else {
return false;
}
}
}
public boolean hasData() {
return getObject() != null;
}
/**
* Moves the index for previous position, in pageable case,
* looking for next page and so on
*
* @return boolean true if has previous, false else
*/
public boolean previous() {
if(this.current - 1 >= 0) {
this.current
}
else {
if(this.page.hasPrevious()) {
this.pageRequest = this.page.previousPageable();
this.fetch();
this.current = this.page.getNumberOfElements() - 1;
}
else {
return false;
}
}
return true;
}
public void setCurrent(int current) {
this.current = current;
}
public int getCurrent() {
return this.current;
}
/**
* Gets a Pageable object retrieved from repository
*
* @return pageable from repository, returns null when fetched by filter
*/
public Page getPage() {
return this.page;
}
/**
* Create a new page request with size passed
*
* @param pageSize
* size of page request
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
this.pageRequest = new PageRequest(0, pageSize);
this.current = -1;
}
/**
* Fetch objects from database by a filter
*
* @param filter
* jpql instruction like a namedQuery
* @param params
* parameters used in jpql instruction
*/
public void filter(String filter, Var ... params) {
this.filter = filter;
this.params = params;
this.pageRequest = new PageRequest(0, pageSize);
this.current = -1;
this.fetch();
}
public void setDataSourceFilter(DataSourceFilter dsFilter) {
this.dsFilter = dsFilter;
}
public void filter(String filter, PageRequest pageRequest, Var ... params) {
if(filter == null) {
if(params.length > 0) {
EntityManager em = getEntityManager(domainClass);
EntityType type = em.getMetamodel().entity(domainClass);
int i = 0;
String jpql = "Select e from " + simpleEntity + " e where (";
for(Object obj : type.getAttributes()) {
SingularAttribute field = (SingularAttribute)obj;
if(field.isId()) {
if(i > 0) {
jpql += " and ";
}
jpql += "e." + field.getName() + " = :p" + i;
params[i].setId("p" + i);
}
}
jpql += ")";
filter = jpql;
}
else {
filter = "Select e from " + simpleEntity + " e ";
}
}
this.params = params;
this.filter = filter;
this.pageRequest = pageRequest;
this.current = -1;
this.fetch();
}
private Class forName(String name) {
try {
return Class.forName(name);
}
catch(ClassNotFoundException e) {
return null;
}
}
private Object newInstance(String name) {
try {
return Class.forName(name).newInstance();
}
catch(Exception e) {
return null;
}
}
private static class TypeKey {
String name;
SingularAttribute field;
}
private void addKeys(EntityManager em, EntityType type, String parent, List<TypeKey> keys) {
for(Object obj : type.getAttributes()) {
SingularAttribute field = (SingularAttribute)obj;
if(field.isId()) {
if(field.getType().getPersistenceType() == Type.PersistenceType.BASIC) {
TypeKey key = new TypeKey();
key.name = parent == null ? field.getName() : parent + "." + field.getName();
key.field = field;
keys.add(key);
}
else {
EntityType subType = (EntityType)field.getType();
addKeys(em, subType, (parent == null ? field.getName() : parent + "." + field.getName()), keys);
}
}
}
}
private List<TypeKey> getKeys(EntityType type) {
EntityManager em = getEntityManager(domainClass);
List<TypeKey> keys = new LinkedList<>();
addKeys(em, type, null, keys);
return keys;
}
public void deleteRelation(String refId, Var[] primaryKeys, Var[] relationKeys) {
EntityMetadata metadata = getMetadata();
RelationMetadata relationMetadata = metadata.getRelations().get(refId);
EntityManager em = getEntityManager(domainClass);
int i = 0;
String jpql = null;
Var[] params = null;
if(relationMetadata.getAssossiationName() != null) {
params = new Var[relationKeys.length + primaryKeys.length];
jpql = " DELETE FROM " + relationMetadata.gettAssossiationSimpleName() + " WHERE ";
EntityType type = em.getMetamodel().entity(domainClass);
List<TypeKey> keys = getKeys(type);
for(TypeKey key : keys) {
if(i > 0) {
jpql += " AND ";
}
jpql += relationMetadata.getAssociationAttribute().getName() + "." + key.name + " = :p" + i;
params[i] = Var.valueOf("p" + i, primaryKeys[i].getObject(key.field.getType().getJavaType()));
i++;
}
int v = 0;
type = em.getMetamodel().entity(forName(relationMetadata.getAssossiationName()));
keys = getKeys(type);
for(TypeKey key : keys) {
if(i > 0) {
jpql += " AND ";
}
jpql += relationMetadata.getAttribute().getName() + "." + key.name + " = :p" + i;
params[i] = Var.valueOf("p" + i, relationKeys[v].getObject(key.field.getType().getJavaType()));
i++;
v++;
}
}
else {
params = new Var[relationKeys.length];
jpql = " DELETE FROM " + relationMetadata.getSimpleName() + " WHERE ";
EntityType type = em.getMetamodel().entity(forName(relationMetadata.getName()));
List<TypeKey> keys = getKeys(type);
for(TypeKey key : keys) {
if(i > 0) {
jpql += " AND ";
}
jpql += "" + key.name + " = :p" + i;
params[i] = Var.valueOf("p" + i, relationKeys[i].getObject(key.field.getType().getJavaType()));
i++;
}
}
execute(jpql, params);
}
public Object insertRelation(String refId, Map<?, ?> data, Var ... primaryKeys) {
EntityMetadata metadata = getMetadata();
RelationMetadata relationMetadata = metadata.getRelations().get(refId);
EntityManager em = getEntityManager(domainClass);
filter(null, new PageRequest(0, 100), primaryKeys);
Object insertion = null;
Object result = null;
if(relationMetadata.getAssossiationName() != null) {
insertion = this.newInstance(relationMetadata.getAssossiationName());
updateField(insertion, relationMetadata.getAttribute().getName(),
Var.valueOf(data).getObject(forName(relationMetadata.getName())));
updateField(insertion, relationMetadata.getAssociationAttribute().getName(), getObject());
result = getObject();
}
else {
insertion = Var.valueOf(data).getObject(forName(relationMetadata.getName()));
updateField(insertion, relationMetadata.getAttribute().getName(), getObject());
result = insertion;
}
if(!em.getTransaction().isActive()) {
em.getTransaction().begin();
}
em.persist(insertion);
return result;
}
public void filterByRelation(String refId, PageRequest pageRequest, Var ... primaryKeys) {
EntityMetadata metadata = getMetadata();
RelationMetadata relationMetadata = metadata.getRelations().get(refId);
EntityManager em = getEntityManager(domainClass);
EntityType type = null;
String name = null;
String selectAttr = "";
String filterAttr = relationMetadata.getAttribute().getName();
type = em.getMetamodel().entity(domainClass);
if(relationMetadata.getAssossiationName() != null) {
name = relationMetadata.gettAssossiationSimpleName();
selectAttr = "." + relationMetadata.getAttribute().getName();
filterAttr = relationMetadata.getAssociationAttribute().getName();
try {
domainClass = Class.forName(relationMetadata.getAttribute().getJavaType().getName());
}
catch(ClassNotFoundException e) {
}
}
else {
name = relationMetadata.getSimpleName();
try {
domainClass = Class.forName(name);
}
catch(ClassNotFoundException e) {
}
}
int i = 0;
String jpql = "Select e" + selectAttr + " from " + name + " e where ";
for(Object obj : type.getAttributes()) {
SingularAttribute field = (SingularAttribute)obj;
if(field.isId()) {
if(i > 0) {
jpql += " and ";
}
jpql += "e." + filterAttr + "." + field.getName() + " = :p" + i;
primaryKeys[i].setId("p" + i);
}
}
filter(jpql, pageRequest, primaryKeys);
}
/**
* Clean Datasource and to free up allocated memory
*/
public void clear() {
this.pageRequest = new PageRequest(0, 100);
this.current = -1;
this.page = null;
}
/**
* Execute Query
*
* @param query
* - JPQL instruction for filter objects to remove
* @param params
* - Bidimentional array with params name and params value
*/
public void execute(String query, Var ... params) {
try {
EntityManager em = getEntityManager(domainClass);
TypedQuery<?> strQuery = em.createQuery(query, domainClass);
for(Var p : params) {
strQuery.setParameter(p.getId(), p.getObject());
}
try {
if(!em.getTransaction().isActive()) {
em.getTransaction().begin();
}
strQuery.executeUpdate();
}
catch(Exception e) {
throw new RuntimeException(e);
}
}
catch(Exception ex) {
throw new RuntimeException(ex);
}
}
public Var getTotalElements() {
return new Var(this.page.getTotalElements());
}
@Override
public String toString() {
if(this.page != null) {
return this.page.getContent().toString();
}
else {
return "[]";
}
}
@Override
public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeObject(this.page.getContent());
}
@Override
public void serializeWithType(JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer)
throws IOException {
gen.writeObject(this.page.getContent());
}
public void checkRESTSecurity(String method) throws Exception {
checkRESTSecurity(domainClass, method);
}
public void checkRESTSecurity(String relationId, String method) throws Exception {
EntityMetadata metadata = getMetadata();
RelationMetadata relationMetadata = metadata.getRelations().get(relationId);
checkRESTSecurity(Class.forName(relationMetadata.getName()), method);
}
private void checkRESTSecurity(Class clazz, String method) throws Exception {
Annotation security = clazz.getAnnotation(CronappSecurity.class);
boolean authorized = false;
if(security instanceof CronappSecurity) {
CronappSecurity cronappSecurity = (CronappSecurity)security;
Method methodPermission = cronappSecurity.getClass().getMethod(method.toLowerCase());
if(methodPermission != null) {
String value = (String)methodPermission.invoke(cronappSecurity);
if(value == null || value.trim().isEmpty()) {
value = "authenticated";
}
String[] authorities = value.trim().split(";");
for(String role : authorities) {
if(role.equalsIgnoreCase("authenticated")) {
authorized = RestClient.getRestClient().getUser() != null;
if(authorized)
break;
}
if(role.equalsIgnoreCase("permitAll") || role.equalsIgnoreCase("public")) {
authorized = true;
break;
}
for(GrantedAuthority authority : RestClient.getRestClient().getAuthorities()) {
if(role.equalsIgnoreCase(authority.getAuthority())) {
authorized = true;
break;
}
}
if(authorized)
break;
}
}
}
if(!authorized) {
throw new RuntimeException(Messages.getString("notAllowed"));
}
}
public void disableMultiTenant() {
this.multiTenant = false;
}
public void enableMultiTenant() {
this.multiTenant = true;
}
}
|
package cubicchunks.world.cube;
import com.google.common.base.Predicate;
import cubicchunks.CubicChunks;
import cubicchunks.util.AddressTools;
import cubicchunks.util.Coords;
import cubicchunks.util.CubeCoords;
import cubicchunks.world.EntityContainer;
import cubicchunks.world.ICubicWorld;
import cubicchunks.world.IOpacityIndex;
import cubicchunks.world.column.Column;
import cubicchunks.worldgen.GeneratorStage;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.crash.ICrashReportDetail;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ReportedException;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import org.apache.logging.log4j.Logger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
public class Cube {
private static final Logger LOGGER = CubicChunks.LOGGER;
private ICubicWorld world;
private Column column;
private CubeCoords coords;
private boolean isModified;
private final ExtendedBlockStorage storage;
private EntityContainer entities;
private Map<BlockPos, TileEntity> tileEntityMap;
private GeneratorStage targetStage;
private GeneratorStage currentStage;
private boolean needsRelightAfterLoad;
/**
* "queue containing the BlockPos of tile entities queued for creation"
*/
private ConcurrentLinkedQueue<BlockPos> tileEntityPosQueue;
private final LightUpdateData lightUpdateData = new LightUpdateData(this);
private boolean isCubeLoaded;
public Cube(ICubicWorld world, Column column, int x, int y, int z, boolean isModified) {
this.world = world;
this.column = column;
this.coords = new CubeCoords(x, y, z);
this.isModified = isModified;
this.storage = new ExtendedBlockStorage(Coords.cubeToMinBlock(y), !world.getProvider().getHasNoSky());
this.entities = new EntityContainer();
this.tileEntityMap = new HashMap<>();
this.currentStage = null;
this.needsRelightAfterLoad = false;
this.tileEntityPosQueue = new ConcurrentLinkedQueue<>();
}
public IBlockState getBlockState(BlockPos pos) {
return this.getBlockState(pos.getX(), pos.getY(), pos.getZ());
}
public IBlockState getBlockState(int blockX, int blockY, int blockZ) {
try {
if (this.isEmpty()) {
return Blocks.AIR.getDefaultState();
}
int localX = Coords.blockToLocal(blockX);
int localY = Coords.blockToLocal(blockY);
int localZ = Coords.blockToLocal(blockZ);
return this.getStorage().get(localX, localY, localZ);
} catch (Throwable t) {
CrashReport report = CrashReport.makeCrashReport(t, "Getting block state");
CrashReportCategory category = report.makeCategory("Block being got");
category.setDetail("Location", new ICrashReportDetail<String>() {
@Override
public String call() throws Exception {
return CrashReportCategory.getCoordinateInfo(blockX, blockY, blockZ);
}
});
throw new ReportedException(report);
}
}
public void setBlockStateDirect(BlockPos pos, IBlockState newBlockState) {
if (this.isEmpty() && newBlockState.getBlock() == Blocks.AIR) {
return;
}
this.isModified = true;
int localX = Coords.blockToLocal(pos.getX());
int localY = Coords.blockToLocal(pos.getY());
int localZ = Coords.blockToLocal(pos.getZ());
this.getStorage().set(localX, localY, localZ, newBlockState);
}
public int getLightFor(EnumSkyBlock lightType, BlockPos pos) {
//it may not look like this but it's actually the same logic as in vanilla
if (this.isEmpty()) {
if (this.column.canSeeSky(pos)) {
return lightType.defaultLightValue;
}
return 0;
}
int localX = Coords.blockToLocal(pos.getX());
int localY = Coords.blockToLocal(pos.getY());
int localZ = Coords.blockToLocal(pos.getZ());
switch (lightType) {
case SKY:
if (this.world.getProvider().getHasNoSky()) {
return 0;
}
return this.storage.getExtSkylightValue(localX, localY, localZ);
case BLOCK:
return this.storage.getExtBlocklightValue(localX, localY, localZ);
default:
return lightType.defaultLightValue;
}
}
public void setLightFor(EnumSkyBlock lightType, BlockPos pos, int light) {
this.isModified = true;
int x = Coords.blockToLocal(pos.getX());
int y = Coords.blockToLocal(pos.getY());
int z = Coords.blockToLocal(pos.getZ());
switch (lightType) {
case SKY:
if (!this.world.getProvider().getHasNoSky()) {
this.storage.setExtSkylightValue(x, y, z, light);
}
break;
case BLOCK:
this.storage.setExtBlocklightValue(x, y, z, light);
break;
}
}
public int getLightSubtracted(BlockPos pos, int skyLightDampeningTerm) {
// get sky light
int skyLight = getLightFor(EnumSkyBlock.SKY, pos);
skyLight -= skyLightDampeningTerm;
// get block light
int blockLight = getLightFor(EnumSkyBlock.BLOCK, pos);
// FIGHT!!!
return Math.max(blockLight, skyLight);
}
private TileEntity createTileEntity(BlockPos pos) {
IBlockState blockState = getBlockState(pos);
Block block = blockState.getBlock();
if (block.hasTileEntity(blockState)) {
return block.createTileEntity((World) this.world, blockState);
}
return null;
}
public void addEntity(Entity entity) {
// make sure the entity is in this cube
int cubeX = Coords.getCubeXForEntity(entity);
int cubeY = Coords.getCubeYForEntity(entity);
int cubeZ = Coords.getCubeZForEntity(entity);
if (cubeX != this.coords.getCubeX() || cubeY != this.coords.getCubeY() || cubeZ != this.coords.getCubeZ()) {
LOGGER.warn(String.format("Wrong entity (%s) location. Entity thinks it's in (%d,%d,%d) but actua location is (%d,%d,%d)!",
entity.getClass().getName(), cubeX, cubeY, cubeZ, this.coords.getCubeX(), this.coords.getCubeY(), this.coords.getCubeZ()));
entity.setDead();
}
//post the event, we can't send cube position here :(
MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(
entity, this.getX(), this.getZ(), entity.chunkCoordX, entity.chunkCoordZ));
// tell the entity it's in this cube
entity.addedToChunk = true;
entity.chunkCoordX = this.coords.getCubeX();
entity.chunkCoordY = this.coords.getCubeY();
entity.chunkCoordZ = this.coords.getCubeZ();
this.entities.addEntity(entity);
this.isModified = true;
}
public boolean removeEntity(Entity entity) {
boolean wasRemoved = this.entities.remove(entity);
if (wasRemoved) {
this.isModified = true;
}
return wasRemoved;
}
public TileEntity getTileEntity(BlockPos pos, Chunk.EnumCreateEntityType createType) {
TileEntity blockEntity = this.tileEntityMap.get(pos);
if (blockEntity != null && blockEntity.isInvalid()) {
this.tileEntityMap.remove(pos);
blockEntity = null;
}
if (blockEntity == null) {
if (createType == Chunk.EnumCreateEntityType.IMMEDIATE) {
blockEntity = createTileEntity(pos);
this.world.setTileEntity(pos, blockEntity);
} else if (createType == Chunk.EnumCreateEntityType.QUEUED) {
this.tileEntityPosQueue.add(pos);
}
}
return blockEntity;
}
public void addTileEntity(TileEntity tileEntity) {
this.addTileEntity(tileEntity.getPos(), tileEntity);
if (this.isCubeLoaded) {
this.getWorld().addTileEntity(tileEntity);
}
}
public void addTileEntity(BlockPos pos, TileEntity tileEntity) {
// update the tile entity
tileEntity.setWorldObj((World) this.world);
tileEntity.setPos(pos);
IBlockState blockState = this.getBlockState(pos);
// is this block supposed to have a tile entity?
if (blockState.getBlock().hasTileEntity(blockState)) {
// cleanup the old tile entity
TileEntity oldBlockEntity = this.tileEntityMap.get(pos);
if (oldBlockEntity != null) {
oldBlockEntity.invalidate();
}
// install the new tile entity
tileEntity.validate();
this.tileEntityMap.put(pos, tileEntity);
this.isModified = true;
tileEntity.onLoad();
}
}
public void removeTileEntity(BlockPos pos) {
//it doesn't make sense to me to check if cube is loaded, but vanilla does it
if (this.isCubeLoaded) {
TileEntity tileEntity = this.tileEntityMap.remove(pos);
if (tileEntity != null) {
tileEntity.invalidate();
this.isModified = true;
}
}
}
public void getEntitiesWithinAABBForEntity(Entity excluded, AxisAlignedBB queryBox, List<Entity> out, Predicate<? super Entity> predicate) {
this.entities.getEntitiesWithinAABBForEntity(excluded, queryBox, out, predicate);
}
public <T extends Entity> void getEntitiesOfTypeWithinAAAB(Class<? extends T> entityType, AxisAlignedBB queryBox, List<T> out, Predicate<? super T> predicate) {
this.entities.getEntitiesOfTypeWithinAAAB(entityType, queryBox, out, predicate);
}
public void tickCube() {
while (!this.tileEntityPosQueue.isEmpty()) {
BlockPos blockpos = this.tileEntityPosQueue.poll();
IBlockState state = this.getBlockState(blockpos);
Block block = state.getBlock();
if (this.getTileEntity(blockpos, Chunk.EnumCreateEntityType.CHECK) == null &&
block.hasTileEntity(state)) {
TileEntity tileentity = this.createTileEntity(blockpos);
this.world.setTileEntity(blockpos, tileentity);
this.world.markBlockRangeForRenderUpdate(blockpos, blockpos);
}
}
}
public boolean isEmpty() {
return this.storage.isEmpty();
}
public GeneratorStage getCurrentStage() {
return this.currentStage;
}
public boolean isBeforeStage(GeneratorStage stage) {
return this.getCurrentStage().precedes(stage);
}
public boolean hasReachedStage(GeneratorStage stage) {
return !this.getCurrentStage().precedes(stage);
}
public boolean hasReachedTargetStage() {
return this.hasReachedStage(this.targetStage);
}
public void setCurrentStage(GeneratorStage val) {
this.currentStage = val;
}
public GeneratorStage getTargetStage() {
return this.targetStage;
}
public void setTargetStage(GeneratorStage targetStage) {
this.targetStage = targetStage;
}
public long getAddress() {
return AddressTools.getAddress(this.coords.getCubeX(), this.coords.getCubeY(), this.coords.getCubeZ());
}
public BlockPos localAddressToBlockPos(int localAddress) {
int x = Coords.localToBlock(this.coords.getCubeX(), AddressTools.getLocalX(localAddress));
int y = Coords.localToBlock(this.coords.getCubeY(), AddressTools.getLocalY(localAddress));
int z = Coords.localToBlock(this.coords.getCubeZ(), AddressTools.getLocalZ(localAddress));
return new BlockPos(x, y, z);
}
public ICubicWorld getWorld() {
return this.world;
}
public Column getColumn() {
return this.column;
}
public int getX() {
return this.coords.getCubeX();
}
public int getY() {
return this.coords.getCubeY();
}
public int getZ() {
return this.coords.getCubeZ();
}
public CubeCoords getCoords() {
return this.coords;
}
public boolean containsBlockPos(BlockPos blockPos) {
return this.coords.getCubeX() == Coords.blockToCube(blockPos.getX())
&& this.coords.getCubeY() == Coords.blockToCube(blockPos.getY())
&& this.coords.getCubeZ() == Coords.blockToCube(blockPos.getZ());
}
public ExtendedBlockStorage getStorage() {
return this.storage;
}
public IBlockState setBlockForGeneration(BlockPos blockOrLocalPos, IBlockState newBlockState) {
IBlockState oldBlockState = getBlockState(blockOrLocalPos);
// did anything actually change?
if (newBlockState == oldBlockState) {
return null;
}
int x = Coords.blockToLocal(blockOrLocalPos.getX());
int y = Coords.blockToLocal(blockOrLocalPos.getY());
int z = Coords.blockToLocal(blockOrLocalPos.getZ());
// set the block
this.storage.set(x, y, z, newBlockState);
Block newBlock = newBlockState.getBlock();
// did the block change work correctly?
if (this.storage.get(x, y, z) != newBlockState) {
return null;
}
this.isModified = true;
//update the column light index
int blockY = Coords.localToBlock(this.coords.getCubeY(), y);
IOpacityIndex index = this.column.getOpacityIndex();
int opacity = newBlock.getLightOpacity(newBlockState);
index.onOpacityChange(x, blockY, z, opacity);
return oldBlockState;
}
public boolean hasBlocks() {
if (isEmpty()) {
return false;
}
return !this.storage.isEmpty();
}
public Map<BlockPos, TileEntity> getTileEntityMap() {
return this.tileEntityMap;
}
public EntityContainer getEntityContainer() {
return this.entities;
}
public void onLoad() {
// tell the world about tile entities
this.world.addTileEntities(this.tileEntityMap.values());
this.world.loadEntities(this.entities.getEntities());
this.isCubeLoaded = true;
}
public void onUnload() {
// tell the world to forget about entities
this.world.unloadEntities(this.entities.getEntities());
// tell the world to forget about tile entities
for (TileEntity blockEntity : this.tileEntityMap.values()) {
this.world.removeTileEntity(blockEntity.getPos());
}
this.isCubeLoaded = false;
}
public boolean needsSaving() {
return this.entities.needsSaving(true, this.world.getTotalWorldTime(), this.isModified);
}
public void markSaved() {
this.entities.markSaved(this.world.getTotalWorldTime());
this.isModified = false;
}
public void markForRenderUpdate() {
this.world.markBlockRangeForRenderUpdate(
Coords.cubeToMinBlock(this.coords.getCubeX()), Coords.cubeToMinBlock(this.coords.getCubeY()), Coords.cubeToMinBlock(this.coords.getCubeZ()),
Coords.cubeToMaxBlock(this.coords.getCubeX()), Coords.cubeToMaxBlock(this.coords.getCubeY()), Coords.cubeToMaxBlock(this.coords.getCubeZ())
);
}
public long cubeRandomSeed() {
long hash = 3;
hash = 41*hash + this.world.getSeed();
hash = 41*hash + getX();
hash = 41*hash + getY();
return 41*hash + getZ();
}
public boolean needsRelightAfterLoad() {
return this.needsRelightAfterLoad;
}
public void setNeedsRelightAfterLoad(boolean val) {
this.needsRelightAfterLoad = val;
}
public LightUpdateData getLightUpdateData() {
return this.lightUpdateData;
}
public static class LightUpdateData {
private final Cube cube;
private final short[] minMaxHeights = new short[256];
//TODO: nullify minMaxHeights if toUpdateCounter is 0
private int toUpdateCounter = 0;
public LightUpdateData(Cube cube) {
this.cube = cube;
Arrays.fill(minMaxHeights, (short) 0xFFFF);
}
public void queueLightUpdate(int localX, int localZ, int minY, int maxY) {
if (localX < 0 || localX > 15) {
throw new IndexOutOfBoundsException("LocalX must be between 0 and 15, but was " + localX);
}
if (localZ < 0 || localZ > 15) {
throw new IndexOutOfBoundsException("LocalZ must be between 0 and 15, but was " + localZ);
}
if (minY > maxY) {
throw new IllegalArgumentException("minY > maxY (" + minY + " > " + maxY + ")");
}
minY -= Coords.cubeToMinBlock(cube.getY());
maxY -= Coords.cubeToMinBlock(cube.getY());
minY = MathHelper.clamp_int(minY, 0, 15);
maxY = MathHelper.clamp_int(maxY, 0, 15);
int index = index(localX, localZ);
short v = minMaxHeights[localX << 4 | localZ];
if (v == -1) {
toUpdateCounter++;
assert toUpdateCounter >= 0 && toUpdateCounter <= 256;
}
int min = unpackMin(v);
int max = unpackMax(v);
if (minY < min) {
min = minY;
}
if (maxY > max) {
max = maxY;
}
v = pack(min, max);
assert v >= 0 && v < 256;
this.minMaxHeights[index] = v;
}
public int getMin(int localX, int localZ) {
return unpackMin(minMaxHeights[index(localX, localZ)]);
}
public int getMax(int localX, int localZ) {
return unpackMax(minMaxHeights[index(localX, localZ)]);
}
public void remove(int localX, int localZ) {
int index = index(localX, localZ);
if (minMaxHeights[index] != -1) {
toUpdateCounter
}
minMaxHeights[index] = -1;
}
private short pack(int min, int max) {
return (short) (min << 4 | max);
}
private int unpackMin(short val) {
if (val == -1) {
return 16;
}
return val >> 4;
}
private int unpackMax(short val) {
if (val == -1) {
return -1;
}
return val & 0xf;
}
private int index(int x, int z) {
return x << 4 | z;
}
}
}
|
package de.fhws.fiw.pvs.grpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.StatusRuntimeException;
import java.util.concurrent.TimeUnit;
public class Client
{
private final ManagedChannel channel;
private final GreeterServiceGrpc.GreeterServiceBlockingStub blockingStub;
public Client( String host, int port )
{
/* In the following statement, do NOT remove usePlaintext or set it to false. */
channel = ManagedChannelBuilder.forAddress( host, port ).usePlaintext( true ).build( );
blockingStub = GreeterServiceGrpc.newBlockingStub( channel );
}
public static void main( String[] args ) throws InterruptedException
{
Client client = new Client( "localhost", 8888 );
try
{
client.greet( "James" );
}
finally
{
client.shutdown( );
}
}
public void shutdown( ) throws InterruptedException
{
channel.shutdown( ).awaitTermination( 5, TimeUnit.SECONDS );
}
/**
* Say hello to server.
*/
public void greet( String name )
{
Greeter.Request request = Greeter.Request.newBuilder( ).setName( name ).build( );
//Greeter.Person person = Greeter.Person.newBuilder().setFirstName("John").setLastName("Doe").build();
try
{
Greeter.Reply response = blockingStub.getGreeting( request );
System.out.println( response.getGreeting( ) );
}
catch ( StatusRuntimeException e )
{
return;
}
}
}
|
package dynamok.source;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import org.apache.kafka.connect.data.Schema;
import org.apache.kafka.connect.data.SchemaBuilder;
import org.apache.kafka.connect.data.Struct;
import java.util.HashMap;
import java.util.Map;
public enum RecordMapper {
;
private static final Schema AV_SCHEMA =
SchemaBuilder.struct()
.name("DynamoDB.AttributeValue")
.field("S", Schema.OPTIONAL_STRING_SCHEMA)
.field("N", Schema.OPTIONAL_STRING_SCHEMA)
.field("B", Schema.OPTIONAL_BYTES_SCHEMA)
.field("SS", SchemaBuilder.array(Schema.STRING_SCHEMA).optional().build())
.field("NS", SchemaBuilder.array(Schema.STRING_SCHEMA).optional().build())
.field("BS", SchemaBuilder.array(Schema.BYTES_SCHEMA).optional().build())
.field("NULL", Schema.OPTIONAL_BOOLEAN_SCHEMA)
.field("BOOL", Schema.OPTIONAL_BOOLEAN_SCHEMA)
.version(1)
.build();
private static final Schema DYNAMODB_ATTRIBUTES_SCHEMA =
SchemaBuilder.map(Schema.STRING_SCHEMA, AV_SCHEMA)
.name("DynamoDB.Attributes")
.version(1)
.build();
public static Schema attributesSchema() {
return DYNAMODB_ATTRIBUTES_SCHEMA;
}
public static Map<String, Struct> toConnect(Map<String, AttributeValue> attributes) {
Map<String, Struct> connectAttributes = new HashMap<>(attributes.size());
for (Map.Entry<String, AttributeValue> attribute : attributes.entrySet()) {
final String attributeName = attribute.getKey();
final AttributeValue attributeValue = attribute.getValue();
final Struct attributeValueStruct = new Struct(AV_SCHEMA);
if (attributeValue.getS() != null) {
attributeValueStruct.put("S", attributeValue.getS());
} else if (attributeValue.getN() != null) {
attributeValueStruct.put("N", attributeValue.getN());
} else if (attributeValue.getB() != null) {
attributeValueStruct.put("B", attributeValue.getB());
} else if (attributeValue.getSS() != null) {
attributeValueStruct.put("SS", attributeValue.getSS());
} else if (attributeValue.getNS() != null) {
attributeValueStruct.put("NS", attributeValue.getNS());
} else if (attributeValue.getBS() != null) {
attributeValueStruct.put("BS", attributeValue.getBS());
} else if (attributeValue.getNULL() != null) {
attributeValueStruct.put("NULL", attributeValue.getNULL());
} else if (attributeValue.getBOOL() != null) {
attributeValueStruct.put("BOOL", attributeValue.getBOOL());
}
connectAttributes.put(attributeName, attributeValueStruct);
}
return connectAttributes;
}
}
|
package soot;
import soot.options.*;
import static java.lang.System.gc;
import static java.lang.System.nanoTime;
/**
* Utility class providing a timer. Used for profiling various phases of
* Sootification.
*/
public class Timer {
private long duration;
private long startTime;
private boolean hasStarted;
private String name;
/** Creates a new timer with the given name. */
public Timer(String name) {
this.name = name;
duration = 0;
}
/** Creates a new timer. */
public Timer() {
this("unnamed");
}
static void doGarbageCollecting() {
final G g = G.v();
// Subtract garbage collection time
if (g.Timer_isGarbageCollecting)
return;
if (!Options.v().subtract_gc())
return;
// garbage collects only every 4 calls to avoid round off errors
if ((g.Timer_count++ % 4) != 0)
return;
g.Timer_isGarbageCollecting = true;
g.Timer_forcedGarbageCollectionTimer.start();
// Stop all outstanding timers
for (Timer t : g.Timer_outstandingTimers) {
t.end();
}
gc();
// Start all outstanding timers
for (Timer t : g.Timer_outstandingTimers) {
t.start();
}
g.Timer_forcedGarbageCollectionTimer.end();
g.Timer_isGarbageCollecting = false;
}
/** Starts the given timer. */
public void start() {
doGarbageCollecting();
startTime = nanoTime();
if (hasStarted)
throw new RuntimeException("timer " + name + " has already been started!");
hasStarted = true;
if (!G.v().Timer_isGarbageCollecting) {
synchronized(G.v().Timer_outstandingTimers) {
G.v().Timer_outstandingTimers.add(this);
}
}
}
/** Returns the name of the current timer. */
public String toString() {
return name;
}
/** Stops the current timer. */
public void end() {
if (!hasStarted)
throw new RuntimeException("timer " + name + " has not been started!");
hasStarted = false;
duration += nanoTime() - startTime;
if (!G.v().Timer_isGarbageCollecting) {
synchronized(G.v().Timer_outstandingTimers) {
G.v().Timer_outstandingTimers.remove(this);
}
}
}
/** Returns the sum of the intervals start()-end() of the current timer. */
public long getTime() {
return duration / 1000000L;
}
}
|
package exnihiloadscensio.util;
import java.util.ArrayList;
import java.util.Arrays;
import exnihiloadscensio.texturing.Color;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.UniversalBucket;
public class Util {
public static Color whiteColor = new Color(1f, 1f, 1f, 1f);
public static Color blackColor = new Color(0f, 0f, 0f, 1f);
public static Color greenColor = new Color(0f, 1f, 0f, 1f);
public static void dropItemInWorld(TileEntity source, EntityPlayer player, ItemStack stack, double speedfactor)
{
int hitOrientation = player == null ? 0 : MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
double stackCoordX = 0.0D, stackCoordY = 0.0D, stackCoordZ = 0.0D;
switch (hitOrientation) {
case 0:
stackCoordX = source.getPos().getX() + 0.5D;
stackCoordY = source.getPos().getY() + 0.5D + 1;
stackCoordZ = source.getPos().getZ() - 0.25D;
break;
case 1:
stackCoordX = source.getPos().getX() + 1.25D;
stackCoordY = source.getPos().getY() + 0.5D + 1;
stackCoordZ = source.getPos().getZ() + 0.5D;
break;
case 2:
stackCoordX = source.getPos().getX() + 0.5D;
stackCoordY = source.getPos().getY() + 0.5D + 1;
stackCoordZ = source.getPos().getZ() + 1.25D;
break;
case 3:
stackCoordX = source.getPos().getX() - 0.25D;
stackCoordY = source.getPos().getY() + 0.5D + 1;
stackCoordZ = source.getPos().getZ() + 0.5D;
break;
}
EntityItem droppedEntity = new EntityItem(source.getWorld(), stackCoordX, stackCoordY, stackCoordZ, stack);
if (player != null) {
Vec3d motion = new Vec3d(player.posX - stackCoordX, player.posY - stackCoordY, player.posZ - stackCoordZ);
motion.normalize();
droppedEntity.motionX = motion.xCoord;
droppedEntity.motionY = motion.yCoord;
droppedEntity.motionZ = motion.zCoord;
double offset = 0.25D;
droppedEntity.moveEntity(motion.xCoord * offset, motion.yCoord * offset, motion.zCoord * offset);
}
droppedEntity.motionX *= speedfactor;
droppedEntity.motionY *= speedfactor;
droppedEntity.motionZ *= speedfactor;
source.getWorld().spawnEntityInWorld(droppedEntity);
}
public static TextureAtlasSprite getTextureFromBlockState(IBlockState state) {
return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes()
.getTexture(state);
}
public static boolean isSurroundingBlocksAtLeastOneOf(BlockInfo[] blocks, BlockPos pos, World world) {
ArrayList<BlockInfo> blockList = new ArrayList<BlockInfo>(Arrays.asList(blocks));
for (int xShift = -2 ; xShift <= 2 ; xShift++) {
for (int zShift = -2 ; zShift <= 2 ; zShift++) {
BlockPos checkPos = pos.add(xShift, 0, zShift);
BlockInfo checkBlock = new BlockInfo(world.getBlockState(checkPos));
if (blockList.contains(checkBlock))
return true;
}
}
return false;
}
public static int getNumSurroundingBlocksAtLeastOneOf(BlockInfo[] blocks, BlockPos pos, World world) {
int ret = 0;
ArrayList<BlockInfo> blockList = new ArrayList<BlockInfo>(Arrays.asList(blocks));
for (int xShift = -2 ; xShift <= 2 ; xShift++) {
for (int zShift = -2 ; zShift <= 2 ; zShift++) {
BlockPos checkPos = pos.add(xShift, 0, zShift);
BlockInfo checkBlock = new BlockInfo(world.getBlockState(checkPos));
if (blockList.contains(checkBlock))
ret++;
}
}
return ret;
}
public static int getLightValue(FluidStack fluid)
{
if(fluid != null && fluid.getFluid() != null)
{
return fluid.getFluid().getLuminosity(fluid);
}
else
{
return 0;
}
}
public static float weightedAverage(float a, float b, float percent)
{
return a * percent + b * (1 - percent);
}
public static ItemStack getBucketStack(Fluid fluid)
{
return UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid);
}
}
|
package fxlauncher;
import javafx.application.Application;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.xml.bind.JAXB;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.stream.Collectors;
@SuppressWarnings("unchecked")
public abstract class AbstractLauncher<APP> {
private static final Logger log = Logger.getLogger("AbstractLauncher");
protected FXManifest manifest;
private String phase;
/**
* Make java.util.logger log to a file. Default it will log to
* $TMPDIR/fxlauncher.log. This can be overriden by using comman line parameter
* <code>--logfile=logfile</code>
*
* @throws IOException
*/
protected void setupLogFile() throws IOException {
String filename = System.getProperty("java.io.tmpdir") + File.separator + "fxlauncher.log";
if (getParameters().getNamed().containsKey("logfile"))
filename = getParameters().getNamed().get("logfile");
System.out.println("logging to " + filename);
FileHandler handler = new FileHandler(filename);
handler.setFormatter(new SimpleFormatter());
log.addHandler(handler);
}
/**
* Check if the SSL connection needs to ignore the validity of the ssl
* certificate.
*
* @throws KeyManagementException
* @throws NoSuchAlgorithmException
*/
protected void checkSSLIgnoreflag() throws KeyManagementException, NoSuchAlgorithmException {
if (getParameters().getUnnamed().contains("--ignoressl")) {
setupIgnoreSSLCertificate();
}
}
protected ClassLoader createClassLoader(Path cacheDir) {
List<URL> libs = manifest.files.stream().filter(LibraryFile::loadForCurrentPlatform)
.map(it -> it.toURL(cacheDir)).collect(Collectors.toList());
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
if (systemClassLoader instanceof FxlauncherClassLoader) {
((FxlauncherClassLoader) systemClassLoader).addUrls(libs);
return systemClassLoader;
} else {
ClassLoader classLoader = new URLClassLoader(libs.toArray(new URL[libs.size()]));
Thread.currentThread().setContextClassLoader(classLoader);
setupClassLoader(classLoader);
return classLoader;
}
}
protected void updateManifest() throws Exception {
phase = "Update Manifest";
syncManifest();
}
/**
* Check if remote files are newer then local files. Return true if files are
* updated, triggering the whatsnew option else false. Also return false and do
* not check for updates if the <code>--offline</code> commandline argument is
* set.
*
* @return true if new files have been downloaded, false otherwise.
* @throws Exception
*/
protected boolean syncFiles() throws Exception {
Path cacheDir = manifest.resolveCacheDir(getParameters().getNamed());
log.info(String.format("Using cache dir %s", cacheDir));
phase = "File Synchronization";
if (getParameters().getUnnamed().contains("--offline")) {
log.info("not updating files from remote, offline selected");
return false; // to signal that nothing has changed.
}
List<LibraryFile> needsUpdate = manifest.files.stream().filter(LibraryFile::loadForCurrentPlatform)
.filter(it -> it.needsUpdate(cacheDir)).collect(Collectors.toList());
if (needsUpdate.isEmpty())
return false;
Signature sig = null;
if (getParameters().getNamed().containsKey("cert")) {
String certPath = getParameters().getNamed().get("cert");
try (InputStream certIn = Files.newInputStream(Paths.get(certPath))) {
Certificate cert = CertificateFactory.getInstance("X.509").generateCertificate(certIn);
sig = Signature.getInstance("SHA256with" + cert.getPublicKey().getAlgorithm());
sig.initVerify(cert);
}
}
long totalBytes = needsUpdate.stream().mapToLong(f -> f.size).sum();
long totalWritten = 0L;
for (LibraryFile lib : needsUpdate) {
Path target = cacheDir.resolve(lib.file).toAbsolutePath();
Path temp = cacheDir.resolve("~" + lib.file + ".tmp");
Files.createDirectories(target.getParent());
try (InputStream input = openDownloadStream(lib.uri); OutputStream output = Files.newOutputStream(temp)) {
byte[] buf = new byte[65536];
int read;
while ((read = input.read(buf)) > -1) {
output.write(buf, 0, read);
if (sig != null) {
sig.update(buf, 0, read);
}
totalWritten += read;
double progress = (double) totalWritten / totalBytes;
updateProgress(progress);
}
if (sig != null) {
if (lib.signature == null)
throw new SecurityException("No signature in manifest.");
byte[] sigData = Base64.getDecoder().decode(lib.signature);
if (!sig.verify(sigData))
throw new SecurityException("Signature verification failed.");
}
Files.move(temp, target, StandardCopyOption.REPLACE_EXISTING);
} finally {
Files.deleteIfExists(temp);
}
}
return true;
}
private InputStream openDownloadStream(URI uri) throws IOException {
if (uri.getScheme().equals("file"))
return Files.newInputStream(new File(uri.getPath()).toPath());
URLConnection connection = uri.toURL().openConnection();
if (uri.getUserInfo() != null) {
byte[] payload = uri.getUserInfo().getBytes(StandardCharsets.UTF_8);
String encoded = Base64.getEncoder().encodeToString(payload);
connection.setRequestProperty("Authorization", String.format("Basic %s", encoded));
}
return connection.getInputStream();
}
protected void createApplicationEnvironment() throws Exception {
phase = "Create Application";
if (manifest == null)
throw new IllegalArgumentException("Unable to retrieve embedded or remote manifest.");
List<String> preloadLibs = manifest.getPreloadNativeLibraryList();
for (String preloadLib : preloadLibs)
System.loadLibrary(preloadLib);
Path cacheDir = manifest.resolveCacheDir(getParameters() != null ? getParameters().getNamed() : null);
ClassLoader classLoader = createClassLoader(cacheDir);
Class<APP> appclass = (Class<APP>) classLoader.loadClass(manifest.launchClass);
createApplication(appclass);
}
protected void syncManifest() throws Exception {
Map<String, String> namedParams = getParameters().getNamed();
URI remote = null;
Path local = null;
FXManifest man = null;
if (namedParams.containsKey("remote")) {
try {
remote = URI.create(namedParams.get("remote"));
} catch (Exception e) {
e.printStackTrace();
}
}
if (namedParams.containsKey("local")) {
local = Paths.get(namedParams.get("local")).toAbsolutePath();
Files.createDirectories(local.getParent());
}
if (remote != null) {
try {
man = FXManifest.load(remote);
if (getParameters().getUnnamed().contains("--syncLocal")) {
try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(local))) {
out.print(man);
}
}
} catch (Exception e) {
e.printStackTrace();
}
} else if (local != null) {
try {
man = FXManifest.load(local.toUri());
} catch (Exception e) {
e.printStackTrace();
}
}
if(man == null) {
URL embedded = getClass().getResource("/app.xml");
if(embedded != null) {
try {
man = JAXB.unmarshal(embedded, FXManifest.class);
}catch (Exception e) {
e.printStackTrace();
}
}
}
if(man == null) {
throw new IOException("Could not load manifest.");
}
manifest = man;
}
protected void setupIgnoreSSLCertificate() throws NoSuchAlgorithmException, KeyManagementException {
log.info("starting ssl setup");
TrustManager[] trustManager = new TrustManager[] { new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
} };
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustManager, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
HostnameVerifier hostnameVerifier = (s, sslSession) -> true;
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
}
protected boolean checkIgnoreUpdateErrorSetting() {
return getParameters().getUnnamed().contains("--stopOnUpdateErrors");
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public FXManifest getManifest() {
return manifest;
}
protected abstract Application.Parameters getParameters();
protected abstract void updateProgress(double progress);
protected abstract void createApplication(Class<APP> appClass);
protected abstract void reportError(String title, Throwable error);
protected abstract void setupClassLoader(ClassLoader classLoader);
}
|
package stray;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import stray.achievements.Achievement;
import stray.achievements.Achievements;
import stray.achievements.Appearance;
import stray.achievements.CompletedAchievements;
import stray.animation.Animation;
import stray.animation.LoopingAnimation;
import stray.blocks.Blocks;
import stray.conversation.Conversation;
import stray.conversation.Conversations;
import stray.transition.Transition;
import stray.transition.TransitionScreen;
import stray.util.AssetMap;
import stray.util.CaptureStream;
import stray.util.CaptureStream.Consumer;
import stray.util.Difficulty;
import stray.util.GameException;
import stray.util.Logger;
import stray.util.MathHelper;
import stray.util.MemoryUtils;
import stray.util.ScreenshotFactory;
import stray.util.Splashes;
import stray.util.Utils;
import stray.util.render.Gears;
import stray.util.render.Shaders;
import stray.util.version.VersionGetter;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
/**
*
* Main class, think of it like slick's Main class
*
*/
public class Main extends Game implements Consumer {
public OrthographicCamera camera;
private static Viewport viewport;
public SpriteBatch batch;
public SpriteBatch maskRenderer;
public SpriteBatch blueprintrenderer;
public ShapeRenderer shapes;
public FrameBuffer buffer;
public FrameBuffer buffer2;
public BitmapFont font;
public BitmapFont arial;
private static Color rainbow = new Color();
private static Color inverseRainbow = new Color();
CompletedAchievements achievements = new CompletedAchievements();
Array<Appearance> toShow = new Array<Appearance>();
Matrix4 normalProjection;
public static final String version = "v0.4.2-alpha";
public static String latestVersion = "";
public AssetManager manager;
public static AssetLoadingScreen ASSETLOADING = null;
public static MainMenuScreen MAINMENU = null;
public static HelpScreen HELP = null;
public static GameScreen GAME = null;
public static TransitionScreen TRANSITION = null;
public static ColourScreen COLOUR = null;
public static CutsceneScreen CUTSCENE = null;
public static MiscLoadingScreen MISCLOADING = null;
public static LevelSelectScreen LEVELSELECT = null;
public static LevelEditor LEVELEDITOR = null;
public static TestLevel TESTLEVEL = null;
public static NewGameScreen NEWGAME = null;
public static BackstoryScreen BACKSTORY = null;
public static SettingsScreen SETTINGS = null;
public static ResultsScreen RESULTS = null;
public static Texture filltex;
private Conversation currentConvo = null;
public ShaderProgram maskshader;
public ShaderProgram blueprintshader;
public ShaderProgram toonshader;
public ShaderProgram greyshader;
public ShaderProgram warpshader;
public ShaderProgram blurshader;
public ShaderProgram defaultShader;
public ShaderProgram invertshader;
public ShaderProgram swizzleshader;
public HashMap<String, Animation> animations = new HashMap<String, Animation>();
public HashMap<String, Texture> textures = new HashMap<String, Texture>();
private CaptureStream output;
private PrintStream printstrm;
private JFrame consolewindow;
private JTextArea consoletext;
private JScrollPane conscrollPane;
/**
* used for storing progress, level data etc
*/
public Preferences progress;
public static final int TICKS = 30;
public static final int MAX_FPS = 60;
private int[] lastFPS = new int[5];
private float deltaUntilTick = 0;
private float totalSeconds = 0f;
public static Gears gears;
/**
* use this rather than Gdx.app.log
*/
public static Logger logger;
public Main(Logger l) {
super();
logger = l;
}
@Override
public void create() {
defaultShader = SpriteBatch.createDefaultShader();
progress = getPref("progress");
Gdx.graphics.setTitle(getTitle() + " - " + Splashes.getRandomSplash());
redirectSysOut();
for (int i = 0; i < lastFPS.length; i++) {
lastFPS[i] = 0;
}
ShaderProgram.pedantic = false;
camera = new OrthographicCamera();
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
viewport = new StretchViewport(Settings.DEFAULT_WIDTH, Settings.DEFAULT_HEIGHT, camera);
batch = new SpriteBatch();
batch.enableBlending();
maskRenderer = new SpriteBatch();
maskRenderer.enableBlending();
blueprintrenderer = new SpriteBatch();
manager = new AssetManager();
font = new BitmapFont(Gdx.files.internal("fonts/couriernewbold.fnt"),
Gdx.files.internal("fonts/couriernewbold.png"), false);
font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
font.setMarkupEnabled(true);
arial = new BitmapFont();
arial.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
normalProjection = new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(),
Gdx.graphics.getHeight());
Pixmap pix = new Pixmap(1, 1, Format.RGBA8888);
pix.setColor(Color.WHITE);
pix.fill();
filltex = new Texture(pix);
pix.dispose();
shapes = new ShapeRenderer();
buffer = new FrameBuffer(Format.RGBA8888, Settings.DEFAULT_WIDTH, Settings.DEFAULT_HEIGHT,
true);
buffer2 = new FrameBuffer(Format.RGBA8888, Settings.DEFAULT_WIDTH, Settings.DEFAULT_HEIGHT,
true);
maskshader = new ShaderProgram(Shaders.VERTDEFAULT, Shaders.FRAGBAKE);
maskshader.begin();
maskshader.setUniformi("u_texture1", 1);
maskshader.setUniformi("u_mask", 2);
maskshader.end();
maskRenderer.setShader(maskshader);
blueprintshader = new ShaderProgram(Shaders.VERTBLUEPRINT, Shaders.FRAGBLUEPRINT);
blueprintshader.begin();
blueprintshader.end();
blueprintrenderer.setShader(blueprintshader);
toonshader = new ShaderProgram(Shaders.VERTTOON, Shaders.FRAGTOON);
greyshader = new ShaderProgram(Shaders.VERTGREY, Shaders.FRAGGREY);
warpshader = new ShaderProgram(Shaders.VERTDEFAULT, Shaders.FRAGWARP);
warpshader.begin();
warpshader.setUniformf(warpshader.getUniformLocation("time"), totalSeconds);
warpshader.setUniformf(warpshader.getUniformLocation("amplitude"), 1.0f, 1.0f);
warpshader.setUniformf(warpshader.getUniformLocation("frequency"), 1.0f, 1.0f);
warpshader.setUniformf(warpshader.getUniformLocation("speed"), 1f);
warpshader.end();
blurshader = new ShaderProgram(Shaders.VERTBLUR, Shaders.FRAGBLUR);
blurshader.begin();
blurshader.setUniformf("dir", 1f, 0f);
blurshader.setUniformf("resolution", Gdx.graphics.getWidth());
blurshader.setUniformf("radius", 2f);
blurshader.end();
invertshader = new ShaderProgram(Shaders.VERTINVERT, Shaders.FRAGINVERT);
swizzleshader = new ShaderProgram(Shaders.VERTSWIZZLE, Shaders.FRAGSWIZZLE);
loadUnmanagedAssets();
loadAssets();
Gdx.input.setInputProcessor(getDefaultInput());
prepareStates();
this.setScreen(ASSETLOADING);
achievements.load("achievement", getPref("achievements"));
Gdx.app.postRunnable(new Thread("Stray-version checker") {
public void run() {
VersionGetter.instance().getVersionFromServer();
}
});
}
public void prepareStates() {
ASSETLOADING = new AssetLoadingScreen(this);
MAINMENU = new MainMenuScreen(this);
HELP = new HelpScreen(this);
GAME = new GameScreen(this);
COLOUR = new ColourScreen(this);
TRANSITION = new TransitionScreen(this);
CUTSCENE = new CutsceneScreen(this);
MISCLOADING = new MiscLoadingScreen(this);
LEVELSELECT = new LevelSelectScreen(this);
LEVELEDITOR = new LevelEditor(this);
TESTLEVEL = new TestLevel(this);
NEWGAME = new NewGameScreen(this);
BACKSTORY = new BackstoryScreen(this);
SETTINGS = new SettingsScreen(this);
RESULTS = new ResultsScreen(this);
}
@Override
public void dispose() {
Settings.instance().save();
batch.dispose();
manager.dispose();
font.dispose();
arial.dispose();
Blocks.instance().dispose();
maskshader.dispose();
blueprintshader.dispose();
toonshader.dispose();
warpshader.dispose();
maskRenderer.dispose();
blurshader.dispose();
blueprintrenderer.dispose();
invertshader.dispose();
swizzleshader.dispose();
shapes.dispose();
buffer.dispose();
buffer2.dispose();
Iterator it = animations.entrySet().iterator();
while (it.hasNext()) {
((LoopingAnimation) ((Entry) it.next()).getValue()).dispose();
}
it = textures.entrySet().iterator();
while (it.hasNext()) {
((Texture) ((Entry) it.next()).getValue()).dispose();
}
// dispose screens
ASSETLOADING.dispose();
MAINMENU.dispose();
HELP.dispose();
GAME.dispose();
COLOUR.dispose();
TRANSITION.dispose();
CUTSCENE.dispose();
MISCLOADING.dispose();
LEVELSELECT.dispose();
LEVELEDITOR.dispose();
TESTLEVEL.dispose();
BACKSTORY.dispose();
SETTINGS.dispose();
RESULTS.dispose();
}
private void preRender() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Gdx.gl.glClearDepthf(1f);
Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT);
camera.update();
gears.update(1);
}
@Override
public void render() {
deltaUntilTick += Gdx.graphics.getRawDeltaTime();
try {
while (deltaUntilTick >= (1.0f / TICKS)) {
if (getScreen() != null) ((Updateable) getScreen()).tickUpdate();
tickUpdate();
deltaUntilTick -= (1.0f / TICKS);
}
if (getScreen() != null) {
((Updateable) getScreen()).renderUpdate();
}
preRender();
super.render();
postRender();
} catch (Exception e) {
e.printStackTrace();
Gdx.files.local("crash/").file().mkdir();
String date = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss").format(new Date());
date.trim();
FileHandle handle = Gdx.files.local("crash/crash-log_" + date + ".txt");
handle.writeString(output.toString(), false);
consoletext.setText(output.toString());
resetSystemOut();
System.out.println("\n\nThe game crashed. There is an error log at " + handle.path()
+ " ; please send it to the game developer!\n");
try {
Thread.sleep(5);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
e.printStackTrace();
Gdx.app.exit();
System.exit(1);
}
}
private void postRender() {
batch.begin();
font.setColor(Color.WHITE);
if (Settings.showFPS || Settings.debug) {
font.draw(batch, "FPS: "
+ (Gdx.graphics.getFramesPerSecond() <= (MAX_FPS / 4f) ? "[RED]"
: (Gdx.graphics.getFramesPerSecond() <= (MAX_FPS / 2f) ? "[YELLOW]"
: "")) + Gdx.graphics.getFramesPerSecond() + "[]", 5,
Settings.DEFAULT_HEIGHT - 5);
}
if (Settings.debug) {
font.setMarkupEnabled(false);
font.draw(
batch,
"(avg of " + lastFPS.length + " sec: " + String.format("%.1f", getAvgFPS())
+ ") " + Arrays.toString(lastFPS) + ", delta "
+ Gdx.graphics.getDeltaTime(),
5 + font.getSpaceWidth()
+ (font.getBounds("FPS: " + Gdx.graphics.getFramesPerSecond()).width),
Settings.DEFAULT_HEIGHT - 5);
font.setMarkupEnabled(true);
}
renderAchievements();
if (currentConvo != null) {
batch.setColor(0, 0, 0, 0.5f);
fillRect(0, 0, Gdx.graphics.getWidth(), 128);
batch.setColor(Color.LIGHT_GRAY);
int width = 3;
fillRect(0, 0, width, 128);
fillRect(0, 126, Gdx.graphics.getWidth(), width);
fillRect(0, 0, Gdx.graphics.getWidth(), width);
fillRect(Gdx.graphics.getWidth() - width, 0, width, 128);
font.setColor(Color.WHITE);
if (currentConvo.getCurrent().speaker != null) font.draw(batch,
Translator.getMsg("conv.name." + currentConvo.getCurrent().speaker) + ": ", 10,
120);
font.drawWrapped(batch, Translator.getMsg(currentConvo.getCurrent().text), 10, 100,
Gdx.graphics.getWidth() - 20);
drawInverse(Translator.getMsg("conversation.next"), Gdx.graphics.getWidth() - 8, 20);
batch.setColor(Color.WHITE);
}
if (this.getScreen() != null) {
if (Settings.debug) ((Updateable) this.getScreen()).renderDebug(this.renderDebug());
}
batch.end();
fpstimer += Gdx.graphics.getDeltaTime();
if (fpstimer >= 1) {
fpstimer
int[] temp = lastFPS.clone();
for (int i = 1; i < lastFPS.length; i++) {
lastFPS[i] = temp[i - 1];
}
lastFPS[0] = Gdx.graphics.getFramesPerSecond();
}
totalSeconds += Gdx.graphics.getDeltaTime();
warpshader.begin();
warpshader.setUniformf(warpshader.getUniformLocation("time"), totalSeconds);
warpshader.setUniformf(warpshader.getUniformLocation("amplitude"), 0.25f, 0.1f);
warpshader.setUniformf(warpshader.getUniformLocation("frequency"), 10f, 5f);
warpshader.setUniformf(warpshader.getUniformLocation("speed"), 2.5f);
warpshader.end();
inputUpdate();
}
private int renderDebug() {
int offset = 0;
if (getScreen() != null) offset = ((Updateable) getScreen()).getDebugOffset();
if (MemoryUtils.getUsedMemory() > getMostMemory) getMostMemory = MemoryUtils
.getUsedMemory();
font.setColor(Color.WHITE);
font.draw(batch, "version: " + Main.version
+ (latestVersion.equals("") ? "" : "; server: " + Main.latestVersion), 5,
Main.convertY(30 + offset));
font.draw(batch, "Memory: "
+ NumberFormat.getInstance().format(MemoryUtils.getUsedMemory()) + " KB / "
+ NumberFormat.getInstance().format(MemoryUtils.getMaxMemory()) + " KB (max "
+ NumberFormat.getInstance().format(getMostMemory) + " KB) ", 5,
Main.convertY(45 + offset));
font.draw(batch, "Available cores: " + MemoryUtils.getCores(), 5,
Main.convertY(60 + offset));
font.draw(batch, "OS: " + System.getProperty("os.name"), 5, Main.convertY(75 + offset));
if (getScreen() != null) {
font.draw(batch, "state: " + getScreen().getClass().getSimpleName(), 5,
Main.convertY(90 + offset));
} else {
font.draw(batch, "state: null", 5, Main.convertY(90 + offset));
}
return 75 + 30 + offset;
}
public void inputUpdate() {
if (Gdx.input.isKeyJustPressed(Keys.F12)) {
Settings.debug = !Settings.debug;
} else if (Gdx.input.isKeyJustPressed(Keys.F5)) {
ScreenshotFactory.saveScreenshot();
}
if (Settings.debug) { // console things -> alt + key
if (((Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT)))) {
if (Gdx.input.isKeyJustPressed(Keys.C)) {
if (consolewindow.isVisible()) {
consolewindow.setVisible(false);
} else {
consolewindow.setVisible(true);
conscrollPane.getVerticalScrollBar().setValue(
conscrollPane.getVerticalScrollBar().getMaximum());
}
} else if (Gdx.input.isKeyJustPressed(Keys.Q)) {
throw new GameException(
"This is a forced crash caused by pressing ALT+Q while in debug mode.");
} else if (Gdx.input.isKeyJustPressed(Keys.L) && getScreen() != Main.ASSETLOADING) {
LEVELEDITOR.resetWorld();
setScreen(LEVELEDITOR);
} else if (Gdx.input.isKeyJustPressed(Keys.A)) {
toShow.add(new Appearance(Achievements.instance().achievements.get(Achievements
.instance().achievementId.get("test"))));
} else if (Gdx.input.isKeyJustPressed(Keys.G)) {
gears.reset();
}
}
}
}
public void tickUpdate() {
if (!(toShow.size == 0)) {
if (toShow.first().time == Appearance.startingTime) {
manager.get(AssetMap.get("questcomplete"), Sound.class).play(0.5f);
}
if (toShow.first().time > 0) {
toShow.first().time
} else if (toShow.first().time <= 0 && toShow.first().y <= 0) {
toShow.removeIndex(0);
}
}
}
private void loadAssets() {
AssetMap.instance(); // load asset map namer thing
Achievements.instance();
Translator.instance();
Conversations.instance();
addColors();
// missing
manager.load(AssetMap.add("blockmissingtexture", "images/blocks/missing/missing.png"),
Texture.class);
manager.load(AssetMap.add("missingtexture", "images/missing.png"), Texture.class);
// blocks
Blocks.instance().addBlockTextures(this);
manager.load(AssetMap.add("spacekraken", "images/ui/misc.png"), Texture.class);
manager.load(AssetMap.add("guilanguage", "images/ui/button/language.png"), Texture.class);
manager.load(AssetMap.add("guisettings", "images/ui/button/settings.png"), Texture.class);
manager.load(AssetMap.add("guibg", "images/ui/button/bg.png"), Texture.class);
manager.load(AssetMap.add("guislider", "images/ui/button/slider.png"), Texture.class);
manager.load(AssetMap.add("guisliderarrow", "images/ui/button/sliderarrow.png"),
Texture.class);
manager.load(AssetMap.add("guiexit", "images/ui/button/exit.png"), Texture.class);
manager.load(AssetMap.add("guiback", "images/ui/button/backbutton.png"), Texture.class);
manager.load(AssetMap.add("guibgfalse", "images/ui/button/bgfalse.png"), Texture.class);
manager.load(AssetMap.add("guibgtrue", "images/ui/button/bgtrue.png"), Texture.class);
manager.load(AssetMap.add("detectionarrow", "images/ui/detection.png"), Texture.class);
manager.load(AssetMap.add("guilevelselect", "images/ui/button/levelselect.png"),
Texture.class);
manager.load(AssetMap.add("guinextlevel", "images/ui/button/nextlevel.png"), Texture.class);
manager.load(AssetMap.add("guiretry", "images/ui/button/retry.png"), Texture.class);
manager.load("images/ui/damage/yourMother.png", Texture.class);
manager.load("images/ui/damage/spikes.png", Texture.class);
manager.load("images/ui/damage/generic.png", Texture.class);
manager.load("images/ui/damage/fire.png", Texture.class);
manager.load("images/ui/damage/electric.png", Texture.class);
manager.load("images/ui/damage/theVoid.png", Texture.class);
manager.load(AssetMap.add("playerdirectionarrow", "images/ui/player-arrow.png"),
Texture.class);
// particle
manager.load(AssetMap.add("money", "images/particle/money.png"), Texture.class);
manager.load(AssetMap.add("checkpoint", "images/particle/checkpoint.png"), Texture.class);
manager.load(AssetMap.add("poof", "images/particle/poof.png"), Texture.class);
manager.load(AssetMap.add("sparkle", "images/particle/sparkle.png"), Texture.class);
manager.load(AssetMap.add("arrowup", "images/particle/arrow/up.png"), Texture.class);
manager.load(AssetMap.add("arrowdown", "images/particle/arrow/down.png"), Texture.class);
manager.load(AssetMap.add("arrowleft", "images/particle/arrow/left.png"), Texture.class);
manager.load(AssetMap.add("arrowright", "images/particle/arrow/right.png"), Texture.class);
manager.load(AssetMap.add("arrowcentre", "images/particle/arrow/centre.png"), Texture.class);
manager.load(AssetMap.add("lasercube", "images/particle/lasercube.png"), Texture.class);
manager.load(AssetMap.add("particlepower", "images/particle/power.png"), Texture.class);
manager.load(AssetMap.add("magnetglow", "images/particle/magnetglow.png"), Texture.class);
manager.load(AssetMap.add("airwhoosh", "images/particle/airwhoosh.png"), Texture.class);
manager.load(AssetMap.add("particlecircle", "images/particle/circle.png"), Texture.class);
manager.load(AssetMap.add("particlestar", "images/particle/star.png"), Texture.class);
// cutscene
manager.load("images/cutscene/stunning.png", Texture.class);
manager.load("images/cutscene/stunning2.png", Texture.class);
manager.load("images/cutscene/controls0.png", Texture.class);
manager.load("images/cutscene/controls1.png", Texture.class);
manager.load("images/cutscene/controls2.png", Texture.class);
manager.load("images/cutscene/rep.png", Texture.class);
manager.load("images/cutscene/scientistface.png", Texture.class);
// effects
manager.load(AssetMap.add("effecticonblindness", "images/ui/effect/icon/blindness.png"),
Texture.class);
manager.load(AssetMap.add("effectoverlayblindness", "images/ui/effect/blindness.png"),
Texture.class);
// entities
manager.load(AssetMap.add("player", "images/entity/player/player.png"), Texture.class);
manager.load(AssetMap.add("playerGears", "images/entity/player/Copy of player.png"),
Texture.class);
manager.load(AssetMap.add("smallasteroid", "images/entity/smallasteroid.png"),
Texture.class);
manager.load(AssetMap.add("entityzaborinox", "images/entity/zaborinox.png"), Texture.class);
manager.load(AssetMap.add("entitywhale", "images/entity/whale.png"), Texture.class);
// misc
manager.load(AssetMap.add("vignette", "images/ui/vignette.png"), Texture.class);
manager.load(AssetMap.add("entityshield", "images/entity/shield.png"), Texture.class);
manager.load(AssetMap.add("levelselectbg", "images/levelselectbg.png"), Texture.class);
manager.load(AssetMap.add("levelselectdot", "images/levelselectdot.png"), Texture.class);
manager.load(AssetMap.add("levelselected", "images/levelselected.png"), Texture.class);
manager.load(AssetMap.add("glintsquare", "images/item/glintsquare.png"), Texture.class);
manager.load(AssetMap.add("voidend", "images/voidend.png"), Texture.class);
manager.load(AssetMap.add("circlegradient", "images/circlegradient.png"), Texture.class);
manager.load(AssetMap.add("stunhalo", "images/stunhalo.png"), Texture.class);
// level backgrounds
manager.load(AssetMap.add("levelbgcity", "images/levelbg/city.png"), Texture.class);
manager.load(AssetMap.add("levelbgcircuit", "images/levelbg/circuit.png"), Texture.class);
// colour
manager.load(AssetMap.add("colourblue", "images/colour/blue.png"), Texture.class);
manager.load(AssetMap.add("colourred", "images/colour/red.png"), Texture.class);
manager.load(AssetMap.add("colourorange", "images/colour/orange.png"), Texture.class);
manager.load(AssetMap.add("colourgreen", "images/colour/green.png"), Texture.class);
manager.load(AssetMap.add("colourpurple", "images/colour/purple.png"), Texture.class);
manager.load(AssetMap.add("colouryellow", "images/colour/yellow.png"), Texture.class);
manager.load(AssetMap.add("colourmetal", "images/colour/metal_back.jpg"), Texture.class);
manager.load(AssetMap.add("colourpointer1", "images/colour/pointer1.png"), Texture.class);
manager.load(AssetMap.add("colourpointer2", "images/colour/pointer2.png"), Texture.class);
manager.load(AssetMap.add("colournuclear", "images/colour/radioactiveFull.png"),
Texture.class);
// sfx
manager.load(AssetMap.add("questcomplete", "sounds/questcomplete.ogg"), Sound.class);
manager.load(AssetMap.add("switchsfx", "sounds/switch.ogg"), Sound.class);
manager.load(AssetMap.add("voidambient", "sounds/ambient/void.ogg"), Sound.class);
// voice (assetmap -> "voice-<voice in convs>")
// music
// colour
manager.load(AssetMap.add("colour200pts", "sounds/colour/200pts.ogg"), Sound.class);
manager.load(AssetMap.add("colourswap", "sounds/colour/apocalypseSwap.ogg"), Sound.class);
manager.load(AssetMap.add("colourcoverup", "sounds/colour/coverUpAndLand.ogg"), Sound.class);
manager.load(AssetMap.add("colourincorrect", "sounds/colour/incorrect.ogg"), Sound.class);
}
private void loadUnmanagedAssets() {
// misc
// unmanaged textures
textures.put("gear", new Texture("images/gear.png"));
gears = new Gears(this);
textures.put("switch", new Texture("images/blocks/switch/switch.png"));
textures.put("switch_bg", new Texture("images/blocks/switch/switch_bg.png"));
textures.put("timer", new Texture("images/blocks/timer/timer.png"));
textures.put("timer_colour", new Texture("images/blocks/timer/timer_colour.png"));
textures.put("toggle", new Texture("images/blocks/toggle/toggle.png"));
textures.put("toggle_warning", new Texture("images/blocks/toggle/toggle_warning.png"));
// animations
animations.put("shine",
new LoopingAnimation(0.1f, 20, "images/item/shine/shine.png", false));
animations.put("portal", new LoopingAnimation(0.05f, 32, "images/blocks/portal/portal.png",
true).setRegionTile(64, 64));
animations.put("fire", new LoopingAnimation(0.05f, 30, "images/blocks/fire/fire.png", true)
.setRegionTile(128, 128).setVertical(false));
animations.put("fire-hud", new LoopingAnimation(0.05f, 8, "images/ui/fire-hudnomiddle.png",
true).setRegionTile(864, 468).setVertical(false));
animations.put("jumppad", new LoopingAnimation(0.25f, 4,
"images/blocks/jumppad/jumppad.png", true).setRegionTile(64, 64));
animations.put("accelerationpad", new LoopingAnimation(0.5f, 2,
"images/blocks/accpad/accelerationpad.png", true).setRegionTile(64, 64)
.setVertical(false));
// load animations
Iterator it = animations.entrySet().iterator();
while (it.hasNext()) {
((LoopingAnimation) ((Entry) it.next()).getValue()).load();
}
}
private void addColors() {
Colors.put("VOID_PURPLE", new Color(123f / 255f, 0, 1, 1));
// text related
Colors.put("PERSON", new Color(37 / 255f, 217 / 255f, 217 / 255f, 1));
Colors.put("DANGER", new Color(1, 0, 0, 1));
Colors.put("OBJECT", new Color(1, 217 / 255f, 0, 1));
Colors.put("VERB", new Color(1, 75 / 255f, 3 / 255f, 1));
Colors.put("KEY", new Color(0, 204 / 255f, 0, 1));
}
private static Vector2 unprojector = new Vector2(0, 0);
public static int getInputX() {
return (int) (Gdx.input.getX() * getScaleFactorX());
// return ((int) (viewport.unproject(unprojector.set(Gdx.input.getX(),
// Gdx.input.getY())).x));
}
public static int getInputY() {
return (int) (Gdx.input.getY() * getScaleFactorY());
// return viewport.getScreenHeight()
// - ((int) (viewport.unproject(unprojector.set(Gdx.input.getX(),
// Gdx.input.getY())).y));
}
public static float getScaleFactorX() {
return ((Gdx.graphics.getWidth() * 1f) / Settings.DEFAULT_WIDTH);
}
public static float getScaleFactorY() {
return ((Gdx.graphics.getHeight() * 1f) / Settings.DEFAULT_HEIGHT);
}
public Texture getCurrentShine() {
return animations.get("shine").getCurrentFrame().getTexture();
}
public static String getTitle() {
return (Translator.getMsg("gamename") + " " + Main.version);
}
public void awardAchievement(String id) {
Achievement a = Achievements.instance().achievements
.get(Achievements.instance().achievementId.get(id));
if (achievements.getAll().get(a) == false) {
toShow.add(new Appearance(a));
achievements.complete(a);
achievements.save("achievement", getPref("achievements"));
}
}
@Override
public void resize(int x, int y) {
viewport.update(x, y, false);
viewport.apply();
camera.setToOrtho(false, x, y);
}
public void redirectSysOut() {
PrintStream ps = System.out;
output = new CaptureStream(this, ps);
printstrm = new PrintStream(output);
resetConsole();
System.setOut(printstrm);
}
public Conversation getConv() {
return currentConvo;
}
public void resetConsole() {
consolewindow = new JFrame();
consolewindow.setTitle("Console for " + Translator.getMsg("gamename") + " " + Main.version);
consolewindow.setVisible(false);
consoletext = new JTextArea(40, 60);
consoletext.setEditable(false);
conscrollPane = new JScrollPane(consoletext);
consolewindow.add(conscrollPane, null);
consolewindow.pack();
}
public void resetSystemOut() {
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
}
@Override
public void appendText(final String text) {
consoletext.append(text);
consoletext.setCaretPosition(consoletext.getText().length());
}
public void setConv(Conversation c) {
if (currentConvo != null) {
currentConvo.reset();
}
currentConvo = c;
if (currentConvo != null) {
currentConvo.talk(this, 1 / 3f);
}
}
public void transition(Transition from, Transition to, Screen next) {
TRANSITION.prepare(this.getScreen(), from, to, next);
setScreen(TRANSITION);
}
public static Color getRainbow() {
return getRainbow(1, 1);
}
public static Color getRainbow(float s) {
return getRainbow(s, 1);
}
public static Color getRainbow(float s, float saturation) {
return rainbow.set(
Utils.HSBtoRGBA8888(
(s < 0 ? 1.0f : 0)
- MathHelper.getNumberFromTime(System.currentTimeMillis(),
Math.abs(s)), saturation, 0.75f)).clamp();
}
public InputMultiplexer getDefaultInput() {
InputMultiplexer plexer = new InputMultiplexer();
plexer.addProcessor(new MainInputProcessor(this));
return plexer;
}
private static Random random = new Random();
public static Random getRandom() {
return random;
}
public void fillRect(float x, float y, float width, float height) {
batch.draw(filltex, x, y, width, height);
}
public static String getSpecialChar(String type) {
if (type.equals("power") || type.equals("electricity")) {
return Character.toString((char) 221);
} else if (type.equals("zacharie")) {
return Character.toString((char) 189);
}
return type;
}
/**
* Directions to use
*
* 1) Draw original texture (the base tex) on main batch - this renders the
* actual sprite
*
* 2) end main batch, start itemRenderer
*
* 3) call this method (base tex, mask) - prepares mask
*
* 4) re-draw original texture (base tex) - draws the stencil (which uses
* base tex)
*
* 5) end itemRenderer, begin main batch
*
*
*
* @param mask
* mask itself (generally base tex as well)
* @param tostencil
* texture to cake on
*/
public static void useMask(Texture mask, Texture tostencil) {
// bind mask to glActiveTexture(GL_TEXTURE2)
mask.bind(2);
// bind sprite to glActiveTexture(GL_TEXTURE1)
tostencil.bind(1);
// now we need to reset glActiveTexture to zero!!!! since sprite batch
// does not do this for us
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
}
private static final char specialDelimiter = '`';
/**
* call sparingly
*
* @param data
* @return
*/
public static String convertStringToSpecial(String data) {
boolean found = false;
String ret = data.toString();
StringBuilder copy = new StringBuilder();
char[] arr = data.toCharArray();
for (int i = 0; i < arr.length; i++) {
char c = arr[i];
if (found) { // inside
if (c == specialDelimiter) {
ret = ret.replace(
Character.toString(specialDelimiter) + copy
+ Character.toString(specialDelimiter),
getSpecialChar(copy.toString()));
found = false;
copy = new StringBuilder();
} else {
copy.append(c);
}
} else {
if (c == specialDelimiter) {
found = true;
}
}
}
return ret;
}
/**
* converts y-down to y-up
*
* @param f
* the num. of px down from the top of the screen
* @return the y-down conversion of input
*/
public static int convertY(float f) {
return Math.round(Settings.DEFAULT_HEIGHT - f);
}
public void drawInverse(String s, float x, float y) {
font.draw(batch, s, x - font.getBounds(s).width, y);
}
public void drawCentered(String s, float x, float y) {
font.draw(batch, s, x - (font.getBounds(s).width / 2), y);
}
public void drawTextBg(String text, float x, float y) {
batch.setColor(0, 0, 0, batch.getColor().a * 0.6f);
fillRect(x, y, font.getBounds(text).width + 2, 17);
font.draw(batch, text, x + 1, y + 15);
batch.setColor(1, 1, 1, 1);
}
public void drawScaled(String text, float x, float y, float width, float padding) {
if (font.getBounds(text).width + (padding * 2) > width) {
font.setScale(width / (font.getBounds(text).width + (padding * 2)));
}
drawCentered(text, x, y);
font.setScale(1);
}
public void renderAchievements() {
// achievement -- 0 is fully up, 64 is fully down
if (!(toShow.size == 0)) {
Appearance ap = toShow.first();
if (ap.time > 0) {
if (ap.y < 64) {
ap.y += 192 * Gdx.graphics.getDeltaTime();
if (ap.y > 64) ap.y = 64;
}
} else { // retract
if (ap.y > 0) {
ap.y -= 192 * Gdx.graphics.getDeltaTime();
if (ap.y < 0) ap.y = 0;
}
}
if (ap.a.special) {
batch.setColor(Main.getRainbow(-1));
}
batch.draw(manager.get(AssetMap.get("achievementui"), Texture.class),
Gdx.graphics.getWidth() - 256, Main.convertY(ap.y));
font.setColor(Main.getRainbow());
drawCentered(Translator.getMsg("achievementget"), Gdx.graphics.getWidth() - 128,
Main.convertY(ap.y - 60));
font.setColor(Color.WHITE);
font.setScale(0.75f);
font.drawWrapped(batch, Translator.getMsg("achievement." + ap.a.data + ".name") + " - "
+ Translator.getMsg("achievement." + ap.a.data + ".desc"),
Gdx.graphics.getWidth() - 250, Main.convertY(ap.y - 45), 246);
font.setScale(1f);
batch.setColor(Color.WHITE);
}
}
private int totalavgFPS = 0;
private float fpstimer = 0;
public float getAvgFPS() {
totalavgFPS = 0;
for (int i = 0; i < lastFPS.length; i++) {
totalavgFPS += lastFPS[i];
}
return ((totalavgFPS) / (lastFPS.length * 1f));
}
public int getMostMemory = MemoryUtils.getUsedMemory();
public int getDifficulty() {
return progress.getInteger("difficulty", Difficulty.NORMAL_ID);
}
/**
* basically appends "stray-" to the beginning of your preference
*
* Preferences used: settings, achievements, progress
*
* @param ref
* @return preferences
*/
public static Preferences getPref(String ref) {
return Gdx.app.getPreferences("stray-" + ref);
}
public void setClearColor(int r, int g, int b) {
Gdx.gl20.glClearColor(r / 255f, g / 255f, b / 255f, 1f);
}
}
|
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import java.io.File;
public class Upload {
WebDriver driver;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
}
// If uploading to a Grid node or Sauce Labs, check out driver.setFileDetector()
@Test
public void uploadFile() throws Exception {
String filename = "some-file.txt";
File file = new File(filename);
String path = file.getAbsolutePath();
driver.get("http://the-internet.herokuapp.com/upload");
driver.findElement(By.id("file-upload")).sendKeys(path);
driver.findElement(By.id("file-submit")).click();
String text = driver.findElement(By.id("uploaded-files")).getText();
assertThat(text, is(equalTo(filename)));
}
@After
public void tearDown() throws Exception {
driver.quit();
}
}
|
import java.io.*;
import java.util.concurrent.locks.*;
public class SinglePileSandGrid implements Serializable {
protected int[][] gridQuad;
private transient ReentrantLock lock;
private volatile transient boolean toppling;
private static final long serialVersionUID = 8309200284561310866L;
private static final boolean fairLock = true;
public SinglePileSandGrid(int size) {
gridQuad = new int[size][size];
lock = new ReentrantLock(fairLock);
toppling = false;
}
public void place(int sand) {
gridQuad[0][0] += sand;
}
public long topple(String saveFileName) {
int width = gridQuad.length, height = gridQuad[0].length;
int calc_width = 1, calc_height = 1;
boolean isStable;
int loops = 0;
toppling = true;
do {
int new_calc_width = 0, new_calc_height = 0;
isStable = true;
lock.lock();
for (int i = 0; i < calc_width; i++) {
for (int j = 0; j < calc_height; j++) {
int sand = gridQuad[i][j];
if (sand >= 4) {
new_calc_width = Math.max(i+2, new_calc_width);
new_calc_height = Math.max(j+2, new_calc_height);
new_calc_width = Math.min(new_calc_width, width);
new_calc_height = Math.min(new_calc_height, height);
isStable = false;
gridQuad[i][j] &= 3;
if (i > 1) {
gridQuad[i-1][j] += sand >>> 2;
}
else if (i == 1) {
gridQuad[0][j] += sand >>> 2 << 1;
}
if (i < width - 1) {
gridQuad[i+1][j] += sand >>> 2;
}
if (j > 1) {
gridQuad[i][j-1] += sand >>> 2;
}
else if (j == 1) {
gridQuad[i][0] += sand >>> 2 << 1;
}
if (j < height - 1) {
gridQuad[i][j+1] += sand >>> 2;
}
}
}
}
lock.unlock();
calc_width = new_calc_width;
calc_height = new_calc_height;
if (calc_width >= width || calc_height >= height) {
resize(width * 2, height * 2);
width *= 2;
height *= 2;
}
loops++;
} while (!isStable && toppling);
toppling = false;
return loops;
}
public void stopTopple() {
toppling = false;
}
public int amountSand() {
int sand = 0;
lock.lock();
for (int i = 0; i < gridQuad.length; i++) {
for (int j = 0; j < gridQuad[0].length; j++) {
sand += gridQuad[i][j];
}
}
lock.unlock();
return sand;
}
public void trim() {
lock.lock();
int width = gridQuad.length, height = gridQuad[0].length;
int maxX = 1, maxY = 1;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if (gridQuad[i][j] >= 4) {
maxX = Math.max(i, maxX);
maxY = Math.max(j, maxY);
}
}
}
int[][] newGrid = new int[maxX][maxY];
for (int i = 0; i < maxX; i++) {
for (int j = 0; j < maxY; j++) {
newGrid[i][j] = gridQuad[i][j];
}
}
gridQuad = newGrid;
lock.unlock();
}
public int getWidth() {
return gridQuad.length * 2 - 1;
}
public int getHeight() {
return gridQuad[0].length * 2 - 1;
}
public void resize(int w, int h) {
lock.lock();
int[][] newGrid = new int[w][h];
int width = Math.min(gridQuad.length, w);
int height = Math.min(gridQuad[0].length, h);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
newGrid[i][j] = gridQuad[i][j];
}
}
gridQuad = newGrid;
lock.unlock();
}
public int[][] getGrid() {
return gridQuad;
}
public SandPileGrid toSandPileGrid() {
lock.lock();
int width = gridQuad.length, height = gridQuad[0].length;
int fullWidth = width * 2 - 1, fullHeight = height * 2 - 1;
int[][] fullGrid = new int[fullWidth][fullHeight];
for (int i = 0; i < fullWidth; i++) {
for (int j = 0; j < fullHeight; j++) {
int x = Math.abs(i - (width - 1));
int y = Math.abs(j - (height - 1));
fullGrid[i][j] = gridQuad[x][y];
}
}
lock.unlock();
return new SandPileGrid(fullGrid);
}
private void writeObject(ObjectOutputStream out) throws IOException {
lock.lock();
try {
out.writeObject(gridQuad);
} finally {
lock.unlock();
}
}
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
gridQuad = (int[][]) in.readObject();
lock = new ReentrantLock(fairLock);
}
}
|
package com.plugin.gcm;
import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.os.Build;
import android.graphics.Color;
import com.google.android.gcm.GCMBaseIntentService;
@SuppressLint("NewApi")
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super("GCMIntentService");
}
@Override
public void onRegistered(Context context, String regId) {
Log.v(TAG, "onRegistered: " + regId);
JSONObject json;
try {
json = new JSONObject().put("event", "registered");
json.put("regid", regId);
Log.v(TAG, "onRegistered: " + json.toString());
// Send this JSON data to the JavaScript application above EVENT should be set to the msg type
// In this case this is the registration ID
PushPlugin.sendJavascript(json);
} catch (JSONException e) {
// No message to the user is sent, JSON failed
Log.e(TAG, "onRegistered: JSON exception");
}
}
@Override
public void onUnregistered(Context context, String regId) {
Log.d(TAG, "onUnregistered - regId: " + regId);
}
@Override
protected void onMessage(Context context, Intent intent) {
Log.d(TAG, "onMessage - context: " + context);
// Extract the payload from the message
Bundle extras = intent.getExtras();
if (extras != null) {
// if we are in the foreground, just surface the payload, else post it to the statusbar
if (PushPlugin.isInForeground()) {
extras.putBoolean("foreground", true);
PushPlugin.sendExtras(extras);
} else {
extras.putBoolean("foreground", false);
// Send a notification if there is a message
if (extras.getString("message") != null && extras.getString("message").length() != 0) {
createNotification(context, extras);
}
}
}
}
public void createNotification(Context context, Bundle extras) {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String appName = getAppName(this);
Intent notificationIntent = new Intent(this, PushHandlerActivity.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
notificationIntent.putExtra("pushBundle", extras);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int defaults = Notification.DEFAULT_ALL;
if (extras.getString("defaults") != null) {
try {
defaults = Integer.parseInt(extras.getString("defaults"));
} catch (NumberFormatException e) {}
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setDefaults(defaults)
.setSmallIcon(getNotificationIcon(context))
.setWhen(System.currentTimeMillis())
.setContentTitle(extras.getString("title"))
.setTicker(extras.getString("title"))
.setContentIntent(contentIntent)
.setAutoCancel(true);
String color = extras.getString("color");
if(color != null) {
mBuilder.setColor(Color.parseColor(color));
}
String message = extras.getString("message");
if (message != null) {
mBuilder.setContentText(message);
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
} else {
mBuilder.setContentText("<missing message content>");
}
String msgcnt = extras.getString("msgcnt");
if (msgcnt != null) {
mBuilder.setNumber(Integer.parseInt(msgcnt));
}
int notId = 0;
try {
notId = Integer.parseInt(extras.getString("notId"));
} catch (NumberFormatException e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID: " + e.getMessage());
} catch (Exception e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}
mNotificationManager.notify((String) appName, notId, mBuilder.build());
}
private static String getAppName(Context context) {
CharSequence appName = context.getPackageManager()
.getApplicationLabel(context.getApplicationInfo());
return (String) appName;
}
private int getNotificationIcon(Context context) {
boolean isLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
if (isLollipop) {
Resources r = getResources();
return r.getIdentifier("notification_icon", "raw", context.getPackageName());
}
return context.getApplicationInfo().icon;
}
@Override
public void onError(Context context, String errorId) {
Log.e(TAG, "onError - errorId: " + errorId);
}
}
|
package com.plugin.gcm;
import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.android.gcm.GCMBaseIntentService;
@SuppressLint("NewApi")
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super("GCMIntentService");
}
@Override
public void onRegistered(Context context, String regId) {
Log.v(TAG, "onRegistered: "+ regId);
JSONObject json;
try
{
json = new JSONObject().put("event", "registered");
json.put("regid", regId);
Log.v(TAG, "onRegistered: " + json.toString());
// Send this JSON data to the JavaScript application above EVENT should be set to the msg type
// In this case this is the registration ID
PushPlugin.sendJavascript( json );
}
catch( JSONException e)
{
// No message to the user is sent, JSON failed
Log.e(TAG, "onRegistered: JSON exception");
}
}
@Override
public void onUnregistered(Context context, String regId) {
Log.d(TAG, "onUnregistered - regId: " + regId);
}
@Override
protected void onMessage(Context context, Intent intent) {
Log.d(TAG, "onMessage - context: " + context);
// Extract the payload from the message
Bundle extras = intent.getExtras();
if (extras != null)
{
// if we are in the foreground, just surface the payload, else post it to the statusbar
if (PushPlugin.isInForeground()) {
extras.putBoolean("foreground", true);
PushPlugin.sendExtras(extras);
}
else {
extras.putBoolean("foreground", false);
// Send a notification if there is a message
if (extras.getString("message") != null && extras.getString("message").length() != 0) {
// createNotification(context, extras);
}
}
}
}
public void createNotification(Context context, Bundle extras)
{
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String appName = getAppName(this);
Intent notificationIntent = new Intent(this, PushHandlerActivity.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
notificationIntent.putExtra("pushBundle", extras);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int defaults = Notification.DEFAULT_ALL;
if (extras.getString("defaults") != null) {
try {
defaults = Integer.parseInt(extras.getString("defaults"));
} catch (NumberFormatException e) {}
}
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setDefaults(defaults)
.setSmallIcon(context.getApplicationInfo().icon)
.setWhen(System.currentTimeMillis())
.setContentTitle(extras.getString("title"))
.setTicker(extras.getString("title"))
.setContentIntent(contentIntent)
.setAutoCancel(true);
String message = extras.getString("message");
if (message != null) {
mBuilder.setContentText(message);
} else {
mBuilder.setContentText("<missing message content>");
}
String msgcnt = extras.getString("msgcnt");
if (msgcnt != null) {
mBuilder.setNumber(Integer.parseInt(msgcnt));
}
int notId = 0;
try {
notId = Integer.parseInt(extras.getString("notId"));
}
catch(NumberFormatException e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID: " + e.getMessage());
}
catch(Exception e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}
mNotificationManager.notify((String) appName, notId, mBuilder.build());
}
private static String getAppName(Context context)
{
CharSequence appName =
context
.getPackageManager()
.getApplicationLabel(context.getApplicationInfo());
return (String)appName;
}
@Override
public void onError(Context context, String errorId) {
Log.e(TAG, "onError - errorId: " + errorId);
}
}
|
package plugin.google.maps;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class PluginMarker extends MyPlugin {
private HashMap<String, Bitmap> cache = null;
/**
* Create a marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void createMarker(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
if (cache == null) {
cache = new HashMap<String, Bitmap>();
}
// Create an instance of Marker class
final MarkerOptions markerOptions = new MarkerOptions();
JSONObject opts = args.getJSONObject(1);
if (opts.has("position")) {
JSONObject position = opts.getJSONObject("position");
markerOptions.position(new LatLng(position.getDouble("lat"), position.getDouble("lng")));
}
if (opts.has("title")) {
markerOptions.title(opts.getString("title"));
}
if (opts.has("snippet")) {
markerOptions.snippet(opts.getString("snippet"));
}
if (opts.has("visible")) {
markerOptions.visible(opts.getBoolean("visible"));
}
if (opts.has("draggable")) {
markerOptions.draggable(opts.getBoolean("draggable"));
}
if (opts.has("rotation")) {
markerOptions.rotation((float)opts.getDouble("rotation"));
}
if (opts.has("flat")) {
markerOptions.flat(opts.getBoolean("flat"));
}
if (opts.has("opacity")) {
markerOptions.alpha((float) opts.getDouble("opacity"));
}
Marker marker = map.addMarker(markerOptions);
// Store the marker
String id = "marker_" + marker.getId();
this.objects.put(id, marker);
// Load icon
if (opts.has("icon")) {
Bundle bundle = null;
Object value = opts.get("icon");
if (JSONObject.class.isInstance(value)) {
bundle = PluginUtil.Json2Bundle((JSONObject)value);
} else {
bundle = new Bundle();
bundle.putString("url", (String)value);
}
this.setIcon_(marker, bundle);
}
//Return the result
JSONObject result = new JSONObject();
result.put("hashCode", marker.hashCode());
result.put("id", id);
callbackContext.success(result);
}
/**
* Show the InfoWindow binded with the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void showInfoWindow(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Marker marker = this.getMarker(id);
marker.showInfoWindow();
callbackContext.success();
}
/**
* Set rotation for the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setRotation(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
float rotation = (float)args.getDouble(2);
String id = args.getString(1);
this.setFloat("setRotation", id, rotation, callbackContext);
callbackContext.success();
}
/**
* Set opacity for the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setOpacity(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
float alpha = (float)args.getDouble(2);
String id = args.getString(1);
this.setFloat("setAlpha", id, alpha, callbackContext);
}
/**
* set position
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setPosition(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
LatLng position = new LatLng(args.getDouble(2), args.getDouble(3));
Marker marker = this.getMarker(id);
marker.setPosition(position);
callbackContext.success();
}
/**
* Set flat for the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setFlat(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
boolean isFlat = args.getBoolean(2);
String id = args.getString(1);
this.setBoolean("setFlat", id, isFlat, callbackContext);
}
/**
* Set visibility for the object
* @param args
* @param callbackContext
* @throws JSONException
*/
protected void setVisible(JSONArray args, CallbackContext callbackContext) throws JSONException {
boolean visible = args.getBoolean(2);
String id = args.getString(1);
this.setBoolean("setVisible", id, visible, callbackContext);
}
/**
* Set title for the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setTitle(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String title = args.getString(2);
String id = args.getString(1);
this.setString("setTitle", id, title, callbackContext);
}
/**
* Set the snippet for the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setSnippet(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String snippet = args.getString(2);
String id = args.getString(1);
this.setString("setSnippet", id, snippet, callbackContext);
}
/**
* Hide the InfoWindow binded with the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void hideInfoWindow(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Marker marker = this.getMarker(id);
marker.hideInfoWindow();
callbackContext.success();
}
/**
* Return the position of the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void getPosition(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Marker marker = this.getMarker(id);
LatLng position = marker.getPosition();
JSONObject result = new JSONObject();
result.put("lat", position.latitude);
result.put("lng", position.longitude);
callbackContext.success(result);
}
/**
* Return 1 if the InfoWindow of the marker is shown
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void isInfoWindowShown(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Marker marker = this.getMarker(id);
Boolean isInfoWndShown = marker.isInfoWindowShown();
callbackContext.success(isInfoWndShown ? 1 : 0);
}
/**
* Remove the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void remove(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Marker marker = this.getMarker(id);
if (marker == null) {
callbackContext.success();
return;
}
marker.remove();
this.objects.remove(id);
callbackContext.success();
}
/**
* Set anchor for the InfoWindow of the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setAnchor(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
float anchorU = (float)args.getDouble(2);
float anchorV = (float)args.getDouble(3);
String id = args.getString(1);
Marker marker = this.getMarker(id);
marker.setInfoWindowAnchor(anchorU, anchorV);
callbackContext.success();
}
/**
* Set draggable for the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setDraggable(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
Boolean draggable = args.getBoolean(2);
String id = args.getString(1);
this.setBoolean("setDraggable", id, draggable, callbackContext);
}
/**
* Set icon of the marker
* @param args
* @param callbackContext
* @throws JSONException
*/
@SuppressWarnings("unused")
private void setIcon(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
String id = args.getString(1);
Marker marker = this.getMarker(id);
Bundle bundle = null;
Object value = args.get(2);
if (JSONObject.class.isInstance(value)) {
bundle = PluginUtil.Json2Bundle((JSONObject)value);
} else {
bundle = new Bundle();
bundle.putString("url", (String)value);
}
callbackContext.success();
}
private void setIcon_(Marker marker, Bundle iconProperty) {
String iconUrl = iconProperty.getString("url");
if (iconUrl == null) {
return;
}
if (iconUrl.indexOf("http") == -1) {
Bitmap image = null;
if (iconUrl.indexOf("data:image/") > -1 && iconUrl.indexOf(";base64,") > -1) {
String[] tmp = iconUrl.split(",");
image = PluginUtil.getBitmapFromBase64encodedImage(tmp[1]);
} else {
AssetManager assetManager = this.cordova.getActivity().getAssets();
InputStream inputStream;
try {
inputStream = assetManager.open(iconUrl);
image = BitmapFactory.decodeStream(inputStream);
} catch (IOException e) {
e.printStackTrace();
return;
}
}
if (image == null) {
return;
}
if (iconProperty.containsKey("size") == true) {
Object size = iconProperty.get("size");
if (Bundle.class.isInstance(size)) {
Bundle sizeInfo = (Bundle)size;
int width = sizeInfo.getInt("width", 0);
int height = sizeInfo.getInt("height", 0);
if (width > 0 && height > 0) {
image = PluginUtil.resizeBitmap(image, width, height);
}
}
}
image = PluginUtil.scaleBitmapForDevice(image);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(image);
marker.setIcon(bitmapDescriptor);
return;
}
if (iconUrl.indexOf("http") == 0) {
AsyncLoadImage task;
if (iconProperty.containsKey("size") == false) {
task = new AsyncLoadImage(marker, "setIcon", cache);
} else {
task = new AsyncLoadImage(marker, "setIcon", iconProperty, cache);
}
task.execute(iconUrl);
}
}
}
|
package model.organization.id;
import java.io.Serializable;
import model.organization.Organization;
/**
* The {@linkplain UniqueId} is class that allows customizable ways for identifying elements of an {@linkplain Organization}.
* <p>
* Implementations of {@linkplain UniqueId} are not required to ensure that instances of {@linkplain UniqueId} are unique because that is the responsibility of
* an {@linkplain Organization}.
* <p>
* In the typical case, uniqueness is ensured by the parameter that is passed to the constructor of a subclass of {@linkplain UniqueId}. For example, if
* <code>x = y</code>, then <code>UniqueId(x).equals(UniqueId(y))</code> should return <code>true</code>. But that does not mean that
* <code>UniqueId(x) = UniqueId(y)</code>.
* <p>
* Should a developer wish to ensure that if <code>x = y</code> then <code>UniqueId(x) = UniqueId(y)</code>, the developer should ensure that such an
* implementation can be used correctly across multiple JVMs because {@linkplain UniqueId} is {@linkplain Serializable}, so {@linkplain UniqueId} should
* de-serialize properly.
*
* @author Christopher Zhong
* @param <T>
* the type of the {@linkplain UniqueId}.
* @since 4.0
*/
@FunctionalInterface
public interface UniqueId<T> extends Serializable {
/**
* Returns the type of this {@linkplain UniqueId}.
*
* @return the type.
*/
Class<T> getType();
@Override
boolean equals(Object object);
@Override
int hashCode();
@Override
String toString();
}
|
// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@
package example;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
public final class MainPanel extends JPanel {
private MainPanel() {
super(new BorderLayout());
String[] columnNames = {"String", "Integer", "Boolean"};
Object[][] data = {
{"aaa", -1, true}
};
DefaultTableModel model = new DefaultTableModel(data, columnNames) {
@Override public Class<?> getColumnClass(int column) {
return getValueAt(0, column).getClass();
}
};
IntStream.range(0, 20)
.mapToObj(i -> new Object[] {"Name: " + i, i, i % 2 == 0})
.forEach(model::addRow);
JTable table = new FishEyeTable(model);
table.setRowSelectionInterval(0, 0);
JScrollPane scroll = new JScrollPane(table);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
scroll.setPreferredSize(new Dimension(320, 240));
add(scroll, BorderLayout.NORTH);
}
public static void main(String[] args) {
EventQueue.invokeLater(MainPanel::createAndShowGui);
}
private static void createAndShowGui() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
Toolkit.getDefaultToolkit().beep();
}
JFrame frame = new JFrame("@title@");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(new MainPanel());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
class FishEyeRowContext implements Serializable {
private static final long serialVersionUID = 1L;
public final int height;
public final Font font;
public final Color color;
protected FishEyeRowContext(int height, Font font, Color color) {
this.height = height;
this.font = font;
this.color = color;
}
}
class FishEyeTable extends JTable {
private final List<FishEyeRowContext> fishEyeRowList;
private final Font minFont;
private transient FishEyeTableHandler handler;
protected FishEyeTable(TableModel m) {
super(m);
Font font = getFont();
minFont = font.deriveFont(8f);
Font font12 = font.deriveFont(10f);
Font font18 = font.deriveFont(16f);
Font font24 = font.deriveFont(22f);
Font font32 = font.deriveFont(30f);
Color color12 = new Color(0xFA_FA_FA);
Color color18 = new Color(0xF5_F5_F5);
Color color24 = new Color(0xF0_F0_F0);
Color color32 = new Color(0xE6_E6_FA);
fishEyeRowList = Arrays.asList(
new FishEyeRowContext(12, font12, color12),
new FishEyeRowContext(18, font18, color18),
new FishEyeRowContext(24, font24, color24),
new FishEyeRowContext(32, font32, color32),
new FishEyeRowContext(24, font24, color24),
new FishEyeRowContext(18, font18, color18),
new FishEyeRowContext(12, font12, color12)
);
}
@Override public void updateUI() {
removeMouseListener(handler);
removeMouseMotionListener(handler);
getSelectionModel().removeListSelectionListener(handler);
super.updateUI();
setColumnSelectionAllowed(false);
setRowSelectionAllowed(true);
setFillsViewportHeight(true);
handler = new FishEyeTableHandler();
addMouseListener(handler);
addMouseMotionListener(handler);
getSelectionModel().addListSelectionListener(handler);
}
private class FishEyeTableHandler extends MouseAdapter implements ListSelectionListener {
protected int prevRow = -1;
protected int prevHeight;
@Override public void mouseMoved(MouseEvent e) {
update(rowAtPoint(e.getPoint()));
}
@Override public void mouseDragged(MouseEvent e) {
update(rowAtPoint(e.getPoint()));
}
@Override public void mousePressed(MouseEvent e) {
e.getComponent().repaint();
}
@Override public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
update(getSelectedRow());
}
private void update(int row) {
if (prevRow == row) {
return;
}
initRowHeight(prevHeight, row);
prevRow = row;
}
}
@Override public void doLayout() {
super.doLayout();
Container p = SwingUtilities.getAncestorOfClass(JViewport.class, this);
if (!(p instanceof JViewport)) {
return;
}
int h = ((JViewport) p).getExtentSize().height;
if (h == handler.prevHeight) {
return;
}
initRowHeight(h, getSelectedRow());
handler.prevHeight = h;
}
@Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
int rowCount = getModel().getRowCount();
Color color = Color.WHITE;
Font font = minFont;
int ccRow = handler.prevRow;
int index = 0;
int rd2 = (fishEyeRowList.size() - 1) / 2;
for (int i = -rd2; i < rowCount; i++) {
if (ccRow - rd2 <= i && i <= ccRow + rd2) {
if (i == row) {
color = fishEyeRowList.get(index).color;
font = fishEyeRowList.get(index).font;
break;
}
index++;
}
}
c.setBackground(color);
c.setFont(font);
if (isRowSelected(row)) {
c.setBackground(getSelectionBackground());
}
return c;
}
private int getViewableColoredRowCount(int idx) {
int rd2 = (fishEyeRowList.size() - 1) / 2;
int rc = getModel().getRowCount();
if (rd2 - idx > 0) {
return rd2 + 1 + idx;
} else if (idx > rc - 1 - rd2 && idx < rc - 1 + rd2) {
return rc - idx + rd2;
}
return fishEyeRowList.size();
}
protected void initRowHeight(int height, int ccRow) {
int rd2 = (fishEyeRowList.size() - 1) / 2;
int rowCount = getModel().getRowCount();
int viewRc = getViewableColoredRowCount(ccRow);
int viewH = getViewHeight(viewRc);
int restRc = rowCount - viewRc;
int restH = height - viewH;
int restRh = Math.max(1, restH / restRc); // restRh = restRh > 0 ? restRh : 1;
int restGap = restH - restRh * restRc;
// System.out.println(String.format("%d-%d=%dx%d+%d=%d", height, viewH, restRc, restRh, restGap, restH));
int index = -1;
for (int i = -rd2; i < rowCount; i++) {
int crh;
if (ccRow - rd2 <= i && i <= ccRow + rd2) {
index++;
if (i < 0) {
continue;
}
crh = fishEyeRowList.get(index).height;
} else {
if (i < 0) {
continue;
}
crh = restRh + (restGap > 0 ? 1 : 0);
restGap
}
setRowHeight(i, crh);
}
}
private int getViewHeight(int count) {
int h = 0;
for (int i = 0; i < count; i++) {
h += fishEyeRowList.get(i).height;
}
return h;
}
}
|
package net.ossrs.yasea;
import android.content.res.Configuration;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.util.Log;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
public class SrsEncoder {
private static final String TAG = "SrsEncoder";
public static final String VCODEC = "video/avc";
public static final String ACODEC = "audio/mp4a-latm";
public static String x264Preset = "veryfast";
public static int vPrevWidth = 640;
public static int vPrevHeight = 360;
public static int vPortraitWidth = 720;
public static int vPortraitHeight = 1280;
public static int vLandscapeWidth = 1280;
public static int vLandscapeHeight = 720;
public static int vOutWidth = 720; // Note: the stride of resolution must be set as 16x for hard encoding with some chip like MTK
public static int vOutHeight = 1280; // Since Y component is quadruple size as U and V component, the stride must be set as 32x
public static int vBitrate = 1200 * 1024; // 1200 kbps
public static final int VFPS = 24;
public static final int VGOP = 48;
public static final int ASAMPLERATE = 44100;
public static int aChannelConfig = AudioFormat.CHANNEL_IN_STEREO;
public static final int ABITRATE = 128 * 1024; // 128 kbps
private SrsEncodeHandler mHandler;
private SrsFlvMuxer flvMuxer;
private SrsMp4Muxer mp4Muxer;
private MediaCodecInfo vmci;
private MediaCodec vencoder;
private MediaCodec aencoder;
private MediaCodec.BufferInfo vebi = new MediaCodec.BufferInfo();
private MediaCodec.BufferInfo aebi = new MediaCodec.BufferInfo();
private boolean networkWeakTriggered = false;
private boolean mCameraFaceFront = true;
private boolean useSoftEncoder = false;
private boolean canSoftEncode = false;
private long mPresentTimeUs;
private int mVideoColorFormat;
private int videoFlvTrack;
private int videoMp4Track;
private int audioFlvTrack;
private int audioMp4Track;
// Y, U (Cb) and V (Cr)
// yuv420 yuv yuv yuv yuv
// yuv420p (planar) yyyy*2 uu vv
// yuv420sp(semi-planner) yyyy*2 uv uv
// I420 -> YUV420P yyyy*2 uu vv
// YV12 -> YUV420P yyyy*2 vv uu
// NV12 -> YUV420SP yyyy*2 uv uv
// NV21 -> YUV420SP yyyy*2 vu vu
// NV16 -> YUV422SP yyyy uv uv
// YUY2 -> YUV422SP yuyv yuyv
public SrsEncoder(SrsEncodeHandler handler) {
mHandler = handler;
mVideoColorFormat = chooseVideoEncoder();
}
public void setFlvMuxer(SrsFlvMuxer flvMuxer) {
this.flvMuxer = flvMuxer;
}
public void setMp4Muxer(SrsMp4Muxer mp4Muxer) {
this.mp4Muxer = mp4Muxer;
}
public boolean start() {
if (flvMuxer == null || mp4Muxer == null) {
return false;
}
// the referent PTS for video and audio encoder.
mPresentTimeUs = System.nanoTime() / 1000;
// Note: the stride of resolution must be set as 16x for hard encoding with some chip like MTK
// Since Y component is quadruple size as U and V component, the stride must be set as 32x
if (!useSoftEncoder && (vOutWidth % 32 != 0 || vOutHeight % 32 != 0)) {
if (vmci.getName().contains("MTK")) {
//throw new AssertionError("MTK encoding revolution stride must be 32x");
}
}
setEncoderResolution(vOutWidth, vOutHeight);
setEncoderFps(VFPS);
setEncoderGop(VGOP);
// Unfortunately for some android phone, the output fps is less than 10 limited by the
// capacity of poor cheap chips even with x264. So for the sake of quick appearance of
// the first picture on the player, a spare lower GOP value is suggested. But note that
// lower GOP will produce more I frames and therefore more streaming data flow.
// setEncoderGop(15);
setEncoderBitrate(vBitrate);
setEncoderPreset(x264Preset);
if (useSoftEncoder) {
canSoftEncode = openSoftEncoder();
if (!canSoftEncode) {
return false;
}
}
// aencoder pcm to aac raw stream.
// requires sdk level 16+, Android 4.1, 4.1.1, the JELLY_BEAN
try {
aencoder = MediaCodec.createEncoderByType(ACODEC);
} catch (IOException e) {
Log.e(TAG, "create aencoder failed.");
e.printStackTrace();
return false;
}
// setup the aencoder.
int ach = aChannelConfig == AudioFormat.CHANNEL_IN_STEREO ? 2 : 1;
MediaFormat audioFormat = MediaFormat.createAudioFormat(ACODEC, ASAMPLERATE, ach);
audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, ABITRATE);
audioFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
aencoder.configure(audioFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
// add the audio tracker to muxer.
audioFlvTrack = flvMuxer.addTrack(audioFormat);
audioMp4Track = mp4Muxer.addTrack(audioFormat);
// vencoder yuv to 264 es stream.
// requires sdk level 16+, Android 4.1, 4.1.1, the JELLY_BEAN
try {
vencoder = MediaCodec.createByCodecName(vmci.getName());
} catch (IOException e) {
Log.e(TAG, "create vencoder failed.");
e.printStackTrace();
return false;
}
// setup the vencoder.
// Note: landscape to portrait, 90 degree rotation, so we need to switch width and height in configuration
MediaFormat videoFormat = MediaFormat.createVideoFormat(VCODEC, vOutWidth, vOutHeight);
videoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, mVideoColorFormat);
videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
videoFormat.setInteger(MediaFormat.KEY_BIT_RATE, vBitrate);
videoFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VFPS);
videoFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, VGOP / VFPS);
vencoder.configure(videoFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
// add the video tracker to muxer.
videoFlvTrack = flvMuxer.addTrack(videoFormat);
videoMp4Track = mp4Muxer.addTrack(videoFormat);
// start device and encoder.
vencoder.start();
aencoder.start();
return true;
}
public void stop() {
if (useSoftEncoder) {
closeSoftEncoder();
canSoftEncode = false;
}
if (aencoder != null) {
Log.i(TAG, "stop aencoder");
aencoder.stop();
aencoder.release();
aencoder = null;
}
if (vencoder != null) {
Log.i(TAG, "stop vencoder");
vencoder.stop();
vencoder.release();
vencoder = null;
}
}
public void setCameraFrontFace() {
mCameraFaceFront = true;
}
public void setCameraBackFace() {
mCameraFaceFront = false;
}
public void switchToSoftEncoder() {
useSoftEncoder = true;
}
public void switchToHardEncoder() {
useSoftEncoder = false;
}
public boolean isSoftEncoder() {
return useSoftEncoder;
}
public boolean canHardEncode() {
return vencoder != null;
}
public boolean canSoftEncode() {
return canSoftEncode;
}
public boolean isEnabled() {
return canHardEncode() || canSoftEncode();
}
public void setPreviewResolution(int width, int height) {
vPrevWidth = width;
vPrevHeight = height;
}
public void setPortraitResolution(int width, int height) {
vOutWidth = width;
vOutHeight = height;
vPortraitWidth = width;
vPortraitHeight = height;
vLandscapeWidth = height;
vLandscapeHeight = width;
}
public void setLandscapeResolution(int width, int height) {
vOutWidth = width;
vOutHeight = height;
vLandscapeWidth = width;
vLandscapeHeight = height;
vPortraitWidth = height;
vPortraitHeight = width;
}
public void setVideoHDMode() {
vBitrate = 1200 * 1024; // 1200 kbps
x264Preset = "veryfast";
}
public void setVideoSmoothMode() {
vBitrate = 500 * 1024; // 500 kbps
x264Preset = "superfast";
}
public int getPreviewWidth() {
return vPrevWidth;
}
public int getPreviewHeight() {
return vPrevHeight;
}
public int getOutputWidth() {
return vOutWidth;
}
public int getOutputHeight() {
return vOutHeight;
}
public void setScreenOrientation(int orientation) {
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
vOutWidth = vPortraitWidth;
vOutHeight = vPortraitHeight;
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
vOutWidth = vLandscapeWidth;
vOutHeight = vLandscapeHeight;
}
// Note: the stride of resolution must be set as 16x for hard encoding with some chip like MTK
// Since Y component is quadruple size as U and V component, the stride must be set as 32x
if (!useSoftEncoder && (vOutWidth % 32 != 0 || vOutHeight % 32 != 0)) {
if (vmci.getName().contains("MTK")) {
//throw new AssertionError("MTK encoding revolution stride must be 32x");
}
}
setEncoderResolution(vOutWidth, vOutHeight);
}
private void onProcessedYuvFrame(byte[] yuvFrame, long pts) {
ByteBuffer[] inBuffers = vencoder.getInputBuffers();
ByteBuffer[] outBuffers = vencoder.getOutputBuffers();
int inBufferIndex = vencoder.dequeueInputBuffer(-1);
if (inBufferIndex >= 0) {
ByteBuffer bb = inBuffers[inBufferIndex];
bb.clear();
bb.put(yuvFrame, 0, yuvFrame.length);
vencoder.queueInputBuffer(inBufferIndex, 0, yuvFrame.length, pts, 0);
}
for (; ; ) {
int outBufferIndex = vencoder.dequeueOutputBuffer(vebi, 0);
if (outBufferIndex >= 0) {
ByteBuffer bb = outBuffers[outBufferIndex];
onEncodedAnnexbFrame(bb, vebi);
vencoder.releaseOutputBuffer(outBufferIndex, false);
} else {
break;
}
}
}
private void onSoftEncodedData(byte[] es, long pts, boolean isKeyFrame) {
ByteBuffer bb = ByteBuffer.wrap(es);
vebi.offset = 0;
vebi.size = es.length;
vebi.presentationTimeUs = pts;
vebi.flags = isKeyFrame ? MediaCodec.BUFFER_FLAG_KEY_FRAME : 0;
onEncodedAnnexbFrame(bb, vebi);
}
// when got encoded h264 es stream.
private void onEncodedAnnexbFrame(ByteBuffer es, MediaCodec.BufferInfo bi) {
mp4Muxer.writeSampleData(videoMp4Track, es.duplicate(), bi);
flvMuxer.writeSampleData(videoFlvTrack, es, bi);
}
// when got encoded aac raw stream.
private void onEncodedAacFrame(ByteBuffer es, MediaCodec.BufferInfo bi) {
mp4Muxer.writeSampleData(audioMp4Track, es.duplicate(), bi);
flvMuxer.writeSampleData(audioFlvTrack, es, bi);
}
public void onGetPcmFrame(byte[] data, int size) {
ByteBuffer[] inBuffers = aencoder.getInputBuffers();
ByteBuffer[] outBuffers = aencoder.getOutputBuffers();
int inBufferIndex = aencoder.dequeueInputBuffer(-1);
if (inBufferIndex >= 0) {
ByteBuffer bb = inBuffers[inBufferIndex];
bb.clear();
bb.put(data, 0, size);
long pts = System.nanoTime() / 1000 - mPresentTimeUs;
aencoder.queueInputBuffer(inBufferIndex, 0, size, pts, 0);
}
for (; ; ) {
int outBufferIndex = aencoder.dequeueOutputBuffer(aebi, 0);
if (outBufferIndex >= 0) {
ByteBuffer bb = outBuffers[outBufferIndex];
onEncodedAacFrame(bb, aebi);
aencoder.releaseOutputBuffer(outBufferIndex, false);
} else {
break;
}
}
}
public void onGetRgbaFrame(byte[] data, int width, int height) {
// Check video frame cache number to judge the networking situation.
// Just cache GOP / FPS seconds data according to latency.
AtomicInteger videoFrameCacheNumber = flvMuxer.getVideoFrameCacheNumber();
if (videoFrameCacheNumber != null && videoFrameCacheNumber.get() < VGOP) {
long pts = System.nanoTime() / 1000 - mPresentTimeUs;
if (useSoftEncoder) {
swRgbaFrame(data, width, height, pts);
} else {
byte[] processedData = hwRgbaFrame(data, width, height);
if (processedData != null) {
onProcessedYuvFrame(processedData, pts);
} else {
mHandler.notifyEncodeIllegalArgumentException(new IllegalArgumentException("libyuv failure"));
}
}
if (networkWeakTriggered) {
networkWeakTriggered = false;
mHandler.notifyNetworkResume();
}
} else {
mHandler.notifyNetworkWeak();
networkWeakTriggered = true;
}
}
private byte[] hwRgbaFrame(byte[] data, int width, int height) {
switch (mVideoColorFormat) {
case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar:
return RGBAToI420(data, width, height, true, 180);
case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar:
return RGBAToNV12(data, width, height, true, 180);
default:
throw new IllegalStateException("Unsupported color format!");
}
}
private void swRgbaFrame(byte[] data, int width, int height, long pts) {
RGBASoftEncode(data, width, height, true, 180, pts);
}
public AudioRecord chooseAudioRecord() {
AudioRecord mic = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, SrsEncoder.ASAMPLERATE,
AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, getPcmBufferSize() * 4);
if (mic.getState() != AudioRecord.STATE_INITIALIZED) {
mic = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, SrsEncoder.ASAMPLERATE,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, getPcmBufferSize() * 4);
if (mic.getState() != AudioRecord.STATE_INITIALIZED) {
mic = null;
} else {
SrsEncoder.aChannelConfig = AudioFormat.CHANNEL_IN_MONO;
}
} else {
SrsEncoder.aChannelConfig = AudioFormat.CHANNEL_IN_STEREO;
}
return mic;
}
private int getPcmBufferSize() {
int pcmBufSize = AudioRecord.getMinBufferSize(ASAMPLERATE, AudioFormat.CHANNEL_IN_STEREO,
AudioFormat.ENCODING_PCM_16BIT) + 8191;
return pcmBufSize - (pcmBufSize % 8192);
}
// choose the video encoder by name.
private MediaCodecInfo chooseVideoEncoder(String name) {
int nbCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < nbCodecs; i++) {
MediaCodecInfo mci = MediaCodecList.getCodecInfoAt(i);
if (!mci.isEncoder()) {
continue;
}
String[] types = mci.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(VCODEC)) {
Log.i(TAG, String.format("vencoder %s types: %s", mci.getName(), types[j]));
if (name == null) {
return mci;
}
if (mci.getName().contains(name)) {
return mci;
}
}
}
}
return null;
}
// choose the right supported color format. @see below:
private int chooseVideoEncoder() {
// choose the encoder "video/avc":
// 1. select default one when type matched.
// 2. google avc is unusable.
// 3. choose qcom avc.
vmci = chooseVideoEncoder(null);
//vmci = chooseVideoEncoder("google");
//vmci = chooseVideoEncoder("qcom");
int matchedColorFormat = 0;
MediaCodecInfo.CodecCapabilities cc = vmci.getCapabilitiesForType(VCODEC);
for (int i = 0; i < cc.colorFormats.length; i++) {
int cf = cc.colorFormats[i];
Log.i(TAG, String.format("vencoder %s supports color fomart 0x%x(%d)", vmci.getName(), cf, cf));
// choose YUV for h.264, prefer the bigger one.
// corresponding to the color space transform in onPreviewFrame
if (cf >= cc.COLOR_FormatYUV420Planar && cf <= cc.COLOR_FormatYUV420SemiPlanar) {
if (cf > matchedColorFormat) {
matchedColorFormat = cf;
}
}
}
for (int i = 0; i < cc.profileLevels.length; i++) {
MediaCodecInfo.CodecProfileLevel pl = cc.profileLevels[i];
Log.i(TAG, String.format("vencoder %s support profile %d, level %d", vmci.getName(), pl.profile, pl.level));
}
Log.i(TAG, String.format("vencoder %s choose color format 0x%x(%d)", vmci.getName(), matchedColorFormat, matchedColorFormat));
return matchedColorFormat;
}
private native void setEncoderResolution(int outWidth, int outHeight);
private native void setEncoderFps(int fps);
private native void setEncoderGop(int gop);
private native void setEncoderBitrate(int bitrate);
private native void setEncoderPreset(String preset);
private native byte[] RGBAToI420(byte[] rgbaFrame, int width, int height, boolean flip, int rotate);
private native byte[] RGBAToNV12(byte[] rgbaFrame, int width, int height, boolean flip, int rotate);
private native int RGBASoftEncode(byte[] rgbaFrame, int width, int height, boolean flip, int rotate, long pts);
private native boolean openSoftEncoder();
private native void closeSoftEncoder();
static {
System.loadLibrary("yuv");
System.loadLibrary("enc");
}
}
|
package net.simonvt.menudrawer;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
public class OverlayDrawer extends DraggableDrawer {
private static final String TAG = "OverlayDrawer";
OverlayDrawer(Activity activity, int dragMode) {
super(activity, dragMode);
}
public OverlayDrawer(Context context) {
super(context);
}
public OverlayDrawer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public OverlayDrawer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void initDrawer(Context context, AttributeSet attrs, int defStyle) {
super.initDrawer(context, attrs, defStyle);
super.addView(mContentContainer, -1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
super.addView(mMenuContainer, -1, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
@Override
protected void drawOverlay(Canvas canvas) {
final int width = getWidth();
final int height = getHeight();
final int offsetPixels = (int) mOffsetPixels;
final float openRatio = Math.abs(mOffsetPixels) / mMenuSize;
switch (mPosition) {
case LEFT:
mMenuOverlay.setBounds(offsetPixels, 0, width, height);
break;
case RIGHT:
mMenuOverlay.setBounds(0, 0, width + offsetPixels, height);
break;
case TOP:
mMenuOverlay.setBounds(0, offsetPixels, width, height);
break;
case BOTTOM:
mMenuOverlay.setBounds(0, 0, width, height + offsetPixels);
break;
}
mMenuOverlay.setAlpha((int) (MAX_MENU_OVERLAY_ALPHA * openRatio));
mMenuOverlay.draw(canvas);
}
@Override
public void openMenu(boolean animate) {
int animateTo = 0;
switch (mPosition) {
case LEFT:
case TOP:
animateTo = mMenuSize;
break;
case RIGHT:
case BOTTOM:
animateTo = -mMenuSize;
break;
}
animateOffsetTo(animateTo, 0, animate);
}
@Override
public void closeMenu(boolean animate) {
animateOffsetTo(0, 0, animate);
}
@Override
protected void onOffsetPixelsChanged(int offsetPixels) {
if (USE_TRANSLATIONS) {
switch (mPosition) {
case LEFT:
mMenuContainer.setTranslationX(offsetPixels - mMenuSize);
break;
case TOP:
mMenuContainer.setTranslationY(offsetPixels - mMenuSize);
break;
case RIGHT:
mMenuContainer.setTranslationX(offsetPixels + mMenuSize);
break;
case BOTTOM:
mMenuContainer.setTranslationY(offsetPixels + mMenuSize);
break;
}
} else {
switch (mPosition) {
case TOP:
mMenuContainer.offsetTopAndBottom(offsetPixels - mMenuContainer.getBottom());
break;
case BOTTOM:
mMenuContainer.offsetTopAndBottom(offsetPixels - (mMenuContainer.getTop() - getHeight()));
break;
case LEFT:
mMenuContainer.offsetLeftAndRight(offsetPixels - mMenuContainer.getRight());
break;
case RIGHT:
mMenuContainer.offsetLeftAndRight(offsetPixels - (mMenuContainer.getLeft() - getWidth()));
break;
}
}
invalidate();
}
@Override
protected void initPeekScroller() {
switch (mPosition) {
case RIGHT:
case BOTTOM: {
final int dx = -mMenuSize / 3;
mPeekScroller.startScroll(0, 0, dx, 0, PEEK_DURATION);
break;
}
default: {
final int dx = mMenuSize / 3;
mPeekScroller.startScroll(0, 0, dx, 0, PEEK_DURATION);
break;
}
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
onOffsetPixelsChanged((int) mOffsetPixels);
}
@Override
protected GradientDrawable.Orientation getDropShadowOrientation() {
switch (mPosition) {
case TOP:
return GradientDrawable.Orientation.TOP_BOTTOM;
case RIGHT:
return GradientDrawable.Orientation.RIGHT_LEFT;
case BOTTOM:
return GradientDrawable.Orientation.BOTTOM_TOP;
default:
return GradientDrawable.Orientation.LEFT_RIGHT;
}
}
@Override
protected void updateDropShadowRect() {
final float openRatio = Math.abs(mOffsetPixels) / mMenuSize;
final int dropShadowSize = (int) (mDropShadowSize * openRatio);
switch (mPosition) {
case LEFT:
mDropShadowRect.top = 0;
mDropShadowRect.bottom = getHeight();
mDropShadowRect.left = ViewHelper.getRight(mMenuContainer);
mDropShadowRect.right = mDropShadowRect.left + dropShadowSize;
break;
case TOP:
mDropShadowRect.left = 0;
mDropShadowRect.right = getWidth();
mDropShadowRect.top = ViewHelper.getBottom(mMenuContainer);
mDropShadowRect.bottom = mDropShadowRect.top + dropShadowSize;
break;
case RIGHT:
mDropShadowRect.top = 0;
mDropShadowRect.bottom = getHeight();
mDropShadowRect.right = ViewHelper.getLeft(mMenuContainer);
mDropShadowRect.left = mDropShadowRect.right - dropShadowSize;
break;
case BOTTOM:
mDropShadowRect.left = 0;
mDropShadowRect.right = getWidth();
mDropShadowRect.bottom = ViewHelper.getTop(mMenuContainer);
mDropShadowRect.top = mDropShadowRect.bottom - dropShadowSize;
break;
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int width = r - l;
final int height = b - t;
mContentContainer.layout(0, 0, width, height);
if (USE_TRANSLATIONS) {
switch (mPosition) {
case LEFT:
mMenuContainer.layout(0, 0, mMenuSize, height);
break;
case RIGHT:
mMenuContainer.layout(width - mMenuSize, 0, width, height);
break;
case TOP:
mMenuContainer.layout(0, 0, width, mMenuSize);
break;
case BOTTOM:
mMenuContainer.layout(0, height - mMenuSize, width, height);
break;
}
} else {
final int offsetPixels = (int) mOffsetPixels;
final int menuSize = mMenuSize;
switch (mPosition) {
case LEFT:
mMenuContainer.layout(-menuSize + offsetPixels, 0, offsetPixels, height);
break;
case RIGHT:
mMenuContainer.layout(width + offsetPixels, 0, width + menuSize + offsetPixels, height);
break;
case TOP:
mMenuContainer.layout(0, -menuSize + offsetPixels, width, offsetPixels);
break;
case BOTTOM:
mMenuContainer.layout(0, height + offsetPixels, width, height + menuSize + offsetPixels);
break;
}
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (widthMode != MeasureSpec.EXACTLY || heightMode != MeasureSpec.EXACTLY) {
throw new IllegalStateException("Must measure with an exact size");
}
final int width = MeasureSpec.getSize(widthMeasureSpec);
final int height = MeasureSpec.getSize(heightMeasureSpec);
if (mOffsetPixels == -1) openMenu(false);
int menuWidthMeasureSpec;
int menuHeightMeasureSpec;
switch (mPosition) {
case TOP:
case BOTTOM:
menuWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, 0, width);
menuHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, 0, mMenuSize);
break;
default:
// LEFT/RIGHT
menuWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, 0, mMenuSize);
menuHeightMeasureSpec = getChildMeasureSpec(widthMeasureSpec, 0, height);
}
mMenuContainer.measure(menuWidthMeasureSpec, menuHeightMeasureSpec);
final int contentWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, 0, width);
final int contentHeightMeasureSpec = getChildMeasureSpec(widthMeasureSpec, 0, height);
mContentContainer.measure(contentWidthMeasureSpec, contentHeightMeasureSpec);
setMeasuredDimension(width, height);
updateTouchAreaSize();
}
private boolean isContentTouch(int x, int y) {
boolean contentTouch = false;
switch (mPosition) {
case LEFT:
contentTouch = ViewHelper.getRight(mMenuContainer) < x;
break;
case RIGHT:
contentTouch = ViewHelper.getLeft(mMenuContainer) > x;
break;
case TOP:
contentTouch = ViewHelper.getBottom(mMenuContainer) < y;
break;
case BOTTOM:
contentTouch = ViewHelper.getTop(mMenuContainer) > y;
break;
}
return contentTouch;
}
protected boolean onDownAllowDrag(int x, int y) {
switch (mPosition) {
case LEFT:
return (!mMenuVisible && mInitialMotionX <= mTouchSize)
|| (mMenuVisible && mInitialMotionX <= mOffsetPixels);
case RIGHT:
final int width = getWidth();
final int initialMotionX = (int) mInitialMotionX;
return (!mMenuVisible && initialMotionX >= width - mTouchSize)
|| (mMenuVisible && initialMotionX >= width + mOffsetPixels);
case TOP:
return (!mMenuVisible && mInitialMotionY <= mTouchSize)
|| (mMenuVisible && mInitialMotionY <= mOffsetPixels);
case BOTTOM:
final int height = getHeight();
return (!mMenuVisible && mInitialMotionY >= height - mTouchSize)
|| (mMenuVisible && mInitialMotionY >= height + mOffsetPixels);
}
return false;
}
protected boolean onMoveAllowDrag(int x, int y, float dx, float dy) {
if (mMenuVisible && mTouchMode == TOUCH_MODE_FULLSCREEN) {
return true;
}
switch (mPosition) {
case LEFT:
return (!mMenuVisible && mInitialMotionX <= mTouchSize && (dx > 0))
|| (mMenuVisible && x <= mOffsetPixels);
case RIGHT:
final int width = getWidth();
return (!mMenuVisible && mInitialMotionX >= width - mTouchSize && (dx < 0))
|| (mMenuVisible && x >= width + mOffsetPixels);
case TOP:
return (!mMenuVisible && mInitialMotionY <= mTouchSize && (dy > 0))
|| (mMenuVisible && y <= mOffsetPixels);
case BOTTOM:
final int height = getHeight();
return (!mMenuVisible && mInitialMotionY >= height - mTouchSize && (dy < 0))
|| (mMenuVisible && y >= height + mOffsetPixels);
}
return false;
}
protected void onMoveEvent(float dx, float dy) {
switch (mPosition) {
case LEFT:
setOffsetPixels(Math.min(Math.max(mOffsetPixels + dx, 0), mMenuSize));
break;
case RIGHT:
setOffsetPixels(Math.max(Math.min(mOffsetPixels + dx, 0), -mMenuSize));
break;
case TOP:
setOffsetPixels(Math.min(Math.max(mOffsetPixels + dy, 0), mMenuSize));
break;
case BOTTOM:
setOffsetPixels(Math.max(Math.min(mOffsetPixels + dy, 0), -mMenuSize));
break;
}
}
protected void onUpEvent(int x, int y) {
final int offsetPixels = (int) mOffsetPixels;
switch (mPosition) {
case LEFT: {
if (mIsDragging) {
mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
final int initialVelocity = (int) mVelocityTracker.getXVelocity(mActivePointerId);
mLastMotionX = x;
animateOffsetTo(initialVelocity > 0 ? mMenuSize : 0, initialVelocity, true);
// Close the menu when content is clicked while the menu is visible.
} else if (mMenuVisible && x > offsetPixels) {
closeMenu();
}
break;
}
case TOP: {
if (mIsDragging) {
mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
final int initialVelocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
mLastMotionY = y;
animateOffsetTo(initialVelocity > 0 ? mMenuSize : 0, initialVelocity, true);
// Close the menu when content is clicked while the menu is visible.
} else if (mMenuVisible && y > offsetPixels) {
closeMenu();
}
break;
}
case RIGHT: {
final int width = getWidth();
if (mIsDragging) {
mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
final int initialVelocity = (int) mVelocityTracker.getXVelocity(mActivePointerId);
mLastMotionX = x;
animateOffsetTo(initialVelocity > 0 ? 0 : -mMenuSize, initialVelocity, true);
// Close the menu when content is clicked while the menu is visible.
} else if (mMenuVisible && x < width + offsetPixels) {
closeMenu();
}
break;
}
case BOTTOM: {
if (mIsDragging) {
mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
final int initialVelocity = (int) mVelocityTracker.getYVelocity(mActivePointerId);
mLastMotionY = y;
animateOffsetTo(initialVelocity < 0 ? -mMenuSize : 0, initialVelocity, true);
// Close the menu when content is clicked while the menu is visible.
} else if (mMenuVisible && y < getHeight() + offsetPixels) {
closeMenu();
}
break;
}
}
}
protected boolean checkTouchSlop(float dx, float dy) {
switch (mPosition) {
case TOP:
case BOTTOM:
return Math.abs(dy) > mTouchSlop && Math.abs(dy) > Math.abs(dx);
default:
return Math.abs(dx) > mTouchSlop && Math.abs(dx) > Math.abs(dy);
}
}
public boolean onInterceptTouchEvent(MotionEvent ev) {
final int action = ev.getAction() & MotionEvent.ACTION_MASK;
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
mActivePointerId = INVALID_POINTER;
mIsDragging = false;
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
if (Math.abs(mOffsetPixels) > mMenuSize / 2) {
openMenu();
} else {
closeMenu();
}
return false;
}
if (action == MotionEvent.ACTION_DOWN && mMenuVisible && isCloseEnough()) {
setOffsetPixels(0);
stopAnimation();
endPeek();
setDrawerState(STATE_CLOSED);
mIsDragging = false;
}
// Always intercept events over the content while menu is visible.
if (mMenuVisible) {
int index = 0;
if (mActivePointerId != INVALID_POINTER) {
index = ev.findPointerIndex(mActivePointerId);
index = index == -1 ? 0 : index;
}
final int x = (int) ev.getX(index);
final int y = (int) ev.getY(index);
if (isContentTouch(x, y)) {
return true;
}
}
if (mTouchMode == TOUCH_MODE_NONE) {
return false;
}
if (action != MotionEvent.ACTION_DOWN && mIsDragging) {
return true;
}
switch (action) {
case MotionEvent.ACTION_DOWN: {
mLastMotionX = mInitialMotionX = ev.getX();
mLastMotionY = mInitialMotionY = ev.getY();
final boolean allowDrag = onDownAllowDrag((int) mLastMotionX, (int) mLastMotionY);
mActivePointerId = ev.getPointerId(0);
if (allowDrag) {
setDrawerState(mMenuVisible ? STATE_OPEN : STATE_CLOSED);
stopAnimation();
endPeek();
mIsDragging = false;
}
break;
}
case MotionEvent.ACTION_MOVE: {
final int activePointerId = mActivePointerId;
if (activePointerId == INVALID_POINTER) {
// If we don't have a valid id, the touch down wasn't on content.
break;
}
final int pointerIndex = ev.findPointerIndex(activePointerId);
final float x = ev.getX(pointerIndex);
final float dx = x - mLastMotionX;
final float y = ev.getY(pointerIndex);
final float dy = y - mLastMotionY;
if (checkTouchSlop(dx, dy)) {
if (mOnInterceptMoveEventListener != null && mTouchMode == TOUCH_MODE_FULLSCREEN
&& canChildScrollHorizontally(mContentContainer, false, (int) dx, (int) x, (int) y)) {
endDrag(); // Release the velocity tracker
return false;
}
final boolean allowDrag = onMoveAllowDrag((int) x, (int) y, dx, dy);
if (allowDrag) {
setDrawerState(STATE_DRAGGING);
mIsDragging = true;
mLastMotionX = x;
mLastMotionY = y;
}
}
break;
}
case MotionEvent.ACTION_POINTER_UP:
onPointerUp(ev);
mLastMotionX = ev.getX(ev.findPointerIndex(mActivePointerId));
mLastMotionY = ev.getY(ev.findPointerIndex(mActivePointerId));
break;
}
if (mVelocityTracker == null) mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(ev);
return mIsDragging;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!mMenuVisible && !mIsDragging && (mTouchMode == TOUCH_MODE_NONE)) {
return false;
}
final int action = ev.getAction() & MotionEvent.ACTION_MASK;
if (mVelocityTracker == null) mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(ev);
switch (action) {
case MotionEvent.ACTION_DOWN: {
mLastMotionX = mInitialMotionX = ev.getX();
mLastMotionY = mInitialMotionY = ev.getY();
final boolean allowDrag = onDownAllowDrag((int) mLastMotionX, (int) mLastMotionY);
mActivePointerId = ev.getPointerId(0);
if (allowDrag) {
stopAnimation();
endPeek();
startLayerTranslation();
}
break;
}
case MotionEvent.ACTION_MOVE: {
if (!mIsDragging) {
final int pointerIndex = ev.findPointerIndex(mActivePointerId);
final float x = ev.getX(pointerIndex);
final float dx = x - mLastMotionX;
final float y = ev.getY(pointerIndex);
final float dy = y - mLastMotionY;
if (checkTouchSlop(dx, dy)) {
final boolean allowDrag = onMoveAllowDrag((int) x, (int) y, dx, dy);
if (allowDrag) {
setDrawerState(STATE_DRAGGING);
mIsDragging = true;
mLastMotionX = x;
mLastMotionY = y;
} else {
mInitialMotionX = x;
mInitialMotionY = y;
}
}
}
if (mIsDragging) {
startLayerTranslation();
final int pointerIndex = ev.findPointerIndex(mActivePointerId);
final float x = ev.getX(pointerIndex);
final float dx = x - mLastMotionX;
final float y = ev.getY(pointerIndex);
final float dy = y - mLastMotionY;
mLastMotionX = x;
mLastMotionY = y;
onMoveEvent(dx, dy);
}
break;
}
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
final int index = ev.findPointerIndex(mActivePointerId);
final int x = (int) ev.getX(index);
final int y = (int) ev.getY(index);
onUpEvent(x, y);
mActivePointerId = INVALID_POINTER;
mIsDragging = false;
break;
}
case MotionEvent.ACTION_POINTER_DOWN:
final int index = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
>> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
mLastMotionX = ev.getX(index);
mLastMotionY = ev.getY(index);
mActivePointerId = ev.getPointerId(index);
break;
case MotionEvent.ACTION_POINTER_UP:
onPointerUp(ev);
mLastMotionX = ev.getX(ev.findPointerIndex(mActivePointerId));
mLastMotionY = ev.getY(ev.findPointerIndex(mActivePointerId));
break;
}
return true;
}
private void onPointerUp(MotionEvent ev) {
final int pointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mLastMotionX = ev.getX(newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
}
|
package com.joelapenna.foursquared;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Environment;
import android.view.Window;
import android.widget.TabHost;
import android.widget.Toast;
/**
* @author Joe LaPenna (joe@joelapenna.com)
*/
public class MainActivity extends TabActivity {
public static final String TAG = "MainActivity";
public static final boolean DEBUG = FoursquaredSettings.DEBUG;
private TabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Don't start the main activity if we don't have credentials
if (!((Foursquared)getApplication()).getFoursquare().hasCredentials()) {
setVisible(false);
Intent intent = new Intent(this, LoginActivity.class);
intent.setAction(Intent.ACTION_MAIN);
startActivityForResult(intent, LoginActivity.ACTIVITY_REQUEST_LOGIN);
return;
}
// Otherwise, resume as normal.
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
Toast.makeText(this, "Please insert an SD card before using Foursquared",
Toast.LENGTH_LONG).show();
finish();
return;
}
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main_activity);
initTabHost();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
startActivity(new Intent(this, MainActivity.class));
}
finish();
}
private void initTabHost() {
if (mTabHost != null) {
throw new IllegalStateException("Trying to intialize already initializd TabHost");
}
Resources resources = getResources();
mTabHost = getTabHost();
// Places tab
mTabHost.addTab(mTabHost.newTabSpec("places")
.setIndicator(resources.getString(R.string.nearby_label),
getResources().getDrawable(R.drawable.places_tab)) // the tab icon
.setContent(new Intent(this, NearbyVenuesActivity.class)) // The contained activity
);
// Friends tab
mTabHost.addTab(mTabHost.newTabSpec("friends")
.setIndicator(resources.getString(R.string.checkins_label),
getResources().getDrawable(R.drawable.friends_tab)) // the tab
// icon
.setContent(new Intent(this, FriendsActivity.class)) // The contained activity
);
mTabHost.setCurrentTab(0);
}
}
|
package gumtree.spoon.diff;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.stream.Collectors;
import spoon.reflect.factory.Factory;
import spoon.reflect.factory.FactoryImpl;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
// import org.apache.log4j.Level;
import com.github.gumtreediff.actions.ActionGenerator;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.actions.model.Delete;
import com.github.gumtreediff.actions.model.Insert;
import com.github.gumtreediff.actions.model.Move;
import com.github.gumtreediff.actions.model.Update;
import com.github.gumtreediff.matchers.CompositeMatchers;
import com.github.gumtreediff.matchers.MappingStore;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.tree.ITree;
import com.github.gumtreediff.tree.TreeContext;
import gumtree.spoon.builder.SpoonGumTreeBuilder;
import gumtree.spoon.diff.operations.DeleteOperation;
import gumtree.spoon.diff.operations.InsertOperation;
import gumtree.spoon.diff.operations.MoveOperation;
import gumtree.spoon.diff.operations.Operation;
import gumtree.spoon.diff.operations.OperationKind;
import gumtree.spoon.diff.operations.UpdateOperation;
import spoon.reflect.code.CtAssert;
import spoon.reflect.code.CtAssignment;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtCodeSnippetStatement;
import spoon.reflect.code.CtComment;
import spoon.reflect.code.CtConditional;
import spoon.reflect.code.CtExecutableReferenceExpression;
import spoon.reflect.code.CtFieldAccess;
import spoon.reflect.code.CtIf;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLiteral;
import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.code.CtStatement;
// import spoon.reflect.code.CtStatement;
import spoon.reflect.code.CtSwitch;
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.code.CtVariableAccess;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtModifiable;
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.CtTypedElement;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.DefaultCoreFactory;
import spoon.support.StandardEnvironment;
import spoon.support.reflect.reference.CtPackageReferenceImpl;
// import spoon.reflect.factory.CodeFactory;;;
/**
* @author Matias Martinez, matias.martinez@inria.fr
*/
public class DiffImpl implements Diff {
// Name of Extracted Method
String Name_Ext_Mtd;
// Name of Source Method
String Name_Src_Mtd;
// Extracted code
String Extracted_Code;
// Package only used in the extracted code
CtPackageReferenceImpl package_most_used;
CtVariable variable_most_used;
CtVariableAccess variable_access_most_used;
CtFieldAccess field_access_most_used;
CtInvocation invocation_most_used;
CtTypeAccess type_access_most_used;
CtTypedElement typed_ele_most_used;
CtModifiable modifiable_most_used;
List<CtElement> callMethod = new ArrayList<CtElement>(); // after versionsource method
List<CtElement> sourceMethod = new ArrayList<CtElement>(); // before versionsource method
List<CtElement> deleteStuff = new ArrayList<CtElement>(); // before versionsource
// methoddeletecode
CtMethod extracted_Method; // extracted method
CtElement deleted; // deleted code
// common variable declaration
List<CtVariable> deletedVariable;
List<CtVariable> srcVariable;
List<CtVariable> commonVariable;
// common variable access
List<CtVariableAccess> delVarAcc;
List<CtVariableAccess> srcVarAcc;
List<CtVariableAccess> commonVariableAccess;
// common field access
List<CtFieldAccess> delFieldAcc;
List<CtFieldAccess> srcFieldAcc;
List<CtFieldAccess> commonFieldAccess;
// common invocation
List<CtInvocation> delInvo;
List<CtInvocation> srcInvo;
List<CtInvocation> commonInvo;
// common field access
List<CtTypeAccess> delTypeAcc;
List<CtTypeAccess> srcTypeAcc;
List<CtTypeAccess> commonTypeAccess;
// common typed element
List<CtTypedElement> delTypedEle;
List<CtTypedElement> srcTypedEle;
List<CtTypedElement> commonTypedElement;
// common modifiable
List<CtModifiable> delMod;
List<CtModifiable> srcMod;
List<CtModifiable> commonModifiable;
// declaration
String Access_Modifier;
String Returned_Type;
int Num_Parameters;
boolean flagtemp = false;
// metrics
int LOC_Extracted_Method;
// variable
int Num_Variable;
int Num_local;
// Literal
int Num_Literal;
// Comments & Annotation
int Num_Com;
int Num_Annotation;
int Num_AnnotationType;
// Invocation
int Num_Invocation;
int Num_Executable;
int Num_ExeRefExp;
// Structure
int Num_Loop;
int Num_While;
int Num_For;
int Num_If;
int Num_Conditional;
int Num_Switch;
// Access
int Num_Var_Ac;
int Num_Type_Ac;
int Num_Field_Ac;
int Num_Arr_Ac;
int Num_Com_Var;
int Num_Com_Var_Acc;
int Num_Com_Field_Acc;
int Num_Com_Invocation;
int Num_Com_Type_Acc;
int Num_Com_Typed_Ele;
int Num_Com_Mod;
/**
* Actions over all tree nodes (CtElements)
*/
private final List<Operation> allOperations;
/**
* Actions over the changes roots.
*/
private final List<Operation> rootOperations;
/**
* the mapping of this diff
*/
private final MappingStore _mappingsComp;
/**
* Context of the spoon diff.
*/
private final TreeContext context;
private int Num_Assert;
private int Num_Assign;
public DiffImpl(TreeContext context, ITree rootSpoonLeft, ITree rootSpoonRight, String Extracted_Mtd,
String Src_Mtd) {
final MappingStore mappingsComp = new MappingStore();
final Matcher matcher = new CompositeMatchers.ClassicGumtree(rootSpoonLeft, rootSpoonRight, mappingsComp);
matcher.match();
final ActionGenerator actionGenerator = new ActionGenerator(rootSpoonLeft, rootSpoonRight,
matcher.getMappings());
actionGenerator.generate();
final ActionClassifier actionClassifier = new ActionClassifier();
this.allOperations = convertToSpoon(actionGenerator.getActions());
this.rootOperations = convertToSpoon(
actionClassifier.getRootActions(matcher.getMappingSet(), actionGenerator.getActions()));
this._mappingsComp = mappingsComp;
this.context = context;
this.Name_Ext_Mtd = Extracted_Mtd;
this.Name_Src_Mtd = Src_Mtd;
}
private List<Operation> convertToSpoon(List<Action> actions) {
return actions.stream().map(action -> {
if (action instanceof Insert) {
return new InsertOperation((Insert) action);
} else if (action instanceof Delete) {
return new DeleteOperation((Delete) action);
} else if (action instanceof Update) {
return new UpdateOperation((Update) action);
} else if (action instanceof Move) {
return new MoveOperation((Move) action);
} else {
throw new IllegalArgumentException("Please support the new type " + action.getClass());
}
}).collect(Collectors.toList());
}
@Override
public List<Operation> getAllOperations() {
return Collections.unmodifiableList(allOperations);
}
@Override
public List<Operation> getRootOperations() {
return Collections.unmodifiableList(rootOperations);
}
@Override
public List<Operation> getOperationChildren(Operation operationParent, List<Operation> rootOperations) {
return rootOperations.stream()
.filter(operation -> operation.getNode().getParent().equals(operationParent))
.collect(Collectors.toList());
}
@Override
public CtElement changedNode() {
if (rootOperations.size() != 1) {
throw new IllegalArgumentException("Should have only one root action.");
}
return commonAncestor();
}
@Override
public CtElement commonAncestor() {
final List<CtElement> copy = new ArrayList<>();
for (Operation operation : rootOperations) {
CtElement el = operation.getNode();
if (operation instanceof InsertOperation) {
// we take the corresponding node in the source tree
el = (CtElement) _mappingsComp.getSrc(operation.getAction().getNode().getParent())
.getMetadata(SpoonGumTreeBuilder.SPOON_OBJECT);
}
copy.add(el);
}
while (copy.size() >= 2) {
CtElement first = copy.remove(0);
CtElement second = copy.remove(0);
copy.add(commonAncestor(first, second));
}
return copy.get(0);
}
private CtElement commonAncestor(CtElement first, CtElement second) {
while (first != null) {
CtElement el = second;
while (el != null) {
if (first == el) {
return first;
}
el = el.getParent();
}
first = first.getParent();
}
return null;
}
@Override
public CtElement changedNode(Class<? extends Operation> operationWanted) {
final Optional<Operation> firstNode = rootOperations.stream()
.filter(operation -> operationWanted.isAssignableFrom(operation.getClass()))
.findFirst();
if (firstNode.isPresent()) {
return firstNode.get().getNode();
}
throw new NoSuchElementException();
}
@Override
public boolean containsOperation(OperationKind kind, String nodeKind) {
return rootOperations.stream()
.anyMatch(operation -> operation.getAction().getClass().getSimpleName().equals(kind.name())
&& context.getTypeLabel(operation.getAction().getNode()).equals(nodeKind));
}
@Override
public boolean containsOperation(OperationKind kind, String nodeKind, String nodeLabel) {
return containsOperations(getRootOperations(), kind, nodeKind, nodeLabel);
}
@Override
public boolean containsOperations(List<Operation> operations, OperationKind kind, String nodeKind,
String nodeLabel) {
return operations.stream()
.anyMatch(operation -> operation.getAction().getClass().getSimpleName().equals(kind.name())
&& context.getTypeLabel(operation.getAction().getNode()).equals(nodeKind)
&& operation.getAction().getNode().getLabel().equals(nodeLabel));
}
@Override
public void debugInformation() {
System.err.println(toDebugString());
}
private String toDebugString() {
String result = "";
for (Operation operation : rootOperations) {
ITree node = operation.getAction().getNode();
final CtElement nodeElement = operation.getNode();
String label = "\"" + node.getLabel() + "\"";
if (operation instanceof UpdateOperation) {
label += " to \"" + ((Update) operation.getAction()).getValue() + "\"";
}
String nodeType = "CtfakenodeImpl";
if (nodeElement != null) {
nodeType = nodeElement.getClass().getSimpleName();
nodeType = nodeType.substring(2, nodeType.length() - 4);
}
result += "\"" + operation.getAction().getClass().getSimpleName() + "\", \"" + nodeType + "\", " + label
+ " (size: " + node.getDescendants().size() + ")" + node.toTreeString();
}
System.out.println(result);
return result;
}
public <T> List<T> getNewList(List<T> li) {
List<T> list = new ArrayList<T>();
for (int i = 0; i < li.size(); i++) {
T str = li.get(i);
if (!list.contains(str)) {
list.add(str);
}
}
return list;
}
public void print_after() throws IOException {
File file_after = new File("after_method");
file_after.createNewFile();
FileWriter fileWriter = new FileWriter(file_after);
fileWriter.write("
+ extracted_Method.toString() + "\n" + "\n"
+ "
callMethod = getNewList(callMethod);
int size = callMethod.size();
System.out.println("
for (int i = 0; i < size; i++) {
fileWriter.write(callMethod.get(i).toString() + "\n" + "\n");
}
fileWriter.write("
fileWriter.close();
}
public void print_before() throws IOException {
int size3 = deleteStuff.size();
int t;
double sim1, sim2;
sim1 = 0;
sim2 = 0;
CtElement tempEl;
for (t = 0; t < size3; t++) {
tempEl = deleteStuff.get(t);
sim2 = sim(tempEl.toString(), extracted_Method.getBody().toString());
System.out.println("the code is: " + tempEl.toString() + "the similarity of this stuff is: " + sim2);
if (sim2 > sim1) {
deleted = tempEl;
sim1 = sim2;
}
}
if (size3 == 0 || sim(deleted.toString(), extracted_Method.getBody().toString()) < 0.6) {
deleted = extracted_Method.getBody();
System.out.println("use extracted method directly");
}
File file_before = new File("before_method");
file_before.createNewFile();
FileWriter fileWriter2 = new FileWriter(file_before);
fileWriter2.write("
+ deleted.toString() + "\n" + "\n");
fileWriter2.write("
sourceMethod = getNewList(sourceMethod);
int size = sourceMethod.size();
for (int i = 0; i < size; i++) {
fileWriter2.write(sourceMethod.get(i).toString() + "\n" + "\n");
}
fileWriter2.write("
fileWriter2.close();
}
@Override
public String toString() {
if (rootOperations.size() == 0) {
return "no AST change";
}
final StringBuilder stringBuilder = new StringBuilder();
final CtElement ctElement = commonAncestor();
String temp = null;
for (Operation operation : rootOperations) {
try {
temp = toStringAction(operation.getAction());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (temp.length() > 0) {
stringBuilder.append(temp);
if (operation.getNode().equals(ctElement) && operation instanceof InsertOperation) {
break;
}
}
}
try {
print_after();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
print_before();
} catch (IOException e) {
e.printStackTrace();
}
print_file();
return stringBuilder.toString();
}
private static int min(int one, int two, int three) {
int min = one;
if (two < min) {
min = two;
}
if (three < min) {
min = three;
}
return min;
}
public static int ld(String str1, String str2) {
int d[][];
int n = str1.length();
int m = str2.length();
int i; // str1
int j; // str2
char ch1; // str1
char ch2; // str2
int temp;
if (n == 0) {
return m;
}
if (m == 0) {
return n;
}
d = new int[n + 1][m + 1];
for (i = 0; i <= n; i++) {
d[i][0] = i;
}
for (j = 0; j <= m; j++) {
d[0][j] = j;
}
for (i = 1; i <= n; i++) { // str1
ch1 = str1.charAt(i - 1);
for (j = 1; j <= m; j++) {
ch2 = str2.charAt(j - 1);
if (ch1 == ch2) {
temp = 0;
} else {
temp = 1;
}
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + temp);
}
}
return d[n][m];
}
public static double sim(String str1, String str2) {
int ld = ld(str1, str2);
return 1 - (double) ld / Math.max(str1.length(), str2.length());
}
public void print_file() {
File file = new File("file.csv");
// File file = new File("file.csv");
CSVFormat format = null;
if (file.exists()) {
format = CSVFormat.DEFAULT.withHeader("Src_LOC", "Src_Num_local", "Src_Num_Literal", "Src_Num_Invocation",
"Src_Num_If", "Src_Num_Conditional", "Src_Num_Switch", "Src_Num_Var_Ac", "Src_Num_Type_Ac",
"Src_Num_Field_Ac", "Src_Num_Assert", "Src_Num_Assign", "Src_Num_Typed_Ele", "Src_Num_Package",
"LOC_Extracted_Method", "Num_Variable", "Num_local", "Num_Literal", "Num_Invocation", "Num_If",
"Num_Conditional", "Num_Switch", "Num_Var_Ac", "Num_Type_Ac", "Num_Field_Ac", "Num_Assign",
"Num_Typed_Ele", "Num_Package", "ratio_LOC", "Ratio_Variable_Access", "Ratio_Field_Access",
"Ratio_Type_Access", "Ratio_Typed_Ele", "Ratio_Package").withSkipHeaderRecord();
} else {
format = CSVFormat.DEFAULT.withHeader("Src_LOC", "Src_Num_local", "Src_Num_Literal", "Src_Num_Invocation",
"Src_Num_If", "Src_Num_Conditional", "Src_Num_Switch", "Src_Num_Var_Ac", "Src_Num_Type_Ac",
"Src_Num_Field_Ac", "Src_Num_Assert", "Src_Num_Assign", "Src_Num_Typed_Ele", "Src_Num_Package",
"LOC_Extracted_Method", "Num_Variable", "Num_local", "Num_Literal", "Num_Invocation", "Num_If",
"Num_Conditional", "Num_Switch", "Num_Var_Ac", "Num_Type_Ac", "Num_Field_Ac", "Num_Assign",
"Num_Typed_Ele", "Num_Package", "ratio_LOC", "Ratio_Variable_Access", "Ratio_Field_Access",
"Ratio_Type_Access", "Ratio_Typed_Ele", "Ratio_Package");
}
try (Writer out = new FileWriter("file.csv", true); CSVPrinter printer = new CSVPrinter(out, format)) {
System.out.println("
for (int w = 0; w < sourceMethod.size(); w++) {
// get the body of source method: blk
CtBlock blk = null;
if (sourceMethod.get(w) instanceof CtMethod) {
CtMethod m = (CtMethod) sourceMethod.get(w);
blk = m.getBody();
} else if (sourceMethod.get(w) instanceof CtConstructor) {
CtConstructor constr = (CtConstructor) sourceMethod.get(w);
blk = constr.getBody();
}
// get the body of Call Method(the after version of source method) : blk2
// get the src
// F1 metrics (src)
CtBlock cblk = blk.clone();
for (int y = 0; y < cblk.getStatements().size(); y++) {
cblk.removeStatement(cblk.getStatement(y));
y
}
List<CtStatement> srcStat = new ArrayList<CtStatement>();
srcStat = blk.getElements(new TypeFilter(CtStatement.class));
for (int q = 0; q < srcStat.size(); q++) {
System.out.println("Statements" + (q + 1) + ": " + srcStat.get(q));
}
System.out.println("
CtStatement chozen = ((CtStatement) blk.getElements(new TypeFilter(CtStatement.class)).get(3));
CtIf tIf = (CtIf) chozen;
System.out.println("if statement: " + tIf.toString());
System.out.println("then statement: " + tIf.getThenStatement());
Factory factory = new FactoryImpl(new DefaultCoreFactory(), new StandardEnvironment());
CtCodeSnippetStatement statementInConstructor = factory.Code().createCodeSnippetStatement(tIf.getThenStatement().toString());
List<CtStatement> list = factory.Code().createStatementList(tIf.getThenStatement()).getStatements();
System.out.println("statementInConstructor: " + list.size());
CtBlock CtBlockOfConstructor = factory.Code().createCtBlock(statementInConstructor);
System.out.println("CtBlockOfConstructor" + CtBlockOfConstructor.getStatements().size());
System.out.println("else statement: " + tIf.getElseStatement());
System.out.println("deletedStatements: " + chozen);
cblk.addStatement(chozen);
System.out.println("the body of negative sample:" + cblk.toString());
System.out.println("LOC of negative sample:" + cblk.getStatements().size());
System.out.println("LOC of src:" + blk.getStatements());
int Src_LOC = blk.getStatements().size();
System.out.println("LOC of src:" + Src_LOC);
int Src_Num_local = blk.getElements(new TypeFilter(CtLocalVariable.class)).size();
int Src_Num_Literal = blk.getElements(new TypeFilter(CtLiteral.class)).size();
int Src_Num_Assert = blk.getElements(new TypeFilter(CtAssert.class)).size();
int Src_Num_Com = blk.getElements(new TypeFilter(CtComment.class)).size();
// int Src_Num_Annotation = m.getBody().getElements(new TypeFilter(CtAnnotation.class)).size();
int Src_Num_Invocation = blk.getElements(new TypeFilter(CtInvocation.class)).size();
int Src_Num_Executable = blk.getElements(new TypeFilter(CtExecutable.class)).size();
int Src_Num_ExeRefExp = blk.getElements(new TypeFilter(CtExecutableReferenceExpression.class)).size();
int Src_Num_If = blk.getElements(new TypeFilter(CtIf.class)).size();
int Src_Num_Conditional = blk.getElements(new TypeFilter(CtConditional.class)).size();
int Src_Num_Switch = blk.getElements(new TypeFilter(CtSwitch.class)).size();
int Src_Num_Var_Ac = blk.getElements(new TypeFilter(CtVariableAccess.class)).size();
int Src_Num_Type_Ac = blk.getElements(new TypeFilter(CtTypeAccess.class)).size();
int Src_Num_Field_Ac = blk.getElements(new TypeFilter(CtFieldAccess.class)).size();
int Src_Num_Assign = blk.getElements(new TypeFilter(CtAssignment.class)).size();
double ratio_LOC = 0;
// F2 metrics
LOC_Extracted_Method = extracted_Method.getBody().getStatements().size();
if (Src_LOC > 0) {
ratio_LOC = LOC_Extracted_Method / (double) Src_LOC;
}
// variable
Num_Variable = deleted.getElements(new TypeFilter(CtVariable.class)).size();
Num_local = deleted.getElements(new TypeFilter(CtLocalVariable.class)).size();
// Literal
Num_Literal = deleted.getElements(new TypeFilter(CtLiteral.class)).size();
// Invocation
Num_Invocation = deleted.getElements(new TypeFilter(CtInvocation.class)).size();
// Structure
Num_If = deleted.getElements(new TypeFilter(CtIf.class)).size();
Num_Conditional = deleted.getElements(new TypeFilter(CtConditional.class)).size();
Num_Switch = deleted.getElements(new TypeFilter(CtSwitch.class)).size();
// Access
Num_Var_Ac = deleted.getElements(new TypeFilter(CtVariableAccess.class)).size();
Num_Type_Ac = deleted.getElements(new TypeFilter(CtTypeAccess.class)).size();
Num_Field_Ac = deleted.getElements(new TypeFilter(CtFieldAccess.class)).size();
Num_Assign = deleted.getElements(new TypeFilter(CtAssignment.class)).size();
// F3 the ratio of frequency of variable access in the deleted part to that in src
delVarAcc = new ArrayList<CtVariableAccess>(
deleted.getElements(new TypeFilter(CtVariableAccess.class)));
srcVarAcc = new ArrayList<CtVariableAccess>(blk.getElements(new TypeFilter(CtVariableAccess.class)));
System.out.println("Variable Access that almost only used in the deleted part is: ");
double Ratio_Variable_Access = ratio_u(delVarAcc, srcVarAcc, variable_access_most_used);
// F3 the ratio of frequency of field access in the deleted part to that in src
delFieldAcc = new ArrayList<CtFieldAccess>(deleted.getElements(new TypeFilter(CtFieldAccess.class)));
srcFieldAcc = new ArrayList<CtFieldAccess>(blk.getElements(new TypeFilter(CtFieldAccess.class)));
System.out.println("Field Access that almost only used in the deleted part is: ");
double Ratio_Field_Access = ratio_u(delFieldAcc, srcFieldAcc, field_access_most_used);
// F3 the ratio of frequency of invocation in the deleted part to that in src
delInvo = new ArrayList<CtInvocation>(deleted.getElements(new TypeFilter(CtInvocation.class)));
srcInvo = new ArrayList<CtInvocation>(blk.getElements(new TypeFilter(CtInvocation.class)));
System.out.println("Invocation that almost only used in the deleted part is: ");
double Ratio_Invocation = ratio_u(delInvo, srcInvo, invocation_most_used);
// F3 the ratio of frequency of type access in the deleted part to that in src
delTypeAcc = new ArrayList<CtTypeAccess>(deleted.getElements(new TypeFilter(CtTypeAccess.class)));
srcTypeAcc = new ArrayList<CtTypeAccess>(blk.getElements(new TypeFilter(CtTypeAccess.class)));
System.out.println("Type Access that almost only used in the deleted part is: ");
int Src_Num_Type_Acc = srcTypeAcc.size();
double Ratio_Type_Access = ratio_u(delTypeAcc, srcTypeAcc, type_access_most_used);
// F3 the ratio of frequency of typed element in the deleted part to that in src
delTypedEle = new ArrayList<CtTypedElement>(deleted.getElements(new TypeFilter(CtTypedElement.class)));
srcTypedEle = new ArrayList<CtTypedElement>(blk.getElements(new TypeFilter(CtTypedElement.class)));
System.out.println("Typed element that almost only used in the deleted part is: ");
int Num_Typed_Ele = delTypedEle.size();
int Src_Num_Typed_Ele = srcTypedEle.size();
double Ratio_Typed_Ele = ratio_u(delTypedEle, srcTypedEle, typed_ele_most_used);
// F3 the ratio of frequency of packages in the deleted part to that in src
List<CtPackageReferenceImpl> delPackage = new ArrayList<CtPackageReferenceImpl>(
deleted.getElements(new TypeFilter(CtPackageReferenceImpl.class)));
List<CtPackageReferenceImpl> srcPackage = new ArrayList<CtPackageReferenceImpl>(
blk.getElements(new TypeFilter(CtPackageReferenceImpl.class)));
int Num_Package = delPackage.size();
int Src_Num_Package = srcPackage.size();
System.out.println("Package that almost only used in the deleted part is: ");
double Ratio_Package = ratio(delPackage, srcPackage, package_most_used);
// Print
printer.printRecord(Src_LOC, Src_Num_local, Src_Num_Literal, Src_Num_Invocation, Src_Num_If,
Src_Num_Conditional, Src_Num_Switch, Src_Num_Var_Ac, Src_Num_Type_Ac, Src_Num_Field_Ac,
Src_Num_Assert, Src_Num_Assign, Src_Num_Typed_Ele, Src_Num_Package, LOC_Extracted_Method,
Num_Variable, Num_local, Num_Literal, Num_Invocation, Num_If, Num_Conditional, Num_Switch,
Num_Var_Ac, Num_Type_Ac, Num_Field_Ac, Num_Assign, Num_Typed_Ele, Num_Package, ratio_LOC,
Ratio_Variable_Access, Ratio_Field_Access, Ratio_Type_Access, Ratio_Typed_Ele, Ratio_Package);
printer.flush();
}
printer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private double ratio(List<CtPackageReferenceImpl> delPackage, List<CtPackageReferenceImpl> srcPackage,
CtPackageReferenceImpl pkg) {
// TODO Auto-generated method stub
List<CtPackageReferenceImpl> parPackage = new ArrayList<CtPackageReferenceImpl>();
for (int p = 0; p < extracted_Method.getParameters().size(); p++) {
CtParameter par = (CtParameter) extracted_Method.getParameters().get(p);
List<CtPackageReferenceImpl> ttt = par.getType().getElements(new TypeFilter(CtPackageReferenceImpl.class));
for (int k = 0; k < ttt.size(); k++) {
parPackage.add(ttt.get(k));
}
}
List<CtPackageReferenceImpl> delPackage2 = getNewList(delPackage);
for (int l = 0; l < delPackage2.size(); l++) {
CtPackageReferenceImpl tem = delPackage2.get(l);
if (parPackage.contains(tem)) {
delPackage2.remove(tem);
l
}
}
System.out.println("
int num1, num2;
CtPackageReferenceImpl temp;
int size = delPackage2.size();
double[] all_ratios = new double[size];
for (int i = 0; i < size; i++) {
temp = delPackage2.get(i);
num1 = Collections.frequency(delPackage, temp);
num2 = Collections.frequency(srcPackage, temp);
if (num2 != 0) {
all_ratios[i] = num1 / (double) num2;
} else {
all_ratios[i] = 0;
}
}
double result = 0;
int index = -1;
for (int j = 0; j < size; j++) {
if (all_ratios[j] > result) {
index = j;
result = all_ratios[j];
}
}
if (index == -1) {
System.out.println("No package used in the code");
} else {
System.out.println(" " + delPackage2.get(index));
pkg = delPackage2.get(index);
}
if (result > 1) {
result = 1;
}
return result;
}
private <T> double ratio_u(List<T> delPackage, List<T> srcPackage, T pkg) {
// TODO Auto-generated method stub
List<T> delPackage2 = getNewList(delPackage);
System.out.println("
int num1, num2;
T temp;
int size = delPackage2.size();
double[] all_ratios = new double[size];
for (int i = 0; i < size; i++) {
temp = delPackage2.get(i);
num1 = Collections.frequency(delPackage, temp);
num2 = Collections.frequency(srcPackage, temp);
if (num2 != 0) {
all_ratios[i] = num1 / (double) num2;
} else {
all_ratios[i] = 0;
}
}
double result = 0;
int index = -1;
for (int j = 0; j < size; j++) {
if (all_ratios[j] > result) {
index = j;
result = all_ratios[j];
}
}
if (index == -1) {
System.out.println("Nothing used in the code");
} else {
System.out.println(" " + delPackage2.get(index));
pkg = delPackage2.get(index);
}
if (result > 1) {
result = 1;
}
return result;
}
private <T> List<T> getCommon(List<T> deletedStuff, List<T> srcStuff) {
List<T> temp1 = new ArrayList<T>(deletedStuff);
List<T> temp2 = new ArrayList<T>(srcStuff);
temp2.retainAll(temp1);
int i, j;
T t;
for (i = 0; i < temp2.size(); i++) {
t = temp2.get(i);
if (temp1.contains(t)) {
temp2.remove(i);
i
temp1.remove(temp1.indexOf(t));
}
}
return temp2;
}
private String toStringAction(Action action) throws IOException {
String newline = System.getProperty("line.separator");
StringBuilder stringBuilder = new StringBuilder();
CtElement element = (CtElement) action.getNode().getMetadata(SpoonGumTreeBuilder.SPOON_OBJECT);
if (element != null) {
// element != Try
if (!((element.getClass().getSimpleName().substring(2, element.getClass().getSimpleName().length() - 4))
.equalsIgnoreCase("Try"))) {
// action name
stringBuilder.append(action.getClass().getSimpleName());
System.out.println("action: " + action.getClass().getSimpleName());
// node type
String nodeType = element.getClass().getSimpleName();
nodeType = nodeType.substring(2, nodeType.length() - 4);
System.out.println("nodeType: " + nodeType + "");
stringBuilder.append(" ").append(nodeType);
// action position
CtElement parent = element;
while (parent.getParent() != null && !(parent.getParent() instanceof CtPackage)) {
parent = parent.getParent();
}
String position = " at ";
if (parent instanceof CtType) {
position += ((CtType) parent).getQualifiedName();
}
if (element.getPosition() != null) {
position += ":" + element.getPosition().getLine();
}
if (action instanceof Insert) {
if ((element instanceof CtMethod)) {
CtMethod te2 = (CtMethod) element;
if (te2.getSimpleName().toString().equals(Name_Src_Mtd)
&& element.toString().contains(Name_Ext_Mtd)) {
callMethod.add(te2);
} else if (te2.getSimpleName().toString().equals(Name_Ext_Mtd) && flagtemp == false) {
flagtemp = true;
System.out.println("
extracted_Method = te2;
}
} else if (element.toString().contains(Name_Ext_Mtd) && !nodeType.equalsIgnoreCase("Constructor")) {
CtElement callIt = element;
while (!(callIt instanceof CtMethod) && !(callIt instanceof CtConstructor)
&& !(callIt instanceof CtClass)) {
callIt = callIt.getParent();
System.out.println("========" + callIt);
}
if (callIt instanceof CtMethod) {
System.out.println("+++++++++++");
CtMethod m = (CtMethod) callIt;
if (m.getSimpleName().toString().equals(Name_Src_Mtd)) {
callMethod.add((CtMethod) callIt);
}
} else if (callIt instanceof CtConstructor) {
CtConstructor m = (CtConstructor) callIt;
while (!(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
CtClass class_name = (CtClass) callIt;
System.out.println("class name:" + class_name.getSimpleName());
if (class_name.getSimpleName().equals(Name_Src_Mtd)) {
System.out.println("extract from constructor!");
callMethod.add(m);
}
}
}
}
if (action instanceof Delete) {
if (!(element instanceof CtMethod)) {
CtElement callIt = element;
while (!(callIt instanceof CtMethod) && !(callIt instanceof CtConstructor)
&& !(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
if (callIt instanceof CtMethod) {
CtMethod src_temp = (CtMethod) callIt;
if (src_temp.getSimpleName().toString().equals(Name_Src_Mtd)) {
deleteStuff.add(element);
sourceMethod.add(src_temp);
}
} else if (callIt instanceof CtConstructor) {
CtConstructor m = (CtConstructor) callIt;
while (!(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
CtClass class_name = (CtClass) callIt;
System.out.println("class name:" + class_name.getSimpleName());
if (class_name.getSimpleName().equals(Name_Src_Mtd)) {
System.out.println("extract from constructor!");
deleteStuff.add(element);
sourceMethod.add(m);
}
}
}
}
if (action instanceof Move) {
if (!nodeType.equalsIgnoreCase("ThisAccess") && !nodeType.equalsIgnoreCase("TypeAccess")
&& !nodeType.equalsIgnoreCase("Constructor")) {
if (!(element instanceof CtMethod)) {
CtElement callIt = element;
while (!(callIt instanceof CtMethod) && !(callIt instanceof CtConstructor)
&& !(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
if (callIt instanceof CtMethod) {
CtMethod temp_method = (CtMethod) callIt;
if (temp_method.getSimpleName().toString().equals(Name_Src_Mtd)) {
deleteStuff.add(element);
sourceMethod.add(temp_method);
}
} else if (callIt instanceof CtConstructor) {
CtConstructor m = (CtConstructor) callIt;
while (!(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
CtClass class_name = (CtClass) callIt;
System.out.println("class name:" + class_name.getSimpleName());
if (class_name.getSimpleName().equals(Name_Src_Mtd)) {
System.out.println("extract from constructor!");
deleteStuff.add(element);
sourceMethod.add(m);
}
}
}
CtElement elementDest = (CtElement) action.getNode()
.getMetadata(SpoonGumTreeBuilder.SPOON_OBJECT_DEST);
position = " from " + element.getParent(CtClass.class).getQualifiedName() + ":"
+ element.getPosition().getLine();
position += " to " + elementDest.getParent(CtClass.class).getQualifiedName() + ":"
+ elementDest.getPosition().getLine();
}
}
stringBuilder.append(position).append(newline);
String label = element.toString();
if (action instanceof Update) {
CtElement callIt = element;
while (!(callIt instanceof CtMethod) && !(callIt instanceof CtConstructor)
&& !(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
if (callIt instanceof CtMethod) {
CtMethod temp_method = (CtMethod) callIt;
if (temp_method.getSimpleName().toString().equals(Name_Src_Mtd)) {
sourceMethod.add(temp_method);
}
} else if (callIt instanceof CtConstructor) {
CtConstructor m = (CtConstructor) callIt;
while (!(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
CtClass class_name = (CtClass) callIt;
System.out.println("class name:" + class_name.getSimpleName());
if (class_name.getSimpleName().equals(Name_Src_Mtd)) {
System.out.println("extract from constructor!");
deleteStuff.add(element);
sourceMethod.add(m);
}
}
CtElement elementDest = (CtElement) action.getNode()
.getMetadata(SpoonGumTreeBuilder.SPOON_OBJECT_DEST);
if (elementDest instanceof CtMethod) {
CtMethod temp_dest = (CtMethod) elementDest;
if (flagtemp == false && temp_dest.getSimpleName().toString().equals(Name_Ext_Mtd)) {
flagtemp = true;
extracted_Method = temp_dest;
System.out.println("
} else if (temp_dest.getSimpleName().equals(Name_Src_Mtd)
&& temp_dest.toString().contains(Name_Ext_Mtd)) {
callMethod.add(temp_dest);
}
} else if (!nodeType.equalsIgnoreCase("Constructor")
&& elementDest.toString().contains(Name_Ext_Mtd)) {
CtElement callIt1 = elementDest;
while (!(callIt1 instanceof CtMethod) && !(callIt1 instanceof CtConstructor)
&& !(callIt1 instanceof CtClass)) {
callIt1 = callIt1.getParent();
}
if (callIt1 instanceof CtMethod) {
callMethod.add((CtMethod) callIt1);
} else if (callIt instanceof CtConstructor) {
CtConstructor m = (CtConstructor) callIt;
while (!(callIt instanceof CtClass)) {
callIt = callIt.getParent();
}
CtClass class_name = (CtClass) callIt;
System.out.println("class name:" + class_name.getSimpleName());
if (class_name.getSimpleName().equals(Name_Src_Mtd)) {
System.out.println("extract from constructor!");
callMethod.add(m);
}
}
}
label += " to " + elementDest.toString();
}
String[] split = label.split(newline);
for (String s : split) {
stringBuilder.append("\t").append(s).append(newline);
}
}
}
return stringBuilder.toString();
}
}
|
package hu.bme.mit.spaceship;
/**
* A simple spaceship with two proton torpedos and four lasers
*/
public class GT4500 implements SpaceShip {
private TorpedoStore primaryTorpedoStore;
private TorpedoStore secondaryTorpedoStore;
private boolean wasPrimaryFiredLast = false;
public GT4500() {
this.primaryTorpedoStore = new TorpedoStore(10);
this.secondaryTorpedoStore = new TorpedoStore(10);
}
public boolean fireLasers(FiringMode firingMode) {
// TODO not implemented yet
return false;
}
/**
* Tries to fire the torpedo stores of the ship.
*
* @param firingMode how many torpedo bays to fire
* SINGLE: fires only one of the bays.
* - For the first time the primary store is fired.
* - To give some cooling time to the torpedo stores, torpedo stores are fired alternating.
* - But if the store next in line is empty the ship tries to fire the other store.
* - If the fired store reports a failure, the ship does not try to fire the other one.
* ALL: tries to fire both of the torpedo stores.
*
* @return whether at least one torpedo was fired successfully
*/
@Override
public boolean fireTorpedos(FiringMode firingMode) {
boolean firingSuccess = false;
switch (firingMode) {
case SINGLE:
if (wasPrimaryFiredLast) {
// try to fire the secondary first
if (! secondaryTorpedoStore.isEmpty()) {
firingSuccess = secondaryTorpedoStore.fire(1);
wasPrimaryFiredLast = false;
}
else {
// although primary was fired last time, but the secondary is empty
// thus try to fire primary again
if (! primaryTorpedoStore.isEmpty()) {
firingSuccess = primaryTorpedoStore.fire(1);
wasPrimaryFiredLast = true;
}
// if both of the stores are empty, nothing can be done, return failure
}
}
else {
// try to fire the primary first
if (! primaryTorpedoStore.isEmpty()) {
firingSuccess = primaryTorpedoStore.fire(1);
wasPrimaryFiredLast = true;
}
else {
// although secondary was fired last time, but primary is empty
// thus try to fire secondary again
if (! secondaryTorpedoStore.isEmpty()) {
firingSuccess = secondaryTorpedoStore.fire(1);
wasPrimaryFiredLast = false;
}
// if both of the stores are empty, nothing can be done, return failure
}
}
break;
case ALL:
// try to fire both of the torpedos
//TODO implement feature
boolean primarySuccess = false;
if (! primaryTorpedoStore.isEmpty()) {
primarySuccess = primaryTorpedoStore.fire(primaryTorpedoStore.getNumberOfTorpedos());
}
boolean secondarySuccess = false;
if (! secondaryTorpedoStore.isEmpty()) {
secondarySuccess = secondaryTorpedoStore.fire(secondaryTorpedoStore.getNumberOfTorpedos());
}
firingSuccess = primarySuccess && secondarySuccess;
break;
}
return firingSuccess;
}
}
|
package intellimate.izou;
import intellimate.izou.identification.Identifiable;
import intellimate.izou.identification.IdentificationManager;
import intellimate.izou.main.Main;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* The base class for each IzouModule
* @author Leander Kurscheidt
* @version 1.0
*/
public abstract class IzouModule implements MainProvider, Identifiable {
private String ID = this.getClass().getCanonicalName();
protected Main main;
protected final Logger log = LogManager.getLogger(this.getClass());
public IzouModule(Main main) {
this.main = main;
if (!IdentificationManager.getInstance().registerIdentification(this)) {
log.fatal("unable to register!");
}
}
/**
* returns the instance of Main
*
* @return Main
*/
@Override
public Main getMain() {
return main;
}
/**
* Used to log messages at debug level
*
* @param msg the message
* @param e the Throwable
*/
@Override
public void debug(String msg, Throwable e) {
log.debug(msg, e);
}
/**
* Used to log messages at debug level
*
* @param msg the message
*/
@Override
public void debug(String msg) {
log.debug(msg);
}
/**
* Used to log messages at error level
*
* @param msg the message
* @param e the Throwable
*/
@Override
public void error(String msg, Throwable e) {
log.error(msg, e);
}
/**
* Used to log messages at error level
*
* @param msg the message
*/
@Override
public void error(String msg) {
log.error(msg);
}
/**
* An ID must always be unique.
* A Class like Activator or OutputPlugin can just provide their .class.getCanonicalName()
* If you have to implement this interface multiple times, just concatenate unique Strings to
* .class.getCanonicalName()
*
* @return A String containing an ID
*/
@Override
public String getID() {
return ID;
}
}
|
package javaslang.concurrent;
import javaslang.Value;
import javaslang.collection.Iterator;
import javaslang.collection.List;
import javaslang.collection.Seq;
import javaslang.collection.Stream;
import javaslang.control.*;
import javaslang.control.Try.CheckedRunnable;
import javaslang.control.Try.CheckedSupplier;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.*;
/**
* A Future is a computation result that becomes available at some point. All operations provided are non-blocking.
* <p>
* The underlying {@code ExecutorService} is used to execute asynchronous handlers, e.g. via
* {@code onComplete(...)}.
* <p>
* A Future has three two states: pending and completed.
* <ul>
* <li>Pending: The computation is ongoing. Only a pending future may be cancelled.</li>
* <li>Completed: The computation finished successfully with a result, failed with an exception or was cancelled.</li>
* </ul>
* Callbacks may be registered on a Future at each point of time. These actions are performed as soon as the Future
* is completed. An action which is registered on a completed Future is immediately performed. The action may run on
* a separate Thread, depending on the underlying ExecutionService. Actions which are registered on a cancelled
* Future are performed with the failed result.
*
* @param <T> Type of the computation result.
* @author Daniel Dietrich
* @since 2.0.0
*/
public interface Future<T> extends Value<T> {
/**
* The default executor service is {@link ForkJoinPool#commonPool()}.
*/
ExecutorService DEFAULT_EXECUTOR_SERVICE = ForkJoinPool.commonPool();
/**
* Creates a failed {@code Future} with the given {@code exception}, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param exception The reason why it failed.
* @param <T> The value type of a successful result.
* @return A failed {@code Future}.
* @throws NullPointerException if exception is null
*/
static <T> Future<T> failed(Throwable exception) {
Objects.requireNonNull(exception, "exception is null");
return failed(DEFAULT_EXECUTOR_SERVICE, exception);
}
/**
* Creates a failed {@code Future} with the given {@code exception}, backed by the given {@link ExecutorService}.
*
* @param executorService An executor service.
* @param exception The reason why it failed.
* @param <T> The value type of a successful result.
* @return A failed {@code Future}.
* @throws NullPointerException if executorService or exception is null
*/
static <T> Future<T> failed(ExecutorService executorService, Throwable exception) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(exception, "exception is null");
return Promise.<T> failed(executorService, exception).future();
}
/**
* Returns a {@code Future} that eventually succeeds with the first result of the given {@code Future}s which
* matches the given {@code predicate}. If no result matches, the {@code Future} will contain {@link None}.
* <p>
* The returned {@code Future} is backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param futures An iterable of futures.
* @param predicate A predicate that tests successful future results.
* @param <T> Result type of the futures.
* @return A Future of an {@link Option} of the first result of the given {@code futures} that satisfies the given {@code predicate}.
* @throws NullPointerException if one of the arguments is null
*/
static <T> Future<Option<T>> find(Iterable<? extends Future<? extends T>> futures, Predicate<? super T> predicate) {
return find(DEFAULT_EXECUTOR_SERVICE, futures, predicate);
}
/**
* Returns a {@code Future} that eventually succeeds with the first result of the given {@code Future}s which
* matches the given {@code predicate}. If no result matches, the {@code Future} will contain {@link None}.
* <p>
* The returned {@code Future} is backed by the given {@link ExecutorService}.
*
* @param executorService An executor service.
* @param futures An iterable of futures.
* @param predicate A predicate that tests successful future results.
* @param <T> Result type of the futures.
* @return A Future of an {@link Option} of the first result of the given {@code futures} that satisfies the given {@code predicate}.
* @throws NullPointerException if one of the arguments is null
*/
static <T> Future<Option<T>> find(ExecutorService executorService, Iterable<? extends Future<? extends T>> futures, Predicate<? super T> predicate) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(futures, "futures is null");
Objects.requireNonNull(predicate, "predicate is null");
final Promise<Option<T>> promise = Promise.make(executorService);
final List<Future<? extends T>> list = List.ofAll(futures);
if (list.isEmpty()) {
promise.success(None.instance());
} else {
final AtomicInteger count = new AtomicInteger(list.length());
list.forEach(future -> future.onComplete(result -> {
synchronized (count) {
// if the promise is already completed we already found our result and there is nothing more to do.
if (!promise.isCompleted()) {
// when there are no more results we return a None
final boolean wasLast = count.decrementAndGet() == 0;
// when result is a Failure or predicate is false then we check in onFailure for finish
result.filter(predicate)
.onSuccess(value -> promise.trySuccess(new Some<>(value)))
.onFailure(ignored -> {
if (wasLast) {
promise.trySuccess(None.instance());
}
});
}
}
}));
}
return promise.future();
}
/**
* Returns a new {@code Future} that will contain the result of the first of the given futures that is completed,
* backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param futures An iterable of futures.
* @param <T> The result type.
* @return A new {@code Future}.
* @throws NullPointerException if futures is null
*/
static <T> Future<T> firstCompletedOf(Iterable<? extends Future<? extends T>> futures) {
return firstCompletedOf(DEFAULT_EXECUTOR_SERVICE, futures);
}
/**
* Returns a new {@code Future} that will contain the result of the first of the given futures that is completed,
* backed by the given {@link ExecutorService}.
*
* @param executorService An executor service.
* @param futures An iterable of futures.
* @param <T> The result type.
* @return A new {@code Future}.
* @throws NullPointerException if executorService or futures is null
*/
static <T> Future<T> firstCompletedOf(ExecutorService executorService, Iterable<? extends Future<? extends T>> futures) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(futures, "futures is null");
final Promise<T> promise = Promise.make(executorService);
final Consumer<Try<? extends T>> completeFirst = promise::tryComplete;
futures.forEach(future -> future.onComplete(completeFirst));
return promise.future();
}
/**
* Returns a Future which contains the result of the fold of the given future values. If any future or the fold
* fail, the result is a failure.
* <p>
* The resulting {@code Future} is backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param futures An iterable of futures.
* @param zero The zero element of the fold.
* @param f The fold operation.
* @param <T> The result type of the given {@code Futures}.
* @param <U> The fold result type.
* @return A new {@code Future} that will contain the fold result.
* @throws NullPointerException if futures or f is null.
*/
static <T, U> Future<U> fold(Iterable<? extends Future<? extends T>> futures, U zero, BiFunction<? super U, ? super T, ? extends U> f) {
return fold(DEFAULT_EXECUTOR_SERVICE, futures, zero, f);
}
/**
* Returns a Future which contains the result of the fold of the given future values. If any future or the fold
* fail, the result is a failure.
* <p>
* The resulting {@code Future} is backed by the given {@link ExecutorService}.
*
* @param executorService An {@code ExecutorService}.
* @param futures An iterable of futures.
* @param zero The zero element of the fold.
* @param f The fold operation.
* @param <T> The result type of the given {@code Futures}.
* @param <U> The fold result type.
* @return A new {@code Future} that will contain the fold result.
* @throws NullPointerException if executorService, futures or f is null.
*/
static <T, U> Future<U> fold(ExecutorService executorService, Iterable<? extends Future<? extends T>> futures, U zero, BiFunction<? super U, ? super T, ? extends U> f) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(futures, "futures is null");
Objects.requireNonNull(f, "f is null");
if (!futures.iterator().hasNext()) {
return successful(executorService, zero);
} else {
return sequence(executorService, futures).map(seq -> seq.foldLeft(zero, f));
}
}
/**
* Creates a {@code Future} from a {@link Try}, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param result The result.
* @param <T> The value type of a successful result.
* @return A completed {@code Future} which contains either a {@code Success} or a {@code Failure}.
* @throws NullPointerException if result is null
*/
static <T> Future<T> fromTry(Try<? extends T> result) {
return fromTry(DEFAULT_EXECUTOR_SERVICE, result);
}
/**
* Creates a {@code Future} from a {@link Try}, backed by the given {@link ExecutorService}.
*
* @param executorService An {@code ExecutorService}.
* @param result The result.
* @param <T> The value type of a successful result.
* @return A completed {@code Future} which contains either a {@code Success} or a {@code Failure}.
* @throws NullPointerException if executorService or result is null
*/
static <T> Future<T> fromTry(ExecutorService executorService, Try<? extends T> result) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(result, "result is null");
return Promise.fromTry(executorService, result).future();
}
/**
* Starts an asynchronous computation, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param computation A computation.
* @param <T> Type of the computation result.
* @return A new Future instance.
* @throws NullPointerException if computation is null.
*/
static <T> Future<T> of(CheckedSupplier<? extends T> computation) {
return Future.of(DEFAULT_EXECUTOR_SERVICE, computation);
}
/**
* Starts an asynchronous computation, backed by the given {@link ExecutorService}.
*
* @param executorService An executor service.
* @param computation A computation.
* @param <T> Type of the computation result.
* @return A new Future instance.
* @throws NullPointerException if one of executorService of computation is null.
*/
static <T> Future<T> of(ExecutorService executorService, CheckedSupplier<? extends T> computation) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(computation, "computation is null");
final FutureImpl<T> future = new FutureImpl<>(executorService);
future.run(computation);
return future;
}
/**
* Returns a Future which contains the reduce result of the given future values. The zero is the result of the
* first future that completes. If any future or the reduce operation fail, the result is a failure.
* <p>
* The resulting {@code Future} is backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param futures An iterable of futures.
* @param f The reduce operation.
* @param <T> The result type of the given {@code Futures}.
* @return A new {@code Future} that will contain the reduce result.
* @throws NullPointerException if executorService, futures or f is null.
*/
static <T> Future<T> reduce(Iterable<? extends Future<? extends T>> futures, BiFunction<? super T, ? super T, ? extends T> f) {
return reduce(DEFAULT_EXECUTOR_SERVICE, futures, f);
}
/**
* Returns a Future which contains the reduce result of the given future values. The zero is the result of the
* first future that completes. If any future or the reduce operation fail, the result is a failure.
* <p>
* The resulting {@code Future} is backed by the given {@link ExecutorService}.
*
* @param executorService An {@code ExecutorService}.
* @param futures An iterable of futures.
* @param f The reduce operation.
* @param <T> The result type of the given {@code Futures}.
* @return A new {@code Future} that will contain the reduce result.
* @throws NullPointerException if executorService, futures or f is null.
*/
static <T> Future<T> reduce(ExecutorService executorService, Iterable<? extends Future<? extends T>> futures, BiFunction<? super T, ? super T, ? extends T> f) {
if (!futures.iterator().hasNext()) {
throw new NoSuchElementException("Future.reduce on empty futures");
} else {
return sequence(futures).map(seq -> seq.reduceLeft(f));
}
}
/**
* Runs an asynchronous computation, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param unit A unit of work.
* @return A new Future instance which results in nothing.
* @throws NullPointerException if unit is null.
*/
static Future<Void> run(CheckedRunnable unit) {
Objects.requireNonNull(unit, "unit is null");
return Future.of(DEFAULT_EXECUTOR_SERVICE, () -> {
unit.run();
return null;
});
}
/**
* Starts an asynchronous computation, backed by the given {@link ExecutorService}.
*
* @param executorService An executor service.
* @param unit A unit of work.
* @return A new Future instance which results in nothing.
* @throws NullPointerException if one of executorService of unit is null.
*/
static Future<Void> run(ExecutorService executorService, CheckedRunnable unit) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(unit, "unit is null");
return Future.of(executorService, () -> {
unit.run();
return null;
});
}
/**
* Reduces many {@code Future}s into a single {@code Future} by transforming an
* {@code Iterable<Future<? extends T>>} into a {@code Future<Seq<T>>}.
* <p>
* The resulting {@code Future} is backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param futures An {@code Iterable} of {@code Future}s.
* @param <T> Result type of the futures.
* @return A {@code Future} of a {@link Seq} of results.
* @throws NullPointerException if futures is null.
*/
static <T> Future<Seq<T>> sequence(Iterable<? extends Future<? extends T>> futures) {
return sequence(DEFAULT_EXECUTOR_SERVICE, futures);
}
/**
* Reduces many {@code Future}s into a single {@code Future} by transforming an
* {@code Iterable<Future<? extends T>>} into a {@code Future<Seq<T>>}.
* <p>
* The resulting {@code Future} is backed by the given {@link ExecutorService}.
*
* @param executorService An {@code ExecutorService}.
* @param futures An {@code Iterable} of {@code Future}s.
* @param <T> Result type of the futures.
* @return A {@code Future} of a {@link Seq} of results.
* @throws NullPointerException if executorService or futures is null.
*/
static <T> Future<Seq<T>> sequence(ExecutorService executorService, Iterable<? extends Future<? extends T>> futures) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(futures, "futures is null");
final Future<Seq<T>> zero = successful(executorService, Stream.empty());
final BiFunction<Future<Seq<T>>, Future<? extends T>, Future<Seq<T>>> f =
(result, future) -> result.flatMap(seq -> future.map(seq::append));
return Iterator.ofAll(futures).foldLeft(zero, f);
}
/**
* Creates a succeeded {@code Future}, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param result The result.
* @param <T> The value type of a successful result.
* @return A succeeded {@code Future}.
*/
static <T> Future<T> successful(T result) {
return successful(DEFAULT_EXECUTOR_SERVICE, result);
}
/**
* Creates a succeeded {@code Future}, backed by the given {@link ExecutorService}.
*
* @param executorService An {@code ExecutorService}.
* @param result The result.
* @param <T> The value type of a successful result.
* @return A succeeded {@code Future}.
* @throws NullPointerException if executorService is null
*/
static <T> Future<T> successful(ExecutorService executorService, T result) {
Objects.requireNonNull(executorService, "executorService is null");
return Promise.successful(executorService, result).future();
}
/**
* Maps the values of an iterable in parallel to a sequence of mapped values into a single {@code Future} by
* transforming an {@code Iterable<? extends T>} into a {@code Future<Seq<U>>}.
* <p>
* The resulting {@code Future} is backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
*
* @param values An {@code Iterable} of {@code Future}s.
* @param mapper A mapper of values to Futures
* @param <T> The type of the given values.
* @param <U> The mapped value type.
* @return A {@code Future} of a {@link Seq} of results.
* @throws NullPointerException if values or f is null.
*/
static <T, U> Future<Seq<U>> traverse(Iterable<? extends T> values, Function<? super T, ? extends Future<? extends U>> mapper) {
return traverse(DEFAULT_EXECUTOR_SERVICE, values, mapper);
}
/**
* Maps the values of an iterable in parallel to a sequence of mapped values into a single {@code Future} by
* transforming an {@code Iterable<? extends T>} into a {@code Future<Seq<U>>}.
* <p>
* The resulting {@code Future} is backed by the given {@link ExecutorService}.
*
* @param executorService An {@code ExecutorService}.
* @param values An {@code Iterable} of values.
* @param mapper A mapper of values to Futures
* @param <T> The type of the given values.
* @param <U> The mapped value type.
* @return A {@code Future} of a {@link Seq} of results.
* @throws NullPointerException if executorService, values or f is null.
*/
static <T, U> Future<Seq<U>> traverse(ExecutorService executorService, Iterable<? extends T> values, Function<? super T, ? extends Future<? extends U>> mapper) {
Objects.requireNonNull(executorService, "executorService is null");
Objects.requireNonNull(values, "values is null");
Objects.requireNonNull(mapper, "mapper is null");
return sequence(Iterator.ofAll(values).map(mapper));
}
/**
* Cancels the Future. A running thread is interrupted.
*
* @return {@code false}, if this {@code Future} is already completed or could not be cancelled, otherwise {@code true}.
*/
default boolean cancel() {
return cancel(true);
}
/**
* Cancels the Future. A pending Future may be interrupted, depending on the underlying ExecutionService.
*
* @param mayInterruptIfRunning {@code true} if a running thread should be interrupted, otherwise a running thread
* is allowed to complete its computation.
* @return {@code false}, if this {@code Future} is already completed or could not be cancelled, otherwise {@code true}.
* @see java.util.concurrent.Future#cancel(boolean)
*/
boolean cancel(boolean mayInterruptIfRunning);
/**
* Returns the {@link ExecutorService} used by this {@code Future}.
*
* @return The underlying {@code ExecutorService}.
*/
ExecutorService executorService();
/**
* Returns the value of the Future.
*
* @return {@code None}, if the Future is not yet completed or was cancelled, otherwise {@code Some(Try)}.
*/
Option<Try<T>> getValue();
/**
* Checks if the Future is completed, i.e. has a value.
*
* @return true, if the computation successfully finished, failed or was cancelled, false otherwise.
*/
boolean isCompleted();
/**
* Performs the action once the Future is complete.
*
* @param action An action to be performed when this future is complete.
* @throws NullPointerException if {@code action} is null.
*/
void onComplete(Consumer<? super Try<T>> action);
/**
* Performs the action once the Future is complete and the result is a {@link Failure}. Please note that the
* future is also a failure when it was cancelled.
*
* @param action An action to be performed when this future failed.
* @throws NullPointerException if {@code action} is null.
*/
default void onFailure(Consumer<? super Throwable> action) {
Objects.requireNonNull(action, "action is null");
onComplete(result -> result.onFailure(action));
}
/**
* Performs the action once the Future is complete and the result is a {@link Success}.
*
* @param action An action to be performed when this future succeeded.
* @throws NullPointerException if {@code action} is null.
*/
default void onSuccess(Consumer<? super T> action) {
Objects.requireNonNull(action, "action is null");
onComplete(result -> result.onSuccess(action));
}
// -- Value implementation
@Override
default Future<T> filter(Predicate<? super T> predicate) {
final Promise<T> promise = Promise.make();
onComplete(result -> promise.complete(result.filter(predicate)));
return promise.future();
}
@SuppressWarnings("unchecked")
@Override
default Future<Object> flatten() {
final Promise<Object> promise = Promise.make();
onComplete(result -> result
.onSuccess(t -> {
if (t instanceof Future) {
promise.completeWith(((Future<Object>) t).flatten());
} else if (t instanceof Iterable) {
final Object o = Iterator.ofAll(((Iterable<Object>) t)).flatten().get();
promise.success(o);
} else {
promise.success(t);
}
})
.onFailure(promise::failure)
);
return promise.future();
}
@SuppressWarnings("unchecked")
@Override
default <U> Future<U> flatMap(Function<? super T, ? extends java.lang.Iterable<? extends U>> mapper) {
final Promise<U> promise = Promise.make();
onComplete(result -> result.map(mapper::apply)
.onSuccess(us -> {
if (us instanceof Future) {
promise.completeWith((Future<U>) us);
} else {
final java.util.Iterator<? extends U> iter = us.iterator();
if (iter.hasNext()) {
promise.success(iter.next());
} else {
promise.complete(new Failure<>(new NoSuchElementException()));
}
}
})
.onFailure(promise::failure)
);
return promise.future();
}
/**
* Returns the value of the future or throws if the value is not yet present. It is essential not to block.
*
* @return The value of this future.
* @throws NoSuchElementException if the future is not completed, failed or was cancelled.
*/
@Override
default T get() {
return getValue().get().orElseThrow((Supplier<NoSuchElementException>) NoSuchElementException::new);
}
/**
* Checks, if this future has a value.
*
* @return true, if this future succeeded with a value, false otherwise.
*/
@Override
default boolean isEmpty() {
return getValue().map(Try::isFailure).orElse(true);
}
@Override
default Iterator<T> iterator() {
return isEmpty() ? Iterator.empty() : Iterator.of(get());
}
@Override
default <U> Future<U> map(Function<? super T, ? extends U> mapper) {
final Promise<U> promise = Promise.make();
onComplete(result -> promise.complete(result.map(mapper)));
return promise.future();
}
@Override
default Future<T> peek(Consumer<? super T> action) {
onSuccess(action);
return this;
}
}
|
package kr.jm.utils.helper;
import java.util.*;
import java.util.function.*;
import java.util.stream.Stream;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.*;
/**
* The Class JMLambda.
*/
public class JMLambda {
/**
* Partition by.
*
* @param <T> the generic type
* @param collection the collection
* @param predicate the predicate
* @return the map
*/
public static <T> Map<Boolean, List<T>>
partitionBy(Collection<T> collection, Predicate<T> predicate) {
return collection.stream().collect(partitioningBy(predicate));
}
/**
* Group by.
*
* @param <T> the generic type
* @param <R> the generic type
* @param classifier the classifier
* @return the map
*/
public static <T, R> Map<R, List<T>> groupBy(Stream<T> stream,
Function<T, R> classifier) {
return stream.collect(groupingBy(classifier));
}
public static <T, R> Map<R, T> mapBy(Stream<T> stream,
Function<T, R> classifier) {
return stream
.collect(toMap(classifier, identity(), (o, o2) -> o2));
}
public static <T> Map<T, Long> countBy(Stream<T> stream) {
return stream.collect(groupingBy(identity(), counting()));
}
public static <T, R> Map<R, List<T>> groupBy(Collection<T> collection,
Function<T, R> classifier) {
return groupBy(collection.stream(), classifier);
}
public static <T, R> Map<R, T> mapBy(Collection<T> collection,
Function<T, R> classifier) {
return mapBy(collection.stream(), classifier);
}
public static <T> Map<T, Long> countBy(Collection<T> collection) {
return countBy(collection.stream());
}
public static <T, R> Map<R, T> merge(Stream<Map<R, T>> stream) {
return stream.collect(HashMap::new, Map::putAll, Map::putAll);
}
/**
* Group by two key.
*
* @param <T> the generic type
* @param <R1> the generic type
* @param <R2> the generic type
* @param collection the collection
* @param classifier1 the classifier 1
* @param classifier2 the classifier 2
* @return the map
*/
public static <T, R1, R2> Map<R1, Map<R2, T>> groupByTwoKey(
Collection<T> collection, Function<T, R1> classifier1,
Function<T, R2> classifier2) {
return collection.stream()
.collect(groupingBy(classifier1, toMap(classifier2, t -> t)));
}
/**
* Consume by predicate.
*
* @param <T> the generic type
* @param collection the collection
* @param predicate the predicate
* @param trueConsumer the true consumer
* @param falseConsumer the false consumer
*/
public static <T> void consumeByPredicate(Collection<T> collection,
Predicate<T> predicate, Consumer<T> trueConsumer,
Consumer<T> falseConsumer) {
collection.forEach(target -> JMLambda.consumeByBoolean(
predicate.test(target), target, trueConsumer, falseConsumer));
}
/**
* Consume by predicate in parallel.
*
* @param <T> the generic type
* @param collection the collection
* @param predicate the predicate
* @param trueConsumer the true consumer
* @param falseConsumer the false consumer
*/
public static <T> void consumeByPredicateInParallel(
Collection<T> collection, Predicate<T> predicate,
Consumer<T> trueConsumer, Consumer<T> falseConsumer) {
collection.parallelStream()
.forEach(target -> JMLambda.consumeByBoolean(
predicate.test(target), target, trueConsumer,
falseConsumer));
}
/**
* Consume by boolean.
*
* @param <T> the generic type
* @param bool the bool
* @param target the target
* @param trueConsumer the true consumer
* @param falseConsumer the false consumer
*/
public static <T> void consumeByBoolean(boolean bool, T target,
Consumer<T> trueConsumer, Consumer<T> falseConsumer) {
if (bool)
trueConsumer.accept(target);
else
falseConsumer.accept(target);
}
/**
* Consume if not null.
*
* @param <T> the generic type
* @param target the target
* @param consumer the consumer
*/
public static <T> void consumeIfNotNull(T target, Consumer<T> consumer) {
Optional.ofNullable(target).ifPresent(consumer);
}
/**
* Consume if true.
*
* @param <T> the generic type
* @param bool the bool
* @param target the target
* @param consumer the consumer
*/
public static <T> void consumeIfTrue(boolean bool, T target,
Consumer<T> consumer) {
if (bool)
consumer.accept(target);
}
/**
* Consume if true.
*
* @param <T> the generic type
* @param target the target
* @param targetTester the target tester
* @param consumer the consumer
*/
public static <T> void consumeIfTrue(T target, Predicate<T> targetTester,
Consumer<T> consumer) {
consumeIfTrue(targetTester.test(target), target, consumer);
}
/**
* Consume if true.
*
* @param <T> the generic type
* @param <U> the generic type
* @param bool the bool
* @param target1 the target 1
* @param target2 the target 2
* @param biConsumer the bi consumer
*/
public static <T, U> void consumeIfTrue(boolean bool, T target1, U target2,
BiConsumer<T, U> biConsumer) {
if (bool)
biConsumer.accept(target1, target2);
}
/**
* Consume if true.
*
* @param <T> the generic type
* @param <U> the generic type
* @param target1 the target 1
* @param target2 the target 2
* @param targetTester the target tester
* @param biConsumer the bi consumer
*/
public static <T, U> void consumeIfTrue(T target1, U target2,
BiPredicate<T, U> targetTester, BiConsumer<T, U> biConsumer) {
consumeIfTrue(targetTester.test(target1, target2), target1, target2,
biConsumer);
}
/**
* Function if true.
*
* @param <T> the generic type
* @param <R> the generic type
* @param bool the bool
* @param target the target
* @param function the function
* @return the optional
*/
public static <T, R> Optional<R> functionIfTrue(boolean bool, T target,
Function<T, R> function) {
return supplierIfTrue(bool, () -> function.apply(target));
}
/**
* Bi function if true.
*
* @param <T> the generic type
* @param <U> the generic type
* @param <R> the generic type
* @param bool the bool
* @param target1 the target 1
* @param target2 the target 2
* @param biFunction the bi function
* @return the optional
*/
public static <T, U, R> Optional<R> biFunctionIfTrue(boolean bool,
T target1, U target2, BiFunction<T, U, R> biFunction) {
return supplierIfTrue(bool, () -> biFunction.apply(target1, target2));
}
/**
* Supplier if true.
*
* @param <R> the generic type
* @param bool the bool
* @param supplier the supplier
* @return the optional
*/
public static <R> Optional<R> supplierIfTrue(boolean bool,
Supplier<R> supplier) {
return bool ? Optional.ofNullable(supplier.get()) : Optional.empty();
}
/**
* Function by boolean.
*
* @param <T> the generic type
* @param <R> the generic type
* @param bool the bool
* @param target the target
* @param trueFunction the true function
* @param falseFunction the false function
* @return the r
*/
public static <T, R> R functionByBoolean(boolean bool, T target,
Function<T, R> trueFunction, Function<T, R> falseFunction) {
return bool ? trueFunction.apply(target) : falseFunction.apply(target);
}
/**
* Supplier by boolean.
*
* @param <R> the generic type
* @param bool the bool
* @param trueSupplier the true supplier
* @param falseSupplier the false supplier
* @return the r
*/
public static <R> R supplierByBoolean(boolean bool,
Supplier<R> trueSupplier, Supplier<R> falseSupplier) {
return bool ? trueSupplier.get() : falseSupplier.get();
}
/**
* Change into.
*
* @param <T> the generic type
* @param <R> the generic type
* @param input the input
* @return the function
*/
public static <T, R> Function<T, R> changeInto(R input) {
return t -> input;
}
/**
* Supplier if null.
*
* @param <R> the generic type
* @param target the target
* @param supplier the supplier
* @return the r
*/
public static <R> R supplierIfNull(R target, Supplier<R> supplier) {
return Optional.ofNullable(target).orElseGet(supplier);
}
/**
* Gets the true after running.
*
* @param block the block
* @return the true after running
*/
public static boolean getTrueAfterRunning(Runnable block) {
block.run();
return true;
}
/**
* Gets the false after running.
*
* @param block the block
* @return the false after running
*/
public static boolean getFalseAfterRunning(Runnable block) {
block.run();
return false;
}
/**
* Run if true.
*
* @param bool the bool
* @param block the block
*/
public static void runIfTrue(boolean bool, Runnable block) {
if (bool)
block.run();
}
/**
* Run by boolean.
*
* @param bool the bool
* @param trueBlock the true block
* @param falseBlock the false block
*/
public static void runByBoolean(boolean bool, Runnable trueBlock,
Runnable falseBlock) {
if (bool)
trueBlock.run();
else
falseBlock.run();
}
/**
* Gets the self.
*
* @param <T> the generic type
* @return the self
*/
public static <T> Function<T, T> getSelf() {
return t -> t;
}
/**
* Gets the supplier.
*
* @param <T> the generic type
* @param target the target
* @return the supplier
*/
public static <T> Supplier<T> getSupplier(T target) {
return () -> target;
}
/**
* Consume and get self.
*
* @param <T> the generic type
* @param target the target
* @param targetConsumer the target consumer
* @return the t
*/
public static <T> T consumeAndGetSelf(T target,
Consumer<T> targetConsumer) {
targetConsumer.accept(target);
return target;
}
public static <R> R runAndReturn(Runnable runnable,
Supplier<R> returnSupplier) {
runnable.run();
return returnSupplier.get();
}
public static <R> R runAndReturn(Runnable runnable, R returnObject) {
return runAndReturn(runnable, () -> returnObject);
}
}
|
package mcjty.intwheel.gui;
import mcjty.intwheel.InteractionWheel;
import mcjty.intwheel.api.IWheelAction;
import mcjty.intwheel.api.WheelActionElement;
import mcjty.intwheel.input.KeyBindings;
import mcjty.intwheel.network.PacketHandler;
import mcjty.intwheel.network.PacketPerformAction;
import mcjty.intwheel.varia.RenderHelper;
import mcjty.lib.tools.MinecraftTools;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.input.Keyboard;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class GuiWheel extends GuiScreen {
private static final int WIDTH = 160;
private static final int HEIGHT = 160;
private int guiLeft;
private int guiTop;
private final List<WheelActionElement> actions;
private final BlockPos pos;
private static final ResourceLocation background = new ResourceLocation(InteractionWheel.MODID, "textures/gui/wheel.png");
private static final ResourceLocation hilight = new ResourceLocation(InteractionWheel.MODID, "textures/gui/wheel_hilight.png");
public GuiWheel(World world) {
RayTraceResult mouseOver = Minecraft.getMinecraft().objectMouseOver;
if (mouseOver.typeOfHit == RayTraceResult.Type.BLOCK && mouseOver != null) {
pos = mouseOver.getBlockPos();
} else {
pos = null;
}
actions = InteractionWheel.interactionWheelImp.getActions(MinecraftTools.getPlayer(Minecraft.getMinecraft()), world, pos);
}
@Override
public void initGui() {
super.initGui();
guiLeft = (this.width - WIDTH) / 2;
guiTop = (this.height - HEIGHT) / 2;
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (Keyboard.isKeyDown(KeyBindings.keyOpenWheel.getKeyCode())) {
closeThis();
}
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
int cx = mouseX - guiLeft - WIDTH / 2;
int cy = mouseY - guiTop - HEIGHT / 2;
int q = getSelectedSection(cx, cy);
if (q == -1) {
closeThis();
} else {
if (q < getActionSize()) {
performAction(q);
}
}
closeThis();
}
private void performAction(int index) {
WheelActionElement element = actions.get(index);
IWheelAction action = InteractionWheel.registry.get(element.getId());
if (action != null) {
boolean extended = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
if (action.performClient(MinecraftTools.getPlayer(mc), MinecraftTools.getWorld(mc), pos, extended)) {
PacketHandler.INSTANCE.sendToServer(new PacketPerformAction(pos, element.getId(), extended));
}
}
}
private void closeThis() {
this.mc.displayGuiScreen(null);
if (this.mc.currentScreen == null) {
this.mc.setIngameFocus();
}
}
private static final List<Pair<Integer, Integer>> iconOffsets = new ArrayList<>();
static {
iconOffsets.add(Pair.of(78 + 8, 8));
iconOffsets.add(Pair.of(107 + 12, 22 + 19));
iconOffsets.add(Pair.of(107 + 12, 78 + 9));
iconOffsets.add(Pair.of(78 + 9, 108 + 11));
iconOffsets.add(Pair.of(23 + 18, 107 + 11));
iconOffsets.add(Pair.of(0 + 10, 78 + 9));
iconOffsets.add(Pair.of(0 + 9, 22 + 19));
iconOffsets.add(Pair.of(22 + 19, 8));
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
GlStateManager.enableBlend();
mc.getTextureManager().bindTexture(background);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, WIDTH, HEIGHT);
int cx = mouseX - guiLeft - WIDTH / 2;
int cy = mouseY - guiTop - HEIGHT / 2;
int offset = getActionSize() / 2;
int q = getSelectedSection(cx, cy);
if (q != -1) {
mc.getTextureManager().bindTexture(hilight);
switch ((q - offset + 8) % 8) {
case 0:
drawTexturedModalRect(guiLeft + 78, guiTop, 0, 0, 63, 63);
break;
case 1:
drawTexturedModalRect(guiLeft + 107, guiTop + 22, 64, 0, 63, 63);
break;
case 2:
drawTexturedModalRect(guiLeft + 107, guiTop + 78, 128, 0, 63, 63);
break;
case 3:
drawTexturedModalRect(guiLeft + 78, guiTop + 108, 192, 0, 63, 63);
break;
case 4:
drawTexturedModalRect(guiLeft + 23, guiTop + 107, 0, 64, 63, 63);
break;
case 5:
drawTexturedModalRect(guiLeft, guiTop + 78, 64, 64, 63, 63);
break;
case 6:
drawTexturedModalRect(guiLeft, guiTop + 22, 128, 64, 63, 63);
break;
case 7:
drawTexturedModalRect(guiLeft + 22, guiTop, 192, 64, 63, 63);
break;
}
if (q < getActionSize()) {
boolean extended = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
String desc = actions.get(q).getDescription();
String sneakDesc = actions.get(q).getSneakDescription();
if (extended && sneakDesc != null) {
desc = sneakDesc;
}
int width = mc.fontRendererObj.getStringWidth(desc);
int x = guiLeft + (160 - width) / 2;
int y = guiTop + HEIGHT;
RenderHelper.renderText(mc, x, y, desc);
}
}
for (int i = 0; i < getActionSize(); i++) {
WheelActionElement action = actions.get(i);
mc.getTextureManager().bindTexture(new ResourceLocation(action.getTexture()));
int txtw = action.getTxtw();
int txth = action.getTxth();
int u = q == i ? action.getUhigh() : action.getUlow();
int v = q == i ? action.getVhigh() : action.getVlow();
int offs = (i - offset + 8) % 8;
RenderHelper.drawTexturedModalRect(guiLeft + iconOffsets.get(offs).getLeft(), guiTop + iconOffsets.get(offs).getRight(), u, v, 31, 31, txtw, txth);
}
}
private int getActionSize() {
// @todo, overflow in case there are too many actions
return Math.min(8, actions.size());
}
private int getSelectedSection(int cx, int cy) {
double dist = Math.sqrt(cx * cx + cy * cy);
if (dist < 37 || dist > 80) {
return -1;
}
int q = -1;
if (cx >= 0 && cy < 0 && Math.abs(cx) < Math.abs(cy)) {
q = 0;
} else if (cx >= 0 && cy < 0 && Math.abs(cx) >= Math.abs(cy)) {
q = 1;
} else if (cx >= 0 && cy >= 0 && Math.abs(cx) >= Math.abs(cy)) {
q = 2;
} else if (cx >= 0 && cy >= 0 && Math.abs(cx) < Math.abs(cy)) {
q = 3;
} else if (cx < 0 && cy >= 0 && Math.abs(cx) < Math.abs(cy)) {
q = 4;
} else if (cx < 0 && cy >= 0 && Math.abs(cx) >= Math.abs(cy)) {
q = 5;
} else if (cx < 0 && cy < 0 && Math.abs(cx) >= Math.abs(cy)) {
q = 6;
} else if (cx < 0 && cy < 0 && Math.abs(cx) < Math.abs(cy)) {
q = 7;
}
int offset = getActionSize() / 2;
return (q + offset) % 8;
}
}
|
package ml.iamwhatiam.tao.ddd;
import java.util.List;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* DBMS table abstract
*
* @author iMinusMinus
* @since 2017-01-24
* @version 0.0.1
*
*/
public class Table {
private final Dialect dialect;
public Table (Dialect dialect) {
this.dialect = dialect;
}
private String catalog;//Sybase/MS SQLServer: database name
private String schema;//Oracle: user, MySQL: database name
@NotNull
private String name;//catalog.schema.tbl_name
@Size(max = 1017/*, groups = MySQL*/)
private List<Column> columns;
private PrimaryKey pk;
private List<UniqueKey> uks;
private List<ForeignKey> fks;
private List<Index> indexes;
private List<Check> checks;
private String comment;
//ignore some table options
//ignore partition options
public Dialect getDialect() {
return dialect;
}
public String getCatalog() {
return catalog;
}
public void setCatalog(String catalog) {
this.catalog = catalog;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Column> getColumns() {
return columns;
}
public void setColumns(List<Column> columns) {
this.columns = columns;
}
public PrimaryKey getPk() {
return pk;
}
public void setPk(PrimaryKey pk) {
this.pk = pk;
}
public List<UniqueKey> getUks() {
return uks;
}
public void setUks(List<UniqueKey> uks) {
this.uks = uks;
}
public List<ForeignKey> getFks() {
return fks;
}
public void setFks(List<ForeignKey> fks) {
this.fks = fks;
}
public List<Index> getIndexes() {
return indexes;
}
public void setIndexes(List<Index> indexes) {
this.indexes = indexes;
}
public List<Check> getChecks() {
return checks;
}
public void setChecks(List<Check> checks) {
this.checks = checks;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
/**
* Column abstract
*
*/
public static class Column {
public Column(String name, DataType dataType) {
this.name = name;
this.dataType = dataType;
}
private Table table;
private String name;
private DataType dataType;
private boolean nullable = true;//a constraint!
private String defaultValue;
private boolean autoIncrement;
private String comment;
//ignore some column information
// private PrimaryKey pk;
// private Index index;
// private UniqueKey uk;
// private ForeignKey fk;
// private Check check;
public Table getTable() {
return table;
}
public void setTable(Table table) {
this.table = table;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DataType getDataType() {
return dataType;
}
public void setDataType(DataType dataType) {
this.dataType = dataType;
}
public boolean isNullable() {
return nullable;
}
public void setNullable(boolean nullable) {
this.nullable = nullable;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public boolean isAutoIncrement() {
return autoIncrement;
}
public void setAutoIncrement(boolean autoIncrement) {
this.autoIncrement = autoIncrement;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public static interface DataType {
String toSQL();
public static final DataType BOOLEAN = new DataType() {
public String toSQL() {
return "BOOLEAN";
}
};
}
public static interface CharacterDataType extends DataType {
int get();
void set(int length);
public static final DataType CHARACTER = new CharacterDataType() {
@Min(1)
private int length;
public void set(int length) {
this.length = length;
}
public int get() {
return length;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("CHARACTER");
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
};
public static final DataType CHARACTER_VARYING = new CharacterDataType() {
@Min(1)
private int length;
public void set(int length) {
this.length = length;
}
public int get() {
return length;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("CHARACTER VARYING");
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
};
public static final DataType CHARACTER_LARGE_OBJECT = new CharacterDataType() {//CLOB, TEXT
public void set(int length) {
throw new NotImplementedException();
}
public int get() {
throw new NotImplementedException();
}
public String toSQL() {
return "CHARACTER LARGE OBJECT VARYING";
}
};
public static final DataType BINARY = new CharacterDataType() {
@Min(1)
private int length;
public void set(int length) {
this.length = length;
}
public int get() {
return length;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("BINARY");
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
};
public static final DataType BINARY_VARYING = new CharacterDataType() {
@Min(1)
private int length;
public void set(int length) {
this.length = length;
}
public int get() {
return length;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("BINARY VARYING");
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
};
public static final DataType BINARY_LARGE_OBJECT = new CharacterDataType() {//BLOB
public void set(int length) {
throw new NotImplementedException();
}
public int get() {
throw new NotImplementedException();
}
public String toSQL() {
return "BINARY LARGE OBJECT";
}
};
@Deprecated//deleted from SQL:2003
public static final DataType BIT = new CharacterDataType() {
@Min(1)
private int length;
public void set(int length) {
this.length = length;
}
public int get() {
return length;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("BIT");
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
};
@Deprecated//deleted from SQL:2003
public static final DataType BIT_VARYING = new CharacterDataType() {
@Min(1)
private int length;
public void set(int length) {
this.length = length;
}
public int get() {
return length;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("BIT VARYING");
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
};
}
public static interface NumeberDataType extends DataType {
int getPrecision();
int getScale();
void set(int precision);
void set(int precision, int scale);
public static final DataType NUMERIC = new NumeberDataType() {
@Min(1)
private int precision;
@Min(0)
private int scale;
public int getPrecision() {
return precision;
}
public int getScale() {
return scale;
}
public void set(int precision) {
this.precision = precision;
scale = 0;
}
public void set(int precision, int scale) {
this.precision = precision;
this.scale = scale;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("NUMERIC");
if(precision > 0)
sb.append("(").append(precision).append(",").append(scale).append(")");
return sb.toString();
}
};
public static final DataType DECIMAL = new NumeberDataType() {
@Min(1)
private int precision;
@Min(0)
private int scale;
public int getPrecision() {
return precision;
}
public int getScale() {
return scale;
}
public void set(int length) {
precision = length;
scale = 0;
}
public void set(int precision, int scale) {
this.precision = precision;
this.scale = scale;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("DECIMAL");
if(precision > 0)
sb.append("(").append(precision).append(",").append(scale).append(")");
return sb.toString();
}
};
public static final DataType SMALLINT = new NumeberDataType() {
@Min(1)
private int precision;
public int getPrecision() {
return precision;
}
public int getScale() {
throw new NotImplementedException();
}
public void set(int length) {
precision = length;
}
public void set(int precision, int scale) {
throw new NotImplementedException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("SMALLINT");
if(precision > 0)
sb.append("(").append(precision).append(")");
return sb.toString();
}
};
public static final DataType INTEGER = new NumeberDataType() {
@Min(1)
private int precision;
public int getPrecision() {
return precision;
}
public int getScale() {
throw new NotImplementedException();
}
public void set(int precision) {
this.precision = precision;
}
public void set(int precision, int scale) {
throw new NotImplementedException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("INTEGER");
if(precision > 0)
sb.append("(").append(precision).append(")");
return sb.toString();
}
};
public static final DataType BIGINT = new NumeberDataType() {
@Min(1)
private int precision;
public int getPrecision() {
return precision;
}
public int getScale() {
throw new NotImplementedException();
}
public void set(int precision) {
this.precision = precision;
}
public void set(int precision, int scale) {
throw new NotImplementedException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("BIGINT");
if(precision > 0)
sb.append("(").append(precision).append(")");
return sb.toString();
}
};
public static final DataType FLOAT = new NumeberDataType() {
@Min(1)
private int precision;
public int getPrecision() {
return precision;
}
public int getScale() {
throw new NotImplementedException();
}
public void set(int precision) {
this.precision = precision;
}
public void set(int precision, int scale) {
throw new NotImplementedException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("FLOAT");
if(precision > 0)
sb.append("(").append(precision).append(")");
return sb.toString();
}
};
public static final DataType REAL = new NumeberDataType() {
@Min(1)
private int precision;
public int getPrecision() {
return precision;
}
public int getScale() {
throw new NotImplementedException();
}
public void set(int precision) {
this.precision = precision;
}
public void set(int precision, int scale) {
throw new NotImplementedException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("REAL");
if(precision > 0)
sb.append("(").append(precision).append(")");
return sb.toString();
}
};
public static final DataType DOUBLE_PRECISION = new NumeberDataType() {
@Min(1)
private int precision;
public int getPrecision() {
return precision;
}
public int getScale() {
throw new NotImplementedException();
}
public void set(int precision) {
this.precision = precision;
}
public void set(int precision, int scale) {
throw new NotImplementedException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("DOUBLE PRECISION");
if(precision > 0)
sb.append("(").append(precision).append(")");
return sb.toString();
}
};
}
public static interface EnumeratedDataType extends DataType {
String[] names();
void set(String...names);
public static final DataType ENUMERATED = new EnumeratedDataType() {
private String[] names;
public String[] names() {
return names;
}
public void set(String...names) {
this.names = names;
}
public String toSQL() {//CREATE TYPE name ENUMERATED(names...);
StringBuilder sb = new StringBuilder("ENUMERATED(");
for(String name : names)
sb.append(name).append(",");
sb.setLength(sb.length() - 1);
return sb.append(")").toString();
}
};
}
public static interface DateTimeDataType extends DataType {
int get();
void set(int precision);
boolean withTimeZone();
void set(int precision, boolean withTimeZone);
void set(int precision, int intervalClass, int fracionalPrecision);
public static final DataType DATE = new DateTimeDataType() {
public int get() {
throw new UnsupportedOperationException("[DATE] has no fractional seconds precision!");
}
public void set(int precision) {
throw new UnsupportedOperationException("[DATE] has no fractional seconds precision!");
}
public boolean withTimeZone() {
throw new UnsupportedOperationException();
}
public void set(int precision, boolean withTimeZone) {
throw new UnsupportedOperationException();
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
throw new UnsupportedOperationException();
}
public String toSQL() {
return "DATE";
}
};
public static final DataType TIME = new DateTimeDataType() {
private int precision;
private boolean withTimeZone = false;
public int get() {
return precision;
}
public void set(int precision) {
this.precision = precision;
}
public boolean withTimeZone() {
return withTimeZone;
}
public void set(int precision, boolean withTimeZone) {
this.precision = precision;
this.withTimeZone = withTimeZone;
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
throw new UnsupportedOperationException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("TIME");
if(precision >= 0)
sb.append(" (").append(precision).append(")");
sb.append(" WITH");
if(!withTimeZone)
sb.append("OUT");
sb.append(" TIME ZONE");
return sb.toString();
}
};
public static final DataType TIMESTAMP = new DateTimeDataType() {
private int precision;
private boolean withTimeZone = false;
public int get() {
return precision;
}
public void set(int precision) {
this.precision = precision;
}
public boolean withTimeZone() {
return withTimeZone;
}
public void set(int precision, boolean withTimeZone) {
this.precision = precision;
this.withTimeZone = withTimeZone;
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
throw new UnsupportedOperationException();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("TIMESTAMP");
if(precision >= 0)
sb.append(" (").append(precision).append(")");
sb.append(" WITH");
if(!withTimeZone)
sb.append("OUT");
sb.append(" TIME ZONE");
return sb.toString();
}
};
public static final DataType INTERVAL = new DateTimeDataType() {
private int precision = 2;
private int fractionalSecondPrecision;
@Min(0)
@Max(4)
private int intervalClass;
private final int YEAR_TO_MONTH = 0, DAY_TO_HOUR = 1, DAY_TO_MINUTE = 2/*, DAY_TO_SECOND = 3*/;
public int get() {
return precision;
}
public void set(int intervalClass) {
this.intervalClass = intervalClass;
}
public boolean withTimeZone() {
throw new NotImplementedException();
}
public void set(int precision, boolean withTimeZone) {
throw new NotImplementedException();
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
this.precision = precision;
this.intervalClass = intervalClass;
this.fractionalSecondPrecision = fracionalPrecision;
}
public String toSQL() {
StringBuilder sb = new StringBuilder("INTERVAL ");
if(intervalClass == YEAR_TO_MONTH)
sb.append("YEAR");
else sb.append("DAY");
if(precision > 0)
sb.append(" (").append(precision).append(")");
sb.append(" ");
if(intervalClass == YEAR_TO_MONTH)
sb.append("MONTH");
else if(intervalClass == DAY_TO_HOUR)
sb.append("HOUR");
else if(intervalClass == DAY_TO_MINUTE)
sb.append("MINUTE");
else sb.append("SECOND");
if(fractionalSecondPrecision > 0)
sb.append(" (").append(fractionalSecondPrecision).append(")");
return sb.toString();
}
};
}
/**
* abstract data types: defined by a standard, by an implementation, or by an application
*/
public static interface UserDefinedDataType extends DataType {
//source(type,)
}
public static enum MySQLDataType implements CharacterDataType, NumeberDataType, EnumeratedDataType, DateTimeDataType, UserDefinedDataType {
TINYINT {//synonyms for BIT(8)
private int m = 1;
private boolean unsigned = false;
private boolean zerofill = false;
private boolean init = false;
public int get() {
return m;
}
/**
* @param m the number of bits per value, if m > 1, value also cannot exceed 128 or 255(unsigned)
*/
public void set(int m) {
set(m, false, false);
}
public void set(int m, boolean unsigned, boolean zerofill) {
this.m = m;
this.unsigned = unsigned;
this.zerofill = zerofill;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
SMALLINT {
private int m = 2;
private boolean unsigned = false;
private boolean zerofill = false;
private boolean init = false;
public void set(int m) {
set(m, false, false);
}
public void set(int m, boolean unsigned, boolean zerofill) {
this.m = m;
this.unsigned = unsigned;
this.zerofill = zerofill;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
MEDIUMINT {
private int m = 3;
private boolean unsigned = false;
private boolean zerofill = false;
private boolean init = false;
public int get() {
return m;
}
public void set(int m) {
set(m, false, false);
}
public void set(int m, boolean unsigned, boolean zerofill) {
this.m = m;
this.unsigned = unsigned;
this.zerofill = zerofill;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
INT {//synonyms INTEGER
private int m = 4;
private boolean unsigned = false;
private boolean zerofill = false;
private boolean init = false;
public int get() {
return m;
}
public void set(int m) {
set(m, false, false);
}
public void set(int m, boolean unsigned, boolean zerofill) {
this.m = m;
this.unsigned = unsigned;
this.zerofill = zerofill;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
BIGINT {
private int m = 8;
private boolean unsigned = false;
private boolean zerofill = false;
private boolean init = false;
public int get() {
return m;
}
public void set(int m) {
set(m, false, false);
}
public void set(int m, boolean unsigned, boolean zerofill) {
this.m = m;
this.unsigned = unsigned;
this.zerofill = zerofill;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
/**
* <li>Fixed-Point Types (Exact Value)
*/
DECIMAL {
private boolean init = false;
private int m = 10;
private int d;
private boolean unsigned = false;
private boolean zerofill = false;
public int getPrecision() {
return m;
}
public int getScale() {
return d;
}
public void set(int precision) {
set(precision, 0);
}
public void set(int precision, int scale) {
set(precision, scale, false, false);
}
public void set(int precision, int scale, boolean unsigned, boolean zerofill) {
m = precision;
d = scale;
this.unsigned = unsigned;
this.zerofill = zerofill;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(",").append(d).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
/**
* <li>Floating-Point Types (Approximate Value)
*/
FLOAT{
private int m;
private int d;
private boolean unsigned = false;
private boolean zerofill = false;
public int getPrecision() {
return m;
}
public void set(int m) {//if m > 23, ddl column definition automatic change to double
set(m, 0);
}
public int getScale() {
return d;
}
public void set(int precision, int scale) {
set(precision, scale, false, false);
}
public void set(@Min(1) @Max(23)int precision, int scale, boolean unsigned, boolean zerofill) {
assert precision >= scale;
m = precision;
d = scale;
this.unsigned = unsigned;
this.zerofill = zerofill;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(m > 0)
sb.append("(").append(m).append(",").append(d).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
DOUBLE {//synonyms REAL
private int m;
private int d;
private boolean unsigned = false;
private boolean zerofill = false;
public int getPrecision() {
return m;
}
public void set(int m) {
set(m, 0);
}
public int getScale() {
return d;
}
public void set(int m, int d) {
set(m, d, false, false);
}
public void set(@Min(24) @Max(53)int precision, int scale, boolean unsigned, boolean zerofill) {
assert precision >= scale;
m = precision;
d = scale;
this.unsigned = unsigned;
this.zerofill = zerofill;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(m > 0)
sb.append("(").append(m).append(",").append(d).append(")");
if(unsigned)
sb.append(" UNSIGNED");
if(zerofill)
sb.append(" ZEROFILL");
return sb.toString();
}
},
//DOUBLE_PRECISION,
BIT {//b'111' --> 7
private int m;
private boolean init = false;
public int get() {
return m;
}
public void set(@Min(1) @Max(64) int precision) {
m = precision;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(m).append(")");
return sb.toString();
}
},
DATE,//supported range is '1000-01-01' to '9999-12-31'.
DATETIME{//supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
private int fraction;
private boolean init = false;
public int get() {
return fraction;
}
public void set(@Max(6) int precision) {
this.fraction = precision;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(fraction).append(")");
return sb.toString();
}
},
TIMESTAMP{//range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
private int fraction;
private boolean init = false;
public int get() {
return fraction;
}
public void set(@Max(6) int precision) {
this.fraction = precision;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(fraction).append(")");
return sb.toString();
}
},
TIME{
private int fraction;
private boolean init = false;
public int get() {
return fraction;
}
public void set(@Max(6) int precision) {
this.fraction = precision;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(fraction).append(")");
return sb.toString();
}
},
YEAR{
private int digit = 4;//2 or 4
private boolean init = false;
public void set(@Pattern(regexp = "[2|4]") int m) {
digit = m;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(digit).append(")");
return sb.toString();
}
},
/**
* <ul>String Types:
*/
CHAR {
private int length;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(0) @Max(255) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
VARCHAR {
private int length;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(0) @Max(65535) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
BINARY {
private int length;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(0) @Max(255) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
VARBINARY {
private int length;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(0) @Max(65535) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
/**
* <li>Blob and Text Types
*/
TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB,//8,,24,32
TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT,//8,,24,32; LONG and LONG VARCHAR map to the MEDIUMTEXT
/**
* <li>ENUM Type
*/
ENUM {
private String[] names;
public String[] names() {
return names;
}
public void set(String...names) {
this.names = names;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(names != null && names.length > 0) {
sb.append("(");
for(int i = 0, j = names.length; i < j; i++) {
sb.append(names[i]);
if(i < j - 1)
sb.append(",");
}
sb.append(")");
}
return sb.toString();
}
},
/**
* <li>SET type
*/
SET {
private String[] names;
public String[] names() {
return names;
}
public void set(String...names) {
this.names = names;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(names != null && names.length > 0) {
sb.append("(");
for(int i = 0, j = names.length; i < j; i++) {
sb.append(names[i]);
if(i < j - 1)
sb.append(",");
}
sb.append(")");
}
return sb.toString();
}
},
/**
* <ul>Spatial Data Types
*/
GEOMETRY,
POINT,
LINESTRING,
POLYGON,
MULTIPOINT,
MULTILINESTRING,
MULTIPOLYGON,
GEOMETRYCOLLECTION,;
public String toSQL() {
return super.toString();
}
public boolean withTimeZone() {
throw new UnsupportedOperationException();
}
public void set(int precision, boolean withTimeZone) {
throw new UnsupportedOperationException();
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
throw new UnsupportedOperationException();
}
public String[] names() {
throw new AbstractMethodError();
}
public void set(String... names) {
throw new AbstractMethodError();
}
public int getPrecision() {
throw new AbstractMethodError();
}
public int getScale() {
throw new AbstractMethodError();
}
public void set(int precision, int scale) {
throw new AbstractMethodError();
}
public int get() {
throw new AbstractMethodError();
}
public void set(int length) {
throw new AbstractMethodError();
}
public void set(int precision, boolean unsigned, boolean zerofill) {
throw new AbstractMethodError();
}
public void set(int precision, int scale, boolean unsigned, boolean zerofill) {
throw new AbstractMethodError();
}
}
public static enum OracleDataType implements CharacterDataType, NumeberDataType, DateTimeDataType, UserDefinedDataType {
CHAR{
private int length = 1;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(1) @Max(2000) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
VARCHAR2{
private int length = 1;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(1) @Max(4000) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
NCHAR{
private int length = 1;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(1) @Max(2000) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
NVARCHAR2{
private int length = 1;
private boolean init = false;
public int get() {
return length;
}
public void set(@Min(1) @Max(4000) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
CLOB,
NCLOB,
@Deprecated LONG,//<2G, use CLOB or NCLOB instead!
NUMBER{
private int precision;
private int scale;//maybe negative
public int getPrecision() {
return precision;
}
public void set(int length) {
set(length, 0);
}
public int getScale() {
return scale;
}
public void set(@Max(38) @Min(1) int precision, @Max(127) @Min(-84) int scale) {
if(precision > 38)
throw new IllegalArgumentException("Data Type [NUMBER] cannot exceed 38!");
if(precision + scale < 0 || scale > precision)
throw new IllegalArgumentException("Data Type [NUMBER] |scale| cannot exceed precision!");
this.precision = precision;
this.scale = scale;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(precision > 0)
sb.append("(").append(precision).append(",").append(scale).append(")");
return sb.toString();
}
},
BINARY_FLOAT,//approximate numeric datatypes
BINARY_DOUBLE,//approximate numeric datatypes
TIMESTAMP{
private int fraction;
private boolean withTimeZone;
public int get() {
return fraction;
}
public void set(int fraction) {
this.fraction = fraction;
}
public boolean withTimeZone() {
return withTimeZone;
}
public void set(int fraction, boolean withTimeZone) {
this.fraction = fraction;
this.withTimeZone = withTimeZone;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(fraction > 0)
sb.append("(").append(fraction).append(")");
if(withTimeZone)
sb.append(" WITH TIME ZONE");//XXX ignored TIMESTAMP WITH LOCAL TIME ZONE
return sb.toString();
}
},
BLOB,//<128T
BFILE,//<4G, read only; stores unstructured binary data in operating-system files outside the database
@Deprecated RAW,//<2000bytes, can be indexed
@Deprecated LONG_RAW,//<2G, //cannot be indexed, use the BLOB or BFILE instead!
ROWID,//pseudocolumn
UROWID,
XMLType,
UriType,
;
public String toSQL() {
return super.toString().replace("_", " ");
}
public boolean withTimeZone() {
throw new AbstractMethodError();
}
public void set(int precision, boolean withTimeZone) {
throw new AbstractMethodError();
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
throw new UnsupportedOperationException();
}
public int getPrecision() {
throw new AbstractMethodError();
}
public int getScale() {
throw new AbstractMethodError();
}
public void set(int precision, int scale) {
throw new AbstractMethodError();
}
public int get() {
throw new AbstractMethodError();
}
public void set(int length) {
throw new AbstractMethodError();
}
}
public static enum PostgresDataType implements CharacterDataType, NumeberDataType, EnumeratedDataType, DateTimeDataType, UserDefinedDataType {
/**
* Numeric Types
*/
SMALLINT,//alias INT2
INTEGER,//alias INT or INT4
BIGINT,//alias int8
NUMERIC {//alias DECIMAL
private int precision;
private int scale;
public int getPrecision() {
return precision;
}
public void set(int precision) {
set(precision, 0);
}
public int getScale() {
return scale;
}
public void set(@Max(1000) int precision, int scale) {
this.precision = precision;
this.scale =scale;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(precision > 0)
sb.append("(").append(precision).append(",").append(scale).append(")");
return sb.toString();
}
},
REAL,//alias FLOAT4, FLOAT(p) 1=<p<=24
DOUBLE_PRECISION,//alias FLOAT8, FLOAT(p) 25=<p<=53
SMALLSERIAL,//alias SERIAL2
SERIAL,//alias SERIAL4
BIGSERIAL,//alias SERIAL8
/**
* Monetary Types
*/
MONEY,
/**
* Character Types
*/
CHARACTER {//alias CHAR
private int length = 1;
private boolean init = true;
public int get() {
return length;
}
public void set(@Min(1) int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
CHARACTER_VARING {//alias VARCHAR
private int length;
public int get() {
return length;
}
public void set(int length) {
this.length = length;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
TEXT,
/**
* Binary Data Types
*/
BYTEA,
/**
* Date/Time Types
*/
DATE,
TIME {//alias TIMETZ
private int precision;
private boolean withTimeZone;
private Boolean init = null;
public int get() {
return precision;
}
public void set(@Min(0) @Max(6) int precision) {
this.precision = precision;
init = Boolean.FALSE;
}
public boolean withTimeZone() {
return withTimeZone;
}
public void set(@Min(0) @Max(10) int precision, boolean withTimeZone) {
this.precision = precision;
this.withTimeZone = withTimeZone;
init = Boolean.TRUE;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init != null) {
sb.append(" (").append(precision).append(")");
if(init) {
sb.append(" WITH");
if(!withTimeZone)
sb.append("OUT");
sb.append(" TIME ZONE");
}
}
return sb.toString();
}
},
TIMESTAMP {//alias TIMESTAMPTZ
private int precision;
private boolean withTimeZone;
private Boolean init = null;
public int get() {
return precision;
}
public void set(@Min(0) @Max(6) int precision) {
this.precision = precision;
init = Boolean.FALSE;
}
public boolean withTimeZone() {
return withTimeZone;
}
public void set(@Min(0) @Max(6) int precision, boolean withTimeZone) {
this.precision = precision;
this.withTimeZone = withTimeZone;
init = Boolean.TRUE;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init != null) {
sb.append(" (").append(precision).append(")");
if(init) {
sb.append(" WITH");
if(!withTimeZone)
sb.append("OUT");
sb.append(" TIME ZONE");
}
}
return sb.toString();
}
},
INTERVAL {
private int intervalClass;
private int precision;
private final int YEAR_TO_MONTH = 0, DAY_TO_HOUR = 1, DAY_TO_MINUTE = 2, DAY_TO_SECOND = 3, HOUR_TO_MINUTE = 4, HOUR_TO_SECOND = 5, MINUTE_TO_SECOND = 6;
@Override public String toSQL() {
return null;//TODO
}
},
/**
* Boolean Type
*/
BOOLEAN,//alias BOOL: true, false, unknow
/**
* Enumerated Types
*/
ENUM {//create type name as ENUM(strings...)
private String[] names;
public String[] names() {
return names;
}
public void set(String... names) {
this.names = names;
}
},
/**
* Geometric Types
*/
POINT,//(x, y)
LINE,//{A,B,C}
LSEG,//((x1,y1),(x2,y2))
BOX,//((x1,y1),(x2,y2))
PATH,//close path: ((x1,y1),...) or open path: [(x1,y1),...]
POLYGON,//((x1,y1),...)
CIRCLE,//<(x,y),r>
/**
* Network Address Types
*/
CIDR,
INET,
MACADDR,
/**
* Bit String Types
*/
BIT {
private int length = 1;
private boolean init = false;
public int get() {
return length;
}
public void set(int length) {
this.length = length;
init = true;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(init)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
BIT_VARING {//alias VARBIT
private int length;
public int get() {
return length;
}
public void set(int length) {
this.length = length;
}
@Override public String toSQL() {
StringBuilder sb = new StringBuilder(super.toSQL());
if(length > 0)
sb.append("(").append(length).append(")");
return sb.toString();
}
},
/**
* Text Search Types
*/
TSQUERY,
TSVECTOR,
UUID,
XML,
JSON,
JSONB,
//Arrays: TEXT[][], INTEGER[][], ...
//Composite Types: CREATE TYPE name AS {col type}
//Range Types: INT4RANGE, INT8RANGE, NUMRANGE, TSRANGE, DATERANGE
//Object Identifier Types: oid alias as regproc, regprocedure, regoper, regoperator, regclass, regtype, regrole, regnamespace, regconfig, or regdictionary
PG_SLN {
@Override public String toSQL() {
return "PG_SLN";
}
},
//Pseudo-Types: cannot be used as a column data type
;
public String toSQL() {
return super.toString().replace("_", " ");
}
public boolean withTimeZone() {
throw new AbstractMethodError();
}
public void set(int precision, boolean withTimeZone) {
throw new AbstractMethodError();
}
public void set(int precision, int intervalClass, int fracionalPrecision) {
throw new AbstractMethodError();
}
public int getPrecision() {
throw new AbstractMethodError();
}
public int getScale() {
throw new AbstractMethodError();
}
public void set(int precision, int scale) {
throw new AbstractMethodError();
}
public int get() {
throw new AbstractMethodError();
}
public void set(int length) {
throw new AbstractMethodError();
}
public String[] names() {
throw new AbstractMethodError();
}
public void set(String... names) {
throw new AbstractMethodError();
}
}
/*
public static enum Format {
FIXED,
DYNAMIC,
DEFAULT
}
public static enum Storage {
DISK,
MEMORY,
DEFAULT;
}
*/
}
public static class Constraint {
@Pattern(regexp = "[PK|UK|FK|IDX|C]_[0-9A-Z_]+")
protected String name;
@Size(min = 1)
protected Column[] columns;
public Constraint(Column... columns) {
this.columns = columns;
}
public Constraint(String name, Column... columns) {
this.name = name;
this.columns = columns;
}
protected String getType() {
return "KEY";
}
public String toSQL() {
StringBuilder sb = new StringBuilder(getType());
if(name != null) sb.append(" ").append(name);
sb.append(" ").append("(");
for(int i = 0, j = columns.length; i < j; i++) {
sb.append(columns[i].name);
if(i < j - 1)
sb.append(",");
}
return sb.append(")").toString();
}
//ignore type and options
}
public static class PrimaryKey extends Constraint {
@Override
protected String getType() {
return "PRIMARY KEY";
}
}
public static class Index extends Constraint {
@Override
protected String getType() {
return "INDEX";
}
}
public static class UniqueKey extends Constraint {
@Override
protected String getType() {
return "UNIQUE INDEX";
}
}
public static class ForeignKey extends Constraint {
@Size(min = 1)
private Column[] references;
// private Action update = Action.RESTRICT;
// private Action delete = Action.RESTRICT;
public ForeignKey(String name, Column[] self, Column[] reference) {
this.name = name;
assert self.length == reference.length;
this.columns = self;
this.references = reference;
}
@Override
public String toSQL() {
StringBuilder sb = new StringBuilder("CONSTRAINT");
sb.append(" ").append(name);
sb.append(" FOREIGN KEY (");
for(int i = 0, j = columns.length; i < j; i++) {
sb.append(columns[i].name);
if(i != j - 1)
sb.append(",");
}
sb.append(")").append(" REFERENCES ");
sb.append(references[0].table.name);
sb.append(" (");
for(int i = 0, j = references.length; i < j; i++) {
sb.append(references[i].name);
if(i < j - 1)
sb.append(",");
}
sb.append(")");
return sb.toString();
}
/*
public enum Action {
RESTRICT,
CASCADE,
SET_NULL,NO_ACTION
}*/
}
public static class Check extends Constraint {//XXX
private String expr;
public String getExpr() {
return expr;
}
public void setExpr(String expr) {
this.expr = expr;
}
@Override
public String toSQL() {
return "CHECK (" + expr + ")";
}
}
/*private enum Engine {
InnoDB,//The default storage engine in MySQL 5.7
MyISAM,
MEMORY,
CSV,
ARCHIVE,//compact, unindexed
BLACKHOLE,
NDB,
MRG_MYISAM,//Merge
Federated,
Example,
}*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder("{");
sb.append("\"").append(name).append("\":").append("[");
for(int i = 0, j = columns.size(); i < j; i++) {
sb.append("\"").append(columns.get(i).name).append("\"");
if(i < j - 1)
sb.append(",");
}
return sb.append("]").append("}").toString();
}
public String toSQL() {
StringBuilder sb = new StringBuilder("CREATE TABLE ");
sb.append(name).append(" (\n");
for(int i = 0, j = columns.size(); i < j; i++) {
sb.append("\"").append(columns.get(i).name).append(" ").append(columns.get(i).getDataType());
if(!columns.get(i).nullable)
sb.append(" NOT NULL");
if(columns.get(i).defaultValue != null)
sb.append(" DEFAULT ").append(columns.get(i).defaultValue);
sb.append(",\n");
}
if(indexes != null && !indexes.isEmpty()) {
for(Index index : indexes)
sb.append(index.toSQL()).append(",\n");
}
if(pk != null)
sb.append(pk.toSQL()).append(",\n");
if(uks != null && !uks.isEmpty()) {
for(UniqueKey uk : uks)
sb.append(uk.toSQL()).append(",\n");
}
if(fks != null && !fks.isEmpty()) {
for(ForeignKey fk : fks)
sb.append(fk.toSQL()).append(",\n");
}
if(checks != null && !checks.isEmpty()) {
for(Check ck : checks)
sb.append(ck.toSQL()).append(",\n");
}
sb.deleteCharAt(sb.lastIndexOf(","));
sb.append(");");
return sb.toString();
}
}
|
package net.folab.finddiff;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
public class FindDiff {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
usage();
return;
}
findDiff(new File(args[0]), new File(args[1]), "");
}
public static void usage() {
String className = FindDiff.class.getName();
System.out.println("Usage: ");
System.out.println(" java " + className + " DIR1 DIR2");
System.out.println(" java " + className + " FILE1 FILE2");
}
public static void findDiff(File lBase, File rBase, String path) {
File lFile = new File(lBase, path);
File rFile = new File(rBase, path);
if (!lFile.exists()) {
if (!rFile.exists()) {
System.out.println("! " + path);
return;
} else {
System.out.println("+ " + path);
return;
}
} else {
if (!rFile.exists()) {
System.out.println("- " + path);
return;
}
}
if (lFile.isFile()) {
if (rFile.isFile()) {
findFileDiff(lFile, rFile, path);
return;
} else if (rFile.isDirectory()) {
System.out.println("< " + path);
return;
} else {
System.out.println("? " + path);
System.out.println(" Unexpected case: left is file but right is neither file nor directory");
return;
//throw new RuntimeException("Unexpected case: left is file but right is neither file nor directory - " + path);
}
} else if (lFile.isDirectory()) {
if (rFile.isDirectory()) {
List<String> names = new ArrayList<String>(Arrays.asList(lFile.list()));
names.addAll(Arrays.asList(rFile.list()));
names = new ArrayList<String>(new HashSet<String>(names));
Collections.sort(names);
for (String name : names)
findDiff(lBase, rBase, path + File.separator + name);
} else if (rFile.isFile()) {
System.out.println("> " + path);
return;
} else {
throw new RuntimeException("Unexpected case: left is directory but right is neither directory nor file - " + path);
}
}
}
public static void findFileDiff(File lFile, File rFile, String path) {
String head;
if (lFile.isFile() && rFile.isFile() && "".equals(path)) {
head = "~ " + lFile.getName();
} else {
head = "~ " + path;
}
System.out.print(head);
if (lFile.length() != rFile.length()) {
clear(head, false);
System.out.println("* " + path);
return;
}
FileInputStream lin = null;
FileInputStream rin = null;
byte[] lbuf = new byte[1024 * 1024];
byte[] rbuf = new byte[1024 * 1024];
int llen;
int rlen;
String stat;
long length = lFile.length();
long offset = 0;
int w = String.valueOf(length).length();
w = w + ((w - 1) / 3);
try {
lin = new FileInputStream(lFile);
rin = new FileInputStream(rFile);
stat = ": " + String.format("%6.2f", ((double) offset * 100) / length) + "% (" + String.format("%," + w + "d", offset) + "/" + String.format("%," + w + "d", length) + ")";
while ((llen = lin.read(lbuf)) > 0) {
offset += llen;
System.out.print(stat);
if ((rlen = rin.read(rbuf)) != llen) {
// TODO handle rest bytes
throw new RuntimeException(llen + " != " + rlen);
}
for (int i = 0; i < llen; i++) {
if (lbuf[i] != rbuf[i]) {
clear(head, false);
System.out.println("* " + path);
return;
}
}
clear(stat, false);
stat = ": " + String.format("%6.2f", ((double) offset * 100) / length) + "% (" + String.format("%," + w + "d", offset) + "/" + String.format("%," + w + "d", length) + ")";
}
System.out.print(stat);
clear(stat, true);
clear(head, true);
} catch (IOException e) {
clear(head, false);
System.out.println("! " + path);
e.printStackTrace();
} finally {
if (lin != null) {
try {
lin.close();
} catch (IOException e) {
}
}
if (rin != null) {
try {
rin.close();
} catch (IOException e) {
}
}
}
}
public static void clear(String path, boolean whitening) {
for (int i = 0; i < path.length(); i++) {
System.out.print("\b");
}
if (whitening) {
for (int i = 0; i < path.length(); i++) {
System.out.print(" ");
}
for (int i = 0; i < path.length(); i++) {
System.out.print("\b");
}
}
}
}
|
package no.seria.istribute.sdk;
import no.seria.istribute.sdk.exception.InvalidResponseException;
import no.seria.istribute.sdk.exception.IstributeErrorException;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.EntityBuilder;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.json.*;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class Http {
protected String serverUrl;
protected String appId;
protected String appKey;
public Http(String appId, String appKey, String serverUrl) {
this.appId = appId;
this.appKey = appKey;
this.serverUrl = serverUrl;
}
public String getServerUrl() {
return serverUrl;
}
public String getAppId() {
return appId;
}
public String getAppKey() {
return appKey;
}
private JsonObject jsonResponseFilter(String data) throws InvalidResponseException, IstributeErrorException {
JsonObject jsonData = parsePayload(data);
if (jsonData == null) {
throw new InvalidResponseException("Result from Istribute is not valid JSON");
}
return jsonData;
}
public String sign(String path) throws UnsupportedEncodingException {
return this.sign(path, null);
}
public String sign(String path, Long expiry) throws UnsupportedEncodingException {
String fragment;
if (appKey == null) {
return serverUrl + path;
}
// Add the appId GET parameter.
if (path.contains("?")) {
fragment = String.format("%s&", path);
} else {
fragment = String.format("%s?", path);
}
fragment = String.format("%sappId=%s", fragment, URLEncoder.encode(appId, "UTF-8"));
// If expiry is not provided, expire the URL after 24 hours.
if (expiry == null) {
long unixTimestamp = System.currentTimeMillis() / 1000L;
long computedExpiry = unixTimestamp + (3600 * 24);
fragment = String.format("%s&signExpiry=%s", fragment, String.valueOf(computedExpiry));
} else {
fragment = String.format("%s&signExpiry=%s", fragment, expiry);
}
// Sign the path.
String signature = null;
signature = URLEncoder.encode(hmacDigest(fragment, appKey, "HmacSHA256"), "UTF-8"); // TODO: Verify logic: anonymous Istribute has a null appKey.
// Construct full endpoint.
return String.format("%s%s&signature=%s", serverUrl, fragment, signature);
}
private <T extends JsonStructure>T parsePayload(String payload) throws IstributeErrorException {
T result;
InputStream stream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
try (JsonReader jsonObjectReader = Json.createReader(stream)) {
try {
result = (T) jsonObjectReader.readObject();
} catch (JsonException e) {
stream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8)); // stream.reset();
try (JsonReader jsonArrayReader = Json.createReader(stream)) {
result = (T) jsonArrayReader.readArray();
}
}
}
if (result instanceof JsonObject) {
JsonObject data = (JsonObject) result;
String error = data.getString("error");
if (error != null) {
int code;
try {
code = data.getInt("code");
} catch (Exception e) {
code = 0;
}
throw new IstributeErrorException("[" + code + "] " + error);
}
}
return result;
}
private static String hmacDigest(String msg, String keyString, String algorithm) {
String digest = null;
try {
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algorithm);
Mac mac = Mac.getInstance(algorithm);
mac.init(key);
byte[] bytes = mac.doFinal(msg.getBytes("ASCII"));
StringBuffer hash = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String hex = Integer.toHexString(0xFF & bytes[i]);
if (hex.length() == 1) {
hash.append('0');
}
hash.append(hex);
}
digest = hash.toString();
} catch (UnsupportedEncodingException e) {
System.err.println(e.getMessage()); // TODO: Do something meaningful with the exception (or re-throw).
} catch (InvalidKeyException e) {
System.err.println(e.getMessage());
} catch (NoSuchAlgorithmException e) {
System.err.println(e.getMessage());
}
return digest;
}
// A generic method to execute any type of Http Request and constructs a response object.
private static String executeRequest(HttpRequestBase httpRequestBase) throws IOException {
String responseString = "";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
try (CloseableHttpResponse httpResponse = httpClient.execute(httpRequestBase)) {
if (httpResponse != null) {
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null) {
InputStream inputStream = httpEntity.getContent();
// Scanner iterates over tokens in the stream, and in this case we separate tokens using
// of the stream.
responseString = new Scanner(inputStream, "UTF-8").useDelimiter("\\A").next();
inputStream.close();
}
}
}
}
return responseString;
}
public <T extends JsonStructure>T get(String path) throws IOException, InvalidResponseException, IstributeErrorException {
String signedUrl = sign(path);
HttpGet httpGet = new HttpGet(signedUrl);
String responseString = executeRequest(httpGet);
return parsePayload(responseString);
}
public <T extends JsonStructure>T put(String path, String filename) throws IOException, InvalidResponseException, IstributeErrorException {
String signedUrl = sign(path);
HttpPut httpPut = new HttpPut(signedUrl);
Path binaryPath = Paths.get(filename);
byte[] binary = Files.readAllBytes(binaryPath);
HttpEntity requestEntity = EntityBuilder.create()
.setBinary(binary)
.build();
httpPut.setEntity(requestEntity);
String responseString = executeRequest(httpPut);
return parsePayload(responseString);
}
public <T extends JsonStructure>T post(String path, Map<String, String> fields) throws IOException, InvalidResponseException, IstributeErrorException {
List<NameValuePair> postData = new ArrayList<NameValuePair>();
for (Map.Entry<String, String> entry : fields.entrySet()) {
postData.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
// TODO: Review.
String postChecksum = DigestUtils.md5Hex(String.valueOf(postData.hashCode()).getBytes());
String endpoint;
if (path.contains("?")) {
endpoint = String.format("%s&postChecksum=%s", path, URLEncoder.encode(postChecksum, "UTF-8"));
} else {
endpoint = String.format("%s?postChecksum=%s", path, URLEncoder.encode(postChecksum, "UTF-8"));
}
String signedUrl = sign(endpoint);
HttpPost httpPost = new HttpPost(signedUrl);
httpPost.setEntity(new UrlEncodedFormEntity(postData));
String responseString = executeRequest(httpPost);
return parsePayload(responseString);
}
}
|
package nz.co.crookedhill.wyem;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import nz.co.crookedhill.wyem.item.WYEMItem;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@Mod(modid = WYEM.MODID, version = WYEM.VERSION)
public class WYEM
{
public static final String MODID = "wyem";
public static final String VERSION = "$VERSION$";
public static ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("wyeMaterial", 15, new int[] {1, 3, 2, 1}, 25);
public static WYEMCreativeTab wyemTab = new WYEMCreativeTab("WYEM");
/* static so its not created over and over again */
static Random rand = new Random(System.currentTimeMillis());
@EventHandler
public void init(FMLInitializationEvent event)
{
WYEMItem.init();
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onAttackedEvent(LivingAttackEvent event)
{
if(!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer && event.source.isProjectile())
{
EntityPlayer player = (EntityPlayer)event.entity;
for(ItemStack item : player.inventory.armorInventory)
{
if(item == null)
{
continue;
}
if(item.getItem() == WYEMItem.enderChestplate && rand.nextFloat() < 0.1f) // 10% chance to cancel and teleport.
{
event.setCanceled(true);
event.source.getSourceOfDamage().setDead();
/* this line exists because .setDead doesnt hapen streat away, so the player can still get damaged */
event.source.getSourceOfDamage().setPosition(event.source.getSourceOfDamage().posX, event.source.getSourceOfDamage().posY+1000.0d, event.source.getSourceOfDamage().posZ);
teleportFromDamage((EntityPlayer)event.entity);
item.attemptDamageItem(3, rand);
break;
}
}
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onHurtEvent(LivingHurtEvent event)
{
if(!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer && event.entity.handleLavaMovement())
{
for(ItemStack item : ((EntityPlayer) event.entity).inventory.armorInventory)
{
if(item == null)
{
continue;
}
if(item.getItem() == WYEMItem.enderChestplate)
{
teleportFromDamage((EntityPlayer)event.entity);
item.attemptDamageItem(3, rand);
break;
}
}
}
}
private static void teleportFromDamage(EntityPlayer player)
{
double xpos = ((player.posX-5.0d) + (double)rand.nextInt(10));
double ypos = ((player.posY-5.0d) + (double)rand.nextInt(10));
double zpos = ((player.posZ-5.0d) + (double)rand.nextInt(10));
while(!player.worldObj.isAirBlock((int)xpos, (int)ypos, (int)zpos))
{
ypos += 1.0d;
}
player.setPositionAndUpdate(xpos, ypos, zpos);
}
}
|
package org.basex.query.func;
import java.util.Arrays;
import java.util.Comparator;
import org.basex.query.QueryContext;
import org.basex.query.QueryError;
import org.basex.query.QueryException;
import org.basex.query.expr.DynFunCall;
import org.basex.query.expr.Expr;
import org.basex.query.expr.PartFunApp;
import org.basex.query.expr.VarRef;
import org.basex.query.item.AtomType;
import org.basex.query.item.Empty;
import org.basex.query.item.FunItem;
import org.basex.query.item.FunType;
import org.basex.query.item.Item;
import org.basex.query.item.Itr;
import org.basex.query.item.Value;
import static org.basex.query.util.Err.*;
import org.basex.query.iter.ItemCache;
import org.basex.query.iter.Iter;
import org.basex.query.util.Err;
import org.basex.query.util.Var;
import org.basex.util.InputInfo;
final class FNFunc extends Fun {
/**
* Constructor.
* @param ii input info
* @param f function definition
* @param e arguments
*/
protected FNFunc(final InputInfo ii, final FunDef f, final Expr... e) {
super(ii, f, e);
}
@Override
public Iter iter(final QueryContext ctx) throws QueryException {
switch(def) {
case MAP: return map(ctx);
case FILTER: return filter(ctx);
case MAPPAIRS: return zip(ctx);
case FOLDLEFT: return foldLeft(ctx);
case FOLDLEFT1: return foldLeft1(ctx);
case FOLDRIGHT: return foldRight(ctx);
case SORTWITH: return sortWith(ctx);
case HOFID: return expr[0].iter(ctx);
case CONST: return expr[0].iter(ctx);
case UNTIL: return until(ctx);
default:
return super.iter(ctx);
}
}
@Override
public Item item(final QueryContext ctx, final InputInfo ii)
throws QueryException {
switch(def) {
case FUNCARITY: return Itr.get(getFun(0, FunType.ANY, ctx).arity());
case FUNCNAME: return getFun(0, FunType.ANY, ctx).fName();
case PARTAPP: return partApp(ctx, ii);
case HOFID: return expr[0].item(ctx, ii);
case CONST: return expr[0].item(ctx, ii);
default:
return super.item(ctx, ii);
}
}
/**
* Partially applies the function to one argument.
* @param ctx query context
* @param ii input info
* @return function item
* @throws QueryException query exception
*/
private Item partApp(final QueryContext ctx, final InputInfo ii)
throws QueryException {
final FunItem f = getFun(0, FunType.ANY, ctx);
final long pos = expr.length == 2 ? 0 : checkItr(expr[2], ctx) - 1;
final int arity = f.arity();
if(pos < 0 || pos >= arity) INVPOS.thrw(ii, f.name(), pos + 1);
final FunType ft = (FunType) f.type;
final Var[] vars = new Var[arity - 1];
final Expr[] vals = new Expr[arity];
vals[(int) pos] = expr[1];
for(int i = 0, j = 0; i < arity - 1; i++, j++) {
if(i == pos) j++;
vars[i] = ctx.uniqueVar(ii, ft.args[j]);
vals[j] = new VarRef(ii, vars[i]);
}
return new PartFunApp(ii, new DynFunCall(ii, f, vals),
vars).comp(ctx).item(ctx, ii);
}
/**
* Maps a function onto a sequence of items.
* @param ctx context
* @return sequence of results
* @throws QueryException exception
*/
private Iter map(final QueryContext ctx) throws QueryException {
final FunItem f = withArity(0, 1, ctx);
final Iter xs = expr[1].iter(ctx);
return new Iter() {
/** Results. */
Iter ys = Empty.ITER;
@Override
public Item next() throws QueryException {
do {
final Item it = ys.next();
if(it != null) return it;
final Item x = xs.next();
if(x == null) return null;
ys = f.invIter(ctx, input, x);
} while(true);
}
};
}
/**
* Filters the given sequence with the given predicate.
* @param ctx query context
* @return filtered sequence
* @throws QueryException query exception
*/
private Iter filter(final QueryContext ctx) throws QueryException {
final FunItem f = withArity(0, 1, ctx);
final Iter xs = expr[1].iter(ctx);
return new Iter() {
@Override
public Item next() throws QueryException {
do {
final Item it = xs.next();
if(it == null) return null;
final Item b = f.invItem(ctx, input, it);
if(checkType(b, AtomType.BLN).bool(input)) return it;
} while(true);
}
};
}
/**
* Zips two sequences with the given zipper function.
* @param ctx query context
* @return sequence of results
* @throws QueryException query exception
*/
private Iter zip(final QueryContext ctx) throws QueryException {
final FunItem zipper = withArity(0, 2, ctx);
final Iter xs = expr[1].iter(ctx);
final Iter ys = expr[2].iter(ctx);
return new Iter() {
/** Results. */
Iter zs = Empty.ITER;
@Override
public Item next() throws QueryException {
do {
final Item it = zs.next();
if(it != null) return it;
final Item x = xs.next(), y = ys.next();
if(x == null || y == null) return null;
zs = zipper.invIter(ctx, input, x, y);
} while(true);
}
};
}
/**
* Folds a sequence into a return value, starting from the left.
* @param ctx query context
* @return resulting sequence
* @throws QueryException query exception
*/
private Iter foldLeft(final QueryContext ctx) throws QueryException {
final FunItem f = withArity(0, 2, ctx);
final Iter xs = expr[2].iter(ctx);
Iter res = expr[1].iter(ctx);
for(Item x; (x = xs.next()) != null;)
res = f.invIter(ctx, input, res.finish(), x);
return res;
}
/**
* Folds a sequence into a return value, starting from the left and using the
* leftmost item as start value.
* @param ctx query context
* @return resulting sequence
* @throws QueryException query exception
*/
private Iter foldLeft1(final QueryContext ctx) throws QueryException {
final FunItem f = withArity(0, 2, ctx);
final Iter xs = expr[1].iter(ctx);
Iter res = checkEmpty(xs.next()).iter();
for(Item x; (x = xs.next()) != null;)
res = f.invIter(ctx, input, res.finish(), x);
return res;
}
/**
* Folds a sequence into a return value, starting from the left.
* @param ctx query context
* @return resulting sequence
* @throws QueryException query exception
*/
private Iter foldRight(final QueryContext ctx) throws QueryException {
final FunItem f = withArity(0, 2, ctx);
Iter res = expr[1].iter(ctx);
final ItemCache xs = ItemCache.get(expr[2].iter(ctx));
for(int i = (int) xs.size(); i
res = f.invIter(ctx, input, xs.get(i), res.finish());
return res;
}
/**
* Sorts the input sequence according to the given relation.
* @param ctx query context
* @return sorted sequence
* @throws QueryException query exception
*/
private Iter sortWith(final QueryContext ctx) throws QueryException {
final FunItem lt = withArity(0, 2, ctx);
final ItemCache ic = ItemCache.get(expr[1].iter(ctx));
try {
Arrays.sort(ic.item, 0, (int) ic.size(), new Comparator<Item>(){
@Override
public int compare(final Item it1, final Item it2) {
try {
return checkType(lt.invItem(ctx, input, it1, it2),
AtomType.BLN).bool(input) ? -1 : 1;
} catch(final QueryException qe) {
throw new QueryError(qe);
}
}
});
} catch(final QueryError err) {
throw err.wrapped();
}
return ic;
}
/**
* Applies a function to a start value until the given predicate holds.
* @param ctx query context
* @return accepted value
* @throws QueryException exception
*/
private Iter until(final QueryContext ctx) throws QueryException {
final FunItem pred = withArity(0, 1, ctx);
final FunItem fun = withArity(1, 1, ctx);
Value v = expr[2].value(ctx);
while(!checkType(pred.invItem(ctx, input, v), AtomType.BLN).bool(input)) {
v = fun.invIter(ctx, input, v).finish();
}
return v.iter();
}
/**
* Checks the type of the given function item.
* @param p position
* @param t type
* @param ctx context
* @return function item
* @throws QueryException query exception
*/
private FunItem getFun(final int p, final FunType t, final QueryContext ctx)
throws QueryException {
return (FunItem) checkType(checkItem(expr[p], ctx), t);
}
/**
* Casts and checks the function item for its arity.
* @param p position of the function
* @param a arity
* @param ctx query context
* @return function item
* @throws QueryException query exception
*/
private FunItem withArity(final int p, final int a, final QueryContext ctx)
throws QueryException {
final Item f = checkItem(expr[p], ctx);
if(!f.func() || ((FunItem) f).vars().length != a)
Err.type(this, FunType.arity(a), f);
return (FunItem) f;
}
@Override
public boolean uses(final Use u) {
return def == FunDef.PARTAPP && u == Use.CTX || u == Use.X30 ||
super.uses(u);
}
@Override
public Expr cmp(final QueryContext ctx) throws QueryException {
return super.cmp(ctx);
}
}
|
package org.cirdles.topsoil;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
/**
*
* @author John Zeringue
*/
public class Topsoil extends Application {
public static final String APP_NAME = "Topsoil";
public static final Path USER_HOME = Paths.get(System.getProperty("user.home"));
public static final Path TOPSOIL_PATH = Paths.get(USER_HOME.toString(), APP_NAME);
public static final Path LAST_TABLE_PATH = Paths.get(TOPSOIL_PATH.toString(), "last_table.tsv");
/**
* Text of the error shown if there aren't enough columns to fill all the charts' fields
*/
public static final String NOT_ENOUGH_COLUMNS_MESSAGE = "Careful, you don't have enough columns to create an ErrorEllipse Chart";
@Override
public void start(Stage primaryStage) throws Exception {
// Create the Topsoil folder if it doesn't exist.
Files.createDirectories(TOPSOIL_PATH);
ResourceBundle bundle = ResourceBundle.getBundle("org.cirdles.topsoil.Resources");
// TopsoilMainWindow root = new TopsoilMainWindow(primaryStage);
Pane root = (Pane) FXMLLoader.load(getClass().getResource("topsoil.fxml"), bundle);
primaryStage.setScene(new Scene(root));
primaryStage.setTitle(String.format("%s [%s]",
bundle.getString("applicationName"),
bundle.getString("applicationVersion")));
primaryStage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application. main() serves only as fallback in case the
* application can not be launched through deployment artifacts, e.g., in IDEs with limited FX support. NetBeans
* ignores main().
* <p>
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
|
package org.databene.commons;
import org.databene.commons.collection.MapEntry;
import org.databene.commons.file.FileByNameFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
/**
* Provides stream operations.<br/>
* <br/>
* Created: 17.07.2006 22:17:42
* @since 0.1
* @author Volker Bergmann
*/
public final class IOUtil {
/** The logger. */
private static final Logger LOGGER = LoggerFactory.getLogger(IOUtil.class);
private static final String USER_AGENT = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041122 Firefox/1.0";
/**
* Convenience method that closes a {@link Closeable} if it is not null
* and logs possible exceptions without disturbing program execution.
* @param closeable the stream to close
*/
public static void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
LOGGER.error("Error closing " + closeable, e);
}
}
}
public static <T extends Closeable> void closeAll(T... closeables) {
if (closeables != null) {
Throwable t = null;
for (Closeable closeable : closeables) {
try {
closeable.close();
} catch (IOException e) {
LOGGER.error("Error closing " + closeable, e);
} catch (Throwable e) {
t = e;
}
}
if (t != null)
throw new RuntimeException("Error closing resources", t);
}
}
public static <T extends Collection<? extends Closeable>> void closeAll(T closeables) {
if (closeables != null) {
Throwable t = null;
for (Closeable closeable : closeables) {
try {
closeable.close();
} catch (IOException e) {
LOGGER.error("Error closing " + closeable, e);
} catch (Throwable e) {
t = e;
}
}
if (t != null)
throw new RuntimeException("Error closing resources", t);
}
}
public static void flush(Flushable flushable) {
if (flushable != null) {
try {
flushable.flush();
} catch (IOException e) {
LOGGER.error("Error flushing " + flushable, e);
}
}
}
public static String localFilename(String uri) {
String[] path = uri.split("/");
return path[path.length - 1];
}
public static boolean isURIAvailable(String uri) {
LOGGER.debug("isURIAvailable({})", uri);
InputStream stream = null;
try {
if (uri.startsWith("string:
return true;
if (uri.startsWith("http:
return httpUrlAvailable(uri);
if (uri.startsWith("file:") && !uri.startsWith("file:
stream = getFileOrResourceAsStream(uri.substring("file:".length()), false);
else {
if (!uri.contains(":
uri = "file://" + uri;
if (uri.startsWith("file:
stream = getFileOrResourceAsStream(uri.substring("file://".length()), false);
}
return stream != null;
} catch (FileNotFoundException e) {
return false;
} finally {
close(stream);
}
}
public static String getContentOfURI(String uri) throws IOException {
return getContentOfURI(uri, SystemInfo.getFileEncoding());
}
public static String getContentOfURI(String uri, String encoding) throws IOException {
Reader reader = getReaderForURI(uri, encoding);
StringWriter writer = new StringWriter();
transfer(reader, writer);
return writer.toString();
}
public static String[] readTextLines(String uri, boolean includeEmptyLines) throws IOException {
ArrayBuilder<String> builder = new ArrayBuilder<String>(String.class, 100);
BufferedReader reader = getReaderForURI(uri);
String line;
while ((line = reader.readLine()) != null)
if (line.length() > 0 || includeEmptyLines)
builder.add(line.trim());
return builder.toArray();
}
public static BufferedReader getReaderForURI(String uri) throws IOException {
return getReaderForURI(uri, SystemInfo.getFileEncoding());
}
public static BufferedReader getReaderForURI(String uri, String defaultEncoding) throws IOException {
if (uri.startsWith("string:
return new BufferedReader(new StringReader(uri.substring("string://".length())));
else if (uri.startsWith("http:
return getHttpReader(new URL(uri), defaultEncoding);
else
return getFileReader(uri, defaultEncoding);
}
public static InputStream getInputStreamForURI(String uri) throws IOException {
Assert.notNull(uri, "uri");
return getInputStreamForURI(uri, true);
}
/**
* Creates an InputStream from a url in String representation.
* @param uri the source url
* @return an InputStream that reads the url.
* @throws IOException if the url cannot be read.
*/
public static InputStream getInputStreamForURI(String uri, boolean required) throws IOException {
LOGGER.debug("getInputStreamForURI({}, {})", uri, required);
if (uri.startsWith("string:
String content = uri.substring("string://".length());
return new ByteArrayInputStream(content.getBytes(SystemInfo.getCharset()));
}
if (isFileUri(uri))
return getFileOrResourceAsStream(stripOffProtocolFromUri(uri), true);
else if (uri.startsWith("file:"))
return getFileOrResourceAsStream(uri.substring("file:".length()), true);
else if (uri.contains(":
return getInputStreamForURL(new URL(uri));
} else
return getFileOrResourceAsStream(uri, required);
}
public static String stripOffProtocolFromUri(String uri) {
int index = uri.indexOf(":
if (index >= 0)
return uri.substring(index + 3);
index = uri.indexOf(":");
if (index > 1 || (!SystemInfo.isWindows() && index > 0))
return uri.substring(index + 1);
return uri;
}
public static boolean isFileUri(String uri) {
return (uri.startsWith("file:") || !uri.contains(":
}
public static InputStream getInputStreamForURL(URL url) throws IOException {
try {
URLConnection connection = getConnection(url);
return connection.getInputStream();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
public static InputStream getInputStreamForUriReference(String localUri, String contextUri, boolean required) throws IOException {
LOGGER.debug("getInputStreamForUriReference({}, {})", localUri, contextUri);
// do not resolve context for absolute URLs or missing contexts
if (StringUtil.isEmpty(contextUri) || getProtocol(localUri) != null)
return getInputStreamForURI(localUri, required);
// now resolve the relative uri
String uri = resolveRelativeUri(localUri, contextUri);
if (localUri.startsWith("http:
return getInputStreamForURL(new URL(uri));
}
if (localUri.startsWith("file:") && !localUri.startsWith("file:
return getFileOrResourceAsStream(localUri.substring("file:".length()), true);
if (!localUri.contains(":
localUri = "file://" + localUri;
if (localUri.startsWith("file:
return getFileOrResourceAsStream(localUri.substring("file://".length()), true);
else
throw new ConfigurationError("Can't to handle URL " + localUri);
}
public static String resolveRelativeUri(String relativeUri, String contextUri) {
LOGGER.debug("resolveRelativeUri({}, {})", relativeUri, contextUri);
if (isAbsoluteRef(relativeUri, contextUri))
return relativeUri;
String contextProtocol = getProtocol(contextUri);
if (contextProtocol == null || contextProtocol.equals("file"))
return resolveRelativeFile(getPath(contextUri), getPath(relativeUri));
else
return resolveRelativeURL(contextUri, relativeUri);
}
public static boolean isAbsoluteRef(String uri, String contextUri) {
if (StringUtil.isEmpty(contextUri)) // if there is no context, the URI must be absolute
return true;
if (SystemInfo.isWindows()) { // recognize Winows drive letter formats like C:\
if (uri.length() >= 2 && Character.isLetter(uri.charAt(0)) && uri.charAt(1) == ':' && uri.charAt(1) == '\\')
return true;
}
String refProtocol = getProtocol(uri);
String ctxProtocol = getProtocol(contextUri);
if (ctxProtocol == null) // if no context protocol is given, assume 'file'
ctxProtocol = "file";
if (!ctxProtocol.equals(refProtocol) && refProtocol != null) // if the ref has a different protocol declared than the context, its absolute
return true;
// if the protocols are 'file' and the URI starts with '/' or '~' its an absolute file URI
return ("file".equals(ctxProtocol) && ((uri.startsWith("/") || uri.startsWith("~"))));
}
private static String resolveRelativeFile(String contextPath, String relativePath) {
if (relativePath.charAt(0) == '/' || relativePath.charAt(0) == File.separatorChar)
return relativePath;
else
return new File(contextPath, relativePath).getPath();
}
private static String resolveRelativeURL(String contextUri, String relativeUri) {
try {
URL contextUrl = new URL(contextUri);
URL absoluteUrl = new URL(contextUrl, relativeUri);
String result = absoluteUrl.toString();
return result;
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
public static String getParentUri(String uri) {
if (StringUtil.isEmpty(uri))
return null;
String protocol = getProtocol(uri);
if (protocol != null)
uri = uri.substring(protocol.length());
char systemSeparator = SystemInfo.getFileSeparator();
char uriSeparator = (uri.indexOf(systemSeparator) >= 0 ? systemSeparator : '/');
String parentUri = StringUtil.splitOnLastSeparator(uri, uriSeparator)[0];
if (parentUri == null)
parentUri = ".";
parentUri += uriSeparator;
if (protocol != null)
parentUri = protocol + parentUri;
return parentUri;
}
public static String getProtocol(String uri) {
if (uri == null)
return null;
int sep = uri.indexOf(":
if (sep > 0)
return uri.substring(0, sep);
return (uri.startsWith("file:") ? "file" : null);
}
private static String getPath(String uri) {
if (uri == null || ".".equals(uri))
return null;
int sep = uri.indexOf(":
if (sep > 0)
return uri.substring(sep + 3);
return (uri.startsWith("file:") ? uri.substring(5) : uri);
}
public static PrintWriter getPrinterForURI(String uri, String encoding)
throws FileNotFoundException, UnsupportedEncodingException {
return getPrinterForURI(uri, encoding, false, SystemInfo.getLineSeparator(), false);
}
public static PrintWriter getPrinterForURI(String uri, String encoding, boolean append,
final String lineSeparator, boolean autoCreateFolder)
throws FileNotFoundException, UnsupportedEncodingException {
File file = new File(uri);
if (autoCreateFolder)
FileUtil.ensureDirectoryExists(file.getParentFile());
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(uri, append), encoding)) {
@Override
public void println() {
print(lineSeparator);
}
};
}
public static int transfer(Reader reader, Writer writer) throws IOException {
int totalChars = 0;
char[] buffer = new char[16384];
int charsRead;
while ((charsRead = reader.read(buffer, 0, buffer.length)) > 0) {
writer.write(buffer, 0, charsRead);
totalChars += charsRead;
}
return totalChars;
}
public static int transfer(InputStream in, OutputStream out) throws IOException {
int totalChars = 0;
byte[] buffer = new byte[16384];
int charsRead;
while ((charsRead = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, charsRead);
totalChars += charsRead;
}
return totalChars;
}
public static void copyFile(String srcUri, String targetUri) throws IOException {
LOGGER.debug("copying " + srcUri + " --> " + targetUri);
InputStream in = null;
OutputStream out = null;
try {
in = getInputStreamForURI(srcUri);
out = openOutputStreamForURI(targetUri);
IOUtil.transfer(in, out);
} finally {
close(out);
close(in);
}
}
public static OutputStream openOutputStreamForURI(String uri) throws IOException {
if (uri.startsWith("file:")) {
uri = uri.substring(5);
if (uri.startsWith("
uri = uri.substring(2);
return new FileOutputStream(uri);
} else if (uri.contains(":
try {
URL url = new URL(uri);
URLConnection urlc = url.openConnection();
return urlc.getOutputStream();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
return new FileOutputStream(uri);
}
public static Map<String, String> readProperties(String filename) throws IOException {
return readProperties(filename, SystemInfo.getFileEncoding());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Map<String, String> readProperties(String filename, String encoding) throws IOException {
return readProperties(new OrderedMap(), filename, null, encoding);
}
@SuppressWarnings("rawtypes")
public static <V> Map<String, V> readProperties(
String filename, Converter<Map.Entry, Map.Entry> converter) throws IOException {
return readProperties(filename, converter, SystemInfo.getFileEncoding());
}
@SuppressWarnings("rawtypes")
public static <V> Map<String, V> readProperties(
String filename, Converter<Map.Entry, Map.Entry> converter, String encoding) throws IOException {
return readProperties(new OrderedMap<String, V>(), filename, converter, encoding);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private static <M extends Map> M readProperties(M target, String filename,
Converter<Map.Entry, Map.Entry> converter, String encoding) throws IOException {
Reader reader = null;
ReaderLineIterator iterator = null;
try {
reader = IOUtil.getReaderForURI(filename, encoding);
iterator = new ReaderLineIterator(reader);
String key = null;
String value = "";
while (iterator.hasNext()) {
String line = iterator.next();
line = line.trim();
if (line.startsWith("
continue;
boolean incomplete = (line.endsWith("\\") && line.charAt(line.length() - 2) != '\\');
if (incomplete)
line = line.substring(0, line.length() - 1);
line = StringUtil.unescape(line);
if (key != null) {
value += line;
} else {
String[] assignment = ParseUtil.parseAssignment(line, "=", false);
if (assignment != null && assignment[1] != null) {
key = assignment[0];
value = assignment[1];
} else
continue;
}
if (!incomplete) {
if (converter != null) {
Map.Entry entry = new MapEntry(key, value);
entry = converter.convert(entry);
target.put(entry.getKey(), entry.getValue());
} else
target.put(key, value);
key = null;
value = "";
}
}
} finally {
if (iterator != null)
iterator.close();
else
IOUtil.close(reader);
}
return target;
}
public static void writeProperties(Map<String, String> properties, String filename) throws IOException {
writeProperties(properties, filename, SystemInfo.getFileEncoding());
}
public static void writeProperties(Map<String, String> properties, String filename, String encoding) throws IOException {
PrintWriter stream = null;
try {
stream = IOUtil.getPrinterForURI(filename, encoding);
for (Map.Entry<String, String> entry : properties.entrySet())
stream.println(entry.getKey() + "=" + entry.getValue());
} finally {
IOUtil.close(stream);
}
}
/*
public static String readTextResource(String filename) throws FileNotFoundException, IOException {
InputStreamReader reader = new InputStreamReader(getFileOrResourceAsStream(filename));
String text = read(reader);
reader.close();
return text;
}
public static String readTextFile(File file) throws FileNotFoundException, IOException {
FileReader reader = new FileReader(file);
return read(reader);
}
*/
public static void writeTextFile(String filename, String content) throws IOException {
writeTextFile(filename, content, SystemInfo.getFileEncoding());
}
public static void writeTextFile(String filename, String content, String encoding) throws IOException {
if (encoding == null)
encoding = SystemInfo.getCharset().name();
Writer writer = null;
try {
writer = new OutputStreamWriter(openOutputStreamForURI(filename), encoding);
transfer(new StringReader(content), writer);
} finally {
close(writer);
}
}
/**
* Returns an InputStream that reads a file. The file is first searched on the disk directories
* then in the class path.
* @param filename the name of the file to be searched.
* @return an InputStream that accesses the file.
* @throws FileNotFoundException if the file cannot be found.
*/
private static InputStream getFileOrResourceAsStream(String filename, boolean required) throws FileNotFoundException {
LOGGER.debug("getFileOrResourceAsStream({}, {})", filename, required);
File file = new File(filename);
if (file.exists()) {
return new FileInputStream(filename);
} else
return getResourceAsStream(filename, required);
}
/**
* Returns an InputStream to a resource on the class path.
* @param name the file's name
* @return an InputStream to the resource
*/
private static InputStream getResourceAsStream(String name, boolean required) {
LOGGER.debug("getResourceAsStream({}, {})", name, required);
String searchedName = (name.startsWith("/") ? name : "/" + name);
InputStream stream = IOUtil.class.getResourceAsStream(searchedName);
if (required && stream == null)
throw new ConfigurationError("Resource not found: " + name);
return stream;
}
private static boolean httpUrlAvailable(String urlString) {
try {
URL url = new URL(urlString);
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
return true;
} catch (IOException e) {
return false;
}
}
private static URLConnection getConnection(URL url) throws IOException {
URLConnection connection = url.openConnection();
connection.setRequestProperty("User-Agent", USER_AGENT);
connection.connect();
return connection;
}
public static byte[] getBinaryContentOfUri(String uri) throws IOException {
InputStream in = getInputStreamForURI(uri);
ByteArrayOutputStream out = new ByteArrayOutputStream(25000);
transfer(in, out);
return out.toByteArray();
}
public static void writeBytes(byte[] bytes, File file) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
OutputStream out = new FileOutputStream(file);
try {
transfer(in, out);
} finally {
IOUtil.close(out);
IOUtil.close(in);
}
}
public static void copyDirectory(URL srcUrl, File targetDirectory, Filter<String> filenameFilter)
throws IOException {
LOGGER.debug("copyDirectory({}, {}, {})", new Object[] { srcUrl, targetDirectory, filenameFilter });
String protocol = srcUrl.getProtocol();
if (protocol.equals("file")) {
try {
FileUtil.copy(new File(srcUrl.toURI()), targetDirectory, true, new FileByNameFilter(filenameFilter));
} catch (URISyntaxException e) {
throw new RuntimeException("Unexpected exception", e);
}
} else if (protocol.equals("jar")) {
String path = srcUrl.getPath();
int separatorIndex = path.indexOf("!");
String jarPath = path.substring(5, separatorIndex); // extract jar file name
String relativePath = path.substring(separatorIndex + 2); // extract path inside jar file
if (!relativePath.endsWith("/"))
relativePath += "/";
extractFolderFromJar(jarPath, relativePath, targetDirectory, filenameFilter);
} else
throw new UnsupportedOperationException("Protocol not supported: "+ protocol +
" (URL: " + srcUrl + ")");
}
public static void extractFolderFromJar(String jarPath, String directory, File targetDirectory,
Filter<String> filenameFilter) throws IOException {
LOGGER.debug("extractFolderFromJar({}, {}, {}, {})", new Object[] { jarPath, directory, targetDirectory, filenameFilter});
JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String name = entry.getName();
if (name.startsWith(directory) && !directory.equals(name) && (filenameFilter == null || filenameFilter.accept(name))) {
String relativeName = name.substring(directory.length());
if (entry.isDirectory()) {
File subDir = new File(targetDirectory, relativeName);
LOGGER.debug("creating sub directory {}", subDir);
subDir.mkdir();
} else {
File targetFile = new File(targetDirectory, relativeName);
LOGGER.debug("copying file {} to {}", name, targetFile);
InputStream in = jar.getInputStream(entry);
OutputStream out = new FileOutputStream(targetFile);
transfer(in, out);
out.close();
in.close();
}
}
}
}
public static String[] listResources(URL url) throws IOException {
LOGGER.debug("listResources({})", url);
String protocol = url.getProtocol();
if (protocol.equals("file")) {
try {
String[] result = new File(url.toURI()).list();
if (result == null)
result = new String[0];
LOGGER.debug("found file resources: {}", result);
return result;
} catch (URISyntaxException e) {
throw new RuntimeException("Unexpected exception", e);
}
} else if (protocol.equals("jar")) {
String path = url.getPath();
int separatorIndex = path.indexOf("!");
String jarPath = path.substring(5, separatorIndex); // extract jar file name
String relativePath = path.substring(separatorIndex + 2); // extract path inside jar file
JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
Enumeration<JarEntry> entries = jar.entries();
Set<String> result = new HashSet<String>();
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(relativePath)) {
String entry = name.substring(relativePath.length());
int checkSubdir = entry.indexOf("/");
if (checkSubdir >= 0) // return only the top directory name of all sub directory entries
entry = entry.substring(0, checkSubdir);
result.add(entry);
}
}
LOGGER.debug("found jar resources: {}", result);
return result.toArray(new String[result.size()]);
} else
throw new UnsupportedOperationException("Protocol not supported: "+ protocol +
" (URL: " + url + ")");
}
public static void download(URL url, File targetFile) throws IOException {
LOGGER.info("downloading {}", url);
FileUtil.ensureDirectoryExists(targetFile.getParentFile());
InputStream in = getInputStreamForURL(url);
try {
OutputStream out = new FileOutputStream(targetFile);
try {
IOUtil.transfer(in, out);
} finally {
IOUtil.close(out);
}
} finally {
IOUtil.close(in);
}
}
public static ImageIcon readImageIcon(String resourceName) throws IOException {
InputStream in = getInputStreamForURI(resourceName);
if (in == null)
throw new FileNotFoundException("Resource not found: " + resourceName);
return new ImageIcon(ImageIO.read(in));
}
private static BufferedReader getFileReader(String filename, String defaultEncoding)
throws IOException, UnsupportedEncodingException {
if (defaultEncoding == null)
defaultEncoding = SystemInfo.getFileEncoding();
InputStream is = getInputStreamForURI(filename);
PushbackInputStream in = new PushbackInputStream(is, 4);
defaultEncoding = bomEncoding(in, defaultEncoding);
return new BufferedReader(new InputStreamReader(in, defaultEncoding));
}
private static BufferedReader getHttpReader(URL url, String defaultEncoding)
throws IOException, UnsupportedEncodingException {
try {
URLConnection connection = getConnection(url);
connection.connect();
String encoding = encoding(connection, defaultEncoding);
InputStream inputStream = connection.getInputStream();
return new BufferedReader(new InputStreamReader(inputStream, encoding));
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
static String encoding(URLConnection connection, String defaultEncoding) {
String encoding = connection.getContentEncoding();
if (StringUtil.isEmpty(encoding)) {
String ct = connection.getHeaderField("Content-Type");
if (!StringUtil.isEmpty(ct)) {
int i = ct.indexOf("charset");
if (i >= 0)
encoding = ct.substring(i + "charset".length() + 1).trim();
}
}
if (StringUtil.isEmpty(encoding))
encoding = defaultEncoding;
if (StringUtil.isEmpty(encoding))
encoding = SystemInfo.getFileEncoding();
return encoding;
}
private static String bomEncoding(PushbackInputStream in, String defaultEncoding) throws IOException {
int b1 = in.read();
if (b1 == -1)
return defaultEncoding;
if (b1 != 0xEF) {
in.unread(b1);
return defaultEncoding;
}
int b2 = in.read();
if (b2 == -1) {
in.unread(b1);
return defaultEncoding;
}
if (b2 != 0xBB) {
in.unread(b2);
in.unread(b1);
return defaultEncoding;
}
int b3 = in.read();
if (b3 == -1) {
in.unread(b2);
in.unread(b1);
return defaultEncoding;
}
if (b3 != 0xBF) {
in.unread(b3);
in.unread(b2);
in.unread(b1);
return defaultEncoding;
}
return Encodings.UTF_8;
}
}
|
package org.datacite.mds.util;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import javax.validation.ConstraintValidatorContext;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.apache.commons.validator.UrlValidator;
import org.apache.log4j.Logger;
import org.datacite.mds.domain.Allocator;
import org.datacite.mds.domain.Datacentre;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
/**
* Class with several static util methods
*/
public class Utils {
static Logger log = Logger.getLogger(Utils.class);
/**
* returns the prefix of a doi
*
* @param doi
* Doi (e.g. "10.5072/foobar")
* @return doi prefix (e.g. "10.5072")
*/
public static String getDoiPrefix(String doi) {
return doi.split("/")[0];
}
/**
* returns the suffix of a doi
*
* @param doi
* Doi (e.g. "10.5072/foobar")
* @return doi prefix (e.g. "foobar")
*/
public static String getDoiSuffix(String doi) {
return doi.split("/")[1];
}
/**
* converts a string with comma separated values to a List of Strings
*
* @param csv
* comma separated values
* @return List of Strings
*/
public static List<String> csvToList(String csv) {
if (csv == null) {
csv = "";
}
return Arrays.asList(csv.split(","));
}
/**
* Wrapper to simply validate a property of an object.
*
* @param object
* object to validate
* @param propertyName
* property to validate (e.g. field)
* @return true if property validates
* @see javax.validation.Validator.validateProperty
*/
public static boolean isValid(Object object, String propertyName) {
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
Validator validator = validatorFactory.getValidator();
Set violations = validator.validateProperty(object, propertyName);
return violations.isEmpty();
}
/**
* Check if a specific constraint annotation is violated
*
* @param object
* object to validate
* @param constraint
* constraint annotation to be checked
* @return true if the given constraint is not violated
*/
public static <T> boolean isConstraintValid(T object, Class<? extends Annotation> constraint) {
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
Validator validator = validatorFactory.getValidator();
Set<ConstraintViolation<T>> violations = validator.validate(object);
for (ConstraintViolation<T> violation : violations) {
if (violation.getConstraintDescriptor().getAnnotation().annotationType().equals(constraint)) {
return false;
}
}
return true;
}
public static void addConstraintViolation(ConstraintValidatorContext context, String message, String node) {
context.buildConstraintViolationWithTemplate(message).addNode(node).addConstraintViolation();
}
public static void addConstraintViolation(ConstraintValidatorContext context, String message) {
context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
}
public static boolean isHostname(String str) {
try {
URL url = new URL("http://" + str);
if (!url.getHost().equals(str)) {
// domain should only consists of the pure host name
return false;
}
UrlValidator urlValidator = new UrlValidator();
if (!urlValidator.isValid(url.toString())) {
// url should be valid, e.g. "test.t" or "com" should be fail
return false;
}
} catch (MalformedURLException ex) {
// url should be well formed
return false;
}
return true;
}
public static String getHostname(String urlStr) {
URL url;
try {
url = new URL(urlStr);
String hostname = url.getHost();
return hostname;
} catch (MalformedURLException e) {
return null;
}
}
public static Object getCurrentUser() {
log.debug("get current auth");
Authentication currentAuth = SecurityContextHolder.getContext().getAuthentication();
String symbol = currentAuth.getName();
log.debug("search for '" + symbol + "'");
try {
Allocator al = Allocator.findAllocatorsBySymbolEquals(symbol).getSingleResult();
log.debug("found allocator '" + symbol + "'");
return al;
} catch (Exception e) {
}
try {
Datacentre dc = Datacentre.findDatacentresBySymbolEquals(symbol).getSingleResult();
log.debug("found datacentre '" + symbol + "'");
return dc;
} catch (Exception e) {
}
log.debug("no allocator or datacentre found");
return null;
}
public static String formatXML(String xml) throws Exception {
Document doc = DocumentHelper.parseText(xml);
StringWriter sw = new StringWriter();
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter xw = new XMLWriter(sw, format);
xw.write(doc);
String result = sw.toString();
return result;
}
}
|
package org.gitlab4j.api.models;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Job {
private Integer id;
private Commit commit;
private String coverage;
private Date createdAt;
private Date finishedAt;
private String name;
private Pipeline pipeline;
private String ref;
private Runner runner;
private User user;
private Date startedAt;
private ArtifactsFile artifactsFile;
private Boolean tag;
private String stage;
private JobStatus status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Commit getCommit() {
return commit;
}
public void setCommit(Commit commit) {
this.commit = commit;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getFinishedAt() {
return finishedAt;
}
public void setFinishedAt(Date finishedAt) {
this.finishedAt = finishedAt;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Pipeline getPipeline() {
return pipeline;
}
public void setPipeline(Pipeline pipeline) {
this.pipeline = pipeline;
}
public String getRef() {
return ref;
}
public void setRef(String ref) {
this.ref = ref;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Date getStartedAt() {
return startedAt;
}
public void setStartedAt(Date startedAt) {
this.startedAt = startedAt;
}
public Boolean getTag() {
return tag;
}
public void setTag(Boolean tag) {
this.tag = tag;
}
public String getStage() {
return stage;
}
public void setStage(String stage) {
this.stage = stage;
}
public JobStatus getStatus() {
return status;
}
public void setStatus(JobStatus status) {
this.status = status;
}
public String getCoverage() {
return coverage;
}
public void setCoverage(String coverage) {
this.coverage = coverage;
}
public ArtifactsFile getArtifactsFile() {
return artifactsFile;
}
public void setArtifactsFile(ArtifactsFile artifactsFile) {
this.artifactsFile = artifactsFile;
}
public Runner getRunner() {
return runner;
}
public void setRunner(Runner runner) {
this.runner = runner;
}
}
|
package org.jtrfp.trcl.core;
import java.awt.Color;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Future;
import javax.imageio.ImageIO;
import javax.media.opengl.GL3;
import org.jtrfp.trcl.OutOfTextureSpaceException;
import org.jtrfp.trcl.gpu.GLTexture;
import org.jtrfp.trcl.gpu.GPU;
import org.jtrfp.trcl.img.vq.ByteBufferVectorList;
import org.jtrfp.trcl.img.vq.RGBA8888VectorList;
import org.jtrfp.trcl.img.vq.RasterizedBlockVectorList;
public class Texture implements TextureDescription {
TextureTreeNode nodeForThisTexture;
private final TR tr;
private Color averageColor;
private static double pixelSize = .7 / 4096.; // TODO: This is a kludge;
// doesn't scale with
// texture palette
private static TextureTreeNode rootNode = null;
private static GLTexture globalTexture;
public static final List<Future<TextureDescription>> texturesToBeAccounted = Collections
.synchronizedList(new LinkedList<Future<TextureDescription>>());
private ByteBuffer rgba;
private static void waitUntilTextureProcessingEnds() {
while (!texturesToBeAccounted.isEmpty()) {
try {
texturesToBeAccounted.remove(0).get();
} catch (Exception e) {
e.printStackTrace();
}
}
}// end waitUntilTextureProcessingEnds()
private static ByteBuffer emptyRow = null;
private Texture(Texture parent, double uOff, double vOff, double uSize,
double vSize, TR tr) {
nodeForThisTexture = new UVTranslatingTextureTreeNode(
parent.getNodeForThisTexture(), uOff, vOff, uSize, vSize);
this.tr=tr;
}
public Texture subTexture(double uOff, double vOff, double uSize,
double vSize){
return new Texture(this,uOff,vOff,uSize,vSize,tr);
}
Texture(ByteBuffer imageRGBA8888, String debugName, TR tr) {
if (tr.getTrConfig().isUsingNewTexturing()) {// Temporary; conform size
// to 64x64
final double sideLength = Math.sqrt((imageRGBA8888.capacity() / 4));
imageRGBA8888.clear();
// TEMPORARY TESTING CODE
ByteBuffer nImageRGBA8888 = ByteBuffer.allocate(64 * 64 * 4);
for (int p = 0; p < 64 * 64; p++) {// Slow but temporary
final double u = (p % 64) / 64.;
final double v = (p / 64.) / 64.;
final int sx = (int) (u * sideLength);
final int sy = (int) (v * sideLength);
final int dx = (int) (u * 64.);
final int dy = (int) (v * 64.);
final int sourceIndex = ((int) (Math.floor(sx) + Math.floor(sy
* sideLength)) * 4 + 0);
nImageRGBA8888.put((int) ((dx + dy * 64) * 4 + 0),
imageRGBA8888.get(sourceIndex + 0));
nImageRGBA8888.put((int) ((dx + dy * 64) * 4 + 1),
imageRGBA8888.get(sourceIndex + 1));
nImageRGBA8888.put((int) ((dx + dy * 64) * 4 + 2),
imageRGBA8888.get(sourceIndex + 2));
nImageRGBA8888.put((int) ((dx + dy * 64) * 4 + 3),
imageRGBA8888.get(sourceIndex + 3));
}// end for(p)
imageRGBA8888 = nImageRGBA8888;
final GPU gpu = tr.getGPU();
final TextureManager tm = gpu.getTextureManager();
final VQCodebookManager cbm = tm.getCodebookManager();
final TextureTOCWindow tw = tm.getTOCWindow();
// Break down into 4x4 blocks
ByteBufferVectorList bbvl = new ByteBufferVectorList(imageRGBA8888);
RGBA8888VectorList rgba8888vl = new RGBA8888VectorList(bbvl);
RasterizedBlockVectorList rbvl = new RasterizedBlockVectorList(
rgba8888vl, 64, 4);
// Get a codebook256
final int codebook256Index = tm.getCodebookManager()
.newCodebook256();
final int codebookStartOffset = codebook256Index * 256;
// Get a TOC
final int tocIndex = tw.create();
final ByteBuffer vectorBuffer = ByteBuffer
.allocateDirect(4 * 4 * 4);
tw.startTile.set(tocIndex, codebookStartOffset);
tw.height.set(tocIndex, 64);
tw.width.set(tocIndex, 64);
// Push vectors to codebook
for (int codeIndex = 0; codeIndex < 256; codeIndex++) {
vectorBuffer.clear();
for (int vi = 0; vi < 4 * 4 * 4; vi++) {
vectorBuffer
.put((byte) (rbvl.componentAt(codeIndex, vi) * 255));
}
final int globalCodeIndex = codeIndex + codebookStartOffset;
vectorBuffer.clear();
cbm.setRGBA(globalCodeIndex, vectorBuffer);
tw.subtexturePageIndices.setAt(tocIndex, codeIndex,
globalCodeIndex);
}// end for(codeIndex)
}// end if(newTexturing)
if (imageRGBA8888.capacity() == 0) {
throw new IllegalArgumentException(
"Cannot create texture of zero size.");
}
final int sideLength = (int) Math.sqrt((imageRGBA8888.capacity() / 4));
TextureTreeNode newNode = new TextureTreeNode(sideLength, null,
debugName);
nodeForThisTexture = newNode;
newNode.setImage(imageRGBA8888);
registerNode(newNode);
this.tr=tr;
}// end constructor
Texture(BufferedImage img, String debugName, TR tr) {
if(tr.getTrConfig().isUsingNewTexturing()){//Temporary; conform size to 64x64
final double sx=64./img.getWidth();
final double sy=64./img.getHeight();
BufferedImage nImg = new BufferedImage(64,64,BufferedImage.TYPE_INT_ARGB);
AffineTransform at = new AffineTransform();
at.scale(sx, sy);
AffineTransformOp scaleOp =
new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
img = scaleOp.filter(img, nImg);
}
final int sideLength = img.getWidth();
TextureTreeNode newNode = new TextureTreeNode(sideLength, null,
debugName);
nodeForThisTexture = newNode;
// TODO Add true alpha support and optimize like the one below
long redA = 0, greenA = 0, blueA = 0;
rgba = ByteBuffer.allocateDirect(img.getWidth() * img.getHeight()
* 4);
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
Color c = new Color(img.getRGB(x, y), true);
rgba.put((byte) c.getRed());
rgba.put((byte) c.getGreen());
rgba.put((byte) c.getBlue());
rgba.put((byte) c.getAlpha());
redA += c.getRed();
greenA += c.getGreen();
blueA += c.getBlue();
}// end for(x)
}// end for(y)
final int div = rgba.capacity() / 4;
averageColor = new Color((redA / div) / 255f,
(greenA / div) / 255f, (blueA / div) / 255f);
newNode.setImage(rgba);
registerNode(newNode);
this.tr=tr;
}//end constructor
public static ByteBuffer RGBA8FromPNG(File f) {
try {
return RGBA8FromPNG(new FileInputStream(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
}
public static ByteBuffer RGBA8FromPNG(InputStream is) {
try {
BufferedImage bi = ImageIO.read(is);
return RGBA8FromPNG(bi, 0, 0, bi.getWidth(), bi.getHeight());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static ByteBuffer RGBA8FromPNG(BufferedImage image, int startX,
int startY, int sizeX, int sizeY) {
int color;
ByteBuffer buf = ByteBuffer.allocateDirect(image.getWidth()
* image.getHeight() * 4);
for (int y = startY; y < startY + sizeY; y++) {
for (int x = startX; x < startX + sizeX; x++) {
color = image.getRGB(x, y);
buf.put((byte) ((color & 0x00FF0000) >> 16));
buf.put((byte) ((color & 0x0000FF00) >> 8));
buf.put((byte) (color & 0x000000FF));
buf.put((byte) ((color & 0xFF000000) >> 24));
}// end for(x)
}// end for(y)
buf.clear();// Rewind
return buf;
}// end RGB8FromPNG(...)
static double getPixelSize() {
return pixelSize;
}
public static GLTexture getGlobalTexture() {
return globalTexture;
}
private static synchronized void registerNode(TextureTreeNode newNode) {
if (rootNode == null) {
// System.out.println("Creating initial rootNode with sideLength of "+newNode.getSideLength()*2);
rootNode = new TextureTreeNode(newNode.getSideLength() * 2, null,
"Root or former root as branch");// Assuming square
rootNode.setSizeU(1);
rootNode.setSizeV(1);
// System.out.println("Adding first subnode to this new root..");
rootNode.addNode(newNode);
} else {
if (newNode.getSideLength() >= rootNode.getSideLength())// Too big
// to fit
{// New, bigger root
// System.out.println("NewNode>=rootNode sideLen");
TextureTreeNode oldRoot = rootNode;
rootNode = new TextureTreeNode(newNode.getSideLength() * 2,
null, "Root or former root as branch");
rootNode.addNode(newNode);
// Try again recursively until we fit the old root into the new
// root
registerNode(oldRoot);
} else {// Small enough to fit but might be out of space
try {
// System.out.println("registerNode() small enough to fit but may be out of space...");
rootNode.addNode(newNode);
} catch (OutOfTextureSpaceException e) {// New, bigger root
TextureTreeNode oldRoot = rootNode;
// System.out.println("This resize is upon receiving texture #"+textureCount);
rootNode = new TextureTreeNode(oldRoot.getSideLength() * 2,
null, "Root or former root as branch");
// System.out.println("Adding oldRoot to new rootNode...");
rootNode.addNode(oldRoot);
// Try again recursively until we fit the new node into the
// tree
// System.out.println("Re-attempting to add newNode to new Root");
registerNode(newNode);
}
}// end else(small enough to fit)
}// end else{rootNode!=null}
// System.out.println("...done registering.\n");
}// end registerNode(...)
/*
public static Future<TextureDescription> getFallbackTexture() {
return fallbackTexture;
}*/
// public static int getGlobalTextureID(){return globalTexID;}
public Color getAverageColor() {
if (averageColor == null) {// Compute a new one
double sRed = 0, sGreen = 0, sBlue = 0;
final int sLen = nodeForThisTexture.getSideLength();
final ByteBuffer img = nodeForThisTexture.getImage();
img.clear();// Doesn't erase it. Clears the marks, limits,
// positions.
for (int i = 0; i < sLen; i++) {
sRed += (int) img.get() & 0xFF;
sGreen += (int) img.get() & 0xFF;
sBlue += (int) img.get() & 0xFF;
}
sRed /= sLen;
sGreen /= sLen;
sBlue /= sLen;
averageColor = new Color((int) sRed, (int) sGreen, (int) sBlue);
}
return averageColor;
}// end getAverageColor()
public static void finalize(GPU gpu) {
final int gSideLen = rootNode.getSideLength();
// Setup the empty rows
emptyRow = ByteBuffer.allocate(gSideLen * 4);
for (int i = 0; i < gSideLen; i++) {
emptyRow.put((byte) (Math.random() * 256));
}
emptyRow.rewind();
System.out.println("Finalizing global U/V coordinates...");
waitUntilTextureProcessingEnds();
rootNode.finalizeUV(0, 0, 1, 1);
System.out.println("\t...Done.");
System.out.println("Allocating " + gSideLen + "x" + gSideLen
+ " shared texture in client RAM...");
ByteBuffer buf = ByteBuffer.allocateDirect(gSideLen * gSideLen * 4);
System.out.println("\t...Done.");
System.out.println("Assembling the texture palette...");
// Fill the buffer, raster row by raster row
buf.rewind();
for (int row = 0; row < gSideLen * gSideLen * 4; row++) {
buf.put((byte) (Math.random() * 255.));
}
buf.rewind();
for (int row = gSideLen - 1; row >= 0; row
rootNode.dumpRowToBuffer(buf, row);
}
System.out.println("\t...Done.");
buf.rewind();
System.out
.println("Creating a new OpenGL texture for texture palette...");
GLTexture tex = gpu.newTexture();
tex.setTextureImageRGBA(buf);
globalTexture = tex;
}// end finalize()
public static final int createTextureID(GL3 gl) {
IntBuffer ib = IntBuffer.allocate(1);
gl.glGenTextures(1, ib);
ib.clear();
return ib.get();
}
public static final Color[] GREYSCALE;
static {
GREYSCALE = new Color[256];
for (int i = 0; i < 256; i++) {
GREYSCALE[i] = new Color(i, i, i);
}
}// end static{}
static class UVTranslatingTextureTreeNode extends TextureTreeNode {
private final TextureTreeNode pNode;
private final double uOffset, vOffset, uSize, vSize;
public UVTranslatingTextureTreeNode(TextureTreeNode parent,
double uOffset, double vOffset, double uSize, double vSize) {
super(parent.sideLength, parent.parent, parent.debugName);
pNode = parent;
this.uOffset = uOffset;
this.vOffset = vOffset;
this.uSize = uSize;
this.vSize = vSize;
}
@Override
public double getGlobalUFromLocal(double u) {
return pNode.getGlobalUFromLocal(u * uSize + uOffset);
}
@Override
public double getGlobalVFromLocal(double v) {
return pNode.getGlobalVFromLocal(v * vSize + vOffset);
}
}
public static class TextureTreeNode {
private TextureTreeNode parent;
private double offsetU, offsetV;// In OpenGL orientation: (0,0) is
// bottom left.
private double sizeU, sizeV;
private TextureTreeNode topLeft, topRight, bottomLeft, bottomRight;
private ByteBuffer image;
private int sideLength;
private String debugName = "[unset]";
public TextureTreeNode(int sideLength, TextureTreeNode parent,
String debugName) {
this.sideLength = sideLength;
this.parent = parent;
this.debugName = debugName;
}
public boolean isFull() {
if (image != null)
return true;
if (topLeft != null && topRight != null && bottomLeft != null
&& bottomRight != null) {
return topLeft.isFull() && topRight.isFull()
&& bottomLeft.isFull() && bottomRight.isFull();
}
return false;
}// end isFull()
public void finalizeUV(double offU, double offV, double sU, double sV) {
this.setOffsetU(offU + Texture.getPixelSize());
this.setOffsetV(offV + Texture.getPixelSize());
this.setSizeU(sU - Texture.getPixelSize() * 2.);
this.setSizeV(sV - Texture.getPixelSize() * 2.);
if (topLeft != null) {
topLeft.finalizeUV(offU, offV + sV / 2., sU / 2., sV / 2.);
}
if (topRight != null) {
topRight.finalizeUV(offU + sU / 2., offV + sV / 2., sU / 2.,
sV / 2.);
}
if (bottomLeft != null) {
bottomLeft.finalizeUV(offU, offV, sU / 2., sV / 2.);
}
if (bottomRight != null) {
bottomRight.finalizeUV(offU + sU / 2., offV, sU / 2., sV / 2.);
}
}
public void dumpRowToBuffer(ByteBuffer buf, int row) {// Rows start at
// top, not
// OpenGL-bottom.
if (this.getSizeU() <= 0) {
System.out.println("Usize is " + this.getSizeU() + " name is "
+ debugName);
System.exit(1);
}
if (this.getSizeV() <= 0) {
System.out.println("Vsize is " + this.getSizeV());
System.exit(1);
}
if (image == null) {
if (row >= getSideLength() / 2) {
// Bottom two
if (bottomLeft != null)
bottomLeft.dumpRowToBuffer(buf, row - getSideLength()
/ 2);
else {
emptyRow.clear();
emptyRow.limit(4 * getSideLength() / 2);
buf.put(emptyRow);
}
if (bottomRight != null)
bottomRight.dumpRowToBuffer(buf, row - getSideLength()
/ 2);
else {
emptyRow.clear();
emptyRow.limit(4 * getSideLength() / 2);
buf.put(emptyRow);
}
} else {
// Top two
if (topLeft != null)
topLeft.dumpRowToBuffer(buf, row);
else {
emptyRow.clear();
emptyRow.limit(4 * getSideLength() / 2);
buf.put(emptyRow);
}
if (topRight != null)
topRight.dumpRowToBuffer(buf, row);
else {
emptyRow.clear();
emptyRow.limit(4 * getSideLength() / 2);
buf.put(emptyRow);
}
}
}// end image==null
else {
image.clear();
image.limit((row * getSideLength() * 4) + (getSideLength() * 4));
image.position(row * getSideLength() * 4);
buf.put(image);
}// end image!=null
}// end dumpRowToBuffer()
public boolean isLeaf() {
return image != null;
}
public void addNode(TextureTreeNode newNode) {
if (isFull())
throw new OutOfTextureSpaceException();
final int sideLength = newNode.getSideLength();
// System.out.println("addNode, newNode.sideLength="+newNode.getSideLength()+" to thisNode.sideLength="+this.getSideLength());
// System.out.println("\t");
// System.out.println("Attempting to match to empty leaf...");
if (sideLength == this.sideLength / 2)// Perfectly matches
// branches/leaves
{
if (topLeft == null) {
// TextureTreeNode newNode =new
// TextureTreeNode(sideLength,this);
newNode.setParent(this);
// newNode.setColorGrid(colorGrid);
// Set offsets
// System.out.println("added to TopLeft");
topLeft = newNode;
return;
} else if (topRight == null) {
// TextureTreeNode newNode =new
// TextureTreeNode(sideLength,this);
newNode.setParent(this);
// newNode.setColorGrid(colorGrid);
// Set offsets
// System.out.println("added to TopRight");
topRight = newNode;
return;
} else if (bottomLeft == null) {
// TextureTreeNode newNode =new
// TextureTreeNode(sideLength,this);
newNode.setParent(this);
bottomLeft = newNode;
// System.out.println("added to BottomLeft");
return;
} else if (bottomRight == null) {
// TextureTreeNode newNode =new
// TextureTreeNode(sideLength,this);
newNode.setParent(this);
bottomRight = newNode;
// System.out.println("added to BottomRight");
return;
}
// System.out.println("None of the corners is null. Means that there are branches but no single fragment big enough. Throwing OutOfSpace exception...");
throw new OutOfTextureSpaceException();
}// end if(sideLength==this.sideLength/2)
else if (sideLength <= this.sideLength / 2)// Smaller than
// branches/leaves
{// Find a non-leaf, if none, try to create a leaf. If none can be
// created, throw exception
// System.out.println("Attempt to match to empty leaf failed.");
// System.out.println("Trying to find an existing branch which can accept this texture...");
// Find non-leaf and try to push it there.
if (topLeft != null && !topLeft.isLeaf()) {
try {
topLeft.addNode(newNode);
// System.out.println("pushed to TopLeft");
return;
} catch (OutOfTextureSpaceException e) {
}
}// end if(topLeft)
if (topRight != null && !topRight.isLeaf()) {
try {
topRight.addNode(newNode);
// System.out.println("pushed to TopRight");
return;
} catch (OutOfTextureSpaceException e) {
}
}// end if(topRight)
if (bottomLeft != null && !bottomLeft.isLeaf()) {
try {
bottomLeft.addNode(newNode);
// System.out.println("pushed to BottomLeft");
return;
} catch (OutOfTextureSpaceException e) {
}
}// end if(bottomLeft)
if (bottomRight != null && !bottomRight.isLeaf()) {
try {
bottomRight.addNode(newNode);
// System.out.println("pushed to BottomRight");
return;
} catch (OutOfTextureSpaceException e) {
}
}// end if(bottomRight)
// No leaf found. Try to create one
// System.out.println("Attempt to find an existing branch which can accept this as a leaf has failed.");
// System.out.println("Attempting to create a child branch which is larger than this node which can contain the newNode.");
try {
if (topLeft == null) {
topLeft = new TextureTreeNode(this.sideLength / 2,
this, "Branch");
topLeft.addNode(newNode);
// System.out.println("pushed to new TopLeft");
return;
}
if (topRight == null) {
topRight = new TextureTreeNode(this.sideLength / 2,
this, "Branch");
topRight.addNode(newNode);
// System.out.println("pushed to new TopRight");
return;
}
if (bottomLeft == null) {
bottomLeft = new TextureTreeNode(this.sideLength / 2,
this, "Branch");
bottomLeft.addNode(newNode);
// System.out.println("pushed to new BottomLeft");
return;
}
if (bottomRight == null) {
bottomRight = new TextureTreeNode(this.sideLength / 2,
this, "Branch");
bottomRight.addNode(newNode);
// System.out.println("pushed to new BottomRight");
return;
}
}// end try{}
catch (OutOfTextureSpaceException e) {
e.printStackTrace();
System.out.println("ASSERT: Impossible situation!");
}
// Could not create leaf. Throw exception
throw new OutOfTextureSpaceException();
}// end else if(sideLength<=this.sideLength/2)
else if (sideLength > this.sideLength / 2)// Bigger than these
// leaves
{
throw new RuntimeException(
"Added Node's sideLength is bigger than half this Node's sideLength. Can't integrate. Proposed sideLength="
+ sideLength
+ " this.sideLength="
+ this.sideLength);
}
}// end addTexture(...)
public double getGlobalUFromLocal(double localU) {
double sizeOfPixel = .5 * this.getSizeU()
/ (double) this.getSideLength();
double borderingScalar = (double) this.getSideLength()
/ ((double) this.getSideLength() + 1.);
return this.getOffsetU() + sizeOfPixel + localU * this.getSizeU()
* borderingScalar;
}
public double getGlobalVFromLocal(double localV) {
double sizeOfPixel = .5 * this.getSizeU()
/ (double) this.getSideLength();
double borderingScalar = (double) this.getSideLength()
/ ((double) this.getSideLength() + 1.);
return this.getOffsetV() + sizeOfPixel + localV * this.getSizeV()
* borderingScalar;
}
/*
* public double getGlobalUFromLocal(double localU) {return localU;}
* public double getGlobalVFromLocal(double localV) {return localV;}
*/
/**
* @return the offsetU
*/
public double getOffsetU() {
return offsetU;
}
/**
* @param offsetU
* the offsetU to set
*/
public void setOffsetU(double offsetU) {
this.offsetU = offsetU;
}
/**
* @return the offsetV
*/
public double getOffsetV() {
return offsetV;
}
/**
* @param offsetV
* the offsetV to set
*/
public void setOffsetV(double offsetV) {
this.offsetV = offsetV;
}
/**
* @return the topLeft
*/
public TextureTreeNode getTopLeft() {
return topLeft;
}
/**
* @param topLeft
* the topLeft to set
*/
public void setTopLeft(TextureTreeNode topLeft) {
this.topLeft = topLeft;
}
/**
* @return the topRight
*/
public TextureTreeNode getTopRight() {
return topRight;
}
/**
* @param topRight
* the topRight to set
*/
public void setTopRight(TextureTreeNode topRight) {
this.topRight = topRight;
}
/**
* @return the bottomLeft
*/
public TextureTreeNode getBottomLeft() {
return bottomLeft;
}
/**
* @param bottomLeft
* the bottomLeft to set
*/
public void setBottomLeft(TextureTreeNode bottomLeft) {
this.bottomLeft = bottomLeft;
}
/**
* @return the bottomRight
*/
public TextureTreeNode getBottomRight() {
return bottomRight;
}
/**
* @param bottomRight
* the bottomRight to set
*/
public void setBottomRight(TextureTreeNode bottomRight) {
this.bottomRight = bottomRight;
}
/**
* @return the sideLength
*/
public int getSideLength() {
return sideLength;
}
/**
* @param sideLength
* the sideLength to set
*/
public void setSideLength(int sideLength) {
this.sideLength = sideLength;
}
/**
* @return the parent
*/
public TextureTreeNode getParent() {
return parent;
}
/**
* @param parent
* the parent to set
*/
public void setParent(TextureTreeNode parent) {
this.parent = parent;
}
/**
* @return the sizeU
*/
public double getSizeU() {
return sizeU;
}
/**
* @param sizeU
* the sizeU to set
*/
public void setSizeU(double sizeU) {
this.sizeU = sizeU;
}
/**
* @return the sizeV
*/
public double getSizeV() {
return sizeV;
}
/**
* @param sizeV
* the sizeV to set
*/
public void setSizeV(double sizeV) {
this.sizeV = sizeV;
}
/**
* @return the image
*/
public ByteBuffer getImage() {
return image;
}
/**
* @param image
* the image to set
*/
public void setImage(ByteBuffer image) {
this.image = image;
}
}// end TextureTreeNode
/**
* @return the nodeForThisTexture
*/
public TextureTreeNode getNodeForThisTexture() {
return nodeForThisTexture;
}
/**
* @param nodeForThisTexture
* the nodeForThisTexture to set
*/
public void setNodeForThisTexture(TextureTreeNode nodeForThisTexture) {
this.nodeForThisTexture = nodeForThisTexture;
}
/*
public static Future<TextureDescription> solidColor(Color color, TR tr) {//TODO: move to TextureManager.
BufferedImage img = new BufferedImage(64, 64,
BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
g.setColor(color);
g.fillRect(0, 0, 64, 64);
g.dispose();
final DummyFuture<TextureDescription> result = new DummyFuture<TextureDescription>(new Texture(img,
"Solid color " + color,tr));////////STACK TRACE LOSS OCCURS HERE
return result;
}
*/
/**
* @return the rgba
*/
public ByteBuffer getRgba() {
return rgba;
}
public static ByteBuffer fragmentRGBA(ByteBuffer input, int quadDepth,
int x, int y) {
final int originalSideLen = (int) Math.sqrt(input.capacity() / 4);
final int splitAmount = (int) Math.pow(2, quadDepth);
final int newSideLen = originalSideLen / splitAmount;
ByteBuffer result = ByteBuffer.allocateDirect((int) (Math.pow(
newSideLen, 2) * 4));
for (int row = y * newSideLen; row < (y + 1) * newSideLen; row++) {
input.clear();
input.limit((x + 1) * newSideLen * 4 + row * originalSideLen * 4);
input.position(x * newSideLen * 4 + row * originalSideLen * 4);
result.put(input);
}
return result;
}// end fragmentRGBA(...)
public static ByteBuffer indexed2RGBA8888(ByteBuffer indexedPixels,
Color[] palette) {
Color color;
ByteBuffer buf = ByteBuffer.allocate(indexedPixels.capacity() * 4);
final int cap = indexedPixels.capacity();
for (int i = 0; i < cap; i++) {
color = palette[(indexedPixels.get() & 0xFF)];
buf.put((byte) color.getRed());
buf.put((byte) color.getGreen());
buf.put((byte) color.getBlue());
buf.put((byte) color.getAlpha());
}// end for(i)
buf.clear();// Rewind
return buf;
}
public static ByteBuffer[] indexed2RGBA8888(ByteBuffer[] indexedPixels,
Color[] palette) {
final int len = indexedPixels.length;
ByteBuffer[] result = new ByteBuffer[len];
for (int i = 0; i < len; i++) {
result[i] = indexed2RGBA8888(indexedPixels[i], palette);
}
return result;
}
}// end Texture
|
package org.openbmp.handler;
public class Headers {
private String version;
private String collector_hash_id;
private long length;
private long records;
private String router_hash_id;
/**
* Handle the headers by parsing it and storing the data in memory.
*
* @param data
*/
public Headers(String data) {
parse(data);
}
/**
* Setting the headers' values
*
* @param data
*/
private void parse(String data) {
String headers[] = data.split("\n");
for(String header : headers){
String value = header.split(":")[1].trim();
switch(header.split(":")[0].trim()){
case "V":{
this.version = value;
break;
}
case "C_HASH_ID":{
this.collector_hash_id = value;
break;
}
case "L":{
this.length = Long.valueOf(value);
break;
}
case "R":{
this.records = Long.valueOf(value);
break;
}
case "R_HASH_ID":{
this.router_hash_id = value;
break;
}
}
}
}
public String getVersion() {
return version;
}
public String getCollector_hash_id() {
return collector_hash_id;
}
public long getLength() {
return length;
}
public long getRecords() {
return records;
}
public String getRouter_hash_id() {
return router_hash_id;
}
}
|
package org.realrest.domain;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
/**
* @author volodymyr.tsukur
*/
@Getter
@Setter
public final class Booking extends Identifiable {
private User user;
private Room room;
private LocalDate from;
private LocalDate to;
private boolean includeBreakfast;
private State state;
/**
* @author volodymyr.tsukur
*/
public enum State {
PENDING,
CONFIRMED,
CANCELLED,
SERVED,
REJECTED
}
}
|
package org.rythmengine;
import org.mvel2.MVEL;
import org.mvel2.integration.PropertyHandler;
import org.mvel2.integration.PropertyHandlerFactory;
import org.mvel2.integration.VariableResolverFactory;
import org.rythmengine.conf.RythmConfiguration;
import org.rythmengine.conf.RythmConfigurationKey;
import org.rythmengine.exception.RythmException;
import org.rythmengine.exception.TagLoadException;
import org.rythmengine.extension.*;
import org.rythmengine.internal.*;
import org.rythmengine.internal.compiler.*;
import org.rythmengine.internal.dialect.AutoToString;
import org.rythmengine.internal.dialect.BasicRythm;
import org.rythmengine.internal.dialect.DialectManager;
import org.rythmengine.internal.dialect.ToString;
import org.rythmengine.logger.ILogger;
import org.rythmengine.logger.Logger;
import org.rythmengine.logger.NullLogger;
import org.rythmengine.resource.ITemplateResource;
import org.rythmengine.resource.StringTemplateResource;
import org.rythmengine.resource.TemplateResourceManager;
import org.rythmengine.resource.ToStringTemplateResource;
import org.rythmengine.sandbox.RythmSecurityManager;
import org.rythmengine.sandbox.SandboxExecutingService;
import org.rythmengine.sandbox.SandboxThreadFactory;
import org.rythmengine.template.*;
import org.rythmengine.toString.ToStringOption;
import org.rythmengine.toString.ToStringStyle;
import org.rythmengine.utils.F;
import org.rythmengine.utils.IO;
import org.rythmengine.utils.JSONWrapper;
import org.rythmengine.utils.S;
import java.io.*;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* <p>Not Thread Safe</p>
* <p/>
* <p>A Rythm Template Engine is the entry to the Rythm templating system. It provides a set of
* APIs to render template. Each JVM allows multiple <code>RythmEngine</code> instance, with each
* one represent a set of configurations.</p>
* <p/>
* <p>The {@link Rythm} facade contains a default <code>RythmEngine</code> instance to make it
* easy to use for most cases</p>
*/
public class RythmEngine implements IEventDispatcher {
private static final ILogger logger = Logger.get(RythmEngine.class);
/**
* Rythm Engine Version. Used along with
* {@link org.rythmengine.conf.RythmConfigurationKey#ENGINE_PLUGIN_VERSION plugin version} to
* check if the cached template bytecode need to be refreshed or not
* <p/>
*/
private static final String version;
static {
version = IO.readContentAsString(RythmEngine.class.getClassLoader().getResourceAsStream("rythm-engine-version"));
}
private static final InheritableThreadLocal<RythmEngine> _engine = new InheritableThreadLocal<RythmEngine>();
/**
* Set the engine instance to a {@link ThreadLocal} variable, thus it is easy to
* {@link #get() get} the current
* <code>RythmEngine</code> dominating the rendering process.
* <p/>
* <p><b>Note</b>, this method is NOT an API to be called by user application</p>
*
* @param engine
* @return {@code true} if engine instance set to the threadlocal, {@code false}
* if the threadlocal has set an instance already
*/
public static boolean set(RythmEngine engine) {
if (_engine.get() == null) {
_engine.set(engine);
return true;
} else {
return false;
}
}
/**
* Clear the engine threadlocal variable
*/
public static void clear() {
_engine.remove();
}
/**
* Get the current engine instance from a {@link ThreadLocal} variable which is
* {@link #set(RythmEngine) set} previously.
* <p/>
* <p><b>Note</b>, this method is NOT an API to be called by user application</p>
*
* @return the engine
*/
public static RythmEngine get() {
return _engine.get();
}
/**
* Check if the current rendering is dominated by a {@link Sandbox}
* <p/>
* <p><b>Note</b>, this method is NOT an API to be called by user application</p>
*
* @return true if the current thread is running in Sandbox mode
*/
public static boolean insideSandbox() {
return Sandbox.sandboxMode();
}
@Override
public String toString() {
return null == _conf ? "rythm-engine-uninitialized" : id();
}
private RythmConfiguration _conf = null;
/**
* Return {@link RythmConfiguration configuration} of the engine
* <p/>
* <p>Usually user application should not call this method</p>
*
* @return rythm configuration
*/
public RythmConfiguration conf() {
if (null == _conf) {
throw new IllegalStateException("Rythm engine not initialized");
}
return _conf;
}
/**
* Return Version string of the engine instance. The version string
* is composed by {@link #version Rythm version} and the
* configured {@link RythmConfigurationKey#ENGINE_PLUGIN_VERSION plugin version}. The version
* string will be used by Rythm to see if compiled bytecodes cached on disk should
* be refreshed in an new version or not.
* <p/>
* <p><code>Note</code>, this method is not generally used by user application</p>
*
* @return engine version along with plugin version
*/
public String version() {
return version + "-" + conf().pluginVersion();
}
private Rythm.Mode _mode = null;
/**
* Return the engine {@link Rythm.Mode mode}
*
* @return engine running mode
*/
public Rythm.Mode mode() {
if (null == _mode) {
_mode = conf().get(RythmConfigurationKey.ENGINE_MODE);
}
return _mode;
}
private String _id = null;
/**
* Return the instance {@link org.rythmengine.conf.RythmConfigurationKey#ENGINE_ID ID}
*
* @return the engine id
*/
public String id() {
if (null == _id) {
_id = conf().get(RythmConfigurationKey.ENGINE_ID);
}
return _id;
}
/**
* Alias of {@link #id()}
*
* @return the engine id
*/
public String getId() {
return id();
}
/**
* Is this engine the default {@link Rythm#engine} instance?
* <p/>
* <p><b>Note</b>, not to be used by user application</p>
*
* @return true if this is the default engine
*/
public boolean isSingleton() {
return Rythm.engine == this;
}
/**
* Is the engine running in {@link Rythm.Mode#prod product} mode?
*
* @return true if engine is running in prod mode
*/
public boolean isProdMode() {
return mode() == Rythm.Mode.prod;
}
/**
* Is the engine running in {@link Rythm.Mode#dev development} mode?
*
* @return true if engine is running is debug mode
*/
public boolean isDevMode() {
return mode() != Rythm.Mode.prod;
}
private TemplateResourceManager _resourceManager;
/**
* Get {@link TemplateResourceManager resource manager} of the engine
* <p/>
* <p><b>Note</b>, this method should not be used by user application</p>
*
* @return resource manager
*/
public TemplateResourceManager resourceManager() {
return _resourceManager;
}
private TemplateClassManager _classes;
/**
* Get {@link TemplateClassManager template class manager} of the engine
* <p/>
* <p><b>Note</b>, this method should not be used by user application</p>
*
* @return template class manager
*/
public TemplateClassManager classes() {
return _classes;
}
private TemplateClassLoader _classLoader = null;
/**
* Get {@link TemplateClassLoader class loader} of the engine
* <p/>
* <p><b>Note</b>, this method should not be used by user application</p>
*
* @return template class loader
*/
public TemplateClassLoader classLoader() {
return _classLoader;
}
private TemplateClassCache _classCache = null;
/**
* Get {@link TemplateClassCache class cache} of the engine
* <p/>
* <p><b>Note</b>, this method should not be used by user application</p>
*
* @return template class cache
*/
public TemplateClassCache classCache() {
return _classCache;
}
private ExtensionManager _extensionManager;
/**
* Return {@link ExtensionManager} of this engine
*
* @return extension manager
*/
public ExtensionManager extensionManager() {
return _extensionManager;
}
private final DialectManager _dialectManager = new DialectManager();
/**
* Not an API
*
* @return {@link DialectManager} instance
*/
public DialectManager dialectManager() {
return _dialectManager;
}
private ICacheService _cacheService = null;
/**
* Define the render time settings, which is intialized each time a renderXX method
* get called
*/
public class RenderSettings {
private RenderSettings(RythmConfiguration conf) {
this.conf = conf;
}
private final RythmConfiguration conf;
private final ThreadLocal<Locale> _locale = new ThreadLocal<Locale>() {
@Override
protected Locale initialValue() {
return conf.locale();
}
};
private final ThreadLocal<ICodeType> _codeType = new ThreadLocal<ICodeType>();
private final ThreadLocal<Map<String, Object>> _usrCtx = new ThreadLocal<Map<String, Object>>();
/**
* Init the render time by setting {@link org.rythmengine.extension.ICodeType code type}.
* This method should called before calling render methods to setup the context of this render
*
* @param codeType
* @return the render setting instance
*/
public final RenderSettings init(ICodeType codeType) {
if (null != codeType) _codeType.set(codeType);
else _codeType.remove();
return this;
}
/**
* Init the render time by setting {@link java.util.Locale locale}.
* This method should called before calling render methods to setup the context of this render
*
* @param locale
* @return the render setting instance
*/
public final RenderSettings init(Locale locale) {
if (null != locale) _locale.set(locale);
else _locale.remove();
return this;
}
/**
* Init the render time by setting user context
* This method should called before calling render methods to setup the context of this render
*
* @param usrCtx
* @return the render setting instance
*/
public final RenderSettings init(Map<String, Object> usrCtx) {
if (null != usrCtx) _usrCtx.set(usrCtx);
else _usrCtx.remove();
return this;
}
/**
* Return ThreadLocal locale.
*
* @return locale setting for this render process
*/
public final Locale locale() {
return _locale.get();
}
/**
* Return thread local code type
*
* @return {@link org.rythmengine.extension.ICodeType code type} setting for this render process
*/
public final ICodeType codeType() {
return _codeType.get();
}
/**
* Return thread local user context map
*
* @return the user context map
*/
public final Map<String, Object> userContext() {
return _usrCtx.get();
}
/**
* Clear the render time after render process done
*
* @return this engine instance
*/
public final RythmEngine clear() {
_locale.remove();
_codeType.remove();
_usrCtx.remove();
return RythmEngine.this;
}
}
/**
* The RenderSettings instance keep the environment settings for one render operation
*/
public RenderSettings renderSettings;
private String secureCode = null;
/**
* Prepare the render operation environment settings
*
* @param codeType
* @param locale
* @param usrCtx
* @return the engine instance itself
*/
public final RythmEngine prepare(ICodeType codeType, Locale locale, Map<String, Object> usrCtx) {
renderSettings.init(codeType).init(locale).init(usrCtx);
return this;
}
/**
* Prepare the render operation environment settings
*
* @param codeType
* @return the engine instance itself
*/
public final RythmEngine prepare(ICodeType codeType) {
renderSettings.init(codeType);
return this;
}
/**
* Prepare the render operation environment settings
*
* @param locale
* @return the engine instance itself
*/
public final RythmEngine prepare(Locale locale) {
renderSettings.init(locale);
return this;
}
/**
* Prepare the render operation environment settings
*
* @param userContext
* @return the engine instance itself
*/
public final RythmEngine prepare(Map<String, Object> userContext) {
renderSettings.init(userContext);
return this;
}
private void _initLogger(Map<String, ?> conf) {
boolean logEnabled = (Boolean) RythmConfigurationKey.LOG_ENABLED.getConfiguration(conf);
if (logEnabled) {
ILoggerFactory factory = RythmConfigurationKey.LOG_FACTORY_IMPL.getConfiguration(conf);
Logger.registerLoggerFactory(factory);
} else {
Logger.registerLoggerFactory(new NullLogger.Factory());
}
}
// trim "rythm." from conf keys
private Map<String, Object> _processConf(Map<String, ?> conf) {
Map<String, Object> m = new HashMap<String, Object>(conf.size());
for (String s : conf.keySet()) {
Object o = conf.get(s);
if (s.startsWith("rythm.")) s = s.replaceFirst("rythm\\.", "");
m.put(s, o);
}
return m;
}
private void _initConf(Map<String, ?> conf, File confFile) {
// load conf from disk
Map<String, ?> rawConf = _loadConfFromDisk(confFile);
rawConf = _processConf(rawConf);
// load conf from System.properties
Properties sysProps = System.getProperties();
rawConf.putAll((Map) sysProps);
// load conf from user supplied configuration
if (null != conf) rawConf.putAll((Map) _processConf(conf));
_initLogger(rawConf);
// initialize the configuration with all loaded data
RythmConfiguration rc = new RythmConfiguration(rawConf, this);
this._conf = rc;
// initialize logger factory
ILoggerFactory logFact = rc.get(RythmConfigurationKey.LOG_FACTORY_IMPL);
Logger.registerLoggerFactory(logFact);
// check if it needs to debug the conf information
if (rawConf.containsKey("rythm.debug_conf") && Boolean.parseBoolean(rawConf.get("rythm.debug_conf").toString())) {
rc.debug();
}
}
/**
* Create a rythm engine instance with default configuration
*
* @see org.rythmengine.conf.RythmConfigurationKey
*/
public RythmEngine() {
init(null, null);
}
/**
* Create a rythm engine instance with either template root or configuration file specified
*
* @param file if is directory then the template root, otherwise then the configuration file
* @see org.rythmengine.conf.RythmConfigurationKey
*/
public RythmEngine(File file) {
init(null, file);
}
public RythmEngine(Properties userConfiguration) {
this((Map) userConfiguration);
}
/**
* Create a rythm engine instance with user supplied configuration data
*
* @param userConfiguration
* @see org.rythmengine.conf.RythmConfigurationKey
*/
public RythmEngine(Map<String, ?> userConfiguration) {
init(userConfiguration, null);
}
private Map<String, Object> properties = new HashMap<String, Object>();
/**
* Set user property to the engine. Note The property is not used by the engine program
* it's purely a place for user to add any tags or properties to the engine and later
* get fetched out and use in the user application
*
* @param key
* @param val
*/
public void setProperty(String key, Object val) {
properties.put(key, val);
}
/**
* Get user property by key
*
* @param key
* @param <T>
* @return the property being cast to type T
*/
public <T> T getProperty(String key) {
return (T) properties.get(key);
}
private Map _loadConfFromDisk(File conf) {
InputStream is = null;
boolean emptyConf = false;
if (null == conf) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (null == cl) cl = Rythm.class.getClassLoader();
is = cl.getResourceAsStream("rythm.conf");
} else {
try {
is = new FileInputStream(conf);
} catch (IOException e) {
if (!emptyConf) logger.warn(e, "Error opening conf file:" + conf);
}
}
if (null != is) {
Properties p = new Properties();
try {
p.load(is);
return p;
} catch (Exception e) {
logger.warn(e, "Error loading rythm.conf");
} finally {
try {
if (null != is) is.close();
} catch (Exception e) {
//ignore
}
}
}
return new HashMap();
}
private void init(Map<String, ?> conf, File file) {
if (null == file || file.isDirectory()) {
_initConf(conf, null);
if (null != file) _conf.setTemplateHome(file);
} else if (file.isFile() && file.canRead()) {
_initConf(conf, file);
}
renderSettings = new RenderSettings(_conf);
// post configuration initializations
_mode = _conf.get(RythmConfigurationKey.ENGINE_MODE);
_classes = new TemplateClassManager(this);
_classLoader = new TemplateClassLoader(this);
_classCache = new TemplateClassCache(this);
_resourceManager = new TemplateResourceManager(this);
_extensionManager = new ExtensionManager(this);
int ttl = (Integer) _conf.get(RythmConfigurationKey.DEFAULT_CACHE_TTL);
_cacheService = _conf.get(RythmConfigurationKey.CACHE_SERVICE_IMPL);
_cacheService.setDefaultTTL(ttl);
_cacheService.startup();
// register built-in transformers if enabled
boolean enableBuiltInJavaExtensions = (Boolean) _conf.get(RythmConfigurationKey.BUILT_IN_TRANSFORMER_ENABLED);
if (enableBuiltInJavaExtensions) {
registerTransformer("rythm", "([^a-zA-Z0-9_]s\\(\\)|^s\\(\\))", S.class);
}
boolean enableBuiltInTemplateLang = (Boolean) _conf.get(RythmConfigurationKey.BUILT_IN_CODE_TYPE_ENABLED);
if (enableBuiltInTemplateLang) {
ExtensionManager em = extensionManager();
em.registerCodeType(ICodeType.DefImpl.HTML);
em.registerCodeType(ICodeType.DefImpl.JS);
em.registerCodeType(ICodeType.DefImpl.JSON);
em.registerCodeType(ICodeType.DefImpl.CSV);
em.registerCodeType(ICodeType.DefImpl.CSS);
}
_templates.clear();
_templates.put("chain", new JavaTagBase() {
@Override
protected void call(__ParameterList params, __Body body) {
body.render(__getBuffer());
}
});
List<Class> udts = _conf.getList(RythmConfigurationKey.EXT_TRANSFORMER_IMPLS, Class.class);
registerTransformer(udts.toArray(new Class[]{}));
List<IPropertyAccessor> udpa = _conf.getList(RythmConfigurationKey.EXT_PROP_ACCESSOR_IMPLS, IPropertyAccessor.class);
registerPropertyAccessor(udpa.toArray(new IPropertyAccessor[]{}));
List<Class> udfmt = _conf.getList(RythmConfigurationKey.EXT_FORMATTER_IMPLS, Class.class);
registerFormatter(udfmt.toArray(new Class[]{}));
// -- built-in formatters
try {
Class.forName("org.joda.time.DateTime");
Class<IFormatter> fmtCls = (Class<IFormatter>) Class.forName("org.rythmengine.extension.JodaDateTimeFormatter");
IFormatter fmt = fmtCls.newInstance();
extensionManager().registerFormatter(fmt);
} catch (Exception e) {
// ignore;
logger.info("joda time class not found. Formatter to joda time not registered");
}
if (conf().autoScan()) {
resourceManager().scan();
}
if (conf().gae()) {
logger.warn("Rythm engine : GAE in cloud enabled");
}
logger.debug("Rythm-%s started in %s mode", version, mode());
}
/**
* Register {@link org.rythmengine.extension.IFormatter formatters}
*
* @param formatterClasses
*/
public void registerFormatter(Class<IFormatter>... formatterClasses) {
for (Class<IFormatter> cls : formatterClasses) {
try {
IFormatter fmt = cls.newInstance();
extensionManager().registerFormatter(fmt);
} catch (Exception e) {
Logger.error(e, "Error get formatter instance from class[%s]", cls);
}
}
}
public void registerFormatter(IFormatter... formatters) {
for (IFormatter fmt : formatters) {
extensionManager().registerFormatter(fmt);
}
}
/**
* Register {@link Transformer transformers} using namespace specified in
* the namespace {@link org.rythmengine.extension.Transformer#value() value} defined in
* the annotation.
*
* @param transformerClasses
*/
public void registerTransformer(Class<?>... transformerClasses) {
registerTransformer(null, null, transformerClasses);
}
/**
* Register {@link Transformer transformers} using namespace specified to
* replace the namespace {@link org.rythmengine.extension.Transformer#value() value} defined in
* the annotation.
*
* @param transformerClasses
*/
public void registerTransformer(String namespace, String waivePattern, Class<?>... transformerClasses) {
ExtensionManager jem = extensionManager();
for (Class<?> extensionClass : transformerClasses) {
Transformer t = extensionClass.getAnnotation(Transformer.class);
boolean classAnnotated = null != t;
String nmsp = namespace;
boolean namespaceIsEmpty = S.empty(namespace);
if (classAnnotated && namespaceIsEmpty) {
nmsp = t.value();
}
String waive = waivePattern;
boolean waiveIsEmpty = S.empty(waive);
if (classAnnotated && waiveIsEmpty) {
waive = t.waivePattern();
}
boolean clsRequireTemplate = null == t ? false : t.requireTemplate();
boolean clsLastParam = null == t ? false : t.lastParam();
for (Method m : extensionClass.getDeclaredMethods()) {
int flag = m.getModifiers();
if (!Modifier.isPublic(flag) || !Modifier.isStatic(flag)) continue;
int len = m.getParameterTypes().length;
if (len <= 0) continue;
Transformer tm = m.getAnnotation(Transformer.class);
boolean methodAnnotated = null != tm;
if (!methodAnnotated && !classAnnotated) continue;
String mnmsp = nmsp;
if (methodAnnotated && namespaceIsEmpty) {
mnmsp = tm.value();
if (S.empty(mnmsp)) mnmsp = nmsp;
}
String mwaive = waive;
if (methodAnnotated && waiveIsEmpty) {
mwaive = tm.waivePattern();
if (S.empty(mwaive)) mwaive = waive;
}
String cn = extensionClass.getSimpleName();
if (S.empty(mwaive)) mwaive = cn;
boolean requireTemplate = clsRequireTemplate;
if (null != tm && tm.requireTemplate()) {
requireTemplate = true;
}
boolean lastParam = clsLastParam;
if (null != tm && tm.lastParam()) {
lastParam = true;
}
String cn0 = extensionClass.getName();
String mn = m.getName();
String fullName = String.format("%s.%s", cn0, mn);
if (S.notEmpty(mnmsp) && !"rythm".equals(mnmsp)) {
mn = mnmsp + "_" + mn;
}
if (len == 1) {
jem.registerJavaExtension(new IJavaExtension.VoidParameterExtension(mwaive, mn, fullName, requireTemplate));
} else {
jem.registerJavaExtension(new IJavaExtension.ParameterExtension(mwaive, mn, ".+", fullName, requireTemplate, lastParam));
}
}
}
}
/**
* Register user implemented {@link org.rythmengine.extension.IPropertyAccessor}
*
* @param accessors
*/
public void registerPropertyAccessor(IPropertyAccessor... accessors) {
for (final IPropertyAccessor a : accessors) {
_registerPropertyAccessor(a);
}
PropertyHandlerFactory.unregisterPropertyHandler(Serializable.class);
}
private void _registerPropertyAccessor(final IPropertyAccessor a) {
PropertyHandlerFactory.registerPropertyHandler(a.getTargetType(), new PropertyHandler() {
@Override
public Object getProperty(String name, Object contextObj, VariableResolverFactory variableFactory) {
return a.getProperty(name, contextObj);
}
@Override
public Object setProperty(String name, Object contextObj, VariableResolverFactory variableFactory, Object value) {
return a.setProperty(name, contextObj, value);
}
});
}
public void registerResourceLoader(ITemplateResourceLoader... loaders) {
if (null == _resourceManager) {
throw new IllegalStateException("Engine not initialized");
}
for (int i = loaders.length - 1; i >= 0; --i) {
ITemplateResourceLoader loader = loaders[i];
_resourceManager.prependResourceLoader(loader);
}
}
private void setRenderArgs(ITemplate t, Object... args) {
if (null == args) {
t.__setRenderArg(0, null);
} else if (1 == args.length) {
Object o0 = args[0];
if (o0 instanceof Map) {
t.__setRenderArgs((Map<String, Object>) args[0]);
} else if (o0 instanceof JSONWrapper) {
t.__setRenderArg((JSONWrapper) o0);
} else {
t.__setRenderArgs(args);
}
} else {
t.__setRenderArgs(args);
}
//if (mode.isDev()) cceCounter.remove();
}
@Deprecated
private void handleCCE(ClassCastException ce) {
// Integer I = cceCounter.get();
// if (null == I) {
// I = 0;
// cceCounter.set(1);
// } else {
// cceCounter.set(I);
// if (I > 2) {
// cceCounter.remove();
// throw ce;
// restart(ce);
}
//static ThreadLocal<Integer> cceCounter = new ThreadLocal<Integer>();
private ITemplate getTemplate(IDialect dialect, String template, Object... args) {
if (S.empty(template)) {
return EmptyTemplate.INSTANCE;
}
boolean typeInferenceEnabled = conf().typeInferenceEnabled();
if (typeInferenceEnabled) {
ParamTypeInferencer.registerParams(this, args);
}
String key = template;
if (typeInferenceEnabled) {
key += ParamTypeInferencer.uuid();
}
TemplateClass tc = classes().getByTemplate(key);
if (null == tc) {
tc = new TemplateClass(template, this, dialect);
}
ITemplate t = tc.asTemplate(this);
setRenderArgs(t, args);
return t;
}
/**
* Get an new {@link ITemplate template} instance from a String and an array
* of render args. The string parameter could be either a template file path
* or the inline template source content.
* <p/>
* <p>When the args array contains only one element and is of {@link java.util.Map} type
* the the render args are passed to template
* {@link ITemplate#__setRenderArgs(java.util.Map) by name},
* otherwise they passes to template instance by position</p>
*
* @param template
* @param args
* @return template instance
*/
@SuppressWarnings("unchecked")
public ITemplate getTemplate(String template, Object... args) {
return getTemplate(null, template, args);
}
/**
* (3rd party API, not for user application)
* Get an new template class by {@link org.rythmengine.resource.ITemplateResource template resource}
*
* @param resource the template resource
* @return template class
*/
public TemplateClass getTemplateClass(ITemplateResource resource) {
String key = S.str(resource.getKey());
TemplateClass tc = classes().getByTemplate(key);
if (null == tc) {
tc = new TemplateClass(resource, this);
}
return tc;
}
/**
* Get an new template instance by template source {@link java.io.File file}
* and an array of arguments.
* <p/>
* <p>When the args array contains only one element and is of {@link java.util.Map} type
* the the render args are passed to template
* {@link ITemplate#__setRenderArgs(java.util.Map) by name},
* otherwise they passes to template instance by position</p>
*
* @param file the template source file
* @param args the render args. See {@link #getTemplate(String, Object...)}
* @return template instance
*/
@SuppressWarnings("unchecked")
public ITemplate getTemplate(File file, Object... args) {
boolean typeInferenceEnabled = conf().typeInferenceEnabled();
if (typeInferenceEnabled) {
ParamTypeInferencer.registerParams(this, args);
}
String key = S.str(resourceManager().get(file).getKey());
if (typeInferenceEnabled) {
key += ParamTypeInferencer.uuid();
}
TemplateClass tc = classes().getByTemplate(key);
ITemplate t;
if (null == tc) {
tc = new TemplateClass(file, this);
t = tc.asTemplate(this);
if (null == t) return null;
_templates.put(tc.getKey(), t);
//classes().add(key, tc);
} else {
t = tc.asTemplate(this);
}
setRenderArgs(t, args);
return t;
}
/**
* Render template by string parameter and an array of
* template args. The string parameter could be either
* a path point to the template source file, or the inline
* template source content. The render result is returned
* as a String
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param template either the path of template source file or inline template content
* @param args render args array
* @return render result
*/
public String render(String template, Object... args) {
try {
ITemplate t = getTemplate(template, args);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template by string parameter and an array of
* template args. The string parameter could be either
* a path point to the template source file, or the inline
* template source content. The render result is output
* to the specified binary output stream
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param os the output stream
* @param template either the path of template source file or inline template content
* @param args render args array
*/
public void render(OutputStream os, String template, Object... args) {
outputMode.set(OutputMode.os);
try {
ITemplate t = getTemplate(template, args);
t.render(os);
} finally {
renderCleanUp();
}
}
/**
* Render template by string parameter and an array of
* template args. The string parameter could be either
* a path point to the template source file, or the inline
* template source content. The render result is output
* to the specified character based writer
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param w the writer
* @param template either the path of template source file or inline template content
* @param args render args array
*/
public void render(Writer w, String template, Object... args) {
outputMode.set(OutputMode.writer);
try {
ITemplate t = getTemplate(template, args);
t.render(w);
} finally {
renderCleanUp();
}
}
/**
* Render template with source specified by {@link java.io.File file instance}
* and an array of render args. Render result return as a String
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param file the template source file
* @param args render args array
* @return render result
*/
public String render(File file, Object... args) {
try {
if (!file.exists())
throw new RuntimeException("template '"+file.getName()+"' does not exist!");
if (!file.canRead())
throw new RuntimeException("template '"+file.getName()+"' not readable!");
ITemplate t = getTemplate(file, args);
if (t==null)
throw new RuntimeException("template '"+file.getName()+"' load failed!");
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template with source specified by {@link java.io.File file instance}
* and an array of render args. Render result output into the specified binary
* {@link java.io.OutputStream}
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param os the output stream
* @param file the template source file
* @param args render args array
*/
public void render(OutputStream os, File file, Object... args) {
outputMode.set(OutputMode.os);
try {
ITemplate t = getTemplate(file, args);
t.render(os);
} finally {
renderCleanUp();
}
}
/**
* Render template with source specified by {@link java.io.File file instance}
* and an array of render args. Render result output into the specified binary
* {@link java.io.Writer}
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param w the writer
* @param file the template source file
* @param args render args array
*/
public void render(Writer w, File file, Object... args) {
outputMode.set(OutputMode.writer);
try {
ITemplate t = getTemplate(file, args);
t.render(w);
} finally {
renderCleanUp();
}
}
/**
* Render template by string typed inline template content and an array of
* template args. The render result is returned as a String
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param template the inline template content
* @param args the render args array
* @return render result
*/
public String renderStr(String key, String template, Object... args) {
return renderString(key, template, args);
}
/**
* Render template by string typed inline template content and an array of
* template args. The render result is returned as a String
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param template the inline template content
* @param args the render args array
* @return render result
*/
public String renderStr(String template, Object... args) {
return renderString(template, args);
}
/**
* Render result from a direct template content. The content
* will also be used as the template key to generate the recommended
* class name
* @param template the template content
* @param args the render args
* @return render result
*/
public String renderString(String template, Object... args) {
return renderString(template, template, args);
}
/**
* Render result from a direct template content. The template key
* has been provided as well
*
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param key the template key which will be used to generate
* @param template the inline template content
* @param args the render args array
* @return render result
*/
@SuppressWarnings("unchecked")
public String renderString(String key, String template, Object... args) {
boolean typeInferenceEnabled = conf().typeInferenceEnabled();
if (typeInferenceEnabled) {
ParamTypeInferencer.registerParams(this, args);
}
if (typeInferenceEnabled) {
key += ParamTypeInferencer.uuid();
}
try {
TemplateClass tc = classes().getByTemplate(key, false);
if (null == tc) {
tc = new TemplateClass(new StringTemplateResource(key, template), this);
//classes().add(key, tc);
}
ITemplate t = tc.asTemplate(this);
setRenderArgs(t, args);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template in substitute mode by string typed template source
* and an array of render args. The string parameter could be either
* a path point to the template source file, or the inline
* template source content. Return render result as String
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param template either the template source file path or the inline template content
* @param args the render args array
* @return render result
*/
public String substitute(String template, Object... args) {
try {
ITemplate t = getTemplate(BasicRythm.INSTANCE, template, args);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template in substitute mode by File typed template source
* and an array of render args. Return render result as String
* <p/>
* <p>See {@link #getTemplate(java.io.File, Object...)} for note on
* render args</p>
*
* @param file the template source file
* @param args the render args array
* @return render result
*/
public String substitute(File file, Object... args) {
try {
ITemplate t = getTemplate(file, args, BasicRythm.INSTANCE);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template in ToString mode by string typed template source
* and one object instance which state is to be output.
* The string parameter could be either a path point to the template
* source file, or the inline template source content. Return render
* result as String
*
* @param template either the template source file path or the inline template content
* @param obj the object instance which state is to be output as a string
* @return render result
*/
public String toString(String template, Object obj) {
Class argClass = obj.getClass();
String clsName = argClass.getName();
if (clsName.matches(".*\\$[0-9].*")) {
argClass = obj.getClass().getSuperclass();
}
String key = template + argClass;
try {
TemplateClass tc = classes().getByTemplate(key);
if (null == tc) {
tc = new TemplateClass(template, this, new ToString(argClass));
//classes().add(key, tc);
}
ITemplate t = tc.asTemplate(this);
t.__setRenderArg(0, obj);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template in AutoToString mode by one object instance which state is
* to be output. Return render result as String
*
* @param obj the object instance which state is to be output as a string
* @return render result
*/
public String toString(Object obj) {
return toString(obj, ToStringOption.DEFAULT_OPTION, (ToStringStyle) null);
}
/**
* Render template in AutoToString mode by one object instance which state is
* to be output and {@link ToStringOption option} and {@link ToStringStyle stype}.
* Return render result as String
*
* @param obj the object instance which state is to be output as a string
* @param option the output option
* @param style the output style
* @return render result
*/
public String toString(Object obj, ToStringOption option, ToStringStyle style) {
Class<?> c = obj.getClass();
AutoToString.AutoToStringData key = new AutoToString.AutoToStringData(c, option, style);
try {
//String template = AutoToString.templateStr(c, option, style);
TemplateClass tc = classes().getByTemplate(key);
if (null == tc) {
tc = new TemplateClass(new ToStringTemplateResource(key), this, new AutoToString(c, key));
//classes().add(key, tc);
}
ITemplate t = tc.asTemplate(this);
t.__setRenderArg(0, obj);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Render template in AutoToString mode by one object instance which state is
* to be output and {@link ToStringOption option} and
* {@link org.apache.commons.lang3.builder.ToStringStyle apache commons to string stype}.
* Return render result as String
*
* @param obj the object instance which state is to be output as a string
* @param option the output option
* @param style the output style specified as apache commons ToStringStyle
* @return render result
*/
public String commonsToString(Object obj, ToStringOption option, org.apache.commons.lang3.builder.ToStringStyle style) {
return toString(obj, option, ToStringStyle.fromApacheStyle(style));
}
private Set<String> nonExistsTemplates = new HashSet<String>();
private class NonExistsTemplatesChecker implements IShutdownListener {
boolean started = false;
private ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1);
NonExistsTemplatesChecker() {
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
List<String> toBeRemoved = new ArrayList<String>();
for (String template : nonExistsTemplates) {
ITemplateResource rsrc = resourceManager().getResource(template);
if (rsrc.isValid()) {
toBeRemoved.add(template);
}
}
nonExistsTemplates.removeAll(toBeRemoved);
toBeRemoved.clear();
TemplateClass tc = classes().all().get(0);
for (String tag : _nonExistsTags) {
if (null != resourceManager().tryLoadTemplate(tag, tc, null)) {
toBeRemoved.add(tag);
}
}
_nonExistsTags.removeAll(toBeRemoved);
toBeRemoved.clear();
}
}, 0, 1000 * 10, TimeUnit.MILLISECONDS);
}
@Override
public void onShutdown() {
scheduler.shutdown();
}
}
private NonExistsTemplatesChecker nonExistsTemplatesChecker = null;
/**
* Render template if specified template exists, otherwise return empty string
*
* @param template the template source path
* @param args render args. See {@link #getTemplate(String, Object...)}
* @return render result
*/
public String renderIfTemplateExists(String template, Object... args) {
boolean typeInferenceEnabled = conf().typeInferenceEnabled();
if (typeInferenceEnabled) {
ParamTypeInferencer.registerParams(this, args);
}
if (nonExistsTemplates.contains(template)) return "";
String key = template;
if (typeInferenceEnabled) {
key += ParamTypeInferencer.uuid();
}
try {
TemplateClass tc = classes().getByTemplate(template);
if (null == tc) {
ITemplateResource rsrc = resourceManager().getResource(template);
if (rsrc.isValid()) {
tc = new TemplateClass(rsrc, this);
//classes().add(key, tc);
} else {
nonExistsTemplates.add(template);
if (isDevMode() && nonExistsTemplatesChecker == null) {
nonExistsTemplatesChecker = new NonExistsTemplatesChecker();
}
return "";
}
}
ITemplate t = tc.asTemplate(this);
setRenderArgs(t, args);
return t.render();
} finally {
renderCleanUp();
}
}
/**
* Evaluate a script and return executing result. Note the API is not mature yet
* don't use it in your application
*
* @param script
* @return the result
*/
public Object eval(String script) {
// // use Java's ScriptEngine at the moment
// ScriptEngineManager manager = new ScriptEngineManager();
// ScriptEngine jsEngine = manager.getEngineByName("JavaScript");
// try {
// return jsEngine.eval(script);
// } catch (ScriptException e) {
// throw new RuntimeException(e);
return eval(script, Collections.<String, Object>emptyMap());
}
private Map<String, Serializable> mvels = new HashMap<String, Serializable>();
public Object eval(String script, Map<String, Object> params) {
Serializable ce = mvels.get(script);
if (null == ce) {
ce = MVEL.compileExpression(script);
mvels.put(script, ce);
}
return MVEL.executeExpression(ce, params);
}
public Object eval(String script, Object context, Map<String, Object> params) {
Serializable ce = mvels.get(script);
if (null == ce) {
ce = MVEL.compileExpression(script);
mvels.put(script, ce);
}
return MVEL.executeExpression(ce, context, params);
}
private final Map<String, ITemplate> _templates = new HashMap<String, ITemplate>();
private final Map<String, JavaTagBase> _tags = new HashMap<String, JavaTagBase>();
private final Set<String> _nonTmpls = new HashSet<String>();
/**
* Whether a {@link ITemplate template} is registered to the engine by name specified
* <p/>
* <p>Not an API for user application</p>
*
* @param tmplName
* @return true if there is a template with the name specified
*/
public boolean templateRegistered(String tmplName) {
return _templates.containsKey(tmplName) || _tags.containsKey(tmplName);
}
/**
* Get a {@link ITemplate template} registered to the engine by name
* <p/>
* <p>Not an API for user application</p>
*
* @param tmplName
* @return the template instance
*/
public ITemplate getRegisteredTemplate(String tmplName) {
return _templates.get(tmplName);
}
/**
* Return {@link TemplateClass} from a tag name
* <p/>
* <p>Not an API for user application</p>
*
* @param name
* @return template class
*/
public TemplateClass getRegisteredTemplateClass(String name) {
TemplateBase tmpl = (TemplateBase) _templates.get(name);
if (null == tmpl) return null;
return tmpl.__getTemplateClass(false);
}
/**
* Register a template class and return self
*
* @param tc
* @return this engine instance
*/
public RythmEngine registerTemplateClass(TemplateClass tc) {
classes().add(tc);
return this;
}
/**
* Check if a template exists and return it's name
* <p/>
* <p>Not an API for user application</p>
*
* @param name
* @param callerClass
* @return template name
*/
public String testTemplate(String name, TemplateClass callerClass, ICodeType codeType) {
if (Keyword.THIS.toString().equals(name)) {
return callerClass.getTagName();
}
if (mode().isProd() && _nonTmpls.contains(name)) return null;
if (templateRegistered(name)) return name;
// try imported path
if (null != callerClass.getImportPaths()) {
for (String s : callerClass.getImportPaths()) {
if (s.startsWith("java")) {
continue;
}
String name0 = s + "." + name;
if (_templates.containsKey(name0)) return name0;
}
}
// try relative path
// TODO: handle logic error here, caller foo.bar.html, tag: zee
// then should try foo.zee.html, if tag is zee.js, then should try foo.zee.js
String callerName = callerClass.getTagName();
if (null != callerName) {
int pos = callerName.lastIndexOf(".");
if (-1 != pos) {
String s = callerName.substring(0, pos);
String name0 = s + "." + name;
if (_templates.containsKey(name0)) return name0;
pos = s.lastIndexOf(".");
if (-1 != pos) {
s = callerName.substring(0, pos);
name0 = s + "." + name;
if (_templates.containsKey(name0)) return name0;
}
}
}
try {
// try to ask resource manager
TemplateClass tc = resourceManager().tryLoadTemplate(name, callerClass, codeType);
if (null == tc) {
if (mode().isProd()) _nonTmpls.add(name);
return null;
}
String fullName = tc.getTagName();
return fullName;
} catch (TagLoadException e) {
throw e;
} catch (RythmException e) {
throw e;
} catch (Exception e) {
logger.error(e, "error trying load tag[%s]", name);
// see if the
}
return null;
}
public void registerFastTag(JavaTagBase tag) {
_tags.put(tag.__getName(), tag);
}
/**
* Register a template.
* <p>Not an API for user application</p>
*/
public void registerTemplate(ITemplate template) {
//TemplateResourceManager rm = resourceManager();
String name;
if (template instanceof JavaTagBase) {
name = template.__getName();
} else {
name = template.__getTemplateClass(false).getTagName();
}
registerTemplate(name, template);
}
/**
* Register a tag using the given name
* <p/>
* <p>Not an API for user application</p>
*
* @param name
* @param template
*/
public void registerTemplate(String name, ITemplate template) {
if (null == template) throw new NullPointerException();
// if (_templates.containsKey(name)) {
// return false;
_templates.put(name, template);
return;
}
/**
* Invoke a template
* <p/>
* <p>Not an API for user application</p>
*
* @param line
* @param name
* @param caller
* @param params
* @param body
* @param context
*/
public void invokeTemplate(int line, String name, ITemplate caller, ITag.__ParameterList params, ITag.__Body body, ITag.__Body context) {
invokeTemplate(line, name, caller, params, body, context, false);
}
private Set<String> _nonExistsTags = new HashSet<String>();
/**
* Invoke a tag
* <p/>
* <p>Not an API for user application</p>
*
* @param line
* @param name
* @param caller
* @param params
* @param body
* @param context
* @param ignoreNonExistsTag
*/
public void invokeTemplate(int line, String name, ITemplate caller, ITag.__ParameterList params, ITag.__Body body, ITag.__Body context, boolean ignoreNonExistsTag) {
if (_nonExistsTags.contains(name)) return;
Sandbox.enterSafeZone(secureCode);
RythmEvents.ENTER_INVOKE_TEMPLATE.trigger(this, (TemplateBase) caller);
try {
// try tag registry first
ITemplate t = _tags.get(name);
if (null == t) {
t = _templates.get(name);
}
if (null == t && S.isEqual(name, caller.__getName())) {
// is calling self
t = caller;
}
if (null == t) {
// try imported path
TemplateClass tc = caller.__getTemplateClass(true);
if (null != tc.getImportPaths()) {
for (String s : tc.getImportPaths()) {
if (s.startsWith("java")) {
continue;
}
String name0 = s + "." + name;
t = _tags.get(name0);
if (null == t) t = _templates.get(name0);
if (null != t) break;
}
}
// try relative path
if (null == t) {
String callerName = tc.getTagName();
int pos = -1;
if (null != callerName) pos = callerName.lastIndexOf(".");
if (-1 != pos) {
String name0 = callerName.substring(0, pos) + "." + name;
t = _tags.get(name0);
if (null == t) t = _templates.get(name0);
}
}
// try load the tag from resource
if (null == t) {
tc = resourceManager().tryLoadTemplate(name, tc, caller.__curCodeType());
if (null != tc) t = _templates.get(tc.getTagName());
if (null == t) {
if (ignoreNonExistsTag) {
if (logger.isDebugEnabled()) {
logger.debug("cannot find tag: " + name);
}
_nonExistsTags.add(name);
if (isDevMode() && nonExistsTemplatesChecker == null) {
nonExistsTemplatesChecker = new NonExistsTemplatesChecker();
}
return;
} else {
throw new NullPointerException("cannot find tag: " + name);
}
}
t = t.__cloneMe(this, caller);
}
}
if (!(t instanceof JavaTagBase)) {
// try refresh the tag loaded from template file under tag root
// note Java source tags are not reloaded here
String cn = t.getClass().getName();
TemplateClass tc0 = classes().getByClassName(cn);
if (null == tc0) {
throw new NullPointerException(String.format("null tc0 found. t.class: %s, name: %s, caller.class: %s", cn, name, caller.getClass()));
}
t = tc0.asTemplate(caller, this);
} else {
t = t.__cloneMe(this, caller);
}
if (null != params) {
if (t instanceof JavaTagBase) {
((JavaTagBase) t).__setRenderArgs0(params);
} else {
for (int i = 0; i < params.size(); ++i) {
ITag.__Parameter param = params.get(i);
if (null != param.name) t.__setRenderArg(param.name, param.value);
else t.__setRenderArg(i, param.value);
}
}
}
if (null == body && null != params) {
body = (ITag.__Body) params.getByName("__body");
if (null == body) {
body = (ITag.__Body) params.getByName("_body");
}
}
if (null != body) {
t.__setRenderArg("__body", body);
t.__setRenderArg("_body", body); // for compatibility
}
RythmEvents.ON_TAG_INVOCATION.trigger(this, F.T2((TemplateBase) caller, t));
try {
if (null != context) {
t.__setBodyContext(context);
}
t.__setSecureCode(secureCode).__call(line);
} finally {
RythmEvents.TAG_INVOKED.trigger(this, F.T2((TemplateBase) caller, t));
}
} finally {
RythmEvents.EXIT_INVOKE_TEMPLATE.trigger(this, (TemplateBase) caller);
Sandbox.leaveCurZone(secureCode);
}
}
// -- cache api
/**
* Cache object using key and args for ttl seconds
* <p/>
* <p>Not an API for user application</p>
*
* @param key
* @param o
* @param ttl if zero then defaultTTL used, if negative then never expire
* @param args
*/
public void cache(String key, Object o, int ttl, Object... args) {
if (conf().cacheDisabled()) return;
ICacheService cacheService = _cacheService;
Serializable value = null == o ? "" : (o instanceof Serializable ? (Serializable) o : o.toString());
if (args.length > 0) {
StringBuilder sb = new StringBuilder(key);
for (Object arg : args) {
sb.append("-").append(arg);
}
key = sb.toString();
}
cacheService.put(key, value, ttl);
}
/**
* Store object o into cache service with ttl equals to duration specified.
* <p/>
* <p>The duration is a string to be parsed by @{link #durationParser}</p>
* <p/>
* <p>The object o is associated with given key and a list of argument values</p>
* <p/>
* <p>Not an API for user application</p>
*
* @param key
* @param o
* @param duration
* @param args
*/
public void cache(String key, Object o, String duration, Object... args) {
if (conf().cacheDisabled()) return;
IDurationParser dp = conf().durationParser();
int ttl = null == duration ? 0 : dp.parseDuration(duration);
cache(key, o, ttl, args);
}
/**
* Evict an object from cache service by key
*
* @param key identify the object should be removed from cache service
*/
public void evict(String key) {
if (conf().cacheDisabled()) {
return;
}
_cacheService.evict(key);
}
/**
* Get cached value using key and a list of argument values
* <p/>
* <p>Not an API for user application</p>
*
* @param key
* @param args
* @return cached item
*/
public Serializable cached(String key, Object... args) {
if (conf().cacheDisabled()) return null;
ICacheService cacheService = _cacheService;
if (args.length > 0) {
StringBuilder sb = new StringBuilder(key);
for (Object arg : args) {
sb.append("-").append(arg);
}
key = sb.toString();
}
return cacheService.get(key);
}
// -- SPI interface
// -- issue
private Map<TemplateClass, Set<TemplateClass>> extendMap = new HashMap<TemplateClass, Set<TemplateClass>>();
/**
* Not an API for user application
*
* @param parent
* @param child
*/
public void addExtendRelationship(TemplateClass parent, TemplateClass child) {
if (mode().isProd()) return;
Set<TemplateClass> children = extendMap.get(parent);
if (null == children) {
children = new HashSet<TemplateClass>();
extendMap.put(parent, children);
}
children.add(child);
}
/**
* Not an API for user application
*
* @param parent
*/
// called to invalidate all template class which extends the parent
public void invalidate(TemplateClass parent) {
if (mode().isProd()) return;
Set<TemplateClass> children = extendMap.get(parent);
if (null == children) return;
for (TemplateClass child : children) {
invalidate(child);
child.reset();
}
}
// -- Sandbox
private SandboxExecutingService _secureExecutor = null;
/**
* Create a {@link Sandbox} instance to render the template
*
* @return an new sandbox instance
*/
public Sandbox sandbox() {
if (null != _secureExecutor) {
return new Sandbox(this, _secureExecutor);
}
int poolSize = (Integer) conf().get(RythmConfigurationKey.SANDBOX_POOL_SIZE);
SecurityManager csm = conf().get(RythmConfigurationKey.SANDBOX_SECURITY_MANAGER_IMPL);
int timeout = (Integer) conf().get(RythmConfigurationKey.SANDBOX_TIMEOUT);
SandboxThreadFactory fact = conf().get(RythmConfigurationKey.SANBOX_THREAD_FACTORY_IMPL);
SecurityManager ssm = System.getSecurityManager();
RythmSecurityManager rsm;
String code;
if (null == ssm || !(ssm instanceof RythmSecurityManager)) {
code = conf().get(RythmConfigurationKey.SANDBOX_SECURE_CODE);
rsm = new RythmSecurityManager(csm, code, this);
} else {
rsm = ((RythmSecurityManager) ssm);
code = rsm.getCode();
}
secureCode = code;
_secureExecutor = new SandboxExecutingService(poolSize, fact, timeout, this, code);
Sandbox sandbox = new Sandbox(this, _secureExecutor);
if (ssm != rsm) System.setSecurityManager(rsm);
return sandbox;
}
/**
* Create a {@link Sandbox} instance with user supplied context
*
* @param context
* @return an new sandbox instance
*/
public Sandbox sandbox(Map<String, Object> context) {
return sandbox().setUserContext(context);
}
// dispatch rythm events
private IEventDispatcher eventDispatcher = null;
public IEventDispatcher eventDispatcher() {
if (null == eventDispatcher) {
eventDispatcher = new EventBus(this);
}
return eventDispatcher;
}
/**
* Not an API for user application
*
* @param event
* @param param
* @return event handler process result
*/
@Override
public Object accept(IEvent event, Object param) {
return eventDispatcher().accept(event, param);
}
/**
* Defines the output method for render result.
* <ul>
* <li>os: output to binary {@link java.io.OutputStream}</li>
* <li>writer: output to character based {@link java.io.Writer}</li>
* <li>str: return render result as a {@link java.lang.String}</li>
* </ul>
* <p/>
* <p>This is not an API used in user application</p>
*/
public static enum OutputMode {
os, writer, str {
@Override
public boolean writeOutput() {
return false;
}
};
/**
* Return true if the current output mode is to output to {@link java.io.OutputStream}
* or {@link java.io.Writer}
*
* @return true if output mode is not return string
*/
public boolean writeOutput() {
return true;
}
}
private final static InheritableThreadLocal<OutputMode> outputMode = new InheritableThreadLocal<OutputMode>() {
@Override
protected OutputMode initialValue() {
return OutputMode.str;
}
};
/**
* Valid Suffixes
*/
public static final String[] VALID_SUFFIXES = {
".html",
".json",
".js",
".css",
".csv",
".tag",
".xml",
".txt",
".rythm"
};
/**
* Not an API.
*
* @return output mode
*/
public static OutputMode outputMode() {
return outputMode.get();
}
public static void renderCleanUp() {
outputMode.remove();
TemplateResourceManager.cleanUpTmplBlackList();
}
/**
* Restart the engine with an exception as the cause.
* <p><b>Note</b>, this is not supposed to be called by user application</p>
*
* @param cause
*/
public void restart(RuntimeException cause) {
if (isProdMode()) throw cause;
if (!(cause instanceof ClassReloadException)) {
String msg = cause.getMessage();
if (cause instanceof RythmException) {
RythmException re = (RythmException) cause;
msg = re.getSimpleMessage();
}
logger.warn("restarting rythm engine due to %s", msg);
}
restart();
}
private void restart() {
if (isProdMode()) return;
_classLoader = new TemplateClassLoader(this);
//_classes.clear();
// clear all template tags which is managed by TemplateClassManager
List<String> templateTags = new ArrayList<String>();
for (Map.Entry<String, ITemplate> entry : _templates.entrySet()) {
ITag tag = entry.getValue();
if (!(tag instanceof JavaTagBase)) {
templateTags.add(entry.getKey());
}
}
for (String name : templateTags) {
_templates.remove(name);
}
}
interface IShutdownListener {
void onShutdown();
}
private IShutdownListener shutdownListener = null;
void setShutdownListener(IShutdownListener listener) {
this.shutdownListener = listener;
}
private boolean zombie = false;
/**
* Shutdown this rythm engine
*/
public void shutdown() {
if (zombie) {
return;
}
logger.info("Shutting down Rythm Engine: [%s]", id());
if (null != _cacheService) {
try {
_cacheService.shutdown();
} catch (Exception e) {
logger.error(e, "Error shutdown cache service");
}
}
if (null != _secureExecutor) {
try {
_secureExecutor.shutdown();
} catch (Exception e) {
logger.error(e, "Error shutdown secure executor");
}
}
if (null != _resourceManager) {
try {
_resourceManager.shutdown();
} catch (Exception e) {
logger.error(e, "Error shutdown resource manager");
}
}
if (null != shutdownListener) {
try {
shutdownListener.onShutdown();
} catch (Exception e) {
logger.error(e, "Error execute shutdown listener");
}
}
if (null != nonExistsTemplatesChecker) {
nonExistsTemplatesChecker.onShutdown();
}
if (null != _templates) _templates.clear();
if (null != _classes) _classes.clear();
if (null != _nonExistsTags) _nonExistsTags.clear();
if (null != nonExistsTemplates) nonExistsTemplates.clear();
if (null != _nonTmpls) _nonTmpls.clear();
_classLoader = null;
Rythm.RenderTime.clear();
zombie = true;
}
}
|
package org.tools4j.time.base;
import org.tools4j.time.pack.*;
import org.tools4j.time.validate.DateValidator;
import org.tools4j.time.validate.TimeValidator;
import org.tools4j.time.validate.ValidationMethod;
import java.time.LocalDate;
import java.time.LocalDateTime;
import static org.tools4j.time.base.EpochImpl.divMod;
/**
* Converts dates to days since epoch and vice versa.
*/
public interface Epoch {
long INVALID_EPOCH = DateValidator.INVALID_EPOCH;
ValidationMethod validationMethod();
long toEpochDay(int year, int month, int day);
long toEpochDay(int packedDate, DatePacker datePacker);
long toEpochDay(final LocalDate localDate);
long toEpochSecond(int year, int month, int day);
long toEpochSecond(int year, int month, int day, int hour, int minute);
long toEpochSecond(int year, int month, int day, int hour, int minute, int second);
long toEpochSecond(int packedDate, DatePacker datePacker);
long toEpochSecond(int packedDate, DatePacker datePacker, int packedTime, TimePacker timePacker);
long toEpochSecond(final LocalDateTime localDateTime);
long toEpochMilli(int year, int month, int day);
long toEpochMilli(int year, int month, int day, int hour, int minute, int second, int milli);
long toEpochMilli(int packedDate, DatePacker datePacker);
long toEpochMilli(int packedDate, DatePacker datePacker, int packedMilliTime, MilliTimePacker milliTimePacker);
long toEpochMilli(long packedDateTime, DateTimePacker dateTimePacker);
long toEpochMilli(final LocalDateTime localDateTime);
long toEpochNano(int year, int month, int day);
long toEpochNano(int year, int month, int day, int hour, int minute, int second, int nano);
long toEpochNano(int packedDate, DatePacker datePacker, long packedNanoTime, NanoTimePacker nanoTimePacker);
long toEpochNano(final LocalDateTime localDateTime);
int fromEpochDay(long daysSinceEpoch, DatePacker datePacker);
@Garbage(Garbage.Type.RESULT)
LocalDate fromEpochDay(long daysSinceEpoch);
int fromEpochSecond(long secondsSinceEpoch, DatePacker datePacker);
int fromEpochSecond(long secondsSinceEpoch, TimePacker timePacker);
int fromEpochSecond(long secondsSinceEpoch, MilliTimePacker milliTimePacker);
long fromEpochSecond(long secondsSinceEpoch, NanoTimePacker nanoTimePacker);
long fromEpochSecond(long secondsSinceEpoch, DateTimePacker dateTimePacker);
@Garbage(Garbage.Type.RESULT)
LocalDateTime fromEpochSecond(long secondsSinceEpoch);
int fromEpochMilli(long millisSinceEpoch, DatePacker datePacker);
int fromEpochMilli(long millisSinceEpoch, MilliTimePacker milliTimePacker);
long fromEpochMilli(long millisSinceEpoch, NanoTimePacker nanoTimePacker);
long fromEpochMilli(long millisSinceEpoch, DateTimePacker dateTimePacker);
@Garbage(Garbage.Type.RESULT)
LocalDateTime fromEpochMilli(long millisSinceEpoch);
int fromEpochNano(long nanosSinceEpoch, DatePacker datePacker);
long fromEpochNano(long nanosSinceEpoch, NanoTimePacker nanoTimePacker);
@Garbage(Garbage.Type.RESULT)
LocalDateTime fromEpochNano(long nanosSinceEpoch);
static Epoch valueOf(final ValidationMethod validationMethod) {
return EpochImpl.valueOf(validationMethod);
}
interface Default extends Epoch {
default long toEpochDay(final int packedDate, final DatePacker datePacker) {
return toEpochDay(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate)
);
}
@Override
default long toEpochDay(final LocalDate localDate) {
return toEpochDay(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
}
default long toEpochSecond(final int year, final int month, final int day) {
return toEpochDay(year, month, day) * TimeFactors.SECONDS_PER_DAY;
}
default long toEpochSecond(final int year, final int month, final int day,
final int hour, final int minute) {
return toEpochSecond(year, month, day, hour, minute, 0);
}
default long toEpochSecond(final int year, final int month, final int day,
final int hour, final int minute, final int second) {
if (TimeValidator.INVALID == validationMethod().timeValidator().validateTime(hour, minute, second)) {
return INVALID_EPOCH;
}
return toEpochSecond(year, month, day)
+ hour * TimeFactors.SECONDS_PER_HOUR + minute * TimeFactors.SECONDS_PER_MINUTE + second;
}
default long toEpochSecond(final int packedDate, final DatePacker datePacker) {
return toEpochDay(packedDate, datePacker) * TimeFactors.SECONDS_PER_DAY;
}
default long toEpochSecond(final int packedDate, final DatePacker datePacker,
final int packedTime, final TimePacker timePacker) {
return toEpochSecond(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate),
timePacker.unpackHour(packedTime),
timePacker.unpackMinute(packedTime),
timePacker.unpackSecond(packedTime)
);
}
@Override
default long toEpochSecond(final LocalDateTime localDateTime) {
return toEpochSecond(
localDateTime.getYear(), localDateTime.getMonthValue(), localDateTime.getDayOfMonth(),
localDateTime.getHour(), localDateTime.getMinute(), localDateTime.getSecond()
);
}
default long toEpochMilli(final int year, final int month, final int day) {
return toEpochDay(year, month, day) * TimeFactors.MILLIS_PER_DAY;
}
default long toEpochMilli(final int year, final int month, final int day,
final int hour, final int minute, final int second, final int milli) {
if (TimeValidator.INVALID == validationMethod().timeValidator().validateTimeWithMillis(hour, minute, second, milli)) {
return INVALID_EPOCH;
}
return toEpochMilli(year, month, day)
+ hour * TimeFactors.MILLIS_PER_HOUR + minute * TimeFactors.MILLIS_PER_MINUTE + second * TimeFactors.MILLIS_PER_SECOND + milli;
}
default long toEpochMilli(final int packedDate, final DatePacker datePacker) {
return toEpochDay(packedDate, datePacker) * TimeFactors.MILLIS_PER_DAY;
}
default long toEpochMilli(final int packedDate, final DatePacker datePacker,
final int packedMilliTime, final MilliTimePacker milliTimePacker) {
return toEpochMilli(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate),
milliTimePacker.unpackHour(packedMilliTime),
milliTimePacker.unpackMinute(packedMilliTime),
milliTimePacker.unpackSecond(packedMilliTime),
milliTimePacker.unpackMilli(packedMilliTime)
);
}
default long toEpochMilli(final long packedDateTime, final DateTimePacker dateTimePacker) {
return toEpochMilli(
dateTimePacker.unpackYear(packedDateTime),
dateTimePacker.unpackMonth(packedDateTime),
dateTimePacker.unpackDay(packedDateTime),
dateTimePacker.unpackHour(packedDateTime),
dateTimePacker.unpackMinute(packedDateTime),
dateTimePacker.unpackSecond(packedDateTime),
dateTimePacker.unpackMilli(packedDateTime)
);
}
@Override
default long toEpochMilli(final LocalDateTime localDateTime) {
return toEpochMilli(
localDateTime.getYear(), localDateTime.getMonthValue(), localDateTime.getDayOfMonth(),
localDateTime.getHour(), localDateTime.getMinute(), localDateTime.getSecond(), localDateTime.getNano() / TimeFactors.NANOS_PER_MILLI
);
}
default long toEpochNano(final int year, final int month, final int day) {
return toEpochDay(year, month, day) * TimeFactors.NANOS_PER_DAY;
}
default long toEpochNano(final int year, final int month, final int day,
final int hour, final int minute, final int second, final int nano) {
if (TimeValidator.INVALID == validationMethod().timeValidator().validateTimeWithNanos(hour, minute, second, nano)) {
return INVALID_EPOCH;
}
return toEpochNano(year, month, day)
+ hour * TimeFactors.NANOS_PER_HOUR + minute * TimeFactors.NANOS_PER_MINUTE + second * TimeFactors.NANOS_PER_SECOND + nano;
}
default long toEpochNano(final int packedDate, final DatePacker datePacker,
final long packedNanoTime, final NanoTimePacker nanoTimePacker) {
return toEpochNano(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate),
nanoTimePacker.unpackHour(packedNanoTime),
nanoTimePacker.unpackMinute(packedNanoTime),
nanoTimePacker.unpackSecond(packedNanoTime),
nanoTimePacker.unpackNano(packedNanoTime)
);
}
@Override
default long toEpochNano(final LocalDateTime localDateTime) {
return toEpochNano(
localDateTime.getYear(), localDateTime.getMonthValue(), localDateTime.getDayOfMonth(),
localDateTime.getHour(), localDateTime.getMinute(), localDateTime.getSecond(), localDateTime.getNano()
);
}
@Override
@Garbage(Garbage.Type.RESULT)
default LocalDate fromEpochDay(final long daysSinceEpoch) {
final DatePacker packer = DatePacker.BINARY;
final int packed = fromEpochDay(daysSinceEpoch, packer);
return packer.unpackLocalDate(packed);
}
default int fromEpochSecond(final long secondsSinceEpoch, final DatePacker datePacker) {
return fromEpochDay(Math.floorDiv(secondsSinceEpoch, TimeFactors.SECONDS_PER_DAY), datePacker);
}
default int fromEpochSecond(final long secondsSinceEpoch, final TimePacker timePacker) {
final int timeInSeconds = (int) Math.floorMod(secondsSinceEpoch, TimeFactors.SECONDS_PER_DAY);
return timePacker.pack(
divMod(timeInSeconds, TimeFactors.SECONDS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
Math.floorMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE)
);
}
default int fromEpochSecond(final long secondsSinceEpoch, final MilliTimePacker milliTimePacker) {
final int timeInSeconds = (int) Math.floorMod(secondsSinceEpoch, TimeFactors.SECONDS_PER_DAY);
return milliTimePacker.pack(
divMod(timeInSeconds, TimeFactors.SECONDS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
Math.floorMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE),
0
);
}
default long fromEpochSecond(final long secondsSinceEpoch, final NanoTimePacker nanoTimePacker) {
final int timeInSeconds = (int) Math.floorMod(secondsSinceEpoch, TimeFactors.SECONDS_PER_DAY);
return nanoTimePacker.pack(
divMod(timeInSeconds, TimeFactors.SECONDS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
Math.floorMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE),
0
);
}
default long fromEpochSecond(final long secondsSinceEpoch, final DateTimePacker dateTimePacker) {
final DatePacker datePacker = DatePacker.valueOf(Packing.BINARY, dateTimePacker.validationMethod());
final int packedDate = fromEpochSecond(secondsSinceEpoch, datePacker);
final int timeInSeconds = (int) Math.floorMod(secondsSinceEpoch, TimeFactors.SECONDS_PER_DAY);
return dateTimePacker.pack(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate),
divMod(timeInSeconds, TimeFactors.SECONDS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
Math.floorMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE)
);
}
@Override
@Garbage(Garbage.Type.RESULT)
default LocalDateTime fromEpochSecond(final long secondsSinceEpoch) {
final DateTimePacker packer = DateTimePacker.BINARY;
final long packed = fromEpochSecond(secondsSinceEpoch, packer);
return packer.unpackLocalDateTime(packed);
}
default int fromEpochMilli(final long millisSinceEpoch, final DatePacker datePacker) {
return fromEpochDay(Math.floorDiv(millisSinceEpoch, TimeFactors.MILLIS_PER_DAY), datePacker);
}
default int fromEpochMilli(final long millisSinceEpoch, final MilliTimePacker milliTimePacker) {
final int timeInMillis = (int) Math.floorMod(millisSinceEpoch, TimeFactors.MILLIS_PER_DAY);
return milliTimePacker.pack(
divMod(timeInMillis, TimeFactors.MILLIS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInMillis, TimeFactors.MILLIS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
divMod(timeInMillis, TimeFactors.MILLIS_PER_SECOND, TimeFactors.SECONDS_PER_MINUTE),
Math.floorMod(timeInMillis, TimeFactors.MILLIS_PER_SECOND)
);
}
default long fromEpochMilli(final long millisSinceEpoch, final NanoTimePacker nanoTimePacker) {
final int timeInMillis = (int) Math.floorMod(millisSinceEpoch, TimeFactors.MILLIS_PER_DAY);
return nanoTimePacker.pack(
divMod(timeInMillis, TimeFactors.MILLIS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInMillis, TimeFactors.MILLIS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
divMod(timeInMillis, TimeFactors.MILLIS_PER_SECOND, TimeFactors.SECONDS_PER_MINUTE),
Math.floorMod(timeInMillis, TimeFactors.MILLIS_PER_SECOND) * TimeFactors.NANOS_PER_MILLI
);
}
default long fromEpochMilli(final long millisSinceEpoch, final DateTimePacker dateTimePacker) {
final DatePacker datePacker = DatePacker.valueOf(Packing.BINARY, dateTimePacker.validationMethod());
final int packedDate = fromEpochMilli(millisSinceEpoch, datePacker);
final int timeInMillis = (int) Math.floorMod(millisSinceEpoch, TimeFactors.MILLIS_PER_DAY);
return dateTimePacker.pack(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate),
divMod(timeInMillis, TimeFactors.MILLIS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInMillis, TimeFactors.MILLIS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
divMod(timeInMillis, TimeFactors.MILLIS_PER_SECOND, TimeFactors.SECONDS_PER_MINUTE),
Math.floorMod(timeInMillis, TimeFactors.MILLIS_PER_SECOND)
);
}
@Override
@Garbage(Garbage.Type.RESULT)
default LocalDateTime fromEpochMilli(final long millisSinceEpoch) {
final DateTimePacker packer = DateTimePacker.BINARY;
final long packed = fromEpochMilli(millisSinceEpoch, packer);
return packer.unpackLocalDateTime(packed);
}
default long fromEpochNano(final long nanosSinceEpoch, final NanoTimePacker nanoTimePacker) {
final int timeInSeconds = divMod(nanosSinceEpoch, TimeFactors.NANOS_PER_SECOND, TimeFactors.SECONDS_PER_DAY);
return nanoTimePacker.pack(
divMod(timeInSeconds, TimeFactors.SECONDS_PER_HOUR, TimeFactors.HOURS_PER_DAY),
divMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE, TimeFactors.MINUTES_PER_HOUR),
Math.floorMod(timeInSeconds, TimeFactors.SECONDS_PER_MINUTE),
(int) Math.floorMod(nanosSinceEpoch, TimeFactors.NANOS_PER_SECOND)
);
}
@Override
default int fromEpochNano(final long nanosSinceEpoch, final DatePacker datePacker) {
return fromEpochDay(nanosSinceEpoch / TimeFactors.NANOS_PER_DAY, datePacker);
}
@Override
@Garbage(Garbage.Type.RESULT)
default LocalDateTime fromEpochNano(final long nanosSinceEpoch) {
final DatePacker datePacker = DatePacker.BINARY;
final NanoTimePacker timePacker = NanoTimePacker.BINARY;
final int packedDate = fromEpochNano(nanosSinceEpoch, datePacker);
final long packedTime = fromEpochNano(nanosSinceEpoch, timePacker);
return datePacker.unpackNull(packedDate) & timePacker.unpackNull(packedTime) ? null :
LocalDateTime.of(
datePacker.unpackYear(packedDate),
datePacker.unpackMonth(packedDate),
datePacker.unpackDay(packedDate),
timePacker.unpackHour(packedTime),
timePacker.unpackMinute(packedTime),
timePacker.unpackSecond(packedTime),
timePacker.unpackNano(packedTime)
);
}
}
}
|
package org.webbitserver;
import org.webbitserver.netty.NettyWebServer;
import java.net.SocketAddress;
import java.net.URI;
import java.util.concurrent.Executor;
public class WebServers {
/**
* Returns a new {@link WebServer} object, which runs on the provided port.
*
* @param port
* @return {@link WebServer} object
* @see NettyWebServer
*/
public static WebServer createWebServer(int port) {
return new NettyWebServer(port);
}
/**
* Returns a new {@link WebServer} object, which runs on the provided port
* and adds the executor to the List of executor services to be called when
* the server is running.
*
* @param executor Since Webbit is designed to be a single threaded non-blocking server,<br />
* it is assumed that the user supplied executor will provide only a single thread.
* @param port
* @return {@link WebServer} object
* @see NettyWebServer
*/
public static WebServer createWebServer(Executor executor, int port) {
return new NettyWebServer(executor, port);
}
/**
* Returns a new {@link WebServer} object, adding the executor to the list
* of executor services, running on the stated socket address and accessible
* from the provided public URI.
*
* @param executor Since Webbit is designed to be a single threaded non-blocking server,<br />
* it is assumed that the user supplied executor will provide only a single thread.
* @param socketAddress
* @param publicUri
* @return {@link WebServer} object
* @see NettyWebServer
*/
public static WebServer createWebServer(Executor executor, SocketAddress socketAddress, URI publicUri) {
return new NettyWebServer(executor, socketAddress, publicUri);
}
}
|
package se.lth.cs.connect;
import iot.jcypher.query.JcQueryResult;
import iot.jcypher.query.api.IClause;
import iot.jcypher.query.factories.clause.CREATE;
import iot.jcypher.query.factories.clause.MATCH;
import iot.jcypher.query.factories.clause.NATIVE;
import iot.jcypher.query.factories.clause.RETURN;
import iot.jcypher.query.values.JcNode;
import iot.jcypher.query.values.JcNumber;
import se.lth.cs.connect.modules.AccountSystem;
import se.lth.cs.connect.modules.Database;
public class Bootstrap {
public static class Metadata {
public int version;
public Metadata() {
version = 0;
}
}
public static class Superuser {
public String username, password;
public Superuser() {
username = "superuser";
password = "i-eat-pancakes";
}
}
public static int databaseVersion() {
final JcNode md = new JcNode("md");
final JcNumber version = new JcNumber("v");
JcQueryResult res = Database.query(Database.access(), new IClause[] {
MATCH.node(md).label("metadata"),
RETURN.value(md.property("version")).AS(version)
});
if (res.resultOf(version).size() == 0)
return -1;
else
return res.resultOf(version).get(0).intValue();
}
public static boolean isInitialized() {
return databaseVersion() >= 0;
}
public static void createConstraints() {
Database.query(Database.access(), new IClause[]{
NATIVE.cypher("CREATE CONSTRAINT ON (p:project) ASSERT p.name IS UNIQUE")
});
}
public static void createMetadata(Metadata data) {
Database.query(Database.access(), new IClause[]{
CREATE.node().label("metadata")
.property("version").value(data.version)
});
}
public static void createSuperuser(Superuser superuser) {
AccountSystem.createAccount(superuser.username, superuser.password, TrustLevel.ADMIN);
}
public static void runFirstTimeCheck() {
if (isInitialized())
return;
Metadata metadata = new Metadata();
Superuser superuser = new Superuser();
for (int i = 0; i < 80; i++)
System.out.print("=");
System.out.println();
System.out.println("No database matadata found, bootstrapping database:");
System.out.println();
System.out.println(" > creating database constraints...");
createConstraints();
System.out.println(" > creating metadata node...");
createMetadata(metadata);
System.out.println(" > creating superuser (username=" + superuser.username + " password=" + superuser.password + ")...");
createSuperuser(superuser);
System.out.println("Done!");
}
}
|
package uk.bl.wa.blindex;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.filecache.DistributedCache;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.TextOutputFormat;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.hadoop.Solate;
import org.apache.solr.hadoop.SolrInputDocumentWritable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import au.com.bytecode.opencsv.CSVParser;
/**
*
* @author Andrew Jackson <Andrew.Jackson@bl.uk>
*
*/
public class IndexerJob {
private static final Logger LOG = LoggerFactory.getLogger(IndexerJob.class);
protected static String solrHomeZipName = "solr_home.zip";
/**
*
* This mapper parses the input table, downloads the relevant XML, parses
* the content into Solr documents, computes the target SolrCloud slice and
* passes them down to the reducer.
*
* @author Andrew Jackson <Andrew.Jackson@bl.uk>
*
*/
public static class Map extends MapReduceBase implements
Mapper<LongWritable, Text, IntWritable, SolrInputDocumentWritable> {
private CSVParser p = new CSVParser();
private Solate sp;
private String domidUrlPrefix;
/*
* (non-Javadoc)
*
* @see
* org.apache.hadoop.mapred.MapReduceBase#configure(org.apache.hadoop
* .mapred.JobConf)
*/
@Override
public void configure(JobConf job) {
super.configure(job);
String zkHost = "openstack2.ad.bl.uk:2181,openstack4.ad.bl.uk:2181,openstack5.ad.bl.uk:2181/solr";
String collection = "jisc2";
int numShards = 4;
sp = new Solate(zkHost, collection, numShards);
domidUrlPrefix = "http://194.66.239.142/did/";
}
public void map(LongWritable key, Text value,
OutputCollector<IntWritable, SolrInputDocumentWritable> output,
Reporter reporter)
throws IOException {
// String[] parts = value.toString().split("\\x01");
String[] parts = p.parseLine(value.toString());
// If this is the header line, return now:
if ("entityid".equals(parts[0]))
return;
// Otherwise, grab the content info:
String entityuid = parts[1];
String simpletitle = parts[3];
String originalname = parts[5];
String domid = parts[8];
// Construct URL:
URL xmlUrl = new URL(domidUrlPrefix + domid);
// Pass to the SAX-based parser to collect the outputs:
List<String> docs = null;
try {
docs = JISC2TextExtractor.extract(xmlUrl.openStream());
} catch (Exception e) {
e.printStackTrace();
return;
}
for (int i = 0; i < docs.size(); i++) {
// Skip empty records:
if (docs.get(i).length() == 0)
continue;
// Build up a Solr document:
String doc_id = entityuid + "/p" + i;
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", doc_id);
doc.setField("simpletitle_s", simpletitle);
doc.setField("originalname_s", originalname);
doc.setField("domid_l", domid);
doc.setField("page_i", i);
doc.setField("content", docs.get(i));
output.collect(new IntWritable(sp.getPartition(doc_id, doc)),
new SolrInputDocumentWritable(doc));
}
}
}
/**
*
* This reducer collects the documents for each slice together and commits
* them to an embedded instance of the Solr server stored on HDFS
*
* @author Andrew Jackson <Andrew.Jackson@bl.uk>
*
*/
public static class Reduce extends MapReduceBase implements
Reducer<IntWritable, SolrInputDocumentWritable, Text, IntWritable> {
private FileSystem fs;
private Path solrHomeDir = null;
private Path outputDir;
private String shardPrefix = "shard";
/*
* (non-Javadoc)
*
* @see
* org.apache.hadoop.mapred.MapReduceBase#configure(org.apache.hadoop
* .mapred.JobConf)
*/
@Override
public void configure(JobConf job) {
LOG.info("Calling configure()...");
super.configure(job);
try {
// Filesystem:
fs = FileSystem.get(job);
// Input:
solrHomeDir = findSolrConfig(job, solrHomeZipName);
LOG.info("Found solrHomeDir " + solrHomeDir);
} catch (IOException e) {
e.printStackTrace();
LOG.error("FAILED in reducer configuration: " + e);
}
// Output:
outputDir = new Path("/user/admin/jisc2/solr/");
}
public void reduce(IntWritable key,
Iterator<SolrInputDocumentWritable> values,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
int slice = key.get();
Path outputShardDir = new Path(outputDir, this.shardPrefix + slice);
LOG.info("Running reducer for " + slice + " > " + outputShardDir);
EmbeddedSolrServer solrServer = JISC2TextExtractor
.createEmbeddedSolrServer(solrHomeDir, fs, outputDir,
outputShardDir);
while (values.hasNext()) {
SolrInputDocument doc = values.next().getSolrInputDocument();
try {
solrServer.add(doc);
} catch (SolrServerException e) {
e.printStackTrace();
LOG.error("ADD " + e);
}
output.collect(new Text("" + key), new IntWritable(1));
}
try {
solrServer.commit();
solrServer.shutdown();
} catch (SolrServerException e) {
e.printStackTrace();
LOG.error("COMMIT " + e);
}
}
}
public static Path findSolrConfig(JobConf conf, String zipName)
throws IOException {
Path solrHome = null;
Path[] localArchives = DistributedCache.getLocalCacheArchives(conf);
if (localArchives.length == 0) {
LOG.error("No local cache archives.");
throw new IOException(String.format("No local cache archives."));
}
for (Path unpackedDir : localArchives) {
LOG.info("Looking at: " + unpackedDir + " for " + zipName);
if (unpackedDir.getName().equals(zipName)) {
LOG.info("Using this unpacked directory as solr home: {}",
unpackedDir);
solrHome = unpackedDir;
break;
}
}
return solrHome;
}
/**
* c.f. SolrRecordWriter, SolrOutputFormat
*
* Cloudera Search defaults to: /solr/jisc2/core_node1 ...but note no
* replicas, which is why the shard-to-core mapping looks easy.
*
* Take /user/admin/jisc2-xmls/000000_0 Read line-by-line Split on 0x01.
*
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
JobConf conf = new JobConf(IndexerJob.Map.class);
conf.setJobName("JISC2_Indexer");
conf.setMapOutputKeyClass(IntWritable.class);
conf.setMapOutputValueClass(SolrInputDocumentWritable.class);
conf.setMapperClass(Map.class);
conf.setNumMapTasks(4);
conf.setReducerClass(Reduce.class);
conf.setNumReduceTasks(4);
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
// /user/admin/jisc2-xmls/table_sample.csv
FileInputFormat.setInputPaths(conf, new Path(
"/user/admin/jisc2-xmls/table_sample.csv"));
// /user/admin/jist2/solr
FileOutputFormat.setOutputPath(conf, new Path("/user/admin/jisc2/job"));
conf.setSpeculativeExecution(false);
// File solrHomeZip = new
// File("src/main/resources/jisc2/solr_home.zip");
Path zipPath = new Path("/user/admin/jisc2-xmls/solr_home.zip");
FileSystem fs = FileSystem.get(conf);
// fs.copyFromLocalFile(new Path(solrHomeZip.toString()), zipPath);
final URI baseZipUrl = fs.getUri().resolve(
zipPath.toString() + '#' + solrHomeZipName);
DistributedCache.addCacheArchive(baseZipUrl, conf);
LOG.debug("Set Solr distributed cache: {}",
Arrays.asList(DistributedCache.getCacheArchives(conf)));
LOG.debug("Set zipPath: {}", zipPath);
JobClient.runJob(conf);
}
}
|
// S c o r e T i m e F i x e r //
// Contact author at herve.bitteur@laposte.net to report bugs & suggestions. //
package omr.score.visitor;
import omr.log.Logger;
import omr.score.Score;
import omr.score.entity.Chord;
import omr.score.entity.Measure;
import omr.score.entity.ScoreSystem;
import omr.score.entity.Slot;
import omr.score.entity.TimeSignature.InvalidTimeSignature;
import java.util.Map;
import java.util.TreeMap;
/**
* Class <code>ScoreTimeFixer</code> can visit the score hierarchy to compute
* all measure and system start times and durations.
*
* @author Hervé Bitteur
* @version $Id$
*/
public class ScoreTimeFixer
extends AbstractScoreVisitor
{
/** Usual logger utility */
private static final Logger logger = Logger.getLogger(ScoreTimeFixer.class);
/** Map of Measure id -> Measure duration, whatever the containing part */
private final Map<Integer, Integer> measureDurations = new TreeMap<Integer, Integer>();
/** Pass number */
private int pass = 1;
// ScoreTimeFixer //
/**
* Creates a new ScoreTimeFixer object.
*/
public ScoreTimeFixer ()
{
}
// visit Measure //
@Override
public boolean visit (Measure measure)
{
if (logger.isFineEnabled()) {
logger.fine(
"Visiting Part#" + measure.getPart().getId() + " " + measure);
}
measure.resetStartTime();
measure.getStartTime(); // Value is cached
try {
int measureDur = 0;
// Whole/multi rests are handled outside of slots
for (Slot slot : measure.getSlots()) {
if (slot.getStartTime() != null) {
for (Chord chord : slot.getChords()) {
measureDur = Math.max(
measureDur,
slot.getStartTime() + chord.getDuration());
}
}
}
if (measureDur != 0) {
// Make sure the measure duration is not bigger than limit (?)
if (measureDur <= measure.getExpectedDuration()) {
measure.setActualDuration(measureDur);
} else {
measure.setActualDuration(measure.getExpectedDuration());
}
measureDurations.put(measure.getId(), measureDur);
if (logger.isFineEnabled()) {
logger.fine(measure.getId() + ": " + measureDur);
}
} else if (!measure.getWholeChords()
.isEmpty()) {
if (pass > 1) {
Integer dur = measureDurations.get(measure.getId());
if (dur != null) {
measure.setActualDuration(dur);
} else {
measure.setActualDuration(
measure.getExpectedDuration());
}
}
}
} catch (InvalidTimeSignature ex) {
}
return false; // Dead end, we don't go lower than measures
}
// visit Score //
/**
* Score hierarchy entry point (not used, but provided for completeness)
*
* @param score visit the score to export
* @return false, since no further processing is required after this node
*/
@Override
public boolean visit (Score score)
{
// Delegate to children
score.acceptChildren(this);
return false; // That's all
}
// visit System //
/**
* System processing. The rest of processing is directly delegated to the
* measures
*
* @param system visit the system to export
* @return false
*/
@Override
public boolean visit (ScoreSystem system)
{
if (logger.isFineEnabled()) {
logger.fine("Visiting " + system);
}
// 2 passes are needed, to get the actual duration of whole notes
// Since the measure duration may be specified in another system part
for (pass = 1; pass <= 2; pass++) {
if (logger.isFineEnabled()) {
logger.fine("Pass #" + pass);
}
// System time
system.recomputeStartTime();
// Browse the (SystemParts and the) Measures
system.acceptChildren(this);
// System duration
system.recomputeActualDuration();
if (logger.isFineEnabled()) {
logger.fine("Durations:" + measureDurations);
}
}
return false; // No default browsing this way
}
}
|
package controllers;
import javax.inject.Inject;
import javax.xml.namespace.QName;
import com.fasterxml.jackson.databind.JsonNode;
import com.mysema.query.Tuple;
import com.mysema.query.sql.SQLQuery;
import com.mysema.query.sql.SQLSubQuery;
import com.mysema.query.support.Expressions;
import com.mysema.query.types.Expression;
import com.mysema.query.types.QTuple;
import com.mysema.query.types.expr.BooleanExpression;
import com.mysema.query.types.expr.NumberExpression;
import com.mysema.query.types.path.NumberPath;
import com.mysema.query.types.path.StringPath;
import com.mysema.query.types.template.BooleanTemplate;
import nl.idgis.dav.model.Resource;
import nl.idgis.dav.model.ResourceDescription;
import nl.idgis.dav.model.ResourceProperties;
import nl.idgis.dav.model.DefaultResource;
import nl.idgis.dav.model.DefaultResourceDescription;
import nl.idgis.dav.model.DefaultResourceProperties;
import nl.idgis.publisher.database.QSourceDatasetVersion;
import nl.idgis.publisher.database.QSourceDatasetVersionColumn;
import nl.idgis.publisher.metadata.MetadataDocument;
import nl.idgis.publisher.metadata.MetadataDocumentFactory;
import nl.idgis.publisher.xml.exceptions.NotFound;
import nl.idgis.publisher.xml.exceptions.QueryFailure;
import play.Logger;
import play.api.mvc.Handler;
import play.api.mvc.RequestHeader;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
import util.MetadataConfig;
import util.QueryDSL;
import util.QueryDSL.Transaction;
import static nl.idgis.publisher.database.QDataset.dataset;
import static nl.idgis.publisher.database.QDatasetColumn.datasetColumn;
import static nl.idgis.publisher.database.QSourceDataset.sourceDataset;
import static nl.idgis.publisher.database.QSourceDatasetMetadata.sourceDatasetMetadata;
import static nl.idgis.publisher.database.QSourceDatasetMetadataAttachment.sourceDatasetMetadataAttachment;
import static nl.idgis.publisher.database.QSourceDatasetVersion.sourceDatasetVersion;
import static nl.idgis.publisher.database.QSourceDatasetVersionColumn.sourceDatasetVersionColumn;
import static nl.idgis.publisher.database.QPublishedServiceDataset.publishedServiceDataset;
import static nl.idgis.publisher.database.QPublishedService.publishedService;
import static nl.idgis.publisher.database.QEnvironment.environment;
import static nl.idgis.publisher.database.QDatasetCopy.datasetCopy;
import static nl.idgis.publisher.database.QDatasetView.datasetView;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import java.util.stream.Collectors;
public class DatasetMetadata extends AbstractMetadata {
private final MetadataDocumentFactory mdf;
private final Pattern urlPattern;
@Inject
public DatasetMetadata(MetadataConfig config, QueryDSL q) throws Exception {
this(config, q, new MetadataDocumentFactory(), "/");
}
public DatasetMetadata(MetadataConfig config, QueryDSL q, MetadataDocumentFactory mdf, String prefix) {
super(config, q, prefix);
this.mdf = mdf;
urlPattern = Pattern.compile(".*/(.*)(\\?.*)?$");
}
@Override
public DatasetMetadata withPrefix(String prefix) {
return new DatasetMetadata(config, q, mdf, prefix);
}
private SQLQuery fromNonPublishedSourceDataset(Transaction tx) {
return joinSourceDatasetVersion(
tx.query().from(sourceDataset)
.join(sourceDatasetMetadata).on(sourceDatasetMetadata.sourceDatasetId.eq(sourceDataset.id))
.where(new SQLSubQuery().from(dataset)
.where(dataset.sourceDatasetId.eq(sourceDataset.id))
.where(isPublishedDataset())
.notExists()));
}
private SQLQuery fromSourceDataset(Transaction tx) {
return joinSourceDatasetVersion(
tx.query().from(sourceDataset)
.join(sourceDatasetMetadata).on(sourceDatasetMetadata.sourceDatasetId.eq(sourceDataset.id)));
}
private SQLQuery joinSourceDatasetVersion(SQLQuery query) {
query
.join(sourceDatasetVersion).on(sourceDatasetVersion.sourceDatasetId.eq(sourceDataset.id))
.where(sourceDatasetVersion.id.in(new SQLSubQuery().from(sourceDatasetVersion)
.where(sourceDatasetVersion.sourceDatasetId.eq(sourceDataset.id))
.list(sourceDatasetVersion.id.max())));
if(isTrusted()) {
return query;
} else {
return query.where(sourceDatasetVersion.metadataConfidential.isFalse());
}
}
private SQLQuery fromPublishedDataset(Transaction tx) {
return joinSourceDatasetVersion(tx.query().from(dataset)
.join(sourceDataset).on(sourceDataset.id.eq(dataset.sourceDatasetId))
.join(sourceDatasetMetadata).on(sourceDatasetMetadata.sourceDatasetId.eq(sourceDataset.id))
.where(isPublishedDataset()));
}
private SQLQuery fromDataset(Transaction tx) {
return joinSourceDatasetVersion(tx.query().from(dataset)
.join(sourceDataset).on(sourceDataset.id.eq(dataset.sourceDatasetId))
.join(sourceDatasetMetadata).on(sourceDatasetMetadata.sourceDatasetId.eq(sourceDataset.id)));
}
private BooleanExpression isPublishedDataset() {
return new SQLSubQuery().from(publishedServiceDataset)
.where(publishedServiceDataset.datasetId.eq(dataset.id))
.exists();
}
@Override
public Optional<Resource> resource(String name) {
return getId(name).flatMap(id ->
q.withTransaction(tx -> {
Optional<Resource> optionalDataset = datasetResource(id, tx);
if(optionalDataset.isPresent()) {
return optionalDataset;
} else {
return sourceDatasetResource(id, tx);
}
}));
}
private Optional<Resource> sourceDatasetResource(String id, Transaction tx) {
return Optional.ofNullable(fromSourceDataset(tx)
.where(sourceDataset.metadataFileIdentification.eq(id))
.singleResult(
sourceDataset.metadataIdentification,
sourceDatasetMetadata.sourceDatasetId,
sourceDatasetMetadata.document))
.map(datasetTuple -> tupleToDatasetResource(
tx,
datasetTuple,
datasetTuple.get(sourceDatasetMetadata.sourceDatasetId),
null,
id,
datasetTuple.get(sourceDataset.metadataIdentification)));
}
private Optional<Resource> datasetResource(String id, Transaction tx) throws Exception {
return Optional.ofNullable(fromDataset(tx)
.where(dataset.metadataFileIdentification.eq(id))
.singleResult(
dataset.id,
dataset.metadataIdentification,
sourceDatasetMetadata.sourceDatasetId,
sourceDatasetMetadata.document))
.map(datasetTuple -> tupleToDatasetResource(
tx,
datasetTuple,
datasetTuple.get(sourceDatasetMetadata.sourceDatasetId),
datasetTuple.get(dataset.id),
id,
datasetTuple.get(dataset.metadataIdentification)));
}
private List<Tuple> datasetColumnAliases(Transaction tx, Expression<?> datasetRel, NumberPath<Integer> datasetRelId, StringPath datasetRelName, int datasetId) {
final QSourceDatasetVersionColumn sourceDatasetVersionColumnSub = new QSourceDatasetVersionColumn("source_dataset_version_column_sub");
final QSourceDatasetVersion sourceDatasetVersionSub = new QSourceDatasetVersion("source_dataset_version_sub");
return tx.query().from(datasetRel)
.join(dataset).on(dataset.id.eq(datasetRelId))
.join(sourceDatasetVersionColumn).on(sourceDatasetVersionColumn.name.eq(datasetRelName))
.join(sourceDatasetVersion).on(sourceDatasetVersion.id.eq(sourceDatasetVersionColumn.sourceDatasetVersionId)
.and(dataset.sourceDatasetId.eq(sourceDatasetVersion.sourceDatasetId)))
.where(datasetRelId.eq(datasetId))
.where(new SQLSubQuery().from(sourceDatasetVersionColumnSub)
.join(sourceDatasetVersionSub).on(sourceDatasetVersionSub.id.eq(sourceDatasetVersionColumnSub.sourceDatasetVersionId))
.where(sourceDatasetVersionColumnSub.name.eq(sourceDatasetVersionColumn.name))
.where(sourceDatasetVersionColumnSub.sourceDatasetVersionId.gt(sourceDatasetVersionColumn.sourceDatasetVersionId))
.where(sourceDatasetVersionSub.sourceDatasetId.eq(dataset.sourceDatasetId))
.notExists())
.where(sourceDatasetVersionColumn.alias.isNotNull())
.orderBy(sourceDatasetVersionColumn.index.desc())
.list(sourceDatasetVersionColumn.name, sourceDatasetVersionColumn.alias);
}
private Resource tupleToDatasetResource(Transaction tx, Tuple datasetTuple, int sourceDatasetId, Integer datasetId, String fileIdentifier, String datasetIdentifier) {
try {
MetadataDocument metadataDocument = mdf.parseDocument(datasetTuple.get(sourceDatasetMetadata.document));
metadataDocument.removeStylesheet();
stylesheet("datasets").ifPresent(metadataDocument::setStylesheet);
metadataDocument.setDatasetIdentifier(datasetIdentifier);
metadataDocument.setFileIdentifier(fileIdentifier);
if(!isTrusted()) {
metadataDocument.removeAdditionalPointOfContacts();
}
Map<String, Integer> attachments = tx.query().from(sourceDatasetMetadataAttachment)
.where(sourceDatasetMetadataAttachment.sourceDatasetId.eq(sourceDatasetId))
.list(
sourceDatasetMetadataAttachment.id,
sourceDatasetMetadataAttachment.identification)
.stream()
.collect(Collectors.toMap(
t -> t.get(sourceDatasetMetadataAttachment.identification),
t -> t.get(sourceDatasetMetadataAttachment.id)));
for(String supplementalInformation : metadataDocument.getSupplementalInformation()) {
int separator = supplementalInformation.indexOf("|");
if(separator != -1) {
String type = supplementalInformation.substring(0, separator);
String url = supplementalInformation.substring(separator + 1).trim().replace('\\', '/');
String fileName;
Matcher urlMatcher = urlPattern.matcher(url);
if(urlMatcher.find()) {
fileName = urlMatcher.group(1);
} else {
fileName = "download";
}
if(attachments.containsKey(supplementalInformation)) {
String updatedSupplementalInformation =
type + "|" +
routes.Attachment.get(attachments.get(supplementalInformation).toString(), fileName)
.absoluteURL(false, config.getHost());
metadataDocument.updateSupplementalInformation(
supplementalInformation,
updatedSupplementalInformation);
} else {
metadataDocument.removeSupplementalInformation(supplementalInformation);
}
}
}
List<String> browseGraphics = metadataDocument.getDatasetBrowseGraphics();
for(String browseGraphic : browseGraphics) {
if(attachments.containsKey(browseGraphic)) {
String url = browseGraphic.trim().replace('\\', '/');
String fileName;
Matcher urlMatcher = urlPattern.matcher(url);
if(urlMatcher.find()) {
fileName = urlMatcher.group(1);
} else {
fileName = "preview";
}
String updatedbrowseGraphic =
routes.Attachment.get(attachments.get(browseGraphic).toString(), fileName)
.absoluteURL(false, config.getHost());
metadataDocument.updateDatasetBrowseGraphic(browseGraphic, updatedbrowseGraphic);
}
}
metadataDocument.removeServiceLinkage();
Consumer<List<Tuple>> columnAliasWriter = columnTuples -> {
if(columnTuples.isEmpty()) {
return;
}
StringBuilder textAlias = new StringBuilder("INHOUD ATTRIBUTENTABEL:");
for(Tuple columnTuple : columnTuples) {
textAlias
.append(" ")
.append(columnTuple.get(sourceDatasetVersionColumn.name))
.append(": ")
.append(columnTuple.get(sourceDatasetVersionColumn.alias));
}
try {
metadataDocument.addProcessStep(textAlias.toString());
} catch(NotFound nf) {
throw new RuntimeException(nf);
}
};
if(datasetId == null) {
columnAliasWriter.accept(
tx.query().from(sourceDatasetVersionColumn)
.where(sourceDatasetVersionColumn.sourceDatasetVersionId.eq(
new SQLSubQuery().from(sourceDatasetVersion)
.where(sourceDatasetVersion.sourceDatasetId.eq(sourceDatasetId))
.unique(sourceDatasetVersion.id.max())))
.where(sourceDatasetVersionColumn.alias.isNotNull())
.orderBy(sourceDatasetVersionColumn.index.desc())
.list(sourceDatasetVersionColumn.name, sourceDatasetVersionColumn.alias));
} else {
final QSourceDatasetVersionColumn sourceDatasetVersionColumnSub = new QSourceDatasetVersionColumn("source_dataset_version_column_sub");
List<Tuple> datasetCopyAliases =
datasetColumnAliases(
tx,
datasetCopy,
datasetCopy.datasetId,
datasetCopy.name,
datasetId);
if(datasetCopyAliases.isEmpty()) {
columnAliasWriter.accept(
datasetColumnAliases(
tx, datasetView,
datasetView.datasetId,
datasetView.name,
datasetId));
} else {
columnAliasWriter.accept(datasetCopyAliases);
}
SQLQuery serviceQuery = tx.query().from(publishedService)
.join(publishedServiceDataset).on(publishedServiceDataset.serviceId.eq(publishedService.serviceId))
.join(environment).on(environment.id.eq(publishedService.environmentId));
if(!isTrusted()) {
// do not generate links to services with confidential content as these are inaccessible.
serviceQuery.where(environment.confidential.isFalse());
}
List<Tuple> serviceTuples = serviceQuery.where(publishedServiceDataset.datasetId.eq(datasetId))
.list(
publishedService.content,
environment.identification,
environment.confidential,
environment.url,
publishedServiceDataset.layerName);
if(!serviceTuples.isEmpty()) {
config.getDownloadUrlPrefix().ifPresent(downloadUrlPrefix -> {
try {
metadataDocument.addServiceLinkage(downloadUrlPrefix + fileIdentifier, "download", null);
} catch(NotFound nf) {
throw new RuntimeException(nf);
}
});
}
boolean confidential = true;
int serviceTupleIndex = 0;
for(int i = 0; i < serviceTuples.size(); i++) {
boolean envConfidential = serviceTuples.get(i).get(environment.confidential);
if(!envConfidential) {
confidential = false;
serviceTupleIndex = i;
break;
}
}
for(int i = 0; i < serviceTuples.size(); i++) {
JsonNode serviceInfo = Json.parse(serviceTuples.get(i).get(publishedService.content));
String serviceName = serviceInfo.get("name").asText();
String scopedName = serviceTuples.get(i).get(publishedServiceDataset.layerName);
if(i == serviceTupleIndex) {
if(confidential) {
config.getViewerUrlSecurePrefix().ifPresent(viewerUrlPrefix -> {
try {
metadataDocument.addServiceLinkage(viewerUrlPrefix + "/layer/" + serviceName + "/" + scopedName, "website", null);
} catch(NotFound nf) {
throw new RuntimeException(nf);
}
});
} else {
config.getViewerUrlPublicPrefix().ifPresent(viewerUrlPrefix -> {
try {
metadataDocument.addServiceLinkage(viewerUrlPrefix + "/layer/" + serviceName + "/" + scopedName, "website", null);
} catch(NotFound nf) {
throw new RuntimeException(nf);
}
});
}
}
String environmentUrl = serviceTuples.get(i).get(environment.url);
// we only automatically generate browseGraphics
// when none where provided by the source.
if(browseGraphics.isEmpty()) {
String linkage = getServiceLinkage(environmentUrl, serviceName, ServiceType.WMS);
metadataDocument.addDatasetBrowseGraphic(linkage + config.getBrowseGraphicWmsRequest() + scopedName);
}
for(ServiceType serviceType : ServiceType.values()) {
String linkage = getServiceLinkage(environmentUrl, serviceName, serviceType);
String protocol = serviceType.getProtocol();
for(String spatialSchema : metadataDocument.getSpatialSchema()) {
if(spatialSchema.equals("vector") || protocol.equals("OGC:WMS")) {
metadataDocument.addServiceLinkage(linkage, protocol, scopedName);
}
}
}
}
}
return new DefaultResource("application/xml", metadataDocument.getContent());
} catch(Exception e) {
throw new RuntimeException(e);
}
}
@Override
public Stream<ResourceDescription> descriptions() {
return q.withTransaction(tx -> Stream.concat(
datasetDescriptions(tx),
sourceDatasetDescriptions(tx)));
}
private Stream<ResourceDescription> sourceDatasetDescriptions(Transaction tx) {
return fromNonPublishedSourceDataset(tx).list(
sourceDataset.metadataFileIdentification,
sourceDatasetVersion.metadataConfidential,
sourceDatasetVersion.revision).stream()
.map(tuple -> tupleToDatasetDescription(tuple, sourceDataset.metadataFileIdentification, false));
}
private Stream<ResourceDescription> datasetDescriptions(Transaction tx) {
return fromPublishedDataset(tx).list(
dataset.metadataFileIdentification,
sourceDatasetVersion.metadataConfidential,
sourceDatasetVersion.revision).stream()
.map(tuple -> tupleToDatasetDescription(tuple, dataset.metadataFileIdentification, true));
}
private ResourceDescription tupleToDatasetDescription(Tuple tuple, Expression<String> identificationExpression, boolean published) {
Timestamp createTime = tuple.get(sourceDatasetVersion.revision);
boolean confidential = tuple.get(sourceDatasetVersion.metadataConfidential);
return new DefaultResourceDescription(
getName(tuple.get(identificationExpression)),
new DefaultResourceProperties(
false,
createTime,
resourceProperties(confidential, published)));
}
@Override
public Optional<ResourceProperties> properties(String name) {
return getId(name).flatMap(id ->
q.withTransaction(tx -> {
Optional<ResourceProperties> optionalProperties = datasetProperties(id, tx);
if(optionalProperties.isPresent()) {
return optionalProperties;
} else {
return sourceDatasetProperties(id, tx);
}
}));
}
private Optional<ResourceProperties> sourceDatasetProperties(String id, Transaction tx) {
return tupleToDatasetProperties(
fromSourceDataset(tx).where(sourceDataset.metadataFileIdentification.eq(id)),
BooleanTemplate.FALSE);
}
private Optional<ResourceProperties> datasetProperties(String id, Transaction tx) {
return tupleToDatasetProperties(
fromDataset(tx).where(dataset.metadataFileIdentification.eq(id)),
isPublishedDataset());
}
private Optional<ResourceProperties> tupleToDatasetProperties(SQLQuery query, BooleanExpression isPublished) {
final BooleanExpression isPublishedAliased = isPublished.as("is_published");
return Optional.ofNullable(query
.singleResult(sourceDatasetVersion.revision, sourceDatasetVersion.metadataConfidential, isPublishedAliased))
.map(datasetTuple -> {
Timestamp createTime = datasetTuple.get(sourceDatasetVersion.revision);
boolean confidential = datasetTuple.get(sourceDatasetVersion.metadataConfidential);
return new DefaultResourceProperties(
false,
createTime,
resourceProperties(confidential, datasetTuple.get(isPublishedAliased)));
});
}
private Map<QName, String> resourceProperties(boolean confidential, boolean published) {
Map<QName, String> properties = new HashMap<QName, String>();
properties.put(new QName("http://idgis.nl/geopublisher", "confidential"), "" + confidential);
properties.put(new QName("http://idgis.nl/geopublisher", "published"), "" + published);
return properties;
}
}
|
package com.gdrivefs.test.cases;
import java.io.IOException;
import java.security.GeneralSecurityException;
import org.junit.Assert;
import org.junit.Test;
import com.gdrivefs.simplecache.File;
import com.gdrivefs.test.util.DriveBuilder;
public class TestCreateFile
{
@Test
public void testTrivial() throws IOException, GeneralSecurityException, InterruptedException
{
DriveBuilder builder = new DriveBuilder();
try
{
File test = builder.cleanDriveDirectory();
Assert.assertEquals(0, test.getChildren().size());
File noise = test.createFile("hello.txt");
Assert.assertEquals(1, test.getChildren().size());
noise.trash();
Assert.assertEquals(0, test.getChildren().size());
builder.flush();
Assert.assertEquals(0, test.getChildren().size());
test = builder.uncleanDriveDirectory();
test.refresh();
Assert.assertEquals(0, test.getChildren().size());
}
finally
{
builder.close();
}
}
@Test
public void testChangePersistence() throws IOException, GeneralSecurityException, InterruptedException
{
DriveBuilder builder = new DriveBuilder();
try
{
File test = builder.cleanDriveDirectory();
Assert.assertEquals(0, test.getChildren().size());
File noise = test.createFile("hello.txt");
Assert.assertEquals(1, test.getChildren().size());
builder.flush();
Assert.assertEquals(1, test.getChildren().size());
test = builder.uncleanDriveDirectory();
test.refresh();
Assert.assertEquals(1, test.getChildren().size());
}
finally
{
builder.close();
}
}
}
|
package com.opera.core.systems;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
public class OperaDriverTest extends TestBase
{
// Replace the TestBase setup and teardown so that we don't launch opera
@BeforeClass
public static void setUpBeforeClass() throws Exception {}
@AfterClass
public static void tearDownAfterClass() throws Exception {}
@Test
public void testWithoutSettingsObject()
{
driver = new TestOperaDriver();
Assert.assertNotNull(driver);
driver.shutdown();
}
@Test
public void testDefaultWindowCount()
{
driver = new TestOperaDriver();
Assert.assertTrue(driver.getWindowCount() == 1);
System.out.println("opera");
}
@Test
public void testGetWindowHandle()
{
driver.get("http://t/core/standards/dom0/link/pathname/002.html");
Assert.assertEquals("URL with explicit pathname and hash", driver.getWindowHandle());
}
@Test
public void testGetTitle()
{
Assert.assertEquals("URL with explicit pathname and hash", driver.getTitle());
}
@Test
public void testGetText()
{
driver.get("http://t/core/standards/quotes/none.html");
Assert.assertEquals("you should see nothing below", driver.findElementByTagName("body").getText().trim());
}
@Test
public void testGetURL()
{
driver.get("www.ebay.co.uk");
Assert.assertTrue(driver.getCurrentUrl().indexOf("www.ebay.co.uk") > 0);
}
@Test
public void testGetURL2()
{
driver.get("www.nyt.com", 15000);
Assert.assertTrue(driver.getCurrentUrl().indexOf("www.nytimes.com") > 0);
}
@Test
public void testOperaDriverShutdown()
{
// leave with a fast loading page
driver.get("about:blank");
driver.shutdown();
}
}
|
package at.sw2017.q_up;
import android.app.Activity;
import android.content.Intent;
import android.media.Rating;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.util.Calendar;
public class PlaceDetails extends Activity implements OnClickListener {
static String id, title;
static String user_id;
static String place_id;
static Place current_place;
private Bundle bundle;
private DatabaseHandler db_handle;
private String peopleinQ,Qtime;
private boolean decision ;
private Button ButtonLike;
private Button ButtonDislike;
private RatingBar ratingbar;
TextView peopleInQueue;
boolean QdUP;
Calendar cal;
int start;
int end;
int time;
TextView time_1;
private Intent intent;
ToggleButton ButtonQ;
public static Place getCurrentPlace() {
return current_place;
}
private void LikeDislike()
{
ButtonLike.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
db_handle.votePlacePositive(id);
ButtonLike.setEnabled(false);
ButtonDislike.setEnabled(false);
//ButtonLike.setVisibility(View.INVISIBLE);
}
});
ButtonDislike.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
db_handle.votePlaceNegative(id);
ButtonLike.setEnabled(false);
ButtonDislike.setEnabled(false);
}
});
}
private void Chat()
{
Button ButtonChat = (Button) findViewById(R.id.btn_chat);
ButtonChat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(PlaceDetails.this, ChatActivity.class);
startActivity(intent);
}
});
}
private void InfoButton()
{
Button ButtonInfo = (Button) findViewById(R.id.buttoninfo);
ButtonInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent = new Intent(PlaceDetails.this, InfoActivity.class);
intent.putExtra("title", title);
intent.putExtra("id", id);
startActivity(intent);
}
});
}
public void EvaluationOnTime()
{
Thread t = new Thread() {
@Override
public void run() {
try {
while (!isInterrupted()) {
Thread.sleep(10);
runOnUiThread(new Runnable() {
@Override
public void run() {
bundle = getIntent().getExtras();
db_handle = QUpApp.getInstance().getDBHandler();
Place place = db_handle.getPlaceFromId(id);
if (place != null)
{
TextView txtViewtitle = (TextView) findViewById(R.id.txtview_title);
TextView txtViewlike = (TextView) findViewById(R.id.txt_like);
TextView txtViewdislike = (TextView) findViewById(R.id.txt_dislike);
txtViewtitle.setText(place.placeName);
txtViewlike.setText(place.ratingPos);
txtViewdislike.setText(place.ratingNeg);
LikeDislike();
Chat();
getNumberOfUsers();
if(QdUP == true) {
ButtonLike.setVisibility(View.VISIBLE);
ButtonDislike.setVisibility(View.VISIBLE);
txtViewlike.setVisibility(View.VISIBLE);
txtViewdislike.setVisibility(View.VISIBLE);
ratingbar.setVisibility(View.GONE);
TextView txtViewNumberQUP = (TextView) findViewById(R.id.txtView_numberqup);
txtViewNumberQUP.setText("You are queued up");
}
else {
int like = Integer.valueOf(txtViewlike.getText().toString());
int dislike = Integer.valueOf(txtViewdislike.getText().toString());
float stern = (((float)like) / ((float)like+(float)dislike))*100;
ratingbar.setVisibility(View.VISIBLE);
if((int)stern >=90)
ratingbar.setRating(5);
else if((int)stern >=75)
ratingbar.setRating(4);
else if((int)stern >=60)
ratingbar.setRating(3);
else if((int)stern >=45)
ratingbar.setRating(2);
else if((int)stern >=30)
ratingbar.setRating(1);
else
ratingbar.setRating(0);
NumberQUP(db_handle.getQueuedUserCountFromPlace(id));
ButtonLike.setVisibility(View.GONE);
ButtonDislike.setVisibility(View.GONE);
txtViewlike.setVisibility(View.GONE);
txtViewdislike.setVisibility(View.GONE);
}
}
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
t.start();
}
public void NumberQUP(int number)
{
String text;
switch (number)
{
case 0:
text= "Be the first in the Q!";
break;
case 1:
text = "Be the second in the Q!";
break;
case 2:
text = "Be the third in the Q!";
break;
default:
text = "Be the " + Integer.toString(number+1) + "th in the Q!";
break;
}
TextView txtViewNumberQUP = (TextView) findViewById(R.id.txtView_numberqup);
txtViewNumberQUP.setText(text);
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_details);
QUpApp.getInstance().setCurrentActivity(this);
ButtonQ = (ToggleButton) findViewById(R.id.btn_qup);
ratingbar = (RatingBar)findViewById(R.id.ratingBar);
ratingbar.setFocusable(false);
peopleInQueue = (TextView)findViewById(R.id.UserNr);
time_1 = (TextView) findViewById(R.id.time8);
ButtonQ.setOnClickListener(this);
time_1.setText("");
decision = false;
// ButtonQ.setChecked(getDefaults("togglekey",this));
//setDefaults("togglekey",ButtonQ.isChecked(),this);
ButtonLike = (Button) findViewById(R.id.buttonlike);
ButtonDislike = (Button) findViewById(R.id.buttondislike);
TextView txtViewlike = (TextView) findViewById(R.id.txt_like);
TextView txtViewdislike = (TextView) findViewById(R.id.txt_dislike);
ButtonLike.setEnabled(false);
ButtonDislike.setEnabled(false);
ButtonLike.setVisibility(View.GONE);
ButtonDislike.setVisibility(View.GONE);
txtViewlike.setVisibility(View.GONE);
txtViewdislike.setVisibility(View.GONE);
start = 0;
end = 0;
time = 0;
EvaluationOnTime();
InfoButton();
getNumberOfUsers();
}
public void getNumberOfUsers()
{
bundle = getIntent().getExtras();
place_id = bundle.getString("id");
DatabaseHandler db_handle = QUpApp.getInstance().getDBHandler();
peopleinQ = "People in queue:" + Integer.toString(db_handle.getQueuedUserCountFromPlace(place_id));
peopleInQueue.setText(peopleinQ);
int timee = db_handle.getQueuedUserCountFromPlace(place_id)* db_handle.getPlaceAvgProcessingSecsFromId(place_id);
int Minutes = timee /60;
int Seconds = timee % 60;
Qtime = "Queue Time:" + Integer.toString(Minutes) + ":" + Integer.toString(Seconds);
time_1.setText(Qtime);
}
@Override
protected void onResume() {
super.onResume();
bundle = getIntent().getExtras();
id = bundle.getString("id");
db_handle = QUpApp.getInstance().getDBHandler();
current_place = db_handle.getPlaceFromId(id);
NumberQUP(db_handle.getQueuedUserCountFromPlace(id));
title = current_place.placeName;
}
/*
public static void setDefaults(String key,Boolean value,Context context)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(key,value);
editor.apply();
}
public static Boolean getDefaults(String key,Context context)
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
return preferences.getBoolean(key,true);
}
@Override
public void onStart(){
super.onStart();
ButtonQ.setChecked(getDefaults("togglekey",this));
DatabaseHandler db_handle = QUpApp.getInstance().getDBHandler();
String Username = (MainActivity.currentUser.userName);
db_handle.usersLock();
for (Place p : db_handle.getPlacesList()) {
p.placeId
Toast.makeText(getApplicationContext(),
p.idCheckInPlace, Toast.LENGTH_SHORT).show();
}
db_handle.usersUnlock();
}
@Override
public void onStop(){
super.onStop();
setDefaults("togglekey",ButtonQ.isChecked(),this);
}
*/
@Override
public void onClick(View v) {
ToggleButton clicked = (ToggleButton)v;
DatabaseHandler db_handle = QUpApp.getInstance().getDBHandler();
String Username = (MainActivity.currentUser.userName);
bundle = getIntent().getExtras();
place_id = bundle.getString("id");
//String text = (String) clicked.getText();
if(clicked.isChecked()) {
db_handle.usersLock();
for (User u : db_handle.getUsersList()) {
if (u.userName.equals(Username)) {
user_id = u.userId;
}
}
db_handle.usersUnlock();
db_handle.checkUserIntoPlace(user_id, place_id);
QdUP = true;
decision = true;
cal = Calendar.getInstance();
start = cal.get(Calendar.SECOND);
ButtonLike.setEnabled(true);
ButtonDislike.setEnabled(true);
time_1.setText("");
ButtonLike.setEnabled(true);
ButtonDislike.setEnabled(true);
}
else {
db_handle.checkOutOfPlace(user_id);
QdUP = false;
decision = false;
cal = Calendar.getInstance();
end = cal.get(Calendar.SECOND);
if(end < start)
{
end += 60;
time = end - start;
if(time < 0)
time = time * (-1);
// Qtime = "Queue Time:" + Integer.toString(time);
// time_1.setText(Qtime);
}
else
{
time = start - end;
if(time < 0)
time = time * (-1);
// Qtime = "Queue Time:" + Integer.toString(time);
//time_1.setText(Qtime);
}
}
}
@Override
public void onBackPressed() {
if (decision) {
Toast.makeText(getApplicationContext(),
"You have to exit the queue first !", Toast.LENGTH_SHORT).show();
} else {
super.onBackPressed(); // Process Back key default behavior.
}
}
}
|
package afc.ant.modular;
import junit.framework.TestCase;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Reference;
public class GetModulePathTest extends TestCase
{
private GetModulePath task;
private Project project;
@Override
protected void setUp()
{
task = new GetModulePath();
project = new Project();
task.setProject(project);
}
@Override
protected void tearDown()
{
project = null;
task = null;
}
public void testNoModuleRefId()
{
task.setOutputRefId("out");
try {
task.execute();
fail();
}
catch (BuildException ex)
{
assertEquals("The attribute 'moduleRefId' is undefined.", ex.getMessage());
}
assertEquals(null, project.getReference("out"));
}
public void testNoOutputRefId()
{
final Module module = new Module("foo");
project.addReference("in", module);
task.setModuleRefId(new Reference(project, "in"));
try {
task.execute();
fail();
}
catch (BuildException ex)
{
assertEquals("The attribute 'outputRefId' is undefined.", ex.getMessage());
}
assertSame(module, project.getReference("in"));
}
public void testNoModuleRef()
{
task.setModuleRefId(new Reference(project, "in"));
task.setOutputRefId("out");
try {
task.execute();
fail();
}
catch (BuildException ex)
{
assertEquals("Reference in not found.", ex.getMessage());
}
assertEquals(null, project.getReference("out"));
assertSame(null, project.getReference("in"));
}
public void testNoModuleUnderTheRef()
{
task.setModuleRefId(new Reference(project, "in")
{
@Override
public Object getReferencedObject()
{
return null;
}
});
task.setOutputRefId("out");
try {
task.execute();
fail();
}
catch (BuildException ex)
{
assertEquals("No module is found via the reference 'in'.", ex.getMessage());
}
assertEquals(null, project.getReference("out"));
assertSame(null, project.getReference("in"));
}
public void testInvalidModuleType()
{
final Object invalidModule = Integer.valueOf(0);
project.addReference("in", invalidModule);
task.setModuleRefId(new Reference(project, "in"));
task.setOutputRefId("out");
try {
task.execute();
fail();
}
catch (BuildException ex)
{
assertEquals("Invalid module type is found under the property 'in'. " +
"Expected: 'afc.ant.modular.Module', found: 'java.lang.Integer'.", ex.getMessage());
}
assertEquals(null, project.getReference("out"));
assertSame(invalidModule, project.getReference("in"));
}
public void testSuccessfulExecution()
{
final Module module = new Module("foo");
project.addReference("in", module);
task.setModuleRefId(new Reference(project, "in"));
task.setOutputRefId("out");
task.execute();
assertEquals("foo", project.getReference("out"));
assertSame(module, project.getReference("in"));
}
public void testOutputRefAlreadyDefined()
{
project.setProperty("out", "bar");
final Module module = new Module("foo");
project.addReference("in", module);
task.setModuleRefId(new Reference(project, "in"));
task.setOutputRefId("out");
task.execute();
assertSame("foo", project.getReference("out"));
assertSame(module, project.getReference("in"));
}
public void testNullModulePath() throws Exception
{
// This class loader loads the class afc.ant.modular.Module that returns null path.
final ModuleClassLoader cl = new ModuleClassLoader("test/data/GetModulePath/Module_null.class");
final Class<?> moduleClass = cl.loadClass(Module.class.getName());
final Object module = moduleClass.newInstance();
project.addReference("in", module);
task.setModuleRefId(new Reference(project, "in"));
task.setOutputRefId("out");
try {
task.execute();
fail();
}
catch (BuildException ex) {
assertEquals("The module path is undefined.", ex.getMessage());
}
assertNull(project.getReference("out"));
assertFalse(project.getReferences().containsKey("out"));
assertSame(module, project.getReference("in"));
}
public void testNullModulePath_OutputRefAlreadyDefined() throws Exception
{
project.addReference("out", "bar");
// This class loader loads the class afc.ant.modular.Module that returns null path.
final ModuleClassLoader cl = new ModuleClassLoader("test/data/GetModulePath/Module_null.class");
final Class<?> moduleClass = cl.loadClass(Module.class.getName());
final Object module = moduleClass.newInstance();
project.addReference("in", module);
task.setModuleRefId(new Reference(project, "in"));
task.setOutputRefId("out");
try {
task.execute();
fail();
}
catch (BuildException ex) {
assertEquals("The module path is undefined.", ex.getMessage());
}
assertSame("bar", project.getReference("out"));
assertSame(module, project.getReference("in"));
}
}
|
package wyc.builder;
import static wyc.lang.WhileyFile.internalFailure;
import static wyc.lang.WhileyFile.syntaxError;
import static wycc.lang.SyntaxError.internalFailure;
import static wycc.lang.SyntaxError.syntaxError;
import static wyil.util.ErrorMessages.*;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import wyautl_old.lang.Automata;
import wyautl_old.lang.Automaton;
import wybs.lang.*;
import wybs.util.*;
import wyc.lang.*;
import wyc.lang.WhileyFile.Context;
import wycc.lang.NameID;
import wycc.lang.SyntacticElement;
import wycc.lang.SyntaxError;
import wycc.util.Pair;
import wycc.util.ResolveError;
import wyfs.lang.Path;
import wyfs.util.Trie;
import wyil.lang.Constant;
import wyil.lang.Modifier;
import wyil.lang.Type;
import wyil.lang.WyilFile;
/**
* Propagates type information in a <i>flow-sensitive</i> fashion from declared
* parameter and return types through variable declarations and assigned
* expressions, to determine types for all intermediate expressions and
* variables. During this propagation, type checking is performed to ensure
* types are used soundly. For example:
*
* <pre>
* function sum([int] data) => int:
* int r = 0 // declared int type for r
* for v in data: // infers int type for v, based on type of data
* r = r + v // infers int type for r + v, based on type of operands
* return r // infers int type for return expression
* </pre>
*
* <p>
* The flow typing algorithm distinguishes between the <i>declared type</i> of a
* variable and its <i>known type</i>. That is, the known type at any given
* point is permitted to be more precise than the declared type (but not vice
* versa). For example:
* </p>
*
* <pre>
* function id(int x) => int:
* return x
*
* function f(int y) => int:
* int|null x = y
* f(x)
* </pre>
*
* <p>
* The above example is considered type safe because the known type of
* <code>x</code> at the function call is <code>int</code>, which differs from
* its declared type (i.e. <code>int|null</code>).
* </p>
*
* <p>
* Loops present an interesting challenge for type propagation. Consider this
* example:
* </p>
*
* <pre>
* function loopy(int max) => real:
* var i = 0
* while i < max:
* i = i + 0.5
* return i
* </pre>
*
* <p>
* On the first pass through the loop, variable <code>i</code> is inferred to
* have type <code>int</code> (based on the type of the constant <code>0</code>
* ). However, the add expression is inferred to have type <code>real</code>
* (based on the type of the rhs) and, hence, the resulting type inferred for
* <code>i</code> is <code>real</code>. At this point, the loop must be
* reconsidered taking into account this updated type for <code>i</code>.
* </p>
*
* <p>
* The operation of the flow type checker splits into two stages:
* </p>
* <ul>
* <li><b>Global Propagation.</b> During this stage, all named types are checked
* and expanded.</li>
* <li><b>Local Propagation.</b> During this stage, types are propagated through
* statements and expressions (as above).</li>
* </ul>
*
* <h3>References</h3>
* <ul>
* <li>
* <p>
* David J. Pearce and James Noble. Structural and Flow-Sensitive Types for
* Whiley. Technical Report, Victoria University of Wellington, 2010.
* </p>
* </li>
* </ul>
*
* @author David J. Pearce
*
*/
public class FlowTypeChecker {
private WhileyBuilder builder;
private String filename;
private WhileyFile.FunctionOrMethod current;
/**
* The constant cache contains a cache of expanded constant values. This is
* simply to prevent recomputing them every time.
*/
private final HashMap<NameID, Constant> constantCache = new HashMap<NameID, Constant>();
public FlowTypeChecker(WhileyBuilder builder) {
this.builder = builder;
}
// WhileyFile(s)
public void propagate(List<WhileyFile> files) {
for (WhileyFile wf : files) {
propagate(wf);
}
}
public void propagate(WhileyFile wf) {
this.filename = wf.filename;
for (WhileyFile.Declaration decl : wf.declarations) {
try {
if (decl instanceof WhileyFile.FunctionOrMethod) {
propagate((WhileyFile.FunctionOrMethod) decl);
} else if (decl instanceof WhileyFile.Type) {
propagate((WhileyFile.Type) decl);
} else if (decl instanceof WhileyFile.Constant) {
propagate((WhileyFile.Constant) decl);
}
} catch (ResolveError e) {
syntaxError(errorMessage(RESOLUTION_ERROR, e.getMessage()),
filename, decl, e);
} catch (SyntaxError e) {
throw e;
} catch (Throwable t) {
internalFailure(t.getMessage(), filename, decl, t);
}
}
}
// Declarations
/**
* Resolve types for a given type declaration. If an invariant expression is
* given, then we have to propagate and resolve types throughout the
* expression.
*
* @param td
* Type declaration to check.
* @throws IOException
*/
public void propagate(WhileyFile.Type td) throws IOException {
// First, resolve the declared syntactic type into the corresponding
// nominal type.
td.resolvedType = resolveAsType(td.pattern.toSyntacticType(), td);
if (td.invariant != null) {
// Second, an invariant expression is given, so propagate through
// that.
// Construct the appropriate typing environment
Environment environment = new Environment();
environment = addDeclaredVariables(td.pattern, environment, td);
// Propagate type information through the constraint
td.invariant = propagate(td.invariant, environment, td);
}
}
/**
* Propagate and check types for a given constant declaration.
*
* @param cd
* Constant declaration to check.
* @throws IOException
*/
public void propagate(WhileyFile.Constant cd) throws IOException, ResolveError {
NameID nid = new NameID(cd.file().module, cd.name());
cd.resolvedValue = resolveAsConstant(nid);
}
/**
* Propagate and check types for a given function or method declaration.
*
* @param fd
* Function or method declaration to check.
* @throws IOException
*/
public void propagate(WhileyFile.FunctionOrMethod d) throws IOException {
this.current = d; // ugly
Environment environment = new Environment();
// Resolve the types of all parameters and construct an appropriate
// environment for use in the flow-sensitive type propagation.
for (WhileyFile.Parameter p : d.parameters) {
environment = environment.declare(p.name, resolveAsType(p.type, d), resolveAsType(p.type, d));
}
// Resolve types for any preconditions (i.e. requires clauses) provided.
final List<Expr> d_requires = d.requires;
for (int i = 0; i != d_requires.size(); ++i) {
Expr condition = d_requires.get(i);
condition = propagate(condition, environment.clone(), d);
d_requires.set(i, condition);
}
// Resolve types for any postconditions (i.e. ensures clauses) provided.
final List<Expr> d_ensures = d.ensures;
if (d_ensures.size() > 0) {
// At least one ensures clause is provided; so, first, construct an
// appropriate environment from the initial one create.
Environment ensuresEnvironment = addDeclaredVariables(d.ret,
environment.clone(), d);
// Now, type check each ensures clause
for (int i = 0; i != d_ensures.size(); ++i) {
Expr condition = d_ensures.get(i);
condition = propagate(condition, ensuresEnvironment, d);
d_ensures.set(i, condition);
}
}
// Resolve the overall type for the function or method.
if (d instanceof WhileyFile.Function) {
WhileyFile.Function f = (WhileyFile.Function) d;
f.resolvedType = resolveAsType(f.unresolvedType(), d);
} else {
WhileyFile.Method m = (WhileyFile.Method) d;
m.resolvedType = resolveAsType(m.unresolvedType(), d);
}
// Finally, propagate type information throughout all statements in the
// function / method body.
propagate(d.statements, environment);
}
// Blocks & Statements
/**
* Propagate type information in a flow-sensitive fashion through a block of
* statements, whilst type checking each statement and expression.
*
* @param block
* Block of statements to flow sensitively type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(ArrayList<Stmt> block, Environment environment) {
for (int i = 0; i != block.size(); ++i) {
Stmt stmt = block.get(i);
if (stmt instanceof Expr) {
block.set(i,
(Stmt) propagate((Expr) stmt, environment, current));
} else {
environment = propagate(stmt, environment);
}
}
return environment;
}
/**
* Propagate type information in a flow-sensitive fashion through a given
* statement, whilst type checking it at the same time. For statements which
* contain other statements (e.g. if, while, etc), then this will
* recursively propagate type information through them as well.
*
*
* @param block
* Block of statements to flow-sensitively type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt stmt, Environment environment) {
try {
if (stmt instanceof Stmt.VariableDeclaration) {
return propagate((Stmt.VariableDeclaration) stmt, environment);
} else if (stmt instanceof Stmt.Assign) {
return propagate((Stmt.Assign) stmt, environment);
} else if (stmt instanceof Stmt.Return) {
return propagate((Stmt.Return) stmt, environment);
} else if (stmt instanceof Stmt.IfElse) {
return propagate((Stmt.IfElse) stmt, environment);
} else if (stmt instanceof Stmt.While) {
return propagate((Stmt.While) stmt, environment);
} else if (stmt instanceof Stmt.ForAll) {
return propagate((Stmt.ForAll) stmt, environment);
} else if (stmt instanceof Stmt.Switch) {
return propagate((Stmt.Switch) stmt, environment);
} else if (stmt instanceof Stmt.DoWhile) {
return propagate((Stmt.DoWhile) stmt, environment);
} else if (stmt instanceof Stmt.Break) {
return propagate((Stmt.Break) stmt, environment);
} else if (stmt instanceof Stmt.Throw) {
return propagate((Stmt.Throw) stmt, environment);
} else if (stmt instanceof Stmt.TryCatch) {
return propagate((Stmt.TryCatch) stmt, environment);
} else if (stmt instanceof Stmt.Assert) {
return propagate((Stmt.Assert) stmt, environment);
} else if (stmt instanceof Stmt.Assume) {
return propagate((Stmt.Assume) stmt, environment);
} else if (stmt instanceof Stmt.Debug) {
return propagate((Stmt.Debug) stmt, environment);
} else if (stmt instanceof Stmt.Skip) {
return propagate((Stmt.Skip) stmt, environment);
} else {
internalFailure("unknown statement: "
+ stmt.getClass().getName(), filename, stmt);
return null; // deadcode
}
} catch (ResolveError e) {
syntaxError(errorMessage(RESOLUTION_ERROR, e.getMessage()),
filename, stmt, e);
return null; // dead code
} catch (SyntaxError e) {
throw e;
} catch (Throwable e) {
internalFailure(e.getMessage(), filename, stmt, e);
return null; // dead code
}
}
/**
* Type check an assertion statement. This requires checking that the
* expression being asserted is well-formed and has boolean type.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Assert stmt, Environment environment) {
stmt.expr = propagate(stmt.expr, environment, current);
checkIsSubtype(Type.T_BOOL, stmt.expr);
return environment;
}
/**
* Type check an assume statement. This requires checking that the
* expression being asserted is well-formed and has boolean type.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Assume stmt, Environment environment) {
stmt.expr = propagate(stmt.expr, environment, current);
checkIsSubtype(Type.T_BOOL, stmt.expr);
return environment;
}
/**
* Type check a variable declaration statement. This must associate the
* given variable with either its declared and actual type in the
* environment. If no initialiser is given, then the actual type is the void
* (since the variable is not yet defined). Otherwise, the actual type is
* the type of the initialiser expression. Additionally, when an initialiser
* is given we must check it is well-formed and that it is a subtype of the
* declared type.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.VariableDeclaration stmt,
Environment environment) throws IOException {
// First, resolve declared type
stmt.type = resolveAsType(stmt.pattern.toSyntacticType(), current);
// First, resolve type of initialiser
if (stmt.expr != null) {
stmt.expr = propagate(stmt.expr, environment, current);
checkIsSubtype(stmt.type, stmt.expr);
}
// Second, update environment accordingly. Observe that we can safely
// assume any variable(s) are not already declared in the enclosing
// scope because the parser checks this for us.
environment = addDeclaredVariables(stmt.pattern, environment, current);
// Done.
return environment;
}
/**
* Type check an assignment statement.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Assign stmt, Environment environment)
throws IOException, ResolveError {
Expr.LVal lhs = propagate(stmt.lhs, environment);
Expr rhs = propagate(stmt.rhs, environment, current);
if (lhs instanceof Expr.RationalLVal) {
// represents a destructuring assignment
Expr.RationalLVal tv = (Expr.RationalLVal) lhs;
Pair<Expr.AssignedVariable, Expr.AssignedVariable> avs = inferAfterType(
tv, rhs);
environment = environment.update(avs.first().var,
avs.first().afterType);
environment = environment.update(avs.second().var,
avs.second().afterType);
} else if (lhs instanceof Expr.Tuple) {
// represents a destructuring assignment
Expr.Tuple tv = (Expr.Tuple) lhs;
List<Expr.AssignedVariable> as = inferAfterType(tv, rhs);
for (Expr.AssignedVariable av : as) {
environment = environment.update(av.var, av.afterType);
}
} else {
// represents element or field update
Expr.AssignedVariable av = inferAfterType(lhs, rhs.result());
environment = environment.update(av.var, av.afterType);
}
stmt.lhs = (Expr.LVal) lhs;
stmt.rhs = rhs;
return environment;
}
private Pair<Expr.AssignedVariable, Expr.AssignedVariable> inferAfterType(
Expr.RationalLVal tv, Expr rhs) throws IOException {
Nominal afterType = rhs.result();
if (!Type.isImplicitCoerciveSubtype(Type.T_REAL, afterType.raw())) {
syntaxError("real value expected, got " + afterType, filename, rhs);
}
if (tv.numerator instanceof Expr.AssignedVariable
&& tv.denominator instanceof Expr.AssignedVariable) {
Expr.AssignedVariable lv = (Expr.AssignedVariable) tv.numerator;
Expr.AssignedVariable rv = (Expr.AssignedVariable) tv.denominator;
lv.type = Nominal.T_VOID;
rv.type = Nominal.T_VOID;
lv.afterType = Nominal.T_INT;
rv.afterType = Nominal.T_INT;
return new Pair<Expr.AssignedVariable, Expr.AssignedVariable>(lv,
rv);
} else {
syntaxError(errorMessage(INVALID_TUPLE_LVAL), filename, tv);
return null; // dead code
}
}
private List<Expr.AssignedVariable> inferAfterType(Expr.Tuple lv, Expr rhs)
throws IOException, ResolveError {
Nominal afterType = rhs.result();
// First, check that the rhs is a subtype of the lhs
checkIsSubtype(lv.type, afterType, rhs);
Nominal.EffectiveTuple rhsType = expandAsEffectiveTuple(afterType);
// Second, construct the list of assigned variables
ArrayList<Expr.AssignedVariable> rs = new ArrayList<Expr.AssignedVariable>();
for (int i = 0; i != rhsType.elements().size(); ++i) {
Expr element = lv.fields.get(i);
if (element instanceof Expr.LVal) {
rs.add(inferAfterType((Expr.LVal) element, rhsType.element(i)));
} else {
syntaxError(errorMessage(INVALID_TUPLE_LVAL), filename, element);
}
}
// done
return rs;
}
private Expr.AssignedVariable inferAfterType(Expr.LVal lv, Nominal afterType) {
if (lv instanceof Expr.AssignedVariable) {
Expr.AssignedVariable v = (Expr.AssignedVariable) lv;
v.afterType = afterType;
return v;
} else if (lv instanceof Expr.Dereference) {
Expr.Dereference pa = (Expr.Dereference) lv;
// The before and after types are the same since an assignment
// through a reference does not change its type.
checkIsSubtype(pa.srcType, Nominal.Reference(afterType), lv);
return inferAfterType((Expr.LVal) pa.src, pa.srcType);
} else if (lv instanceof Expr.IndexOf) {
Expr.IndexOf la = (Expr.IndexOf) lv;
Nominal.EffectiveIndexible srcType = la.srcType;
afterType = (Nominal) srcType.update(la.index.result(), afterType);
return inferAfterType((Expr.LVal) la.src, afterType);
} else if (lv instanceof Expr.FieldAccess) {
Expr.FieldAccess la = (Expr.FieldAccess) lv;
Nominal.EffectiveRecord srcType = la.srcType;
// I know I can modify this hash map, since it's created fresh
// in Nominal.Record.fields().
afterType = (Nominal) srcType.update(la.name, afterType);
return inferAfterType((Expr.LVal) la.src, afterType);
} else {
internalFailure("unknown lval: " + lv.getClass().getName(),
filename, lv);
return null; // deadcode
}
}
/**
* Type check a break statement. This requires propagating the current
* environment to the block destination, to ensure that the actual types of
* all variables at that point are precise.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Break stmt, Environment environment) {
// FIXME: need to propagate environment to the break destination
return BOTTOM;
}
/**
* Type check an assume statement. This requires checking that the
* expression being printed is well-formed and has string type.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Debug stmt, Environment environment) {
stmt.expr = propagate(stmt.expr, environment, current);
checkIsSubtype(Type.T_STRING, stmt.expr);
return environment;
}
/**
* Type check a do-while statement.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.DoWhile stmt, Environment environment) {
// Iterate to a fixed point
Environment old = null;
Environment tmp = null;
Environment orig = environment.clone();
boolean firstTime = true;
do {
old = environment.clone();
if (!firstTime) {
// don't do this on the first go around, to mimick how the
// do-while loop works.
tmp = propagateCondition(stmt.condition, true, old.clone(),
current).second();
environment = join(orig.clone(), propagate(stmt.body, tmp));
} else {
firstTime = false;
environment = join(orig.clone(), propagate(stmt.body, old));
}
old.free(); // hacky, but safe
} while (!environment.equals(old));
List<Expr> stmt_invariants = stmt.invariants;
for (int i = 0; i != stmt_invariants.size(); ++i) {
Expr invariant = stmt_invariants.get(i);
invariant = propagate(invariant, environment, current);
stmt_invariants.set(i, invariant);
checkIsSubtype(Type.T_BOOL, invariant);
}
Pair<Expr, Environment> p = propagateCondition(stmt.condition, false,
environment, current);
stmt.condition = p.first();
environment = p.second();
return environment;
}
/**
* Type check a <code>for</code> statement.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.ForAll stmt, Environment environment)
throws IOException, ResolveError {
stmt.source = propagate(stmt.source, environment, current);
Nominal.EffectiveCollection srcType = expandAsEffectiveCollection(stmt.source
.result());
stmt.srcType = srcType;
if (srcType == null) {
syntaxError(errorMessage(INVALID_SET_OR_LIST_EXPRESSION), filename,
stmt);
}
// At this point, the major task is to determine what the types for the
// iteration variables declared in the for loop. More than one variable
// is permitted in some cases.
Nominal[] elementTypes = new Nominal[stmt.variables.size()];
if (elementTypes.length == 2 && srcType instanceof Nominal.EffectiveMap) {
Nominal.EffectiveMap dt = (Nominal.EffectiveMap) srcType;
elementTypes[0] = dt.key();
elementTypes[1] = dt.value();
} else {
if (elementTypes.length == 1) {
elementTypes[0] = srcType.element();
} else {
syntaxError(errorMessage(VARIABLE_POSSIBLY_UNITIALISED),
filename, stmt);
}
}
// Now, update the environment to include those declared variables
ArrayList<String> stmtVariables = stmt.variables;
for (int i = 0; i != elementTypes.length; ++i) {
String var = stmtVariables.get(i);
if (environment.containsKey(var)) {
syntaxError(errorMessage(VARIABLE_ALREADY_DEFINED, var),
filename, stmt);
}
environment = environment.declare(var, elementTypes[i], elementTypes[i]);
}
// Iterate to a fixed point
Environment old = null;
Environment orig = environment.clone();
do {
old = environment.clone();
environment = join(orig.clone(), propagate(stmt.body, old));
old.free(); // hacky, but safe
} while (!environment.equals(old));
// Remove loop variables from the environment, since they are only
// declared for the duration of the body but not beyond.
for (int i = 0; i != elementTypes.length; ++i) {
String var = stmtVariables.get(i);
environment = environment.remove(var);
}
if (stmt.invariant != null) {
stmt.invariant = propagate(stmt.invariant, environment, current);
checkIsSubtype(Type.T_BOOL, stmt.invariant);
}
return environment;
}
private Environment propagate(Stmt.IfElse stmt, Environment environment) {
// First, check condition and apply variable retypings.
Pair<Expr, Environment> p1, p2;
p1 = propagateCondition(stmt.condition, true, environment.clone(),
current);
p2 = propagateCondition(stmt.condition, false, environment, current);
stmt.condition = p1.first();
Environment trueEnvironment = p1.second();
Environment falseEnvironment = p2.second();
// Second, update environments for true and false branches
if (stmt.trueBranch != null && stmt.falseBranch != null) {
trueEnvironment = propagate(stmt.trueBranch, trueEnvironment);
falseEnvironment = propagate(stmt.falseBranch, falseEnvironment);
} else if (stmt.trueBranch != null) {
trueEnvironment = propagate(stmt.trueBranch, trueEnvironment);
} else if (stmt.falseBranch != null) {
trueEnvironment = environment;
falseEnvironment = propagate(stmt.falseBranch, falseEnvironment);
}
// Finally, join results back together
return join(trueEnvironment, falseEnvironment);
}
/**
* Type check a <code>return</code> statement. If a return expression is
* given, then we must check that this is well-formed and is a subtype of
* the enclosing function or method's declared return type. The environment
* after a return statement is "bottom" because that represents an
* unreachable program point.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Return stmt, Environment environment)
throws IOException {
if (stmt.expr != null) {
stmt.expr = propagate(stmt.expr, environment, current);
Nominal rhs = stmt.expr.result();
checkIsSubtype(current.resolvedType().ret(), rhs, stmt.expr);
}
environment.free();
return BOTTOM;
}
/**
* Type check a <code>skip</code> statement, which has no effect on the
* environment.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Skip stmt, Environment environment) {
return environment;
}
private Environment propagate(Stmt.Switch stmt, Environment environment)
throws IOException {
stmt.expr = propagate(stmt.expr, environment, current);
Environment finalEnv = null;
boolean hasDefault = false;
for (Stmt.Case c : stmt.cases) {
// first, resolve the constants
ArrayList<Constant> values = new ArrayList<Constant>();
for (Expr e : c.expr) {
values.add(resolveAsConstant(e, current));
}
c.constants = values;
// second, propagate through the statements
Environment localEnv = environment.clone();
localEnv = propagate(c.stmts, localEnv);
if (finalEnv == null) {
finalEnv = localEnv;
} else {
finalEnv = join(finalEnv, localEnv);
}
// third, keep track of whether a default
hasDefault |= c.expr.isEmpty();
}
if (!hasDefault) {
// in this case, there is no default case in the switch. We must
// therefore assume that there are values which will fall right
// through the switch statement without hitting a case. Therefore,
// we must include the original environment to accound for this.
finalEnv = join(finalEnv, environment);
} else {
environment.free();
}
return finalEnv;
}
/**
* Type check a <code>throw</code> statement. We must check that the throw
* expression is well-formed. The environment after a throw statement is
* "bottom" because that represents an unreachable program point.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.Throw stmt, Environment environment) {
stmt.expr = propagate(stmt.expr, environment, current);
return BOTTOM;
}
/**
* Type check a try-catch statement.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.TryCatch stmt, Environment environment)
throws IOException {
for (Stmt.Catch handler : stmt.catches) {
// FIXME: need to deal with handler environments properly!
try {
Nominal type = resolveAsType(handler.unresolvedType, current);
handler.type = type;
Environment local = environment.clone();
local = local.declare(handler.variable, type, type);
propagate(handler.stmts, local);
local.free();
} catch (SyntaxError e) {
throw e;
} catch (Throwable t) {
internalFailure(t.getMessage(), filename, handler, t);
}
}
environment = propagate(stmt.body, environment);
// need to do handlers here
return environment;
}
/**
* Type check a <code>whiley</code> statement.
*
* @param stmt
* Statement to type check
* @param environment
* Determines the type of all variables immediately going into
* this block
* @return
*/
private Environment propagate(Stmt.While stmt, Environment environment) {
// Iterate to a fixed point
Environment old = null;
Environment tmp = null;
Environment orig = environment.clone();
do {
old = environment.clone();
tmp = propagateCondition(stmt.condition, true, old.clone(), current)
.second();
environment = join(orig.clone(), propagate(stmt.body, tmp));
old.free(); // hacky, but safe
} while (!environment.equals(old));
List<Expr> stmt_invariants = stmt.invariants;
for (int i = 0; i != stmt_invariants.size(); ++i) {
Expr invariant = stmt_invariants.get(i);
invariant = propagate(invariant, environment, current);
stmt_invariants.set(i, invariant);
checkIsSubtype(Type.T_BOOL, invariant);
}
Pair<Expr, Environment> p = propagateCondition(stmt.condition, false,
environment, current);
stmt.condition = p.first();
environment = p.second();
return environment;
}
// LVals
private Expr.LVal propagate(Expr.LVal lval, Environment environment) {
try {
if (lval instanceof Expr.AbstractVariable) {
Expr.AbstractVariable av = (Expr.AbstractVariable) lval;
Nominal p = environment.getCurrentType(av.var);
if (p == null) {
syntaxError(errorMessage(UNKNOWN_VARIABLE), filename, lval);
}
Expr.AssignedVariable lv = new Expr.AssignedVariable(av.var,
av.attributes());
lv.type = p;
return lv;
} else if (lval instanceof Expr.RationalLVal) {
Expr.RationalLVal av = (Expr.RationalLVal) lval;
av.numerator = propagate(av.numerator, environment);
av.denominator = propagate(av.denominator, environment);
return av;
} else if (lval instanceof Expr.Dereference) {
Expr.Dereference pa = (Expr.Dereference) lval;
Expr.LVal src = propagate((Expr.LVal) pa.src, environment);
pa.src = src;
pa.srcType = expandAsReference(src.result());
return pa;
} else if (lval instanceof Expr.IndexOf) {
// this indicates either a list, string or dictionary update
Expr.IndexOf ai = (Expr.IndexOf) lval;
Expr.LVal src = propagate((Expr.LVal) ai.src, environment);
Expr index = propagate(ai.index, environment, current);
ai.src = src;
ai.index = index;
Nominal.EffectiveIndexible srcType = expandAsEffectiveMap(src
.result());
if (srcType == null) {
syntaxError(errorMessage(INVALID_LVAL_EXPRESSION),
filename, lval);
}
ai.srcType = srcType;
return ai;
} else if (lval instanceof Expr.FieldAccess) {
// this indicates a record update
Expr.FieldAccess ad = (Expr.FieldAccess) lval;
Expr.LVal src = propagate((Expr.LVal) ad.src, environment);
Expr.FieldAccess ra = new Expr.FieldAccess(src, ad.name,
ad.attributes());
Nominal.EffectiveRecord srcType = expandAsEffectiveRecord(src
.result());
if (srcType == null) {
syntaxError(errorMessage(INVALID_LVAL_EXPRESSION),
filename, lval);
} else if (srcType.field(ra.name) == null) {
syntaxError(errorMessage(RECORD_MISSING_FIELD, ra.name),
filename, lval);
}
ra.srcType = srcType;
return ra;
} else if (lval instanceof Expr.Tuple) {
// this indicates a tuple update
Expr.Tuple tup = (Expr.Tuple) lval;
ArrayList<Nominal> elements = new ArrayList<Nominal>();
for (int i = 0; i != tup.fields.size(); ++i) {
Expr element = tup.fields.get(i);
if (element instanceof Expr.LVal) {
element = propagate((Expr.LVal) element, environment);
tup.fields.set(i, element);
elements.add(element.result());
} else {
syntaxError(errorMessage(INVALID_LVAL_EXPRESSION),
filename, lval);
}
}
tup.type = Nominal.Tuple(elements);
return tup;
}
} catch (SyntaxError e) {
throw e;
} catch (Throwable e) {
internalFailure(e.getMessage(), filename, lval, e);
return null; // dead code
}
internalFailure("unknown lval: " + lval.getClass().getName(), filename,
lval);
return null; // dead code
}
/**
* The purpose of this method is to add variable names declared within a
* type pattern to the given environment. For example, as follows:
*
* <pre>
* define tup as {int x, int y} where x < y
* </pre>
*
* In this case, <code>x</code> and <code>y</code> are variable names
* declared as part of the pattern.
*
* <p>
* Note, variables are both declared and initialised with the given type. In
* some cases (e.g. parameters), this makes sense. In other cases (e.g.
* local variable declarations), it does not. In the latter, the variable
* should then be updated with an appropriate type.
* </p>
*
* @param src
* @param t
* @param environment
*/
private Environment addDeclaredVariables(TypePattern pattern,
Environment environment, WhileyFile.Context context) {
if (pattern instanceof TypePattern.Union) {
// FIXME: in principle, we can do better here. However, I leave this
// unusual case for the future.
} else if (pattern instanceof TypePattern.Intersection) {
// FIXME: in principle, we can do better here. However, I leave this
// unusual case for the future.
} else if (pattern instanceof TypePattern.Rational) {
TypePattern.Rational tp = (TypePattern.Rational) pattern;
environment = addDeclaredVariables(tp.numerator, environment,
context);
environment = addDeclaredVariables(tp.denominator, environment,
context);
} else if (pattern instanceof TypePattern.Record) {
TypePattern.Record tp = (TypePattern.Record) pattern;
for (TypePattern element : tp.elements) {
environment = addDeclaredVariables(element, environment,
context);
}
} else if (pattern instanceof TypePattern.Tuple) {
TypePattern.Tuple tp = (TypePattern.Tuple) pattern;
for (TypePattern element : tp.elements) {
environment = addDeclaredVariables(element, environment,
context);
}
} else {
TypePattern.Leaf lp = (TypePattern.Leaf) pattern;
if (lp.var != null) {
Nominal type = resolveAsType(pattern.toSyntacticType(), context);
environment = environment.declare(lp.var.var, type, type);
}
}
return environment;
}
// Condition
/**
* <p>
* Propagate type information through an expression being used as a
* condition, whilst checking it is well-typed at the same time. When used
* as a condition (e.g. of an if-statement) an expression may update the
* environment in accordance with any type tests used within. This is
* important to ensure that variables are retyped in e.g. if-statements. For
* example:
* </p>
*
* <pre>
* if x is int && x >= 0
* // x is int
* else:
* //
* </pre>
* <p>
* Here, the if-condition must update the type of x in the true branch, but
* *cannot* update the type of x in the false branch.
* </p>
* <p>
* To handle conditions on the false branch, this function uses a sign flag
* rather than expanding them using DeMorgan's laws (for efficiency). When
* determining type for the false branch, the sign flag is initially false.
* This prevents falsely concluding that e.g. "x is int" holds in the false
* branch.
* </p>
*
* @param expr
* Condition expression to type check and propagate through
* @param sign
* Indicates how expression should be treated. If true, then
* expression is treated "as is"; if false, then expression
* should be treated as negated
* @param environment
* Determines the type of all variables immediately going into
* this expression
* @param context
* Enclosing context of this expression (e.g. type declaration,
* function declaration, etc)
* @return
*/
public Pair<Expr, Environment> propagateCondition(Expr expr, boolean sign,
Environment environment, Context context) {
// Split up into the compound and non-compound forms.
if (expr instanceof Expr.UnOp) {
return propagateCondition((Expr.UnOp) expr, sign, environment,
context);
} else if (expr instanceof Expr.BinOp) {
return propagateCondition((Expr.BinOp) expr, sign, environment,
context);
} else {
// For non-compound forms, can just default back to the base rules
// for general expressions.
expr = propagate(expr, environment, context);
checkIsSubtype(Type.T_BOOL, expr, context);
return new Pair<Expr, Environment>(expr, environment);
}
}
/**
* <p>
* Propagate type information through a unary expression being used as a
* condition and, in fact, only logical not is syntactically valid here.
* </p>
*
* @param expr
* Condition expression to type check and propagate through
* @param sign
* Indicates how expression should be treated. If true, then
* expression is treated "as is"; if false, then expression
* should be treated as negated
* @param environment
* Determines the type of all variables immediately going into
* this expression
* @param context
* Enclosing context of this expression (e.g. type declaration,
* function declaration, etc)
* @return
*/
private Pair<Expr, Environment> propagateCondition(Expr.UnOp expr,
boolean sign, Environment environment, Context context) {
Expr.UnOp uop = (Expr.UnOp) expr;
// Check whether we have logical not
if (uop.op == Expr.UOp.NOT) {
Pair<Expr, Environment> p = propagateCondition(uop.mhs, !sign,
environment, context);
uop.mhs = p.first();
checkIsSubtype(Type.T_BOOL, uop.mhs, context);
uop.type = Nominal.T_BOOL;
return new Pair(uop, p.second());
} else {
// Nothing else other than logical not is valid at this point.
syntaxError(errorMessage(INVALID_BOOLEAN_EXPRESSION), context, expr);
return null; // deadcode
}
}
/**
* <p>
* Propagate type information through a binary expression being used as a
* condition. In this case, only logical connectives ("&&", "||", "^") and
* comparators (e.g. "==", "<=", etc) are permitted here.
* </p>
*
* @param expr
* Condition expression to type check and propagate through
* @param sign
* Indicates how expression should be treated. If true, then
* expression is treated "as is"; if false, then expression
* should be treated as negated
* @param environment
* Determines the type of all variables immediately going into
* this expression
* @param context
* Enclosing context of this expression (e.g. type declaration,
* function declaration, etc)
* @return
*/
private Pair<Expr, Environment> propagateCondition(Expr.BinOp bop,
boolean sign, Environment environment, Context context) {
Expr.BOp op = bop.op;
// Split into the two broard cases: logical connectives and primitives.
switch (op) {
case AND:
case OR:
case XOR:
return resolveNonLeafCondition(bop, sign, environment, context);
case EQ:
case NEQ:
case LT:
case LTEQ:
case GT:
case GTEQ:
case ELEMENTOF:
case SUBSET:
case SUBSETEQ:
case IS:
return resolveLeafCondition(bop, sign, environment, context);
default:
syntaxError(errorMessage(INVALID_BOOLEAN_EXPRESSION), context, bop);
return null; // dead code
}
}
/**
* <p>
* Propagate type information through a binary expression being used as a
* logical connective ("&&", "||", "^").
* </p>
*
* @param bop
* Binary operator for this expression.
* @param sign
* Indicates how expression should be treated. If true, then
* expression is treated "as is"; if false, then expression
* should be treated as negated
* @param environment
* Determines the type of all variables immediately going into
* this expression
* @param context
* Enclosing context of this expression (e.g. type declaration,
* function declaration, etc)
* @return
*/
private Pair<Expr, Environment> resolveNonLeafCondition(Expr.BinOp bop,
boolean sign, Environment environment, Context context) {
Expr.BOp op = bop.op;
Pair<Expr, Environment> p;
boolean followOn = (sign && op == Expr.BOp.AND)
|| (!sign && op == Expr.BOp.OR);
if (followOn) {
// In this case, the environment feeds directly from the result of
// propagating through the lhs into the rhs, and then into the
// result of this expression. This means that updates to the
// environment by either the lhs or rhs are visible outside of this
// method.
p = propagateCondition(bop.lhs, sign, environment.clone(), context);
bop.lhs = p.first();
p = propagateCondition(bop.rhs, sign, p.second(), context);
bop.rhs = p.first();
environment = p.second();
} else {
// We could do better here
p = propagateCondition(bop.lhs, sign, environment.clone(), context);
bop.lhs = p.first();
Environment local = p.second();
// Recompute the lhs assuming that it is false. This is necessary to
// generate the right environment going into the rhs, which is only
// evaluated if the lhs is false. For example:
// if(e is int && e > 0):
// else:
// In the false branch, we're determing the environment for
// !(e is int && e > 0). This becomes !(e is int) || (e <= 0) where
// on the rhs we require (e is int).
p = propagateCondition(bop.lhs, !sign, environment.clone(), context);
// Note, the following is intentional since we're specifically
// considering the case where the lhs was false, and this case is
// true.
p = propagateCondition(bop.rhs, sign, p.second(), context);
bop.rhs = p.first();
environment = join(local, p.second());
}
checkIsSubtype(Type.T_BOOL, bop.lhs, context);
checkIsSubtype(Type.T_BOOL, bop.rhs, context);
bop.srcType = Nominal.T_BOOL;
return new Pair<Expr, Environment>(bop, environment);
}
/**
* <p>
* Propagate type information through a binary expression being used as a
* comparators (e.g. "==", "<=", etc).
* </p>
*
* @param bop
* Binary operator for this expression.
* @param sign
* Indicates how expression should be treated. If true, then
* expression is treated "as is"; if false, then expression
* should be treated as negated
* @param environment
* Determines the type of all variables immediately going into
* this expression
* @param context
* Enclosing context of this expression (e.g. type declaration,
* function declaration, etc)
* @return
*/
private Pair<Expr, Environment> resolveLeafCondition(Expr.BinOp bop,
boolean sign, Environment environment, Context context) {
Expr.BOp op = bop.op;
Expr lhs = propagate(bop.lhs, environment, context);
Expr rhs = propagate(bop.rhs, environment, context);
bop.lhs = lhs;
bop.rhs = rhs;
Type lhsRawType = lhs.result().raw();
Type rhsRawType = rhs.result().raw();
switch (op) {
case IS:
// this one is slightly more difficult. In the special case that
// we have a type constant on the right-hand side then we want
// to check that it makes sense. Otherwise, we just check that
// it has type meta.
if (rhs instanceof Expr.TypeVal) {
// yes, right-hand side is a constant
Expr.TypeVal tv = (Expr.TypeVal) rhs;
Nominal unconstrainedTestType = resolveAsUnconstrainedType(
tv.unresolvedType, context);
/**
* Determine the types guaranteed to hold on the true and false
* branches respectively. We have to use the negated
* unconstrainedTestType for the false branch because only that
* is guaranteed if the test fails. For example:
*
* <pre>
* define nat as int where $ >= 0
* define listnat as [int]|nat
*
* int f([int]|int x):
* if x if listnat:
* x : [int]|int
* ...
* else:
* x : int
* </pre>
*
* The unconstrained type of listnat is [int], since nat is a
* constrained type.
*/
Nominal glbForFalseBranch = Nominal.intersect(lhs.result(),
Nominal.Negation(unconstrainedTestType));
Nominal glbForTrueBranch = Nominal.intersect(lhs.result(),
tv.type);
if (glbForFalseBranch.raw() == Type.T_VOID) {
// DEFINITE TRUE CASE
syntaxError(errorMessage(BRANCH_ALWAYS_TAKEN), context, bop);
} else if (glbForTrueBranch.raw() == Type.T_VOID) {
// DEFINITE FALSE CASE
syntaxError(
errorMessage(INCOMPARABLE_OPERANDS, lhsRawType,
tv.type.raw()), context, bop);
}
// Finally, if the lhs is local variable then update its
// type in the resulting environment.
if (lhs instanceof Expr.LocalVariable) {
Expr.LocalVariable lv = (Expr.LocalVariable) lhs;
Nominal newType;
if (sign) {
newType = glbForTrueBranch;
} else {
newType = glbForFalseBranch;
}
environment = environment.update(lv.var, newType);
}
} else {
// In this case, we can't update the type of the lhs since
// we don't know anything about the rhs. It may be possible
// to support bounds here in order to do that, but frankly
// that's future work :)
checkIsSubtype(Type.T_META, rhs, context);
}
bop.srcType = lhs.result();
break;
case ELEMENTOF:
Type.EffectiveList listType = rhsRawType instanceof Type.EffectiveList ? (Type.EffectiveList) rhsRawType
: null;
Type.EffectiveSet setType = rhsRawType instanceof Type.EffectiveSet ? (Type.EffectiveSet) rhsRawType
: null;
if (listType != null
&& !Type.isImplicitCoerciveSubtype(listType.element(),
lhsRawType)) {
syntaxError(
errorMessage(INCOMPARABLE_OPERANDS, lhsRawType,
listType.element()), context, bop);
} else if (setType != null
&& !Type.isImplicitCoerciveSubtype(setType.element(),
lhsRawType)) {
syntaxError(
errorMessage(INCOMPARABLE_OPERANDS, lhsRawType,
setType.element()), context, bop);
}
bop.srcType = rhs.result();
break;
case SUBSET:
case SUBSETEQ:
case LT:
case LTEQ:
case GTEQ:
case GT:
if (op == Expr.BOp.SUBSET || op == Expr.BOp.SUBSETEQ) {
checkIsSubtype(Type.T_SET_ANY, lhs, context);
checkIsSubtype(Type.T_SET_ANY, rhs, context);
} else {
checkIsSubtype(Type.T_REAL, lhs, context);
checkIsSubtype(Type.T_REAL, rhs, context);
}
if (Type.isImplicitCoerciveSubtype(lhsRawType, rhsRawType)) {
bop.srcType = lhs.result();
} else if (Type.isImplicitCoerciveSubtype(rhsRawType, lhsRawType)) {
bop.srcType = rhs.result();
} else {
syntaxError(
errorMessage(INCOMPARABLE_OPERANDS, lhsRawType,
rhsRawType), context, bop);
return null; // dead code
}
break;
case NEQ:
// following is a sneaky trick for the special case below
sign = !sign;
case EQ:
// first, check for special case of e.g. x != null. This is then
// treated the same as !(x is null)
if (lhs instanceof Expr.LocalVariable
&& rhs instanceof Expr.Constant
&& ((Expr.Constant) rhs).value == Constant.V_NULL) {
// bingo, special case
Expr.LocalVariable lv = (Expr.LocalVariable) lhs;
Nominal newType;
Nominal glb = Nominal.intersect(lhs.result(), Nominal.T_NULL);
if (glb.raw() == Type.T_VOID) {
syntaxError(
errorMessage(INCOMPARABLE_OPERANDS, lhs.result()
.raw(), Type.T_NULL), context, bop);
return null;
} else if (sign) {
newType = glb;
} else {
newType = Nominal
.intersect(lhs.result(), Nominal.T_NOTNULL);
}
bop.srcType = lhs.result();
environment = environment.update(lv.var, newType);
} else {
// handle general case
if (Type.isImplicitCoerciveSubtype(lhsRawType, rhsRawType)) {
bop.srcType = lhs.result();
} else if (Type.isImplicitCoerciveSubtype(rhsRawType,
lhsRawType)) {
bop.srcType = rhs.result();
} else {
syntaxError(
errorMessage(INCOMPARABLE_OPERANDS, lhsRawType,
rhsRawType), context, bop);
return null; // dead code
}
}
}
return new Pair<Expr, Environment>(bop, environment);
}
// Expressions
/**
* Propagate types through a given expression, whilst checking that it is
* well typed. In this case, any use of a runtime type test cannot effect
* callers of this function.
*
* @param expr
* Expression to propagate types through.
* @param environment
* Determines the type of all variables immediately going into
* this expression
* @param context
* Enclosing context of this expression (e.g. type declaration,
* function declaration, etc)
* @return
*/
public Expr propagate(Expr expr, Environment environment, Context context) {
try {
if (expr instanceof Expr.BinOp) {
return propagate((Expr.BinOp) expr, environment, context);
} else if (expr instanceof Expr.UnOp) {
return propagate((Expr.UnOp) expr, environment, context);
} else if (expr instanceof Expr.Comprehension) {
return propagate((Expr.Comprehension) expr, environment,
context);
} else if (expr instanceof Expr.Constant) {
return propagate((Expr.Constant) expr, environment, context);
} else if (expr instanceof Expr.Cast) {
return propagate((Expr.Cast) expr, environment, context);
} else if (expr instanceof Expr.ConstantAccess) {
return propagate((Expr.ConstantAccess) expr, environment,
context);
} else if (expr instanceof Expr.FieldAccess) {
return propagate((Expr.FieldAccess) expr, environment, context);
} else if (expr instanceof Expr.Map) {
return propagate((Expr.Map) expr, environment, context);
} else if (expr instanceof Expr.AbstractFunctionOrMethod) {
return propagate((Expr.AbstractFunctionOrMethod) expr,
environment, context);
} else if (expr instanceof Expr.AbstractInvoke) {
return propagate((Expr.AbstractInvoke) expr, environment,
context);
} else if (expr instanceof Expr.AbstractIndirectInvoke) {
return propagate((Expr.AbstractIndirectInvoke) expr,
environment, context);
} else if (expr instanceof Expr.IndexOf) {
return propagate((Expr.IndexOf) expr, environment, context);
} else if (expr instanceof Expr.Lambda) {
return propagate((Expr.Lambda) expr, environment, context);
} else if (expr instanceof Expr.LengthOf) {
return propagate((Expr.LengthOf) expr, environment, context);
} else if (expr instanceof Expr.LocalVariable) {
return propagate((Expr.LocalVariable) expr, environment,
context);
} else if (expr instanceof Expr.List) {
return propagate((Expr.List) expr, environment, context);
} else if (expr instanceof Expr.Set) {
return propagate((Expr.Set) expr, environment, context);
} else if (expr instanceof Expr.SubList) {
return propagate((Expr.SubList) expr, environment, context);
} else if (expr instanceof Expr.SubString) {
return propagate((Expr.SubString) expr, environment, context);
} else if (expr instanceof Expr.Dereference) {
return propagate((Expr.Dereference) expr, environment, context);
} else if (expr instanceof Expr.Record) {
return propagate((Expr.Record) expr, environment, context);
} else if (expr instanceof Expr.New) {
return propagate((Expr.New) expr, environment, context);
} else if (expr instanceof Expr.Tuple) {
return propagate((Expr.Tuple) expr, environment, context);
} else if (expr instanceof Expr.TypeVal) {
return propagate((Expr.TypeVal) expr, environment, context);
}
} catch (ResolveError e) {
syntaxError(errorMessage(RESOLUTION_ERROR, e.getMessage()),
context, expr, e);
} catch (SyntaxError e) {
throw e;
} catch (Throwable e) {
internalFailure(e.getMessage(), context, expr, e);
return null; // dead code
}
internalFailure("unknown expression: " + expr.getClass().getName(),
context, expr);
return null; // dead code
}
private Expr propagate(Expr.BinOp expr, Environment environment,
Context context) throws IOException {
// TODO: split binop into arithmetic and conditional operators. This
// would avoid the following case analysis since conditional binary
// operators and arithmetic binary operators actually behave quite
// differently.
switch (expr.op) {
case AND:
case OR:
case XOR:
case EQ:
case NEQ:
case LT:
case LTEQ:
case GT:
case GTEQ:
case ELEMENTOF:
case SUBSET:
case SUBSETEQ:
case IS:
return propagateCondition(expr, true, environment, context).first();
}
Expr lhs = propagate(expr.lhs, environment, context);
Expr rhs = propagate(expr.rhs, environment, context);
expr.lhs = lhs;
expr.rhs = rhs;
Type lhsRawType = lhs.result().raw();
Type rhsRawType = rhs.result().raw();
boolean lhs_set = Type.isImplicitCoerciveSubtype(Type.T_SET_ANY,
lhsRawType);
boolean rhs_set = Type.isImplicitCoerciveSubtype(Type.T_SET_ANY,
rhsRawType);
boolean lhs_list = Type.isImplicitCoerciveSubtype(Type.T_LIST_ANY,
lhsRawType);
boolean rhs_list = Type.isImplicitCoerciveSubtype(Type.T_LIST_ANY,
rhsRawType);
boolean lhs_str = Type.isSubtype(Type.T_STRING, lhsRawType);
boolean rhs_str = Type.isSubtype(Type.T_STRING, rhsRawType);
Type srcType;
if (lhs_str || rhs_str) {
switch (expr.op) {
case LISTAPPEND:
expr.op = Expr.BOp.STRINGAPPEND;
case STRINGAPPEND:
break;
default:
syntaxError("Invalid string operation: " + expr.op, context,
expr);
}
srcType = Type.T_STRING;
} else if (lhs_list && rhs_list) {
checkIsSubtype(Type.T_LIST_ANY, lhs, context);
checkIsSubtype(Type.T_LIST_ANY, rhs, context);
Type.EffectiveList lel = (Type.EffectiveList) lhsRawType;
Type.EffectiveList rel = (Type.EffectiveList) rhsRawType;
switch (expr.op) {
case LISTAPPEND:
srcType = Type.List(Type.Union(lel.element(), rel.element()),
false);
break;
default:
syntaxError("invalid list operation: " + expr.op, context, expr);
return null; // dead-code
}
} else if (lhs_set && rhs_set) {
checkIsSubtype(Type.T_SET_ANY, lhs, context);
checkIsSubtype(Type.T_SET_ANY, rhs, context);
// FIXME: something tells me there should be a function for doing
// this. Perhaps effectiveSetType?
if (lhs_list) {
Type.EffectiveList tmp = (Type.EffectiveList) lhsRawType;
lhsRawType = Type.Set(tmp.element(), false);
}
if (rhs_list) {
Type.EffectiveList tmp = (Type.EffectiveList) rhsRawType;
rhsRawType = Type.Set(tmp.element(), false);
}
// FIXME: loss of nominal information here
Type.EffectiveSet ls = (Type.EffectiveSet) lhsRawType;
Type.EffectiveSet rs = (Type.EffectiveSet) rhsRawType;
switch (expr.op) {
case ADD:
expr.op = Expr.BOp.UNION;
case UNION:
// TODO: this forces unnecessary coercions, which would be
// good to remove.
srcType = Type.Set(Type.Union(ls.element(), rs.element()),
false);
break;
case BITWISEAND:
expr.op = Expr.BOp.INTERSECTION;
case INTERSECTION:
// FIXME: this is just plain wierd.
if (Type.isSubtype(lhsRawType, rhsRawType)) {
srcType = rhsRawType;
} else {
srcType = lhsRawType;
}
break;
case SUB:
expr.op = Expr.BOp.DIFFERENCE;
case DIFFERENCE:
srcType = lhsRawType;
break;
default:
syntaxError("invalid set operation: " + expr.op, context, expr);
return null; // deadcode
}
} else {
switch (expr.op) {
case IS:
case AND:
case OR:
case XOR:
return propagateCondition(expr, true, environment, context)
.first();
case BITWISEAND:
case BITWISEOR:
case BITWISEXOR:
checkIsSubtype(Type.T_BYTE, lhs, context);
checkIsSubtype(Type.T_BYTE, rhs, context);
srcType = Type.T_BYTE;
break;
case LEFTSHIFT:
case RIGHTSHIFT:
checkIsSubtype(Type.T_BYTE, lhs, context);
checkIsSubtype(Type.T_INT, rhs, context);
srcType = Type.T_BYTE;
break;
case RANGE:
checkIsSubtype(Type.T_INT, lhs, context);
checkIsSubtype(Type.T_INT, rhs, context);
srcType = Type.List(Type.T_INT, false);
break;
case REM:
checkIsSubtype(Type.T_INT, lhs, context);
checkIsSubtype(Type.T_INT, rhs, context);
srcType = Type.T_INT;
break;
default:
// all other operations go through here
if (Type.isImplicitCoerciveSubtype(lhsRawType, rhsRawType)) {
checkIsSubtype(Type.T_REAL, lhs, context);
if (Type.isSubtype(Type.T_CHAR, lhsRawType)) {
srcType = Type.T_INT;
} else if (Type.isSubtype(Type.T_INT, lhsRawType)) {
srcType = Type.T_INT;
} else {
srcType = Type.T_REAL;
}
} else {
checkIsSubtype(Type.T_REAL, lhs, context);
checkIsSubtype(Type.T_REAL, rhs, context);
if (Type.isSubtype(Type.T_CHAR, rhsRawType)) {
srcType = Type.T_INT;
} else if (Type.isSubtype(Type.T_INT, rhsRawType)) {
srcType = Type.T_INT;
} else {
srcType = Type.T_REAL;
}
}
}
}
// FIXME: loss of nominal information
expr.srcType = Nominal.construct(srcType, srcType);
return expr;
}
private Expr propagate(Expr.UnOp expr, Environment environment,
Context context) throws IOException {
if (expr.op == Expr.UOp.NOT) {
// hand off to special method for conditions
return propagateCondition(expr, true, environment, context).first();
}
Expr src = propagate(expr.mhs, environment, context);
expr.mhs = src;
switch (expr.op) {
case NEG:
checkIsSubtype(Type.T_REAL, src, context);
break;
case INVERT:
checkIsSubtype(Type.T_BYTE, src, context);
break;
default:
internalFailure(
"unknown operator: " + expr.op.getClass().getName(),
context, expr);
}
expr.type = src.result();
return expr;
}
private Expr propagate(Expr.Comprehension expr, Environment environment,
Context context) throws IOException, ResolveError {
ArrayList<Pair<String, Expr>> sources = expr.sources;
Environment local = environment.clone();
for (int i = 0; i != sources.size(); ++i) {
Pair<String, Expr> p = sources.get(i);
Expr e = propagate(p.second(), local, context);
p = new Pair<String, Expr>(p.first(), e);
sources.set(i, p);
Nominal type = e.result();
Nominal.EffectiveCollection colType = expandAsEffectiveCollection(type);
if (colType == null) {
syntaxError(errorMessage(INVALID_SET_OR_LIST_EXPRESSION),
context, e);
return null; // dead code
}
// update environment for subsequent source expressions, the
// condition and the value.
local = local.declare(p.first(), colType.element(), colType.element());
}
if (expr.condition != null) {
expr.condition = propagate(expr.condition, local, context);
}
if (expr.cop == Expr.COp.SETCOMP || expr.cop == Expr.COp.LISTCOMP) {
expr.value = propagate(expr.value, local, context);
expr.type = Nominal.Set(expr.value.result(), false);
} else {
expr.type = Nominal.T_BOOL;
}
local.free();
return expr;
}
private Expr propagate(Expr.Constant expr, Environment environment,
Context context) {
return expr;
}
private Expr propagate(Expr.Cast c, Environment environment, Context context)
throws IOException {
c.expr = propagate(c.expr, environment, context);
c.type = resolveAsType(c.unresolvedType, context);
Type from = c.expr.result().raw();
Type to = c.type.raw();
if (!Type.isExplicitCoerciveSubtype(to, from)) {
syntaxError(errorMessage(SUBTYPE_ERROR, to, from), context, c);
}
return c;
}
private Expr propagate(Expr.AbstractFunctionOrMethod expr,
Environment environment, Context context) throws IOException, ResolveError {
if (expr instanceof Expr.FunctionOrMethod) {
return expr;
}
Pair<NameID, Nominal.FunctionOrMethod> p;
if (expr.paramTypes != null) {
ArrayList<Nominal> paramTypes = new ArrayList<Nominal>();
for (SyntacticType t : expr.paramTypes) {
paramTypes.add(resolveAsType(t, context));
}
// FIXME: clearly a bug here in the case of message reference
p = (Pair<NameID, Nominal.FunctionOrMethod>) resolveAsFunctionOrMethod(
expr.name, paramTypes, context);
} else {
p = resolveAsFunctionOrMethod(expr.name, context);
}
expr = new Expr.FunctionOrMethod(p.first(), expr.paramTypes,
expr.attributes());
expr.type = p.second();
return expr;
}
private Expr propagate(Expr.Lambda expr, Environment environment,
Context context) throws IOException {
ArrayList<Type> rawTypes = new ArrayList<Type>();
ArrayList<Type> nomTypes = new ArrayList<Type>();
for (WhileyFile.Parameter p : expr.parameters) {
Nominal n = resolveAsType(p.type, context);
rawTypes.add(n.raw());
nomTypes.add(n.nominal());
// Now, update the environment to include those declared variables
String var = p.name();
if (environment.containsKey(var)) {
syntaxError(errorMessage(VARIABLE_ALREADY_DEFINED, var),
context, p);
}
environment = environment.declare(var, n, n);
}
expr.body = propagate(expr.body, environment, context);
Type.FunctionOrMethod rawType;
Type.FunctionOrMethod nomType;
if (Exprs.isPure(expr.body, context)) {
rawType = Type.Function(expr.body.result().raw(), Type.T_VOID,
rawTypes);
nomType = Type.Function(expr.body.result().nominal(), Type.T_VOID,
nomTypes);
} else {
rawType = Type.Method(expr.body.result().raw(), Type.T_VOID,
rawTypes);
nomType = Type.Method(expr.body.result().nominal(), Type.T_VOID,
nomTypes);
}
expr.type = (Nominal.FunctionOrMethod) Nominal.construct(nomType,
rawType);
return expr;
}
private Expr propagate(Expr.AbstractIndirectInvoke expr,
Environment environment, Context context) throws IOException, ResolveError {
expr.src = propagate(expr.src, environment, context);
Nominal type = expr.src.result();
if (!(type instanceof Nominal.FunctionOrMethod)) {
syntaxError("function or method type expected", context, expr.src);
}
Nominal.FunctionOrMethod funType = (Nominal.FunctionOrMethod) type;
List<Nominal> paramTypes = funType.params();
ArrayList<Expr> exprArgs = expr.arguments;
if (paramTypes.size() != exprArgs.size()) {
syntaxError(
"insufficient arguments for function or method invocation",
context, expr.src);
}
for (int i = 0; i != exprArgs.size(); ++i) {
Nominal pt = paramTypes.get(i);
Expr arg = propagate(exprArgs.get(i), environment, context);
checkIsSubtype(pt, arg, context);
exprArgs.set(i, arg);
}
if (funType instanceof Nominal.Function) {
Expr.IndirectFunctionCall ifc = new Expr.IndirectFunctionCall(
expr.src, exprArgs, expr.attributes());
ifc.functionType = (Nominal.Function) funType;
return ifc;
} else {
Expr.IndirectMethodCall imc = new Expr.IndirectMethodCall(expr.src,
exprArgs, expr.attributes());
imc.methodType = (Nominal.Method) funType;
return imc;
}
}
private Expr propagate(Expr.AbstractInvoke expr, Environment environment,
Context context) throws IOException, ResolveError {
// first, resolve through receiver and parameters.
Path.ID qualification = expr.qualification;
ArrayList<Expr> exprArgs = expr.arguments;
ArrayList<Nominal> paramTypes = new ArrayList<Nominal>();
for (int i = 0; i != exprArgs.size(); ++i) {
Expr arg = propagate(exprArgs.get(i), environment, context);
exprArgs.set(i, arg);
paramTypes.add(arg.result());
}
// second, determine the fully qualified name of this function based on
// the given function name and any supplied qualifications.
ArrayList<String> qualifications = new ArrayList<String>();
if (expr.qualification != null) {
for (String n : expr.qualification) {
qualifications.add(n);
}
}
qualifications.add(expr.name);
NameID name = resolveAsName(qualifications, context);
// third, lookup the appropriate function or method based on the name
// and given parameter types.
Nominal.FunctionOrMethod funType = resolveAsFunctionOrMethod(name,
paramTypes, context);
if (funType instanceof Nominal.Function) {
Expr.FunctionCall r = new Expr.FunctionCall(name, qualification,
exprArgs, expr.attributes());
r.functionType = (Nominal.Function) funType;
return r;
} else {
Expr.MethodCall r = new Expr.MethodCall(name, qualification,
exprArgs, expr.attributes());
r.methodType = (Nominal.Method) funType;
return r;
}
}
private Expr propagate(Expr.IndexOf expr, Environment environment,
Context context) throws IOException, ResolveError {
expr.src = propagate(expr.src, environment, context);
expr.index = propagate(expr.index, environment, context);
Nominal.EffectiveIndexible srcType = expandAsEffectiveMap(expr.src
.result());
if (srcType == null) {
syntaxError(errorMessage(INVALID_SET_OR_LIST_EXPRESSION), context,
expr.src);
} else {
expr.srcType = srcType;
}
checkIsSubtype(srcType.key(), expr.index, context);
return expr;
}
private Expr propagate(Expr.LengthOf expr, Environment environment,
Context context) throws IOException, ResolveError {
expr.src = propagate(expr.src, environment, context);
Nominal srcType = expr.src.result();
Type rawSrcType = srcType.raw();
// First, check whether this is still only an abstract access and, in
// such case, upgrade it to the appropriate access expression.
if (rawSrcType instanceof Type.EffectiveCollection) {
expr.srcType = expandAsEffectiveCollection(srcType);
return expr;
} else {
syntaxError("found " + expr.src.result().nominal()
+ ", expected string, set, list or dictionary.", context,
expr.src);
}
// Second, determine the expanded src type for this access expression
// and check the key value.
checkIsSubtype(Type.T_STRING, expr.src, context);
return expr;
}
private Expr propagate(Expr.LocalVariable expr, Environment environment,
Context context) throws IOException {
Nominal type = environment.getCurrentType(expr.var);
expr.type = type;
return expr;
}
private Expr propagate(Expr.Set expr, Environment environment,
Context context) {
Nominal element = Nominal.T_VOID;
ArrayList<Expr> exprs = expr.arguments;
for (int i = 0; i != exprs.size(); ++i) {
Expr e = propagate(exprs.get(i), environment, context);
Nominal t = e.result();
exprs.set(i, e);
element = Nominal.Union(t, element);
}
expr.type = Nominal.Set(element, false);
return expr;
}
private Expr propagate(Expr.List expr, Environment environment,
Context context) {
Nominal element = Nominal.T_VOID;
ArrayList<Expr> exprs = expr.arguments;
for (int i = 0; i != exprs.size(); ++i) {
Expr e = propagate(exprs.get(i), environment, context);
Nominal t = e.result();
exprs.set(i, e);
element = Nominal.Union(t, element);
}
expr.type = Nominal.List(element, false);
return expr;
}
private Expr propagate(Expr.Map expr, Environment environment,
Context context) {
Nominal keyType = Nominal.T_VOID;
Nominal valueType = Nominal.T_VOID;
ArrayList<Pair<Expr, Expr>> exprs = expr.pairs;
for (int i = 0; i != exprs.size(); ++i) {
Pair<Expr, Expr> p = exprs.get(i);
Expr key = propagate(p.first(), environment, context);
Expr value = propagate(p.second(), environment, context);
Nominal kt = key.result();
Nominal vt = value.result();
exprs.set(i, new Pair<Expr, Expr>(key, value));
keyType = Nominal.Union(kt, keyType);
valueType = Nominal.Union(vt, valueType);
}
expr.type = Nominal.Map(keyType, valueType);
return expr;
}
private Expr propagate(Expr.Record expr, Environment environment,
Context context) {
HashMap<String, Expr> exprFields = expr.fields;
HashMap<String, Nominal> fieldTypes = new HashMap<String, Nominal>();
ArrayList<String> fields = new ArrayList<String>(exprFields.keySet());
for (String field : fields) {
Expr e = propagate(exprFields.get(field), environment, context);
Nominal t = e.result();
exprFields.put(field, e);
fieldTypes.put(field, t);
}
expr.type = Nominal.Record(false, fieldTypes);
return expr;
}
private Expr propagate(Expr.Tuple expr, Environment environment,
Context context) {
ArrayList<Expr> exprFields = expr.fields;
ArrayList<Nominal> fieldTypes = new ArrayList<Nominal>();
for (int i = 0; i != exprFields.size(); ++i) {
Expr e = propagate(exprFields.get(i), environment, context);
Nominal t = e.result();
exprFields.set(i, e);
fieldTypes.add(t);
}
expr.type = Nominal.Tuple(fieldTypes);
return expr;
}
private Expr propagate(Expr.SubList expr, Environment environment,
Context context) throws IOException, ResolveError {
expr.src = propagate(expr.src, environment, context);
expr.start = propagate(expr.start, environment, context);
expr.end = propagate(expr.end, environment, context);
checkIsSubtype(Type.T_LIST_ANY, expr.src, context);
checkIsSubtype(Type.T_INT, expr.start, context);
checkIsSubtype(Type.T_INT, expr.end, context);
expr.type = expandAsEffectiveList(expr.src.result());
if (expr.type == null) {
// must be a substring
return new Expr.SubString(expr.src, expr.start, expr.end,
expr.attributes());
}
return expr;
}
private Expr propagate(Expr.SubString expr, Environment environment,
Context context) throws IOException {
expr.src = propagate(expr.src, environment, context);
expr.start = propagate(expr.start, environment, context);
expr.end = propagate(expr.end, environment, context);
checkIsSubtype(Type.T_STRING, expr.src, context);
checkIsSubtype(Type.T_INT, expr.start, context);
checkIsSubtype(Type.T_INT, expr.end, context);
return expr;
}
private Expr propagate(Expr.FieldAccess ra, Environment environment,
Context context) throws IOException, ResolveError {
ra.src = propagate(ra.src, environment, context);
Nominal srcType = ra.src.result();
Nominal.EffectiveRecord recType = expandAsEffectiveRecord(srcType);
if (recType == null) {
syntaxError(errorMessage(RECORD_TYPE_REQUIRED, srcType.raw()),
context, ra);
}
Nominal fieldType = recType.field(ra.name);
if (fieldType == null) {
syntaxError(errorMessage(RECORD_MISSING_FIELD, ra.name), context,
ra);
}
ra.srcType = recType;
return ra;
}
private Expr propagate(Expr.ConstantAccess expr, Environment environment,
Context context) throws IOException {
// First, determine the fully qualified name of this function based on
// the given function name and any supplied qualifications.
ArrayList<String> qualifications = new ArrayList<String>();
if (expr.qualification != null) {
for (String n : expr.qualification) {
qualifications.add(n);
}
}
qualifications.add(expr.name);
try {
NameID name = resolveAsName(qualifications, context);
// Second, determine the value of the constant.
expr.value = resolveAsConstant(name);
return expr;
} catch (ResolveError e) {
syntaxError(errorMessage(UNKNOWN_VARIABLE), context, expr);
return null;
}
}
private Expr propagate(Expr.Dereference expr, Environment environment,
Context context) throws IOException, ResolveError {
Expr src = propagate(expr.src, environment, context);
expr.src = src;
Nominal.Reference srcType = expandAsReference(src.result());
if (srcType == null) {
syntaxError("invalid reference expression", context, src);
}
expr.srcType = srcType;
return expr;
}
private Expr propagate(Expr.New expr, Environment environment,
Context context) {
expr.expr = propagate(expr.expr, environment, context);
expr.type = Nominal.Reference(expr.expr.result());
return expr;
}
private Expr propagate(Expr.TypeVal expr, Environment environment,
Context context) throws IOException {
expr.type = resolveAsType(expr.unresolvedType, context);
return expr;
}
// Resolve as Function or Method
/**
* Responsible for determining the true type of a method or function being
* invoked. To do this, it must find the function/method with the most
* precise type that matches the argument types.
*
* @param nid
* @param parameters
* @return
* @throws IOException
*/
public Nominal.FunctionOrMethod resolveAsFunctionOrMethod(NameID nid,
List<Nominal> parameters, Context context) throws IOException,
ResolveError {
// Thet set of candidate names and types for this function or method.
HashSet<Pair<NameID, Nominal.FunctionOrMethod>> candidates = new HashSet<Pair<NameID, Nominal.FunctionOrMethod>>();
// First, add all valid candidates to the list without considering which
// is the most precise.
addCandidateFunctionsAndMethods(nid, parameters, candidates, context);
// Second, add to narrow down the list of candidates to a single choice.
// If this is impossible, then we have an ambiguity error.
return selectCandidateFunctionOrMethod(nid.name(), parameters,
candidates, context).second();
}
public Pair<NameID, Nominal.FunctionOrMethod> resolveAsFunctionOrMethod(
String name, Context context) throws IOException, ResolveError {
return resolveAsFunctionOrMethod(name, null, context);
}
public Pair<NameID, Nominal.FunctionOrMethod> resolveAsFunctionOrMethod(
String name, List<Nominal> parameters, Context context)
throws IOException,ResolveError {
HashSet<Pair<NameID, Nominal.FunctionOrMethod>> candidates = new HashSet<Pair<NameID, Nominal.FunctionOrMethod>>();
// first, try to find the matching message
for (WhileyFile.Import imp : context.imports()) {
String impName = imp.name;
if (impName == null || impName.equals(name) || impName.equals("*")) {
Trie filter = imp.filter;
if (impName == null) {
// import name is null, but it's possible that a module of
// the given name exists, in which case any matching names
// are automatically imported.
filter = filter.parent().append(name);
}
for (Path.ID mid : builder.imports(filter)) {
NameID nid = new NameID(mid, name);
addCandidateFunctionsAndMethods(nid, parameters,
candidates, context);
}
}
}
return selectCandidateFunctionOrMethod(name, parameters, candidates,
context);
}
private boolean paramSubtypes(Type.FunctionOrMethod f1,
Type.FunctionOrMethod f2) {
List<Type> f1_params = f1.params();
List<Type> f2_params = f2.params();
if (f1_params.size() == f2_params.size()) {
for (int i = 0; i != f1_params.size(); ++i) {
Type f1_param = f1_params.get(i);
Type f2_param = f2_params.get(i);
if (!Type.isImplicitCoerciveSubtype(f1_param, f2_param)) {
return false;
}
}
return true;
}
return false;
}
private boolean paramStrictSubtypes(Type.FunctionOrMethod f1,
Type.FunctionOrMethod f2) {
List<Type> f1_params = f1.params();
List<Type> f2_params = f2.params();
if (f1_params.size() == f2_params.size()) {
boolean allEqual = true;
for (int i = 0; i != f1_params.size(); ++i) {
Type f1_param = f1_params.get(i);
Type f2_param = f2_params.get(i);
if (!Type.isImplicitCoerciveSubtype(f1_param, f2_param)) {
return false;
}
allEqual &= f1_param.equals(f2_param);
}
// This function returns true if the parameters are a strict
// subtype. Therefore, if they are all equal it must return false.
return !allEqual;
}
return false;
}
private String parameterString(List<Nominal> paramTypes) {
String paramStr = "(";
boolean firstTime = true;
if (paramTypes == null) {
paramStr += "...";
} else {
for (Nominal t : paramTypes) {
if (!firstTime) {
paramStr += ",";
}
firstTime = false;
paramStr += t.nominal();
}
}
return paramStr + ")";
}
private Pair<NameID, Nominal.FunctionOrMethod> selectCandidateFunctionOrMethod(
String name, List<Nominal> parameters,
Collection<Pair<NameID, Nominal.FunctionOrMethod>> candidates,
Context context) throws IOException,ResolveError {
List<Type> rawParameters;
Type.Function target;
if (parameters != null) {
rawParameters = stripNominal(parameters);
target = (Type.Function) Type.Function(Type.T_ANY, Type.T_ANY,
rawParameters);
} else {
rawParameters = null;
target = null;
}
NameID candidateID = null;
Nominal.FunctionOrMethod candidateType = null;
for (Pair<NameID, Nominal.FunctionOrMethod> p : candidates) {
Nominal.FunctionOrMethod nft = p.second();
Type.FunctionOrMethod ft = nft.raw();
if (parameters == null || paramSubtypes(ft, target)) {
// this is now a genuine candidate
if (candidateType == null
|| paramStrictSubtypes(candidateType.raw(), ft)) {
candidateType = nft;
candidateID = p.first();
} else if (!paramStrictSubtypes(ft, candidateType.raw())) {
// this is an ambiguous error
String msg = name + parameterString(parameters)
+ " is ambiguous";
// FIXME: should report all ambiguous matches here
msg += "\n\tfound: " + candidateID + " : "
+ candidateType.nominal();
msg += "\n\tfound: " + p.first() + " : "
+ p.second().nominal();
throw new ResolveError(msg);
}
}
}
if (candidateType == null) {
// second, didn't find matching message so generate error message
String msg = "no match for " + name + parameterString(parameters);
for (Pair<NameID, Nominal.FunctionOrMethod> p : candidates) {
msg += "\n\tfound: " + p.first() + " : " + p.second().nominal();
}
throw new ResolveError(msg);
} else {
// now check protection modifier
WhileyFile wf = builder.getSourceFile(candidateID.module());
if (wf != null) {
if (wf != context.file()) {
for (WhileyFile.FunctionOrMethod d : wf.declarations(
WhileyFile.FunctionOrMethod.class,
candidateID.name())) {
if (d.parameters.equals(candidateType.params())) {
if (!d.hasModifier(Modifier.PUBLIC)
&& !d.hasModifier(Modifier.PROTECTED)) {
String msg = candidateID.module() + "." + name
+ parameterString(parameters)
+ " is not visible";
throw new ResolveError(msg);
}
}
}
}
} else {
WyilFile m = builder.getModule(candidateID.module());
WyilFile.FunctionOrMethodDeclaration d = m.method(
candidateID.name(), candidateType.raw());
if (!d.hasModifier(Modifier.PUBLIC)
&& !d.hasModifier(Modifier.PROTECTED)) {
String msg = candidateID.module() + "." + name
+ parameterString(parameters) + " is not visible";
throw new ResolveError(msg);
}
}
}
return new Pair<NameID, Nominal.FunctionOrMethod>(candidateID,
candidateType);
}
private void addCandidateFunctionsAndMethods(NameID nid,
List<?> parameters,
Collection<Pair<NameID, Nominal.FunctionOrMethod>> candidates,
Context context) throws IOException {
Path.ID mid = nid.module();
int nparams = parameters != null ? parameters.size() : -1;
WhileyFile wf = builder.getSourceFile(mid);
if (wf != null) {
for (WhileyFile.FunctionOrMethod f : wf.declarations(
WhileyFile.FunctionOrMethod.class, nid.name())) {
if (nparams == -1 || f.parameters.size() == nparams) {
Nominal.FunctionOrMethod ft = (Nominal.FunctionOrMethod) resolveAsType(
f.unresolvedType(), f);
candidates.add(new Pair<NameID, Nominal.FunctionOrMethod>(
nid, ft));
}
}
} else {
WyilFile m = builder.getModule(mid);
for (WyilFile.FunctionOrMethodDeclaration mm : m.methods()) {
if ((mm.isFunction() || mm.isMethod())
&& mm.name().equals(nid.name())
&& (nparams == -1 || mm.type().params().size() == nparams)) {
// FIXME: loss of nominal information
// FIXME: loss of visibility information (e.g if this
// function is declared in terms of a protected type)
Type.FunctionOrMethod t = (Type.FunctionOrMethod) mm
.type();
Nominal.FunctionOrMethod fom;
if (t instanceof Type.Function) {
Type.Function ft = (Type.Function) t;
fom = new Nominal.Function(ft, ft);
} else {
Type.Method mt = (Type.Method) t;
fom = new Nominal.Method(mt, mt);
}
candidates
.add(new Pair<NameID, Nominal.FunctionOrMethod>(
nid, fom));
}
}
}
}
private static List<Type> stripNominal(List<Nominal> types) {
ArrayList<Type> r = new ArrayList<Type>();
for (Nominal t : types) {
r.add(t.raw());
}
return r;
}
// ResolveAsName
public NameID resolveAsName(String name, Context context)
throws IOException, ResolveError {
for (WhileyFile.Import imp : context.imports()) {
String impName = imp.name;
if (impName == null || impName.equals(name) || impName.equals("*")) {
Trie filter = imp.filter;
if (impName == null) {
// import name is null, but it's possible that a module of
// the given name exists, in which case any matching names
// are automatically imported.
filter = filter.parent().append(name);
}
for (Path.ID mid : builder.imports(filter)) {
NameID nid = new NameID(mid, name);
if (builder.isName(nid)) {
// ok, we have found the name in question. But, is it
// visible?
if (isNameVisible(nid, context)) {
return nid;
} else {
throw new ResolveError(nid + " is not visible");
}
}
}
}
}
throw new ResolveError("name not found: " + name);
}
public NameID resolveAsName(List<String> names, Context context)
throws IOException, ResolveError {
if (names.size() == 1) {
return resolveAsName(names.get(0), context);
} else if (names.size() == 2) {
String name = names.get(1);
Path.ID mid = resolveAsModule(names.get(0), context);
NameID nid = new NameID(mid, name);
if (builder.isName(nid)) {
if (isNameVisible(nid, context)) {
return nid;
} else {
throw new ResolveError(nid + " is not visible");
}
}
} else {
String name = names.get(names.size() - 1);
String module = names.get(names.size() - 2);
Path.ID pkg = Trie.ROOT;
for (int i = 0; i != names.size() - 2; ++i) {
pkg = pkg.append(names.get(i));
}
Path.ID mid = pkg.append(module);
NameID nid = new NameID(mid, name);
if (builder.isName(nid)) {
if (isNameVisible(nid, context)) {
return nid;
} else {
throw new ResolveError(nid + " is not visible");
}
}
}
String name = null;
for (String n : names) {
if (name != null) {
name = name + "." + n;
} else {
name = n;
}
}
throw new ResolveError("name not found: " + name);
}
public Path.ID resolveAsModule(String name, Context context)
throws IOException, ResolveError {
for (WhileyFile.Import imp : context.imports()) {
Trie filter = imp.filter;
String last = filter.last();
if (last.equals("*")) {
// this is generic import, so narrow the filter.
filter = filter.parent().append(name);
} else if (!last.equals(name)) {
continue; // skip as not relevant
}
for (Path.ID mid : builder.imports(filter)) {
return mid;
}
}
throw new ResolveError("module not found: " + name);
}
// ResolveAsType
public Nominal.Function resolveAsType(SyntacticType.Function t,
Context context) {
return (Nominal.Function) resolveAsType((SyntacticType) t, context);
}
public Nominal.Method resolveAsType(SyntacticType.Method t, Context context) {
return (Nominal.Method) resolveAsType((SyntacticType) t, context);
}
public Nominal resolveAsType(SyntacticType type, Context context) {
Type nominalType = resolveAsType(type, context, true, false);
Type rawType = resolveAsType(type, context, false, false);
return Nominal.construct(nominalType, rawType);
}
public Nominal resolveAsUnconstrainedType(SyntacticType type,
Context context) {
Type nominalType = resolveAsType(type, context, true, true);
Type rawType = resolveAsType(type, context, false, true);
return Nominal.construct(nominalType, rawType);
}
private Type resolveAsType(SyntacticType t, Context context,
boolean nominal, boolean unconstrained) {
if (t instanceof SyntacticType.Primitive) {
if (t instanceof SyntacticType.Any) {
return Type.T_ANY;
} else if (t instanceof SyntacticType.Void) {
return Type.T_VOID;
} else if (t instanceof SyntacticType.Null) {
return Type.T_NULL;
} else if (t instanceof SyntacticType.Bool) {
return Type.T_BOOL;
} else if (t instanceof SyntacticType.Byte) {
return Type.T_BYTE;
} else if (t instanceof SyntacticType.Char) {
return Type.T_CHAR;
} else if (t instanceof SyntacticType.Int) {
return Type.T_INT;
} else if (t instanceof SyntacticType.Real) {
return Type.T_REAL;
} else if (t instanceof SyntacticType.Strung) {
return Type.T_STRING;
} else {
internalFailure("unrecognised type encountered ("
+ t.getClass().getName() + ")", context, t);
return null; // deadcode
}
} else {
ArrayList<Automaton.State> states = new ArrayList<Automaton.State>();
HashMap<NameID, Integer> roots = new HashMap<NameID, Integer>();
resolveAsType(t, context, states, roots, nominal, unconstrained);
return Type.construct(new Automaton(states));
}
}
private int resolveAsType(SyntacticType type, Context context,
ArrayList<Automaton.State> states, HashMap<NameID, Integer> roots,
boolean nominal, boolean unconstrained) {
if (type instanceof SyntacticType.Primitive) {
return resolveAsType((SyntacticType.Primitive) type, context,
states);
}
int myIndex = states.size();
int myKind;
int[] myChildren;
Object myData = null;
boolean myDeterministic = true;
states.add(null); // reserve space for me
if (type instanceof SyntacticType.List) {
SyntacticType.List lt = (SyntacticType.List) type;
myKind = Type.K_LIST;
myChildren = new int[1];
myChildren[0] = resolveAsType(lt.element, context, states, roots,
nominal, unconstrained);
myData = false;
} else if (type instanceof SyntacticType.Set) {
SyntacticType.Set st = (SyntacticType.Set) type;
myKind = Type.K_SET;
myChildren = new int[1];
myChildren[0] = resolveAsType(st.element, context, states, roots,
nominal, unconstrained);
myData = false;
} else if (type instanceof SyntacticType.Map) {
SyntacticType.Map st = (SyntacticType.Map) type;
myKind = Type.K_MAP;
myChildren = new int[2];
myChildren[0] = resolveAsType(st.key, context, states, roots,
nominal, unconstrained);
myChildren[1] = resolveAsType(st.value, context, states, roots,
nominal, unconstrained);
} else if (type instanceof SyntacticType.Record) {
SyntacticType.Record tt = (SyntacticType.Record) type;
HashMap<String, SyntacticType> ttTypes = tt.types;
Type.Record.State fields = new Type.Record.State(tt.isOpen,
ttTypes.keySet());
Collections.sort(fields);
myKind = Type.K_RECORD;
myChildren = new int[fields.size()];
for (int i = 0; i != fields.size(); ++i) {
String field = fields.get(i);
myChildren[i] = resolveAsType(ttTypes.get(field), context,
states, roots, nominal, unconstrained);
}
myData = fields;
} else if (type instanceof SyntacticType.Tuple) {
SyntacticType.Tuple tt = (SyntacticType.Tuple) type;
ArrayList<SyntacticType> ttTypes = tt.types;
myKind = Type.K_TUPLE;
myChildren = new int[ttTypes.size()];
for (int i = 0; i != ttTypes.size(); ++i) {
myChildren[i] = resolveAsType(ttTypes.get(i), context, states,
roots, nominal, unconstrained);
}
} else if (type instanceof SyntacticType.Nominal) {
// This case corresponds to a user-defined type. This will be
// defined in some module (possibly ours), and we need to identify
// what module that is here, and save it for future use.
// Furthermore, we need to determine whether the name is visible
// (i.e. non-private) and/or whether the body of the type is visible
// (i.e. non-protected).
SyntacticType.Nominal dt = (SyntacticType.Nominal) type;
NameID nid;
try {
// Determine the full qualified name of this nominal type. This
// will additionally ensure that the name is visible
nid = resolveAsName(dt.names, context);
if (nominal || !isTypeVisible(nid, context)) {
myKind = Type.K_NOMINAL;
myData = nid;
myChildren = Automaton.NOCHILDREN;
} else {
// At this point, we're going to expand the given nominal
// type. We're going to use resolveAsType(NameID,...) to do
// this which will load the expanded type onto states at the
// current point. Therefore, we need to remove the initial
// null we loaded on.
states.remove(myIndex);
return resolveAsType(nid, states, roots, unconstrained);
}
} catch (ResolveError e) {
syntaxError(e.getMessage(), context, dt, e);
return 0; // dead-code
} catch (SyntaxError e) {
throw e;
} catch (Throwable e) {
internalFailure(e.getMessage(), context, dt, e);
return 0; // dead-code
}
} else if (type instanceof SyntacticType.Negation) {
SyntacticType.Negation ut = (SyntacticType.Negation) type;
myKind = Type.K_NEGATION;
myChildren = new int[1];
myChildren[0] = resolveAsType(ut.element, context, states, roots,
nominal, unconstrained);
} else if (type instanceof SyntacticType.Union) {
SyntacticType.Union ut = (SyntacticType.Union) type;
ArrayList<SyntacticType.NonUnion> utTypes = ut.bounds;
myKind = Type.K_UNION;
myChildren = new int[utTypes.size()];
for (int i = 0; i != utTypes.size(); ++i) {
myChildren[i] = resolveAsType(utTypes.get(i), context, states,
roots, nominal, unconstrained);
}
myDeterministic = false;
} else if (type instanceof SyntacticType.Intersection) {
internalFailure("intersection types not supported yet", context,
type);
return 0; // dead-code
} else if (type instanceof SyntacticType.Reference) {
SyntacticType.Reference ut = (SyntacticType.Reference) type;
myKind = Type.K_REFERENCE;
myChildren = new int[1];
myChildren[0] = resolveAsType(ut.element, context, states, roots,
nominal, unconstrained);
} else {
SyntacticType.FunctionOrMethod ut = (SyntacticType.FunctionOrMethod) type;
ArrayList<SyntacticType> utParamTypes = ut.paramTypes;
int start = 0;
if (ut instanceof SyntacticType.Method) {
myKind = Type.K_METHOD;
} else {
myKind = Type.K_FUNCTION;
}
myChildren = new int[start + 2 + utParamTypes.size()];
myChildren[start++] = resolveAsType(ut.ret, context, states, roots,
nominal, unconstrained);
if (ut.throwType == null) {
// this case indicates the user did not provide a throws clause.
myChildren[start++] = resolveAsType(new SyntacticType.Void(),
context, states, roots, nominal, unconstrained);
} else {
myChildren[start++] = resolveAsType(ut.throwType, context,
states, roots, nominal, unconstrained);
}
for (SyntacticType pt : utParamTypes) {
myChildren[start++] = resolveAsType(pt, context, states, roots,
nominal, unconstrained);
}
}
states.set(myIndex, new Automaton.State(myKind, myData,
myDeterministic, myChildren));
return myIndex;
}
private int resolveAsType(NameID key, ArrayList<Automaton.State> states,
HashMap<NameID, Integer> roots, boolean unconstrained)
throws IOException, ResolveError {
// First, check the various caches we have
Integer root = roots.get(key);
if (root != null) {
return root;
}
// check whether this type is external or not
WhileyFile wf = builder.getSourceFile(key.module());
if (wf == null) {
// indicates a non-local key which we can resolve immediately
WyilFile mi = builder.getModule(key.module());
WyilFile.TypeDeclaration td = mi.type(key.name());
return append(td.type(), states);
}
WhileyFile.Type td = wf.typeDecl(key.name());
if (td == null) {
// FIXME: the following allows (in certain cases) constants to be
// interpreted as types. This should not be allowed and needs to be
// removed in the future. However, to do this requires some kind of
// unit/constant/enum type. See #315
Type t = resolveAsConstant(key).type();
if (t instanceof Type.Set) {
if (unconstrained) {
// crikey this is ugly
int myIndex = states.size();
int kind = Type.leafKind(Type.T_VOID);
Object data = null;
states.add(new Automaton.State(kind, data, true,
Automaton.NOCHILDREN));
return myIndex;
}
Type.Set ts = (Type.Set) t;
return append(ts.element(), states);
} else {
throw new ResolveError("type not found: " + key);
}
}
// following is needed to terminate any recursion
roots.put(key, states.size());
SyntacticType type = td.pattern.toSyntacticType();
// now, expand the given type fully
if (unconstrained && td.invariant != null) {
int myIndex = states.size();
int kind = Type.leafKind(Type.T_VOID);
Object data = null;
states.add(new Automaton.State(kind, data, true,
Automaton.NOCHILDREN));
return myIndex;
} else if (type instanceof Type.Leaf) {
// FIXME: I believe this code is now redundant, and should be
// removed or updated. The problem is that SyntacticType no longer
// extends Type.
int myIndex = states.size();
int kind = Type.leafKind((Type.Leaf) type);
Object data = Type.leafData((Type.Leaf) type);
states.add(new Automaton.State(kind, data, true,
Automaton.NOCHILDREN));
return myIndex;
} else {
return resolveAsType(type, td, states, roots, false, unconstrained);
}
// TODO: performance can be improved here, but actually assigning the
// constructed type into a cache of previously expanded types cache.
// This is challenging, in the case that the type may not be complete at
// this point. In particular, if it contains any back-links above this
// index there could be an issue.
}
private int resolveAsType(SyntacticType.Primitive t, Context context,
ArrayList<Automaton.State> states) {
int myIndex = states.size();
int kind;
if (t instanceof SyntacticType.Any) {
kind = Type.K_ANY;
} else if (t instanceof SyntacticType.Void) {
kind = Type.K_VOID;
} else if (t instanceof SyntacticType.Null) {
kind = Type.K_NULL;
} else if (t instanceof SyntacticType.Bool) {
kind = Type.K_BOOL;
} else if (t instanceof SyntacticType.Byte) {
kind = Type.K_BYTE;
} else if (t instanceof SyntacticType.Char) {
kind = Type.K_CHAR;
} else if (t instanceof SyntacticType.Int) {
kind = Type.K_INT;
} else if (t instanceof SyntacticType.Real) {
kind = Type.K_RATIONAL;
} else if (t instanceof SyntacticType.Strung) {
kind = Type.K_STRING;
} else {
internalFailure("unrecognised type encountered ("
+ t.getClass().getName() + ")", context, t);
return 0; // dead-code
}
states.add(new Automaton.State(kind, null, true, Automaton.NOCHILDREN));
return myIndex;
}
private static int append(Type type, ArrayList<Automaton.State> states) {
int myIndex = states.size();
Automaton automaton = Type.destruct(type);
Automaton.State[] tStates = automaton.states;
int[] rmap = new int[tStates.length];
for (int i = 0, j = myIndex; i != rmap.length; ++i, ++j) {
rmap[i] = j;
}
for (Automaton.State state : tStates) {
states.add(Automata.remap(state, rmap));
}
return myIndex;
}
// ResolveAsConstant
/**
* <p>
* Resolve a given name as a constant value. This is a global problem, since
* a constant declaration in one source file may refer to constants declared
* in other compilation units. This function will actually evaluate constant
* expressions (e.g. "1+2") to produce actual constant vales.
* </p>
*
* <p>
* Constant declarations form a global graph spanning multiple compilation
* units. In resolving a given constant, this function must traverse those
* portions of the graph which make up the constant. Constants are not
* permitted to be declared recursively (i.e. in terms of themselves) and
* this function will report an error is such a recursive cycle is detected
* in the constant graph.
* </p>
*
* @param nid
* Fully qualified name identifier of constant to resolve
* @return Constant value representing named constant
* @throws IOException
*/
public Constant resolveAsConstant(NameID nid) throws IOException, ResolveError {
return resolveAsConstant(nid, new HashSet<NameID>());
}
/**
* <p>
* Resolve a given <i>constant expression</i> as a constant value. A
* constant expression is one which refers only to known and visible
* constant values, rather than e.g. local variables. Constant expressions
* may still use operators (e.g. "1+2", or "1+c" where c is a declared
* constant).
* </p>
*
* <p>
* Constant expressions used in a few places in Whiley. In particular, the
* cases of a <code>switch</code> statement must be defined using constant
* expressions.
* </p>
*
* @param e
* @param context
* @return
*/
public Constant resolveAsConstant(Expr e, Context context) {
e = propagate(e, new Environment(), context);
return resolveAsConstant(e, context, new HashSet<NameID>());
}
private Constant resolveAsConstant(NameID key, HashSet<NameID> visited)
throws IOException, ResolveError {
Constant result = constantCache.get(key);
if (result != null) {
return result;
} else if (visited.contains(key)) {
throw new ResolveError("cyclic constant definition encountered ("
+ key + " -> " + key + ")");
} else {
visited.add(key);
}
WhileyFile wf = builder.getSourceFile(key.module());
if (wf != null) {
WhileyFile.Declaration decl = wf.declaration(key.name());
if (decl instanceof WhileyFile.Constant) {
WhileyFile.Constant cd = (WhileyFile.Constant) decl;
if (cd.resolvedValue == null) {
cd.constant = propagate(cd.constant, new Environment(), cd);
cd.resolvedValue = resolveAsConstant(cd.constant, cd,
visited);
}
result = cd.resolvedValue;
} else {
throw new ResolveError("unable to find constant " + key);
}
} else {
WyilFile module = builder.getModule(key.module());
WyilFile.ConstantDeclaration cd = module.constant(key.name());
if (cd != null) {
result = cd.constant();
} else {
throw new ResolveError("unable to find constant " + key);
}
}
constantCache.put(key, result);
return result;
}
private Constant resolveAsConstant(Expr expr, Context context,
HashSet<NameID> visited) {
try {
if (expr instanceof Expr.Constant) {
Expr.Constant c = (Expr.Constant) expr;
return c.value;
} else if (expr instanceof Expr.ConstantAccess) {
Expr.ConstantAccess c = (Expr.ConstantAccess) expr;
ArrayList<String> qualifications = new ArrayList<String>();
if (c.qualification != null) {
for (String n : c.qualification) {
qualifications.add(n);
}
}
qualifications.add(c.name);
try {
NameID nid = resolveAsName(qualifications, context);
return resolveAsConstant(nid, visited);
} catch (ResolveError e) {
syntaxError(errorMessage(UNKNOWN_VARIABLE), context, expr);
return null;
}
} else if (expr instanceof Expr.BinOp) {
Expr.BinOp bop = (Expr.BinOp) expr;
Constant lhs = resolveAsConstant(bop.lhs, context, visited);
Constant rhs = resolveAsConstant(bop.rhs, context, visited);
return evaluate(bop, lhs, rhs, context);
} else if (expr instanceof Expr.UnOp) {
Expr.UnOp uop = (Expr.UnOp) expr;
Constant lhs = resolveAsConstant(uop.mhs, context, visited);
return evaluate(uop, lhs, context);
} else if (expr instanceof Expr.Set) {
Expr.Set nop = (Expr.Set) expr;
ArrayList<Constant> values = new ArrayList<Constant>();
for (Expr arg : nop.arguments) {
values.add(resolveAsConstant(arg, context, visited));
}
return Constant.V_SET(values);
} else if (expr instanceof Expr.List) {
Expr.List nop = (Expr.List) expr;
ArrayList<Constant> values = new ArrayList<Constant>();
for (Expr arg : nop.arguments) {
values.add(resolveAsConstant(arg, context, visited));
}
return Constant.V_LIST(values);
} else if (expr instanceof Expr.Record) {
Expr.Record rg = (Expr.Record) expr;
HashMap<String, Constant> values = new HashMap<String, Constant>();
for (Map.Entry<String, Expr> e : rg.fields.entrySet()) {
Constant v = resolveAsConstant(e.getValue(), context,
visited);
if (v == null) {
return null;
}
values.put(e.getKey(), v);
}
return Constant.V_RECORD(values);
} else if (expr instanceof Expr.Tuple) {
Expr.Tuple rg = (Expr.Tuple) expr;
ArrayList<Constant> values = new ArrayList<Constant>();
for (Expr e : rg.fields) {
Constant v = resolveAsConstant(e, context, visited);
if (v == null) {
return null;
}
values.add(v);
}
return Constant.V_TUPLE(values);
} else if (expr instanceof Expr.Map) {
Expr.Map rg = (Expr.Map) expr;
HashSet<Pair<Constant, Constant>> values = new HashSet<Pair<Constant, Constant>>();
for (Pair<Expr, Expr> e : rg.pairs) {
Constant key = resolveAsConstant(e.first(), context,
visited);
Constant value = resolveAsConstant(e.second(), context,
visited);
if (key == null || value == null) {
return null;
}
values.add(new Pair<Constant, Constant>(key, value));
}
return Constant.V_MAP(values);
} else if (expr instanceof Expr.FunctionOrMethod) {
// TODO: add support for proper lambdas
Expr.FunctionOrMethod f = (Expr.FunctionOrMethod) expr;
return Constant.V_LAMBDA(f.nid, f.type.raw());
}
} catch (SyntaxError.InternalFailure e) {
throw e;
} catch (Throwable e) {
internalFailure(e.getMessage(), context, expr, e);
}
internalFailure("unknown constant expression: "
+ expr.getClass().getName(), context, expr);
return null; // deadcode
}
/**
* Determine whether a name is visible in a given context. This effectively
* corresponds to checking whether or not the already name exists in the
* given context; or, a public or protected named is imported from another
* file.
*
* @param nid
* Name to check modifiers of
* @param context
* Context in which we are trying to access named item
*
* @return True if given context permitted to access name
* @throws IOException
*/
public boolean isNameVisible(NameID nid, Context context) throws IOException {
// Any element in the same file is automatically visible
if (nid.module().equals(context.file().module)) {
return true;
} else {
return hasModifier(nid, context, Modifier.PUBLIC)
|| hasModifier(nid, context, Modifier.PROTECTED);
}
}
/**
* Determine whether a named type is fully visible in a given context. This
* effectively corresponds to checking whether or not the already type
* exists in the given context; or, a public type is imported from another
* file.
*
* @param nid
* Name to check modifiers of
* @param context
* Context in which we are trying to access named item
*
* @return True if given context permitted to access name
* @throws IOException
*/
public boolean isTypeVisible(NameID nid, Context context) throws IOException {
// Any element in the same file is automatically visible
if (nid.module().equals(context.file().module)) {
return true;
} else {
return hasModifier(nid, context, Modifier.PUBLIC);
}
}
/**
* Determine whether a named item has a modifier matching one of a given
* list. This is particularly useful for checking visibility (e.g. public,
* private, etc) of named items.
*
* @param nid
* Name to check modifiers of
* @param context
* Context in which we are trying to access named item
* @param modifiers
*
* @return True if given context permitted to access name
* @throws IOException
*/
public boolean hasModifier(NameID nid, Context context, Modifier modifier)
throws IOException {
Path.ID mid = nid.module();
// Attempt to access source file first.
WhileyFile wf = builder.getSourceFile(mid);
if (wf != null) {
// Source file location, so check visible of element.
WhileyFile.NamedDeclaration nd = wf.declaration(nid.name());
return nd != null && nd.hasModifier(modifier);
} else {
// Source file not being compiled, therefore attempt to access wyil
// file directly.
// we have to do the following basically because we don't load
// modifiers properly out of jvm class files (at the moment).
// return false;
WyilFile w = builder.getModule(mid);
List<WyilFile.Declaration> declarations = w.declarations();
for (int i = 0; i != declarations.size(); ++i) {
WyilFile.Declaration d = declarations.get(i);
if (d instanceof WyilFile.NamedDeclaration) {
WyilFile.NamedDeclaration nd = (WyilFile.NamedDeclaration) d;
return nd != null && nd.hasModifier(modifier);
}
}
return false;
}
}
// Constant Evaluation
/**
* Evaluate a given unary operator on a given input value.
*
* @param operator
* Unary operator to evaluate
* @param operand
* Operand to apply operator on
* @param context
* Context in which to apply operator (useful for error
* reporting)
* @return
*/
private Constant evaluate(Expr.UnOp operator, Constant operand,
Context context) {
switch (operator.op) {
case NOT:
if (operand instanceof Constant.Bool) {
Constant.Bool b = (Constant.Bool) operand;
return Constant.V_BOOL(!b.value);
}
syntaxError(errorMessage(INVALID_BOOLEAN_EXPRESSION), context,
operator);
break;
case NEG:
if (operand instanceof Constant.Integer) {
Constant.Integer b = (Constant.Integer) operand;
return Constant.V_INTEGER(b.value.negate());
} else if (operand instanceof Constant.Decimal) {
Constant.Decimal b = (Constant.Decimal) operand;
return Constant.V_DECIMAL(b.value.negate());
}
syntaxError(errorMessage(INVALID_NUMERIC_EXPRESSION), context,
operator);
break;
case INVERT:
if (operand instanceof Constant.Byte) {
Constant.Byte b = (Constant.Byte) operand;
return Constant.V_BYTE((byte) ~b.value);
}
break;
}
syntaxError(errorMessage(INVALID_UNARY_EXPRESSION), context, operator);
return null;
}
private Constant evaluate(Expr.BinOp bop, Constant v1, Constant v2,
Context context) {
Type v1_type = v1.type();
Type v2_type = v2.type();
Type lub = Type.Union(v1_type, v2_type);
// FIXME: there are bugs here related to coercions.
if (Type.isSubtype(Type.T_BOOL, lub)) {
return evaluateBoolean(bop, (Constant.Bool) v1, (Constant.Bool) v2,
context);
} else if (Type.isSubtype(Type.T_INT, lub)) {
return evaluate(bop, (Constant.Integer) v1, (Constant.Integer) v2,
context);
} else if (Type.isImplicitCoerciveSubtype(Type.T_REAL, v1_type)
&& Type.isImplicitCoerciveSubtype(Type.T_REAL, v1_type)) {
if (v1 instanceof Constant.Integer) {
Constant.Integer i1 = (Constant.Integer) v1;
v1 = Constant.V_DECIMAL(new BigDecimal(i1.value));
} else if (v2 instanceof Constant.Integer) {
Constant.Integer i2 = (Constant.Integer) v2;
v2 = Constant.V_DECIMAL(new BigDecimal(i2.value));
}
return evaluate(bop, (Constant.Decimal) v1, (Constant.Decimal) v2,
context);
} else if (Type.isSubtype(Type.T_LIST_ANY, lub)) {
return evaluate(bop, (Constant.List) v1, (Constant.List) v2,
context);
} else if (Type.isSubtype(Type.T_SET_ANY, lub)) {
return evaluate(bop, (Constant.Set) v1, (Constant.Set) v2, context);
}
syntaxError(errorMessage(INVALID_BINARY_EXPRESSION), context, bop);
return null;
}
private Constant evaluateBoolean(Expr.BinOp bop, Constant.Bool v1,
Constant.Bool v2, Context context) {
switch (bop.op) {
case AND:
return Constant.V_BOOL(v1.value & v2.value);
case OR:
return Constant.V_BOOL(v1.value | v2.value);
case XOR:
return Constant.V_BOOL(v1.value ^ v2.value);
}
syntaxError(errorMessage(INVALID_BOOLEAN_EXPRESSION), context, bop);
return null;
}
private Constant evaluate(Expr.BinOp bop, Constant.Integer v1,
Constant.Integer v2, Context context) {
switch (bop.op) {
case ADD:
return Constant.V_INTEGER(v1.value.add(v2.value));
case SUB:
return Constant.V_INTEGER(v1.value.subtract(v2.value));
case MUL:
return Constant.V_INTEGER(v1.value.multiply(v2.value));
case DIV:
return Constant.V_INTEGER(v1.value.divide(v2.value));
case REM:
return Constant.V_INTEGER(v1.value.remainder(v2.value));
}
syntaxError(errorMessage(INVALID_NUMERIC_EXPRESSION), context, bop);
return null;
}
private Constant evaluate(Expr.BinOp bop, Constant.Decimal v1,
Constant.Decimal v2, Context context) {
switch (bop.op) {
case ADD:
return Constant.V_DECIMAL(v1.value.add(v2.value));
case SUB:
return Constant.V_DECIMAL(v1.value.subtract(v2.value));
case MUL:
return Constant.V_DECIMAL(v1.value.multiply(v2.value));
case DIV:
return Constant.V_DECIMAL(v1.value.divide(v2.value));
}
syntaxError(errorMessage(INVALID_NUMERIC_EXPRESSION), context, bop);
return null;
}
private Constant evaluate(Expr.BinOp bop, Constant.List v1,
Constant.List v2, Context context) {
switch (bop.op) {
case ADD:
ArrayList<Constant> vals = new ArrayList<Constant>(v1.values);
vals.addAll(v2.values);
return Constant.V_LIST(vals);
}
syntaxError(errorMessage(INVALID_LIST_EXPRESSION), context, bop);
return null;
}
private Constant evaluate(Expr.BinOp bop, Constant.Set v1, Constant.Set v2,
Context context) {
switch (bop.op) {
case UNION: {
HashSet<Constant> vals = new HashSet<Constant>(v1.values);
vals.addAll(v2.values);
return Constant.V_SET(vals);
}
case INTERSECTION: {
HashSet<Constant> vals = new HashSet<Constant>();
for (Constant v : v1.values) {
if (v2.values.contains(v)) {
vals.add(v);
}
}
return Constant.V_SET(vals);
}
case SUB: {
HashSet<Constant> vals = new HashSet<Constant>();
for (Constant v : v1.values) {
if (!v2.values.contains(v)) {
vals.add(v);
}
}
return Constant.V_SET(vals);
}
}
syntaxError(errorMessage(INVALID_SET_EXPRESSION), context, bop);
return null;
}
// expandAsType
public Nominal.EffectiveSet expandAsEffectiveSet(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.EffectiveSet) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.EffectiveSet)) {
nominal = raw; // discard nominal information
}
return (Nominal.EffectiveSet) Nominal.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.EffectiveList expandAsEffectiveList(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.EffectiveList) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.EffectiveList)) {
nominal = raw; // discard nominal information
}
return (Nominal.EffectiveList) Nominal.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.EffectiveCollection expandAsEffectiveCollection(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.EffectiveCollection) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.EffectiveCollection)) {
nominal = raw; // discard nominal information
}
return (Nominal.EffectiveCollection) Nominal
.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.EffectiveIndexible expandAsEffectiveMap(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.EffectiveIndexible) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.EffectiveIndexible)) {
nominal = raw; // discard nominal information
}
return (Nominal.EffectiveIndexible) Nominal.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.EffectiveMap expandAsEffectiveDictionary(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.EffectiveMap) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.EffectiveMap)) {
nominal = raw; // discard nominal information
}
return (Nominal.EffectiveMap) Nominal.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.EffectiveRecord expandAsEffectiveRecord(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.Record) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.Record)) {
nominal = (Type) raw; // discard nominal information
}
return (Nominal.Record) Nominal.construct(nominal, raw);
} else if (raw instanceof Type.UnionOfRecords) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.UnionOfRecords)) {
nominal = (Type) raw; // discard nominal information
}
return (Nominal.UnionOfRecords) Nominal.construct(nominal, raw);
}
{
return null;
}
}
public Nominal.EffectiveTuple expandAsEffectiveTuple(Nominal lhs)
throws IOException, ResolveError {
Type raw = lhs.raw();
if (raw instanceof Type.EffectiveTuple) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.EffectiveTuple)) {
nominal = raw; // discard nominal information
}
return (Nominal.EffectiveTuple) Nominal.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.Reference expandAsReference(Nominal lhs) throws IOException, ResolveError {
Type.Reference raw = Type.effectiveReference(lhs.raw());
if (raw != null) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.Reference)) {
nominal = raw; // discard nominal information
}
return (Nominal.Reference) Nominal.construct(nominal, raw);
} else {
return null;
}
}
public Nominal.FunctionOrMethod expandAsFunctionOrMethod(Nominal lhs)
throws IOException, ResolveError {
Type.FunctionOrMethod raw = Type.effectiveFunctionOrMethod(lhs.raw());
if (raw != null) {
Type nominal = expandOneLevel(lhs.nominal());
if (!(nominal instanceof Type.FunctionOrMethod)) {
nominal = raw; // discard nominal information
}
return (Nominal.FunctionOrMethod) Nominal.construct(nominal, raw);
} else {
return null;
}
}
private Type expandOneLevel(Type type) throws IOException, ResolveError {
if (type instanceof Type.Nominal) {
Type.Nominal nt = (Type.Nominal) type;
NameID nid = nt.name();
Path.ID mid = nid.module();
WhileyFile wf = builder.getSourceFile(mid);
Type r = null;
if (wf != null) {
WhileyFile.Declaration decl = wf.declaration(nid.name());
if (decl instanceof WhileyFile.Type) {
WhileyFile.Type td = (WhileyFile.Type) decl;
r = resolveAsType(td.pattern.toSyntacticType(), td)
.nominal();
}
} else {
WyilFile m = builder.getModule(mid);
WyilFile.TypeDeclaration td = m.type(nid.name());
if (td != null) {
r = td.type();
}
}
if (r == null) {
throw new ResolveError("unable to locate " + nid);
}
return expandOneLevel(r);
} else if (type instanceof Type.Leaf || type instanceof Type.Reference
|| type instanceof Type.Tuple || type instanceof Type.Set
|| type instanceof Type.List || type instanceof Type.Map
|| type instanceof Type.Record
|| type instanceof Type.FunctionOrMethod
|| type instanceof Type.Negation) {
return type;
} else {
Type.Union ut = (Type.Union) type;
ArrayList<Type> bounds = new ArrayList<Type>();
for (Type b : ut.bounds()) {
bounds.add(expandOneLevel(b));
}
return Type.Union(bounds);
}
}
// Misc
// Check t1 :> t2
private void checkIsSubtype(Nominal t1, Nominal t2, SyntacticElement elem) {
if (!Type.isImplicitCoerciveSubtype(t1.raw(), t2.raw())) {
syntaxError(
errorMessage(SUBTYPE_ERROR, t1.nominal(), t2.nominal()),
filename, elem);
}
}
private void checkIsSubtype(Nominal t1, Expr t2) {
if (!Type.isImplicitCoerciveSubtype(t1.raw(), t2.result().raw())) {
// We use the nominal type for error reporting, since this includes
// more helpful names.
syntaxError(
errorMessage(SUBTYPE_ERROR, t1.nominal(), t2.result()
.nominal()), filename, t2);
}
}
private void checkIsSubtype(Type t1, Expr t2) {
if (!Type.isImplicitCoerciveSubtype(t1, t2.result().raw())) {
// We use the nominal type for error reporting, since this includes
// more helpful names.
syntaxError(errorMessage(SUBTYPE_ERROR, t1, t2.result().nominal()),
filename, t2);
}
}
// Check t1 :> t2
private void checkIsSubtype(Nominal t1, Nominal t2, SyntacticElement elem,
Context context) {
if (!Type.isImplicitCoerciveSubtype(t1.raw(), t2.raw())) {
syntaxError(
errorMessage(SUBTYPE_ERROR, t1.nominal(), t2.nominal()),
context, elem);
}
}
private void checkIsSubtype(Nominal t1, Expr t2, Context context) {
if (!Type.isImplicitCoerciveSubtype(t1.raw(), t2.result().raw())) {
// We use the nominal type for error reporting, since this includes
// more helpful names.
syntaxError(
errorMessage(SUBTYPE_ERROR, t1.nominal(), t2.result()
.nominal()), context, t2);
}
}
private void checkIsSubtype(Type t1, Expr t2, Context context) {
if (!Type.isImplicitCoerciveSubtype(t1, t2.result().raw())) {
// We use the nominal type for error reporting, since this includes
// more helpful names.
syntaxError(errorMessage(SUBTYPE_ERROR, t1, t2.result().nominal()),
context, t2);
}
}
// Environment Class
/**
* <p>
* Responsible for mapping source-level variables to their declared and
* actual types, at any given program point. Since the flow-type checker
* uses a flow-sensitive approach to type checking, then the typing
* environment will change as we move through the statements of a function
* or method.
* </p>
*
* <p>
* This class is implemented in a functional style to minimise possible
* problems related to aliasing (which have been a problem in the past). To
* improve performance, reference counting is to ensure that cloning the
* underling map is only performed when actually necessary.
* </p>
*
* @author David J. Pearce
*
*/
private static final class Environment {
/**
* The mapping of variables to their declared type.
*/
private final HashMap<String, Nominal> declaredTypes;
/**
* The mapping of variables to their current type.
*/
private final HashMap<String, Nominal> currentTypes;
/**
* The reference count, which indicate how many references to this
* environment there are. When there is only one reference, then the put
* and putAll operations will perform an "inplace" update (i.e. without
* cloning the underlying collection).
*/
private int count; // refCount
/**
* Construct an empty environment. Initially the reference count is 1.
*/
public Environment() {
count = 1;
currentTypes = new HashMap<String, Nominal>();
declaredTypes = new HashMap<String, Nominal>();
}
/**
* Construct a fresh environment as a copy of another map. Initially the
* reference count is 1.
*/
private Environment(Environment environment) {
count = 1;
this.currentTypes = (HashMap<String, Nominal>) environment.currentTypes.clone();
this.declaredTypes = (HashMap<String, Nominal>) environment.declaredTypes.clone();
}
/**
* Get the type associated with a given variable at the current program
* point, or null if that variable is not declared.
*
* @param variable
* Variable to return type for.
* @return
*/
public Nominal getCurrentType(String variable) {
return currentTypes.get(variable);
}
/**
* Get the declared type of a given variable, or null if that variable
* is not declared.
*
* @param variable
* Variable to return type for.
* @return
*/
public Nominal getDeclaredType(String variable) {
return declaredTypes.get(variable);
}
/**
* Check whether a given variable is declared within this environment.
*
* @param variable
* @return
*/
public boolean containsKey(String variable) {
return declaredTypes.containsKey(variable);
}
/**
* Return the set of declared variables in this environment (a.k.a the
* domain).
*
* @return
*/
public Set<String> keySet() {
return declaredTypes.keySet();
}
/**
* Declare a new variable with a given type. In the case that this
* environment has a reference count of 1, then an "in place" update is
* performed. Otherwise, a fresh copy of this environment is returned
* with the given variable associated with the given type, whilst this
* environment is unchanged.
*
* @param variable
* Name of variable to be declared with given type
* @param declared
* Declared type of the given variable
* @param initial
* Initial type of given variable
* @return An updated version of the environment which contains the new
* association.
*/
public Environment declare(String variable, Nominal declared, Nominal initial) {
if (declaredTypes.containsKey(variable)) {
throw new RuntimeException("Variable already declared - "
+ variable);
}
if (count == 1) {
declaredTypes.put(variable, declared);
currentTypes.put(variable, initial);
return this;
} else {
Environment nenv = new Environment(this);
nenv.declaredTypes.put(variable, declared);
nenv.currentTypes.put(variable, initial);
count
return nenv;
}
}
/**
* Update the current type of a given variable. If that variable already
* had a current type, then this is overwritten. In the case that this
* environment has a reference count of 1, then an "in place" update is
* performed. Otherwise, a fresh copy of this environment is returned
* with the given variable associated with the given type, whilst this
* environment is unchanged.
*
* @param variable
* Name of variable to be associated with given type
* @param type
* Type to associated with given variable
* @return An updated version of the environment which contains the new
* association.
*/
public Environment update(String variable, Nominal type) {
if (!declaredTypes.containsKey(variable)) {
throw new RuntimeException("Variable not declared - "
+ variable);
}
if (count == 1) {
currentTypes.put(variable, type);
return this;
} else {
Environment nenv = new Environment(this);
nenv.currentTypes.put(variable, type);
count
return nenv;
}
}
/**
* Remove a variable and any associated type from this environment. In
* the case that this environment has a reference count of 1, then an
* "in place" update is performed. Otherwise, a fresh copy of this
* environment is returned with the given variable and any association
* removed.
*
* @param variable
* Name of variable to be removed from the environment
* @return An updated version of the environment in which the given
* variable no longer exists.
*/
public Environment remove(String key) {
if (count == 1) {
currentTypes.remove(key);
return this;
} else {
Environment nenv = new Environment(this);
nenv.currentTypes.remove(key);
count
return nenv;
}
}
/**
* Create a fresh copy of this environment. In fact, this operation
* simply increments the reference count of this environment and returns
* it.
*/
public Environment clone() {
count++;
return this;
}
/**
* Decrease the reference count of this environment by one.
*/
public void free() {
--count;
}
public String toString() {
return currentTypes.toString();
}
public int hashCode() {
return currentTypes.hashCode();
}
public boolean equals(Object o) {
if (o instanceof Environment) {
Environment r = (Environment) o;
return currentTypes.equals(r.currentTypes);
}
return false;
}
}
private static final Environment BOTTOM = new Environment();
private static final Environment join(Environment lhs, Environment rhs) {
// first, need to check for the special bottom value case.
if (lhs == BOTTOM) {
return rhs;
} else if (rhs == BOTTOM) {
return lhs;
}
// ok, not bottom so compute intersection.
lhs.free();
rhs.free();
Environment result = new Environment();
for (String key : lhs.keySet()) {
if (rhs.containsKey(key)) {
Nominal lhs_t = lhs.getCurrentType(key);
Nominal rhs_t = rhs.getCurrentType(key);
result.update(key, Nominal.Union(lhs_t, rhs_t));
}
}
return result;
}
}
|
package com.expedia.database;
import com.expedia.test.config.SpringContextTest;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* test database on test properties configuration
*
* @author shareef on 27/10/2017
*/
public class DataBaseTest extends SpringContextTest {
@Value("${spring.datasource.url}")
private String dbUrl;
@Value("${spring.datasource.username}")
private String userName;
@Value("${spring.datasource.password}")
private String password;
@Value("${spring.datasource.driver}")
private String driver;
@Autowired
private DataSource dataSource;
@Test
public void pingDatabaseConnection() {
ResultSet rs = null;
Statement stmt = null;
try (Connection connection = dataSource.getConnection()) {
stmt = connection.createStatement();
stmt.executeUpdate("DROP TABLE IF EXISTS ticks");
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS ticks (tick TIMESTAMP)");
stmt.executeUpdate("INSERT INTO ticks VALUES (now())");
rs = stmt.executeQuery("SELECT tick FROM ticks");
ArrayList<String> output = new ArrayList<>();
while (rs.next()) {
output.add(String.valueOf(rs.getTimestamp("tick")));
}
Assert.assertTrue(!output.isEmpty());
} catch (Exception e) {
Logger.getLogger(SpringContextTest.class.getName())
.log(Level.INFO, "Exception In " + DataBaseTest.class.getName());
} finally {
try {
if (stmt != null)
stmt.close();
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
@Bean
public DataSource dataSource() throws SQLException {
if (dbUrl == null || dbUrl.isEmpty()) {
return new HikariDataSource();
} else {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(dbUrl);
config.setUsername(userName);
config.setPassword(password);
config.setDriverClassName(driver);
return new HikariDataSource(config);
}
}
}
|
package big.marketing.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import org.apache.log4j.Logger;
import big.marketing.data.DataType;
import big.marketing.data.HealthMessage;
import big.marketing.data.Node;
import big.marketing.reader.NetworkReader;
import big.marketing.reader.ZipReader;
public class DataController extends Observable {
static Logger logger = Logger.getLogger(DataController.class);
private MongoController mongoController;
// qWindow size in milliseconds
static final int QUERYWINDOW_SIZE = 1000 * 60 * 60;
// qWindow variables store the data returned from mongo
private ArrayList<HealthMessage> qWindowHealth = null;
private ArrayList<HealthMessage> qWindowIPS = null;
private ArrayList<HealthMessage> qWindowFlow = null;
private List<Node> network = null;
private Node[] highlightedNodes = null;
private Node selectedNode = null;
public DataController() {
this.mongoController = new MongoController();
NetworkReader nReader = new NetworkReader(this.mongoController);
ZipReader zReader = new ZipReader(this.mongoController);
boolean flowInDB = mongoController.isDataInDatabase(DataType.FLOW);
boolean healthInDB = mongoController.isDataInDatabase(DataType.HEALTH);
boolean ipsInDB = mongoController.isDataInDatabase(DataType.IPS);
try {
// TODO Catch all reading error in DataController
network = nReader.readNetwork();
for (int week = 1; week <= 2; week++) {
if (!flowInDB)
zReader.read(DataType.FLOW, week);
if (!healthInDB)
zReader.read(DataType.HEALTH, week);
if (!ipsInDB)
zReader.read(DataType.IPS, week);
}
} catch (IOException err) {
logger.error("Error while loading network data.", err);
}
}
/**
* Moves QueryWindow to certain position in time and queries data to qWindow
* variables from mongo Hides mongo implementation details from views
*
* @param date in milliseconds
* @return true if data queried successfully from mongo, false otherwise
*/
public boolean moveQueryWindow(int date) {
// TODO implement moveQueryWindow
// TODO fetch health data
// TODO fetch flow data
// TODO fetch IPS data
return false;
}
public List<Node> getNetwork() {
return network;
}
public ArrayList<HealthMessage> getqWindowHealth() {
return qWindowHealth;
}
public ArrayList<HealthMessage> getqWindowIPS() {
return qWindowIPS;
}
public ArrayList<HealthMessage> getqWindowFlow() {
return qWindowFlow;
}
public void setMongoController(MongoController mongoController) {
this.mongoController = mongoController;
}
public MongoController getMongoController() {
return mongoController;
}
public void setHighlightedNodes(Node[] highlightedNodes) {
this.highlightedNodes = highlightedNodes;
setChanged();
}
public void setSelectedNode(Node selectedNode) {
this.selectedNode = selectedNode;
setChanged();
}
public Node[] getHighlightedNodes() {
return highlightedNodes;
}
public Node getSelectedNode() {
return selectedNode;
}
}
|
package fr.jayasoft.ivy.ant;
import java.io.File;
import junit.framework.TestCase;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Delete;
public class IvyReportTest extends TestCase {
private File _cache;
private IvyReport _report;
private Project _project;
protected void setUp() throws Exception {
createCache();
_project = new Project();
_project.setProperty("ivy.conf.file", "test/repositories/ivyconf.xml");
_report = new IvyReport();
_report.setTaskName("report");
_report.setProject(_project);
_report.setCache(_cache);
}
private void createCache() {
_cache = new File("build/cache");
_cache.mkdirs();
}
protected void tearDown() throws Exception {
cleanCache();
}
private void cleanCache() {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(_cache);
del.execute();
}
public void testRegularCircular() throws Exception {
_project.setProperty("ivy.dep.file", "test/repositories/2/mod11.1/ivy-1.0.xml");
IvyResolve res = new IvyResolve();
res.setProject(_project);
res.execute();
_report.setTodir(new File(_cache, "report"));
_report.setXml(true);
// do not test any xsl transformation here, because of problems of build in our continuous integration server
_report.setXsl(false);
_report.setGraph(false);
_report.execute();
assertTrue(new File(_cache, "report/org11-mod11.1-compile.xml").exists());
}
}
|
/* This file is automatically generated. Do not edit. */
package net.runelite.api;
public final class ItemID
{
public static final int DWARF_REMAINS = 0;
public static final int TOOLKIT = 1;
public static final int CANNONBALL = 2;
public static final int NULODIONS_NOTES = 3;
public static final int AMMO_MOULD = 4;
public static final int INSTRUCTION_MANUAL = 5;
public static final int CANNON_BASE = 6;
public static final int CANNON_STAND = 8;
public static final int CANNON_BARRELS = 10;
public static final int CANNON_FURNACE = 12;
public static final int RAILING = 14;
public static final int HOLY_TABLE_NAPKIN = 15;
public static final int MAGIC_WHISTLE = 16;
public static final int GRAIL_BELL = 17;
public static final int MAGIC_GOLD_FEATHER = 18;
public static final int HOLY_GRAIL = 19;
public static final int WHITE_COG = 20;
public static final int BLACK_COG = 21;
public static final int BLUE_COG = 22;
public static final int RED_COG = 23;
public static final int RAT_POISON = 24;
public static final int RED_VINE_WORM = 25;
public static final int FISHING_TROPHY = 26;
public static final int FISHING_PASS = 27;
public static final int INSECT_REPELLENT = 28;
public static final int BUCKET_OF_WAX = 30;
public static final int LIT_BLACK_CANDLE = 32;
public static final int LIT_CANDLE = 33;
public static final int EXCALIBUR = 35;
public static final int CANDLE = 36;
public static final int BLACK_CANDLE = 38;
public static final int BRONZE_ARROWTIPS = 39;
public static final int IRON_ARROWTIPS = 40;
public static final int STEEL_ARROWTIPS = 41;
public static final int MITHRIL_ARROWTIPS = 42;
public static final int ADAMANT_ARROWTIPS = 43;
public static final int RUNE_ARROWTIPS = 44;
public static final int OPAL_BOLT_TIPS = 45;
public static final int PEARL_BOLT_TIPS = 46;
public static final int BARB_BOLTTIPS = 47;
public static final int LONGBOW_U = 48;
public static final int SHORTBOW_U = 50;
public static final int ARROW_SHAFT = 52;
public static final int HEADLESS_ARROW = 53;
public static final int OAK_SHORTBOW_U = 54;
public static final int OAK_LONGBOW_U = 56;
public static final int WILLOW_LONGBOW_U = 58;
public static final int WILLOW_SHORTBOW_U = 60;
public static final int MAPLE_LONGBOW_U = 62;
public static final int MAPLE_SHORTBOW_U = 64;
public static final int YEW_LONGBOW_U = 66;
public static final int YEW_SHORTBOW_U = 68;
public static final int MAGIC_LONGBOW_U = 70;
public static final int MAGIC_SHORTBOW_U = 72;
public static final int KHAZARD_HELMET = 74;
public static final int KHAZARD_ARMOUR = 75;
public static final int KHAZARD_CELL_KEYS = 76;
public static final int KHALI_BREW = 77;
public static final int ICE_ARROWS = 78;
public static final int LEVER = 83;
public static final int STAFF_OF_ARMADYL = 84;
public static final int SHINY_KEY = 85;
public static final int PENDANT_OF_LUCIEN = 86;
public static final int ARMADYL_PENDANT = 87;
public static final int BOOTS_OF_LIGHTNESS = 88;
public static final int BOOTS_OF_LIGHTNESS_89 = 89;
public static final int CHILDS_BLANKET = 90;
public static final int GUAM_POTION_UNF = 91;
public static final int MARRENTILL_POTION_UNF = 93;
public static final int TARROMIN_POTION_UNF = 95;
public static final int HARRALANDER_POTION_UNF = 97;
public static final int RANARR_POTION_UNF = 99;
public static final int IRIT_POTION_UNF = 101;
public static final int AVANTOE_POTION_UNF = 103;
public static final int KWUARM_POTION_UNF = 105;
public static final int CADANTINE_POTION_UNF = 107;
public static final int DWARF_WEED_POTION_UNF = 109;
public static final int TORSTOL_POTION_UNF = 111;
public static final int STRENGTH_POTION4 = 113;
public static final int STRENGTH_POTION3 = 115;
public static final int STRENGTH_POTION2 = 117;
public static final int STRENGTH_POTION1 = 119;
public static final int ATTACK_POTION3 = 121;
public static final int ATTACK_POTION2 = 123;
public static final int ATTACK_POTION1 = 125;
public static final int RESTORE_POTION3 = 127;
public static final int RESTORE_POTION2 = 129;
public static final int RESTORE_POTION1 = 131;
public static final int DEFENCE_POTION3 = 133;
public static final int DEFENCE_POTION2 = 135;
public static final int DEFENCE_POTION1 = 137;
public static final int PRAYER_POTION3 = 139;
public static final int PRAYER_POTION2 = 141;
public static final int PRAYER_POTION1 = 143;
public static final int SUPER_ATTACK3 = 145;
public static final int SUPER_ATTACK2 = 147;
public static final int SUPER_ATTACK1 = 149;
public static final int FISHING_POTION3 = 151;
public static final int FISHING_POTION2 = 153;
public static final int FISHING_POTION1 = 155;
public static final int SUPER_STRENGTH3 = 157;
public static final int SUPER_STRENGTH2 = 159;
public static final int SUPER_STRENGTH1 = 161;
public static final int SUPER_DEFENCE3 = 163;
public static final int SUPER_DEFENCE2 = 165;
public static final int SUPER_DEFENCE1 = 167;
public static final int RANGING_POTION3 = 169;
public static final int RANGING_POTION2 = 171;
public static final int RANGING_POTION1 = 173;
public static final int ANTIPOISON3 = 175;
public static final int ANTIPOISON2 = 177;
public static final int ANTIPOISON1 = 179;
public static final int SUPERANTIPOISON3 = 181;
public static final int SUPERANTIPOISON2 = 183;
public static final int SUPERANTIPOISON1 = 185;
public static final int WEAPON_POISON = 187;
public static final int ZAMORAK_BREW3 = 189;
public static final int ZAMORAK_BREW2 = 191;
public static final int ZAMORAK_BREW1 = 193;
public static final int POTION = 195;
public static final int POISON_CHALICE = 197;
public static final int GRIMY_GUAM_LEAF = 199;
public static final int GRIMY_MARRENTILL = 201;
public static final int GRIMY_TARROMIN = 203;
public static final int GRIMY_HARRALANDER = 205;
public static final int GRIMY_RANARR_WEED = 207;
public static final int GRIMY_IRIT_LEAF = 209;
public static final int GRIMY_AVANTOE = 211;
public static final int GRIMY_KWUARM = 213;
public static final int GRIMY_CADANTINE = 215;
public static final int GRIMY_DWARF_WEED = 217;
public static final int GRIMY_TORSTOL = 219;
public static final int EYE_OF_NEWT = 221;
public static final int RED_SPIDERS_EGGS = 223;
public static final int LIMPWURT_ROOT = 225;
public static final int VIAL_OF_WATER = 227;
public static final int VIAL = 229;
public static final int SNAPE_GRASS = 231;
public static final int PESTLE_AND_MORTAR = 233;
public static final int UNICORN_HORN_DUST = 235;
public static final int UNICORN_HORN = 237;
public static final int WHITE_BERRIES = 239;
public static final int DRAGON_SCALE_DUST = 241;
public static final int BLUE_DRAGON_SCALE = 243;
public static final int WINE_OF_ZAMORAK = 245;
public static final int JANGERBERRIES = 247;
public static final int GUAM_LEAF = 249;
public static final int MARRENTILL = 251;
public static final int TARROMIN = 253;
public static final int HARRALANDER = 255;
public static final int RANARR_WEED = 257;
public static final int IRIT_LEAF = 259;
public static final int AVANTOE = 261;
public static final int KWUARM = 263;
public static final int CADANTINE = 265;
public static final int DWARF_WEED = 267;
public static final int TORSTOL = 269;
public static final int PRESSURE_GAUGE = 271;
public static final int FISH_FOOD = 272;
public static final int POISON = 273;
public static final int POISONED_FISH_FOOD = 274;
public static final int KEY = 275;
public static final int RUBBER_TUBE = 276;
public static final int OIL_CAN = 277;
public static final int CATTLEPROD = 278;
public static final int SHEEP_FEED = 279;
public static final int SHEEP_BONES_1 = 280;
public static final int SHEEP_BONES_2 = 281;
public static final int SHEEP_BONES_3 = 282;
public static final int SHEEP_BONES_4 = 283;
public static final int PLAGUE_JACKET = 284;
public static final int PLAGUE_TROUSERS = 285;
public static final int ORANGE_GOBLIN_MAIL = 286;
public static final int BLUE_GOBLIN_MAIL = 287;
public static final int GOBLIN_MAIL = 288;
public static final int RESEARCH_PACKAGE = 290;
public static final int NOTES = 291;
public static final int BOOK_ON_BAXTORIAN = 292;
public static final int KEY_293 = 293;
public static final int GLARIALS_PEBBLE = 294;
public static final int GLARIALS_AMULET = 295;
public static final int GLARIALS_URN = 296;
public static final int GLARIALS_URN_EMPTY = 297;
public static final int KEY_298 = 298;
public static final int MITHRIL_SEEDS = 299;
public static final int RATS_TAIL = 300;
public static final int LOBSTER_POT = 301;
public static final int SMALL_FISHING_NET = 303;
public static final int BIG_FISHING_NET = 305;
public static final int FISHING_ROD = 307;
public static final int FLY_FISHING_ROD = 309;
public static final int HARPOON = 311;
public static final int FISHING_BAIT = 313;
public static final int FEATHER = 314;
public static final int SHRIMPS = 315;
public static final int RAW_SHRIMPS = 317;
public static final int ANCHOVIES = 319;
public static final int RAW_ANCHOVIES = 321;
public static final int BURNT_FISH = 323;
public static final int SARDINE = 325;
public static final int RAW_SARDINE = 327;
public static final int SALMON = 329;
public static final int RAW_SALMON = 331;
public static final int TROUT = 333;
public static final int RAW_TROUT = 335;
public static final int GIANT_CARP = 337;
public static final int RAW_GIANT_CARP = 338;
public static final int COD = 339;
public static final int RAW_COD = 341;
public static final int BURNT_FISH_343 = 343;
public static final int RAW_HERRING = 345;
public static final int HERRING = 347;
public static final int RAW_PIKE = 349;
public static final int PIKE = 351;
public static final int RAW_MACKEREL = 353;
public static final int MACKEREL = 355;
public static final int BURNT_FISH_357 = 357;
public static final int RAW_TUNA = 359;
public static final int TUNA = 361;
public static final int RAW_BASS = 363;
public static final int BASS = 365;
public static final int BURNT_FISH_367 = 367;
public static final int BURNT_FISH_369 = 369;
public static final int RAW_SWORDFISH = 371;
public static final int SWORDFISH = 373;
public static final int BURNT_SWORDFISH = 375;
public static final int RAW_LOBSTER = 377;
public static final int LOBSTER = 379;
public static final int BURNT_LOBSTER = 381;
public static final int RAW_SHARK = 383;
public static final int SHARK = 385;
public static final int BURNT_SHARK = 387;
public static final int RAW_MANTA_RAY = 389;
public static final int MANTA_RAY = 391;
public static final int BURNT_MANTA_RAY = 393;
public static final int RAW_SEA_TURTLE = 395;
public static final int SEA_TURTLE = 397;
public static final int BURNT_SEA_TURTLE = 399;
public static final int SEAWEED = 401;
public static final int EDIBLE_SEAWEED = 403;
public static final int CASKET = 405;
public static final int OYSTER = 407;
public static final int EMPTY_OYSTER = 409;
public static final int OYSTER_PEARL = 411;
public static final int OYSTER_PEARLS = 413;
public static final int ETHENEA = 415;
public static final int LIQUID_HONEY = 416;
public static final int SULPHURIC_BROLINE = 417;
public static final int PLAGUE_SAMPLE = 418;
public static final int TOUCH_PAPER = 419;
public static final int DISTILLATOR = 420;
public static final int LATHAS_AMULET = 421;
public static final int BIRD_FEED = 422;
public static final int KEY_423 = 423;
public static final int PIGEON_CAGE = 424;
public static final int PIGEON_CAGE_425 = 425;
public static final int PRIEST_GOWN = 426;
public static final int PRIEST_GOWN_428 = 428;
public static final int MEDICAL_GOWN = 430;
public static final int KARAMJAN_RUM = 431;
public static final int CHEST_KEY = 432;
public static final int PIRATE_MESSAGE = 433;
public static final int CLAY = 434;
public static final int COPPER_ORE = 436;
public static final int TIN_ORE = 438;
public static final int IRON_ORE = 440;
public static final int SILVER_ORE = 442;
public static final int GOLD_ORE = 444;
public static final int PERFECT_GOLD_ORE = 446;
public static final int MITHRIL_ORE = 447;
public static final int ADAMANTITE_ORE = 449;
public static final int RUNITE_ORE = 451;
public static final int COAL = 453;
public static final int BARCRAWL_CARD = 455;
public static final int SCORPION_CAGE = 456;
public static final int SCORPION_CAGE_457 = 457;
public static final int SCORPION_CAGE_458 = 458;
public static final int SCORPION_CAGE_459 = 459;
public static final int SCORPION_CAGE_460 = 460;
public static final int SCORPION_CAGE_461 = 461;
public static final int SCORPION_CAGE_462 = 462;
public static final int SCORPION_CAGE_463 = 463;
public static final int STRANGE_FRUIT = 464;
public static final int PICKAXE_HANDLE = 466;
public static final int BROKEN_PICKAXE = 468;
public static final int BROKEN_PICKAXE_470 = 470;
public static final int BROKEN_PICKAXE_472 = 472;
public static final int BROKEN_PICKAXE_474 = 474;
public static final int BROKEN_PICKAXE_476 = 476;
public static final int BROKEN_PICKAXE_478 = 478;
public static final int BRONZE_PICK_HEAD = 480;
public static final int IRON_PICK_HEAD = 482;
public static final int STEEL_PICK_HEAD = 484;
public static final int MITHRIL_PICK_HEAD = 486;
public static final int ADAMANT_PICK_HEAD = 488;
public static final int RUNE_PICK_HEAD = 490;
public static final int AXE_HANDLE = 492;
public static final int BROKEN_AXE = 494;
public static final int BROKEN_AXE_496 = 496;
public static final int BROKEN_AXE_498 = 498;
public static final int BROKEN_AXE_500 = 500;
public static final int BROKEN_AXE_502 = 502;
public static final int BROKEN_AXE_504 = 504;
public static final int BROKEN_AXE_506 = 506;
public static final int BRONZE_AXE_HEAD = 508;
public static final int IRON_AXE_HEAD = 510;
public static final int STEEL_AXE_HEAD = 512;
public static final int BLACK_AXE_HEAD = 514;
public static final int MITHRIL_AXE_HEAD = 516;
public static final int ADAMANT_AXE_HEAD = 518;
public static final int RUNE_AXE_HEAD = 520;
public static final int ENCHANTED_BEEF = 522;
public static final int ENCHANTED_RAT = 523;
public static final int ENCHANTED_BEAR = 524;
public static final int ENCHANTED_CHICKEN = 525;
public static final int BONES = 526;
public static final int BURNT_BONES = 528;
public static final int BAT_BONES = 530;
public static final int BIG_BONES = 532;
public static final int BABYDRAGON_BONES = 534;
public static final int DRAGON_BONES = 536;
public static final int DRUIDS_ROBE = 538;
public static final int DRUIDS_ROBE_TOP = 540;
public static final int MONKS_ROBE = 542;
public static final int MONKS_ROBE_TOP = 544;
public static final int SHADE_ROBE_TOP = 546;
public static final int SHADE_ROBE = 548;
public static final int NEWCOMER_MAP = 550;
public static final int GHOSTSPEAK_AMULET = 552;
public static final int GHOSTS_SKULL = 553;
public static final int FIRE_RUNE = 554;
public static final int WATER_RUNE = 555;
public static final int AIR_RUNE = 556;
public static final int EARTH_RUNE = 557;
public static final int MIND_RUNE = 558;
public static final int BODY_RUNE = 559;
public static final int DEATH_RUNE = 560;
public static final int NATURE_RUNE = 561;
public static final int CHAOS_RUNE = 562;
public static final int LAW_RUNE = 563;
public static final int COSMIC_RUNE = 564;
public static final int BLOOD_RUNE = 565;
public static final int SOUL_RUNE = 566;
public static final int UNPOWERED_ORB = 567;
public static final int FIRE_ORB = 569;
public static final int WATER_ORB = 571;
public static final int AIR_ORB = 573;
public static final int EARTH_ORB = 575;
public static final int BLUE_WIZARD_ROBE = 577;
public static final int BLUE_WIZARD_HAT = 579;
public static final int BLACK_ROBE = 581;
public static final int BAILING_BUCKET = 583;
public static final int BAILING_BUCKET_585 = 585;
public static final int ORB_OF_PROTECTION = 587;
public static final int ORBS_OF_PROTECTION = 588;
public static final int GNOME_AMULET = 589;
public static final int TINDERBOX = 590;
public static final int ASHES = 592;
public static final int LIT_TORCH = 594;
public static final int TORCH = 595;
public static final int UNLIT_TORCH = 596;
public static final int BRONZE_FIRE_ARROW = 598;
public static final int ASTRONOMY_BOOK = 600;
public static final int GOBLIN_KITCHEN_KEY = 601;
public static final int LENS_MOULD = 602;
public static final int OBSERVATORY_LENS = 603;
public static final int BONE_SHARD = 604;
public static final int BONE_KEY = 605;
public static final int STONEPLAQUE = 606;
public static final int TATTERED_SCROLL = 607;
public static final int CRUMPLED_SCROLL = 608;
public static final int RASHILIYIA_CORPSE = 609;
public static final int ZADIMUS_CORPSE = 610;
public static final int LOCATING_CRYSTAL = 611;
public static final int LOCATING_CRYSTAL_612 = 612;
public static final int LOCATING_CRYSTAL_613 = 613;
public static final int LOCATING_CRYSTAL_614 = 614;
public static final int LOCATING_CRYSTAL_615 = 615;
public static final int BEADS_OF_THE_DEAD = 616;
public static final int COINS = 617;
public static final int BONE_BEADS = 618;
public static final int PARAMAYA_TICKET = 619;
public static final int PARAMAYA_TICKET_620 = 620;
public static final int SHIP_TICKET = 621;
public static final int SWORD_POMMEL = 623;
public static final int BERVIRIUS_NOTES = 624;
public static final int WAMPUM_BELT = 625;
public static final int PINK_BOOTS = 626;
public static final int GREEN_BOOTS = 628;
public static final int BLUE_BOOTS = 630;
public static final int CREAM_BOOTS = 632;
public static final int TURQUOISE_BOOTS = 634;
public static final int PINK_ROBE_TOP = 636;
public static final int GREEN_ROBE_TOP = 638;
public static final int BLUE_ROBE_TOP = 640;
public static final int CREAM_ROBE_TOP = 642;
public static final int TURQUOISE_ROBE_TOP = 644;
public static final int PINK_ROBE_BOTTOMS = 646;
public static final int GREEN_ROBE_BOTTOMS = 648;
public static final int BLUE_ROBE_BOTTOMS = 650;
public static final int CREAM_ROBE_BOTTOMS = 652;
public static final int TURQUOISE_ROBE_BOTTOMS = 654;
public static final int PINK_HAT = 656;
public static final int GREEN_HAT = 658;
public static final int BLUE_HAT = 660;
public static final int CREAM_HAT = 662;
public static final int TURQUOISE_HAT = 664;
public static final int PORTRAIT = 666;
public static final int BLURITE_SWORD = 667;
public static final int BLURITE_ORE = 668;
public static final int SPECIMEN_JAR = 669;
public static final int SPECIMEN_BRUSH = 670;
public static final int ANIMAL_SKULL = 671;
public static final int SPECIAL_CUP = 672;
public static final int TEDDY = 673;
public static final int CRACKED_SAMPLE = 674;
public static final int ROCK_PICK = 675;
public static final int TROWEL = 676;
public static final int PANNING_TRAY = 677;
public static final int PANNING_TRAY_678 = 678;
public static final int PANNING_TRAY_679 = 679;
public static final int NUGGETS = 680;
public static final int ANCIENT_TALISMAN = 681;
public static final int UNSTAMPED_LETTER = 682;
public static final int SEALED_LETTER = 683;
public static final int BELT_BUCKLE = 684;
public static final int OLD_BOOT = 685;
public static final int RUSTY_SWORD = 686;
public static final int BROKEN_ARROW = 687;
public static final int BUTTONS = 688;
public static final int BROKEN_STAFF = 689;
public static final int BROKEN_GLASS = 690;
public static final int LEVEL_1_CERTIFICATE = 691;
public static final int LEVEL_2_CERTIFICATE = 692;
public static final int LEVEL_3_CERTIFICATE = 693;
public static final int CERAMIC_REMAINS = 694;
public static final int OLD_TOOTH = 695;
public static final int INVITATION_LETTER = 696;
public static final int DAMAGED_ARMOUR = 697;
public static final int BROKEN_ARMOUR = 698;
public static final int STONE_TABLET = 699;
public static final int CHEMICAL_POWDER = 700;
public static final int AMMONIUM_NITRATE = 701;
public static final int UNIDENTIFIED_LIQUID = 702;
public static final int NITROGLYCERIN = 703;
public static final int GROUND_CHARCOAL = 704;
public static final int MIXED_CHEMICALS = 705;
public static final int MIXED_CHEMICALS_706 = 706;
public static final int CHEMICAL_COMPOUND = 707;
public static final int ARCENIA_ROOT = 708;
public static final int CHEST_KEY_709 = 709;
public static final int VASE = 710;
public static final int BOOK_ON_CHEMICALS = 711;
public static final int CUP_OF_TEA = 712;
public static final int CLUE_SCROLL = 713;
public static final int RADIMUS_NOTES = 714;
public static final int RADIMUS_NOTES_715 = 715;
public static final int BULL_ROARER = 716;
public static final int SCRAWLED_NOTE = 717;
public static final int A_SCRIBBLED_NOTE = 718;
public static final int SCRUMPLED_NOTE = 719;
public static final int SKETCH = 720;
public static final int GOLD_BOWL = 721;
public static final int BLESSED_GOLD_BOWL = 722;
public static final int GOLDEN_BOWL = 723;
public static final int GOLDEN_BOWL_724 = 724;
public static final int GOLDEN_BOWL_725 = 725;
public static final int GOLDEN_BOWL_726 = 726;
public static final int HOLLOW_REED = 727;
public static final int HOLLOW_REED_728 = 728;
public static final int SHAMANS_TOME = 729;
public static final int BINDING_BOOK = 730;
public static final int ENCHANTED_VIAL = 731;
public static final int HOLY_WATER = 732;
public static final int SMASHED_GLASS = 733;
public static final int YOMMI_TREE_SEEDS = 735;
public static final int YOMMI_TREE_SEEDS_736 = 736;
public static final int SNAKEWEED_MIXTURE = 737;
public static final int ARDRIGAL_MIXTURE = 738;
public static final int BRAVERY_POTION = 739;
public static final int BLUE_HAT_740 = 740;
public static final int CHUNK_OF_CRYSTAL = 741;
public static final int HUNK_OF_CRYSTAL = 742;
public static final int LUMP_OF_CRYSTAL = 743;
public static final int HEART_CRYSTAL = 744;
public static final int HEART_CRYSTAL_745 = 745;
public static final int DARK_DAGGER = 746;
public static final int GLOWING_DAGGER = 747;
public static final int HOLY_FORCE = 748;
public static final int YOMMI_TOTEM = 749;
public static final int GILDED_TOTEM = 750;
public static final int GNOMEBALL = 751;
public static final int CADAVA_BERRIES = 753;
public static final int MESSAGE = 755;
public static final int CADAVA_POTION = 756;
public static final int BOOK = 757;
public static final int PHOENIX_HQ_KEY = 758;
public static final int WEAPON_STORE_KEY = 759;
public static final int INTEL_REPORT = 761;
public static final int FALADOR_SHIELD = 762;
public static final int BROKEN_SHIELD = 763;
public static final int COAL_BAG = 764;
public static final int BROKEN_SHIELD_765 = 765;
public static final int GEM_BAG = 766;
public static final int PHOENIX_CROSSBOW = 767;
public static final int CERTIFICATE = 769;
public static final int ARDOUGNE_CLOAK = 770;
public static final int DRAMEN_BRANCH = 771;
public static final int DRAMEN_STAFF = 772;
public static final int PERFECT_RING = 773;
public static final int PERFECT_NECKLACE = 774;
public static final int COOKING_GAUNTLETS = 775;
public static final int GOLDSMITH_GAUNTLETS = 776;
public static final int CHAOS_GAUNTLETS = 777;
public static final int STEEL_GAUNTLETS = 778;
public static final int CREST_PART = 779;
public static final int CREST_PART_780 = 780;
public static final int CREST_PART_781 = 781;
public static final int FAMILY_CREST = 782;
public static final int BARK_SAMPLE = 783;
public static final int TRANSLATION_BOOK = 784;
public static final int GLOUGHS_JOURNAL = 785;
public static final int HAZELMERES_SCROLL = 786;
public static final int LUMBER_ORDER = 787;
public static final int GLOUGHS_KEY = 788;
public static final int TWIGS = 789;
public static final int TWIGS_790 = 790;
public static final int TWIGS_791 = 791;
public static final int TWIGS_792 = 792;
public static final int DACONIA_ROCK = 793;
public static final int INVASION_PLANS = 794;
public static final int WAR_SHIP = 795;
public static final int BRONZE_THROWNAXE = 800;
public static final int IRON_THROWNAXE = 801;
public static final int STEEL_THROWNAXE = 802;
public static final int MITHRIL_THROWNAXE = 803;
public static final int ADAMANT_THROWNAXE = 804;
public static final int RUNE_THROWNAXE = 805;
public static final int BRONZE_DART = 806;
public static final int IRON_DART = 807;
public static final int STEEL_DART = 808;
public static final int MITHRIL_DART = 809;
public static final int ADAMANT_DART = 810;
public static final int RUNE_DART = 811;
public static final int BRONZE_DARTP = 812;
public static final int IRON_DARTP = 813;
public static final int STEEL_DARTP = 814;
public static final int MITHRIL_DARTP = 815;
public static final int ADAMANT_DARTP = 816;
public static final int RUNE_DARTP = 817;
public static final int POISONED_DARTP = 818;
public static final int BRONZE_DART_TIP = 819;
public static final int IRON_DART_TIP = 820;
public static final int STEEL_DART_TIP = 821;
public static final int MITHRIL_DART_TIP = 822;
public static final int ADAMANT_DART_TIP = 823;
public static final int RUNE_DART_TIP = 824;
public static final int BRONZE_JAVELIN = 825;
public static final int IRON_JAVELIN = 826;
public static final int STEEL_JAVELIN = 827;
public static final int MITHRIL_JAVELIN = 828;
public static final int ADAMANT_JAVELIN = 829;
public static final int RUNE_JAVELIN = 830;
public static final int BRONZE_JAVELINP = 831;
public static final int IRON_JAVELINP = 832;
public static final int STEEL_JAVELINP = 833;
public static final int MITHRIL_JAVELINP = 834;
public static final int ADAMANT_JAVELINP = 835;
public static final int RUNE_JAVELINP = 836;
public static final int CROSSBOW = 837;
public static final int LONGBOW = 839;
public static final int SHORTBOW = 841;
public static final int OAK_SHORTBOW = 843;
public static final int OAK_LONGBOW = 845;
public static final int WILLOW_LONGBOW = 847;
public static final int WILLOW_SHORTBOW = 849;
public static final int MAPLE_LONGBOW = 851;
public static final int MAPLE_SHORTBOW = 853;
public static final int YEW_LONGBOW = 855;
public static final int YEW_SHORTBOW = 857;
public static final int MAGIC_LONGBOW = 859;
public static final int MAGIC_SHORTBOW = 861;
public static final int IRON_KNIFE = 863;
public static final int BRONZE_KNIFE = 864;
public static final int STEEL_KNIFE = 865;
public static final int MITHRIL_KNIFE = 866;
public static final int ADAMANT_KNIFE = 867;
public static final int RUNE_KNIFE = 868;
public static final int BLACK_KNIFE = 869;
public static final int BRONZE_KNIFEP = 870;
public static final int IRON_KNIFEP = 871;
public static final int STEEL_KNIFEP = 872;
public static final int MITHRIL_KNIFEP = 873;
public static final int BLACK_KNIFEP = 874;
public static final int ADAMANT_KNIFEP = 875;
public static final int RUNE_KNIFEP = 876;
public static final int BRONZE_BOLTS = 877;
public static final int BRONZE_BOLTS_P = 878;
public static final int OPAL_BOLTS = 879;
public static final int PEARL_BOLTS = 880;
public static final int BARBED_BOLTS = 881;
public static final int BRONZE_ARROW = 882;
public static final int BRONZE_ARROWP = 883;
public static final int IRON_ARROW = 884;
public static final int IRON_ARROWP = 885;
public static final int STEEL_ARROW = 886;
public static final int STEEL_ARROWP = 887;
public static final int MITHRIL_ARROW = 888;
public static final int MITHRIL_ARROWP = 889;
public static final int ADAMANT_ARROW = 890;
public static final int ADAMANT_ARROWP = 891;
public static final int RUNE_ARROW = 892;
public static final int RUNE_ARROWP = 893;
public static final int BRONZE_FIRE_ARROW_LIT = 942;
public static final int WORM = 943;
public static final int THROWING_ROPE = 945;
public static final int KNIFE = 946;
public static final int BEAR_FUR = 948;
public static final int SILK = 950;
public static final int SPADE = 952;
public static final int ROPE = 954;
public static final int FLIER = 956;
public static final int GREY_WOLF_FUR = 958;
public static final int PLANK = 960;
public static final int CHRISTMAS_CRACKER = 962;
public static final int SKULL = 964;
public static final int SKULL_965 = 965;
public static final int TILE = 966;
public static final int ROCK = 968;
public static final int PAPYRUS = 970;
public static final int PAPYRUS_972 = 972;
public static final int CHARCOAL = 973;
public static final int MACHETE = 975;
public static final int COOKING_POT = 977;
public static final int DISK_OF_RETURNING = 981;
public static final int BRASS_KEY = 983;
public static final int TOOTH_HALF_OF_KEY = 985;
public static final int LOOP_HALF_OF_KEY = 987;
public static final int CRYSTAL_KEY = 989;
public static final int MUDDY_KEY = 991;
public static final int SINISTER_KEY = 993;
public static final int COINS_995 = 995;
public static final int WHITE_APRON = 1005;
public static final int RED_CAPE = 1007;
public static final int BRASS_NECKLACE = 1009;
public static final int BLUE_SKIRT = 1011;
public static final int PINK_SKIRT = 1013;
public static final int BLACK_SKIRT = 1015;
public static final int WIZARD_HAT = 1017;
public static final int BLACK_CAPE = 1019;
public static final int BLUE_CAPE = 1021;
public static final int YELLOW_CAPE = 1023;
public static final int RIGHT_EYE_PATCH = 1025;
public static final int GREEN_CAPE = 1027;
public static final int PURPLE_CAPE = 1029;
public static final int ORANGE_CAPE = 1031;
public static final int ZAMORAK_MONK_BOTTOM = 1033;
public static final int ZAMORAK_MONK_TOP = 1035;
public static final int BUNNY_EARS = 1037;
public static final int RED_PARTYHAT = 1038;
public static final int YELLOW_PARTYHAT = 1040;
public static final int BLUE_PARTYHAT = 1042;
public static final int GREEN_PARTYHAT = 1044;
public static final int PURPLE_PARTYHAT = 1046;
public static final int WHITE_PARTYHAT = 1048;
public static final int SANTA_HAT = 1050;
public static final int CAPE_OF_LEGENDS = 1052;
public static final int GREEN_HALLOWEEN_MASK = 1053;
public static final int BLUE_HALLOWEEN_MASK = 1055;
public static final int RED_HALLOWEEN_MASK = 1057;
public static final int LEATHER_GLOVES = 1059;
public static final int LEATHER_BOOTS = 1061;
public static final int LEATHER_VAMBRACES = 1063;
public static final int GREEN_DHIDE_VAMBRACES = 1065;
public static final int IRON_PLATELEGS = 1067;
public static final int STEEL_PLATELEGS = 1069;
public static final int MITHRIL_PLATELEGS = 1071;
public static final int ADAMANT_PLATELEGS = 1073;
public static final int BRONZE_PLATELEGS = 1075;
public static final int BLACK_PLATELEGS = 1077;
public static final int RUNE_PLATELEGS = 1079;
public static final int IRON_PLATESKIRT = 1081;
public static final int STEEL_PLATESKIRT = 1083;
public static final int MITHRIL_PLATESKIRT = 1085;
public static final int BRONZE_PLATESKIRT = 1087;
public static final int BLACK_PLATESKIRT = 1089;
public static final int ADAMANT_PLATESKIRT = 1091;
public static final int RUNE_PLATESKIRT = 1093;
public static final int LEATHER_CHAPS = 1095;
public static final int STUDDED_CHAPS = 1097;
public static final int GREEN_DHIDE_CHAPS = 1099;
public static final int IRON_CHAINBODY = 1101;
public static final int BRONZE_CHAINBODY = 1103;
public static final int STEEL_CHAINBODY = 1105;
public static final int BLACK_CHAINBODY = 1107;
public static final int MITHRIL_CHAINBODY = 1109;
public static final int ADAMANT_CHAINBODY = 1111;
public static final int RUNE_CHAINBODY = 1113;
public static final int IRON_PLATEBODY = 1115;
public static final int BRONZE_PLATEBODY = 1117;
public static final int STEEL_PLATEBODY = 1119;
public static final int MITHRIL_PLATEBODY = 1121;
public static final int ADAMANT_PLATEBODY = 1123;
public static final int BLACK_PLATEBODY = 1125;
public static final int RUNE_PLATEBODY = 1127;
public static final int LEATHER_BODY = 1129;
public static final int HARDLEATHER_BODY = 1131;
public static final int STUDDED_BODY = 1133;
public static final int GREEN_DHIDE_BODY = 1135;
public static final int IRON_MED_HELM = 1137;
public static final int BRONZE_MED_HELM = 1139;
public static final int STEEL_MED_HELM = 1141;
public static final int MITHRIL_MED_HELM = 1143;
public static final int ADAMANT_MED_HELM = 1145;
public static final int RUNE_MED_HELM = 1147;
public static final int DRAGON_MED_HELM = 1149;
public static final int BLACK_MED_HELM = 1151;
public static final int IRON_FULL_HELM = 1153;
public static final int BRONZE_FULL_HELM = 1155;
public static final int STEEL_FULL_HELM = 1157;
public static final int MITHRIL_FULL_HELM = 1159;
public static final int ADAMANT_FULL_HELM = 1161;
public static final int RUNE_FULL_HELM = 1163;
public static final int BLACK_FULL_HELM = 1165;
public static final int LEATHER_COWL = 1167;
public static final int COIF = 1169;
public static final int WOODEN_SHIELD = 1171;
public static final int BRONZE_SQ_SHIELD = 1173;
public static final int IRON_SQ_SHIELD = 1175;
public static final int STEEL_SQ_SHIELD = 1177;
public static final int BLACK_SQ_SHIELD = 1179;
public static final int MITHRIL_SQ_SHIELD = 1181;
public static final int ADAMANT_SQ_SHIELD = 1183;
public static final int RUNE_SQ_SHIELD = 1185;
public static final int DRAGON_SQ_SHIELD = 1187;
public static final int BRONZE_KITESHIELD = 1189;
public static final int IRON_KITESHIELD = 1191;
public static final int STEEL_KITESHIELD = 1193;
public static final int BLACK_KITESHIELD = 1195;
public static final int MITHRIL_KITESHIELD = 1197;
public static final int ADAMANT_KITESHIELD = 1199;
public static final int RUNE_KITESHIELD = 1201;
public static final int IRON_DAGGER = 1203;
public static final int BRONZE_DAGGER = 1205;
public static final int STEEL_DAGGER = 1207;
public static final int MITHRIL_DAGGER = 1209;
public static final int ADAMANT_DAGGER = 1211;
public static final int RUNE_DAGGER = 1213;
public static final int DRAGON_DAGGER = 1215;
public static final int BLACK_DAGGER = 1217;
public static final int IRON_DAGGERP = 1219;
public static final int BRONZE_DAGGERP = 1221;
public static final int STEEL_DAGGERP = 1223;
public static final int MITHRIL_DAGGERP = 1225;
public static final int ADAMANT_DAGGERP = 1227;
public static final int RUNE_DAGGERP = 1229;
public static final int DRAGON_DAGGERP = 1231;
public static final int BLACK_DAGGERP = 1233;
public static final int POISONED_DAGGERP = 1235;
public static final int BRONZE_SPEAR = 1237;
public static final int IRON_SPEAR = 1239;
public static final int STEEL_SPEAR = 1241;
public static final int MITHRIL_SPEAR = 1243;
public static final int ADAMANT_SPEAR = 1245;
public static final int RUNE_SPEAR = 1247;
public static final int DRAGON_SPEAR = 1249;
public static final int BRONZE_SPEARP = 1251;
public static final int IRON_SPEARP = 1253;
public static final int STEEL_SPEARP = 1255;
public static final int MITHRIL_SPEARP = 1257;
public static final int ADAMANT_SPEARP = 1259;
public static final int RUNE_SPEARP = 1261;
public static final int DRAGON_SPEARP = 1263;
public static final int BRONZE_PICKAXE = 1265;
public static final int IRON_PICKAXE = 1267;
public static final int STEEL_PICKAXE = 1269;
public static final int ADAMANT_PICKAXE = 1271;
public static final int MITHRIL_PICKAXE = 1273;
public static final int RUNE_PICKAXE = 1275;
public static final int BRONZE_SWORD = 1277;
public static final int IRON_SWORD = 1279;
public static final int STEEL_SWORD = 1281;
public static final int BLACK_SWORD = 1283;
public static final int MITHRIL_SWORD = 1285;
public static final int ADAMANT_SWORD = 1287;
public static final int RUNE_SWORD = 1289;
public static final int BRONZE_LONGSWORD = 1291;
public static final int IRON_LONGSWORD = 1293;
public static final int STEEL_LONGSWORD = 1295;
public static final int BLACK_LONGSWORD = 1297;
public static final int MITHRIL_LONGSWORD = 1299;
public static final int ADAMANT_LONGSWORD = 1301;
public static final int RUNE_LONGSWORD = 1303;
public static final int DRAGON_LONGSWORD = 1305;
public static final int BRONZE_2H_SWORD = 1307;
public static final int IRON_2H_SWORD = 1309;
public static final int STEEL_2H_SWORD = 1311;
public static final int BLACK_2H_SWORD = 1313;
public static final int MITHRIL_2H_SWORD = 1315;
public static final int ADAMANT_2H_SWORD = 1317;
public static final int RUNE_2H_SWORD = 1319;
public static final int BRONZE_SCIMITAR = 1321;
public static final int IRON_SCIMITAR = 1323;
public static final int STEEL_SCIMITAR = 1325;
public static final int BLACK_SCIMITAR = 1327;
public static final int MITHRIL_SCIMITAR = 1329;
public static final int ADAMANT_SCIMITAR = 1331;
public static final int RUNE_SCIMITAR = 1333;
public static final int IRON_WARHAMMER = 1335;
public static final int BRONZE_WARHAMMER = 1337;
public static final int STEEL_WARHAMMER = 1339;
public static final int BLACK_WARHAMMER = 1341;
public static final int MITHRIL_WARHAMMER = 1343;
public static final int ADAMANT_WARHAMMER = 1345;
public static final int RUNE_WARHAMMER = 1347;
public static final int IRON_AXE = 1349;
public static final int BRONZE_AXE = 1351;
public static final int STEEL_AXE = 1353;
public static final int MITHRIL_AXE = 1355;
public static final int ADAMANT_AXE = 1357;
public static final int RUNE_AXE = 1359;
public static final int BLACK_AXE = 1361;
public static final int IRON_BATTLEAXE = 1363;
public static final int STEEL_BATTLEAXE = 1365;
public static final int BLACK_BATTLEAXE = 1367;
public static final int MITHRIL_BATTLEAXE = 1369;
public static final int ADAMANT_BATTLEAXE = 1371;
public static final int RUNE_BATTLEAXE = 1373;
public static final int BRONZE_BATTLEAXE = 1375;
public static final int DRAGON_BATTLEAXE = 1377;
public static final int STAFF = 1379;
public static final int STAFF_OF_AIR = 1381;
public static final int STAFF_OF_WATER = 1383;
public static final int STAFF_OF_EARTH = 1385;
public static final int STAFF_OF_FIRE = 1387;
public static final int MAGIC_STAFF = 1389;
public static final int BATTLESTAFF = 1391;
public static final int FIRE_BATTLESTAFF = 1393;
public static final int WATER_BATTLESTAFF = 1395;
public static final int AIR_BATTLESTAFF = 1397;
public static final int EARTH_BATTLESTAFF = 1399;
public static final int MYSTIC_FIRE_STAFF = 1401;
public static final int MYSTIC_WATER_STAFF = 1403;
public static final int MYSTIC_AIR_STAFF = 1405;
public static final int MYSTIC_EARTH_STAFF = 1407;
public static final int IBANS_STAFF = 1409;
public static final int IBANS_STAFF_1410 = 1410;
public static final int FARMERS_FORK = 1411;
public static final int HALBERD = 1413;
public static final int WARHAMMER = 1415;
public static final int JAVELIN = 1417;
public static final int SCYTHE = 1419;
public static final int IRON_MACE = 1420;
public static final int BRONZE_MACE = 1422;
public static final int STEEL_MACE = 1424;
public static final int BLACK_MACE = 1426;
public static final int MITHRIL_MACE = 1428;
public static final int ADAMANT_MACE = 1430;
public static final int RUNE_MACE = 1432;
public static final int DRAGON_MACE = 1434;
public static final int RUNE_ESSENCE = 1436;
public static final int AIR_TALISMAN = 1438;
public static final int EARTH_TALISMAN = 1440;
public static final int FIRE_TALISMAN = 1442;
public static final int WATER_TALISMAN = 1444;
public static final int BODY_TALISMAN = 1446;
public static final int MIND_TALISMAN = 1448;
public static final int CHAOS_TALISMAN = 1452;
public static final int COSMIC_TALISMAN = 1454;
public static final int DEATH_TALISMAN = 1456;
public static final int LAW_TALISMAN = 1458;
public static final int NATURE_TALISMAN = 1462;
public static final int ARCHERY_TICKET = 1464;
public static final int WEAPON_POISON_1465 = 1465;
public static final int SEA_SLUG = 1466;
public static final int DAMP_STICKS = 1467;
public static final int DRY_STICKS = 1468;
public static final int BROKEN_GLASS_1469 = 1469;
public static final int RED_BEAD = 1470;
public static final int YELLOW_BEAD = 1472;
public static final int BLACK_BEAD = 1474;
public static final int WHITE_BEAD = 1476;
public static final int AMULET_OF_ACCURACY = 1478;
public static final int ROCK_1480 = 1480;
public static final int ORB_OF_LIGHT = 1481;
public static final int ORB_OF_LIGHT_1482 = 1482;
public static final int ORB_OF_LIGHT_1483 = 1483;
public static final int ORB_OF_LIGHT_1484 = 1484;
public static final int OILY_CLOTH = 1485;
public static final int PIECE_OF_RAILING = 1486;
public static final int UNICORN_HORN_1487 = 1487;
public static final int PALADINS_BADGE = 1488;
public static final int PALADINS_BADGE_1489 = 1489;
public static final int PALADINS_BADGE_1490 = 1490;
public static final int WITCHS_CAT = 1491;
public static final int DOLL_OF_IBAN = 1492;
public static final int OLD_JOURNAL = 1493;
public static final int HISTORY_OF_IBAN = 1494;
public static final int KLANKS_GAUNTLETS = 1495;
public static final int IBANS_DOVE = 1496;
public static final int AMULET_OF_OTHANIAN = 1497;
public static final int AMULET_OF_DOOMION = 1498;
public static final int AMULET_OF_HOLTHION = 1499;
public static final int IBANS_SHADOW = 1500;
public static final int DWARF_BREW = 1501;
public static final int IBANS_ASHES = 1502;
public static final int WARRANT = 1503;
public static final int HANGOVER_CURE = 1504;
public static final int ARDOUGNE_TELEPORT_SCROLL = 1505;
public static final int GAS_MASK = 1506;
public static final int A_SMALL_KEY = 1507;
public static final int A_SCRUFFY_NOTE = 1508;
public static final int BOOK_1509 = 1509;
public static final int PICTURE = 1510;
public static final int LOGS = 1511;
public static final int MAGIC_LOGS = 1513;
public static final int YEW_LOGS = 1515;
public static final int MAPLE_LOGS = 1517;
public static final int WILLOW_LOGS = 1519;
public static final int OAK_LOGS = 1521;
public static final int LOCKPICK = 1523;
public static final int GRIMY_SNAKE_WEED = 1525;
public static final int SNAKE_WEED = 1526;
public static final int GRIMY_ARDRIGAL = 1527;
public static final int ARDRIGAL = 1528;
public static final int GRIMY_SITO_FOIL = 1529;
public static final int SITO_FOIL = 1530;
public static final int GRIMY_VOLENCIA_MOSS = 1531;
public static final int VOLENCIA_MOSS = 1532;
public static final int GRIMY_ROGUES_PURSE = 1533;
public static final int ROGUES_PURSE = 1534;
public static final int MAP_PART = 1535;
public static final int MAP_PART_1536 = 1536;
public static final int MAP_PART_1537 = 1537;
public static final int CRANDOR_MAP = 1538;
public static final int STEEL_NAILS = 1539;
public static final int ANTIDRAGON_SHIELD = 1540;
public static final int MAZE_KEY = 1542;
public static final int KEY_1543 = 1543;
public static final int KEY_1544 = 1544;
public static final int KEY_1545 = 1545;
public static final int KEY_1546 = 1546;
public static final int KEY_1547 = 1547;
public static final int KEY_1548 = 1548;
public static final int STAKE = 1549;
public static final int GARLIC = 1550;
public static final int SEASONED_SARDINE = 1552;
public static final int FLUFFS_KITTEN = 1554;
public static final int PET_KITTEN = 1555;
public static final int PET_KITTEN_1556 = 1556;
public static final int PET_KITTEN_1557 = 1557;
public static final int PET_KITTEN_1558 = 1558;
public static final int PET_KITTEN_1559 = 1559;
public static final int PET_KITTEN_1560 = 1560;
public static final int PET_CAT = 1561;
public static final int PET_CAT_1562 = 1562;
public static final int PET_CAT_1563 = 1563;
public static final int PET_CAT_1564 = 1564;
public static final int PET_CAT_1565 = 1565;
public static final int PET_CAT_1566 = 1566;
public static final int PET_CAT_1567 = 1567;
public static final int PET_CAT_1568 = 1568;
public static final int PET_CAT_1569 = 1569;
public static final int PET_CAT_1570 = 1570;
public static final int PET_CAT_1571 = 1571;
public static final int PET_CAT_1572 = 1572;
public static final int DOOGLE_LEAVES = 1573;
public static final int CAT_TRAINING_MEDAL = 1575;
public static final int PETES_CANDLESTICK = 1577;
public static final int THIEVES_ARMBAND = 1579;
public static final int ICE_GLOVES = 1580;
public static final int BLAMISH_SNAIL_SLIME = 1581;
public static final int BLAMISH_OIL = 1582;
public static final int FIRE_FEATHER = 1583;
public static final int ID_PAPERS = 1584;
public static final int OILY_FISHING_ROD = 1585;
public static final int MISCELLANEOUS_KEY = 1586;
public static final int GRIPS_KEYRING = 1588;
public static final int DUSTY_KEY = 1590;
public static final int JAIL_KEY = 1591;
public static final int RING_MOULD = 1592;
public static final int UNHOLY_MOULD = 1594;
public static final int AMULET_MOULD = 1595;
public static final int NECKLACE_MOULD = 1597;
public static final int HOLY_MOULD = 1599;
public static final int DIAMOND = 1601;
public static final int RUBY = 1603;
public static final int EMERALD = 1605;
public static final int SAPPHIRE = 1607;
public static final int OPAL = 1609;
public static final int JADE = 1611;
public static final int RED_TOPAZ = 1613;
public static final int DRAGONSTONE = 1615;
public static final int UNCUT_DIAMOND = 1617;
public static final int UNCUT_RUBY = 1619;
public static final int UNCUT_EMERALD = 1621;
public static final int UNCUT_SAPPHIRE = 1623;
public static final int UNCUT_OPAL = 1625;
public static final int UNCUT_JADE = 1627;
public static final int UNCUT_RED_TOPAZ = 1629;
public static final int UNCUT_DRAGONSTONE = 1631;
public static final int CRUSHED_GEM = 1633;
public static final int GOLD_RING = 1635;
public static final int SAPPHIRE_RING = 1637;
public static final int EMERALD_RING = 1639;
public static final int RUBY_RING = 1641;
public static final int DIAMOND_RING = 1643;
public static final int DRAGONSTONE_RING = 1645;
public static final int GOLD_NECKLACE = 1654;
public static final int SAPPHIRE_NECKLACE = 1656;
public static final int EMERALD_NECKLACE = 1658;
public static final int RUBY_NECKLACE = 1660;
public static final int DIAMOND_NECKLACE = 1662;
public static final int DRAGON_NECKLACE = 1664;
public static final int GOLD_AMULET_U = 1673;
public static final int SAPPHIRE_AMULET_U = 1675;
public static final int EMERALD_AMULET_U = 1677;
public static final int RUBY_AMULET_U = 1679;
public static final int DIAMOND_AMULET_U = 1681;
public static final int DRAGONSTONE_AMULET_U = 1683;
public static final int KARAMJA_GLOVES = 1686;
public static final int GOLD_AMULET = 1692;
public static final int SAPPHIRE_AMULET = 1694;
public static final int EMERALD_AMULET = 1696;
public static final int RUBY_AMULET = 1698;
public static final int DIAMOND_AMULET = 1700;
public static final int DRAGONSTONE_AMULET = 1702;
public static final int AMULET_OF_GLORY = 1704;
public static final int AMULET_OF_GLORY1 = 1706;
public static final int AMULET_OF_GLORY2 = 1708;
public static final int AMULET_OF_GLORY3 = 1710;
public static final int AMULET_OF_GLORY4 = 1712;
public static final int UNSTRUNG_SYMBOL = 1714;
public static final int UNBLESSED_SYMBOL = 1716;
public static final int HOLY_SYMBOL = 1718;
public static final int UNSTRUNG_EMBLEM = 1720;
public static final int UNPOWERED_SYMBOL = 1722;
public static final int UNHOLY_SYMBOL = 1724;
public static final int AMULET_OF_STRENGTH = 1725;
public static final int AMULET_OF_MAGIC = 1727;
public static final int AMULET_OF_DEFENCE = 1729;
public static final int AMULET_OF_POWER = 1731;
public static final int NEEDLE = 1733;
public static final int THREAD = 1734;
public static final int SHEARS = 1735;
public static final int WOOL = 1737;
public static final int COWHIDE = 1739;
public static final int LEATHER = 1741;
public static final int HARD_LEATHER = 1743;
public static final int GREEN_DRAGON_LEATHER = 1745;
public static final int BLACK_DRAGONHIDE = 1747;
public static final int RED_DRAGONHIDE = 1749;
public static final int BLUE_DRAGONHIDE = 1751;
public static final int GREEN_DRAGONHIDE = 1753;
public static final int CHISEL = 1755;
public static final int BROWN_APRON = 1757;
public static final int BALL_OF_WOOL = 1759;
public static final int SOFT_CLAY = 1761;
public static final int RED_DYE = 1763;
public static final int YELLOW_DYE = 1765;
public static final int BLUE_DYE = 1767;
public static final int ORANGE_DYE = 1769;
public static final int GREEN_DYE = 1771;
public static final int PURPLE_DYE = 1773;
public static final int MOLTEN_GLASS = 1775;
public static final int BOW_STRING = 1777;
public static final int FLAX = 1779;
public static final int SODA_ASH = 1781;
public static final int BUCKET_OF_SAND = 1783;
public static final int GLASSBLOWING_PIPE = 1785;
public static final int UNFIRED_POT = 1787;
public static final int UNFIRED_PIE_DISH = 1789;
public static final int UNFIRED_BOWL = 1791;
public static final int WOAD_LEAF = 1793;
public static final int BRONZE_WIRE = 1794;
public static final int SILVER_NECKLACE = 1796;
public static final int SILVER_NECKLACE_1797 = 1797;
public static final int SILVER_CUP = 1798;
public static final int SILVER_CUP_1799 = 1799;
public static final int SILVER_BOTTLE = 1800;
public static final int SILVER_BOTTLE_1801 = 1801;
public static final int SILVER_BOOK = 1802;
public static final int SILVER_BOOK_1803 = 1803;
public static final int SILVER_NEEDLE = 1804;
public static final int SILVER_NEEDLE_1805 = 1805;
public static final int SILVER_POT = 1806;
public static final int SILVER_POT_1807 = 1807;
public static final int CRIMINALS_THREAD = 1808;
public static final int CRIMINALS_THREAD_1809 = 1809;
public static final int CRIMINALS_THREAD_1810 = 1810;
public static final int FLYPAPER = 1811;
public static final int PUNGENT_POT = 1812;
public static final int CRIMINALS_DAGGER = 1813;
public static final int CRIMINALS_DAGGER_1814 = 1814;
public static final int KILLERS_PRINT = 1815;
public static final int ANNAS_PRINT = 1816;
public static final int BOBS_PRINT = 1817;
public static final int CAROLS_PRINT = 1818;
public static final int DAVIDS_PRINT = 1819;
public static final int ELIZABETHS_PRINT = 1820;
public static final int FRANKS_PRINT = 1821;
public static final int UNKNOWN_PRINT = 1822;
public static final int WATERSKIN4 = 1823;
public static final int WATERSKIN3 = 1825;
public static final int WATERSKIN2 = 1827;
public static final int WATERSKIN1 = 1829;
public static final int WATERSKIN0 = 1831;
public static final int DESERT_SHIRT = 1833;
public static final int DESERT_ROBE = 1835;
public static final int DESERT_BOOTS = 1837;
public static final int METAL_KEY = 1839;
public static final int CELL_DOOR_KEY = 1840;
public static final int BARREL = 1841;
public static final int ANA_IN_A_BARREL = 1842;
public static final int WROUGHT_IRON_KEY = 1843;
public static final int SLAVE_SHIRT = 1844;
public static final int SLAVE_ROBE = 1845;
public static final int SLAVE_BOOTS = 1846;
public static final int SCRUMPLED_PAPER = 1847;
public static final int SHANTAY_DISCLAIMER = 1848;
public static final int PROTOTYPE_DART = 1849;
public static final int TECHNICAL_PLANS = 1850;
public static final int TENTI_PINEAPPLE = 1851;
public static final int BEDABIN_KEY = 1852;
public static final int PROTOTYPE_DART_TIP = 1853;
public static final int SHANTAY_PASS = 1854;
public static final int ROCK_1855 = 1855;
public static final int GUIDE_BOOK = 1856;
public static final int TOTEM = 1857;
public static final int ADDRESS_LABEL = 1858;
public static final int RAW_UGTHANKI_MEAT = 1859;
public static final int UGTHANKI_MEAT = 1861;
public static final int PITTA_DOUGH = 1863;
public static final int PITTA_BREAD = 1865;
public static final int BURNT_PITTA_BREAD = 1867;
public static final int CHOPPED_TOMATO = 1869;
public static final int CHOPPED_ONION = 1871;
public static final int CHOPPED_UGTHANKI = 1873;
public static final int ONION__TOMATO = 1875;
public static final int UGTHANKI__ONION = 1877;
public static final int UGTHANKI__TOMATO = 1879;
public static final int KEBAB_MIX = 1881;
public static final int UGTHANKI_KEBAB = 1883;
public static final int UGTHANKI_KEBAB_1885 = 1885;
public static final int CAKE_TIN = 1887;
public static final int UNCOOKED_CAKE = 1889;
public static final int CAKE = 1891;
public static final int _23_CAKE = 1893;
public static final int SLICE_OF_CAKE = 1895;
public static final int CHOCOLATE_CAKE = 1897;
public static final int _23_CHOCOLATE_CAKE = 1899;
public static final int CHOCOLATE_SLICE = 1901;
public static final int BURNT_CAKE = 1903;
public static final int ASGARNIAN_ALE = 1905;
public static final int WIZARDS_MIND_BOMB = 1907;
public static final int GREENMANS_ALE = 1909;
public static final int DRAGON_BITTER = 1911;
public static final int DWARVEN_STOUT = 1913;
public static final int GROG = 1915;
public static final int BEER = 1917;
public static final int BEER_GLASS = 1919;
public static final int BOWL_OF_WATER = 1921;
public static final int BOWL = 1923;
public static final int BUCKET = 1925;
public static final int BUCKET_OF_MILK = 1927;
public static final int BUCKET_OF_WATER = 1929;
public static final int POT = 1931;
public static final int POT_OF_FLOUR = 1933;
public static final int JUG = 1935;
public static final int JUG_OF_WATER = 1937;
public static final int SWAMP_TAR = 1939;
public static final int RAW_SWAMP_PASTE = 1940;
public static final int SWAMP_PASTE = 1941;
public static final int POTATO = 1942;
public static final int EGG = 1944;
public static final int FLOUR = 1946;
public static final int GRAIN = 1947;
public static final int CHEFS_HAT = 1949;
public static final int REDBERRIES = 1951;
public static final int PASTRY_DOUGH = 1953;
public static final int COOKING_APPLE = 1955;
public static final int ONION = 1957;
public static final int PUMPKIN = 1959;
public static final int EASTER_EGG = 1961;
public static final int BANANA = 1963;
public static final int CABBAGE = 1965;
public static final int CABBAGE_1967 = 1967;
public static final int SPINACH_ROLL = 1969;
public static final int KEBAB = 1971;
public static final int CHOCOLATE_BAR = 1973;
public static final int CHOCOLATE_DUST = 1975;
public static final int CHOCOLATEY_MILK = 1977;
public static final int CUP_OF_TEA_1978 = 1978;
public static final int EMPTY_CUP = 1980;
public static final int TOMATO = 1982;
public static final int ROTTEN_APPLE = 1984;
public static final int CHEESE = 1985;
public static final int GRAPES = 1987;
public static final int HALF_FULL_WINE_JUG = 1989;
public static final int JUG_OF_BAD_WINE = 1991;
public static final int JUG_OF_BAD_WINE_1992 = 1992;
public static final int JUG_OF_WINE = 1993;
public static final int UNFERMENTED_WINE = 1995;
public static final int UNFERMENTED_WINE_1996 = 1996;
public static final int INCOMPLETE_STEW = 1997;
public static final int INCOMPLETE_STEW_1999 = 1999;
public static final int UNCOOKED_STEW = 2001;
public static final int STEW = 2003;
public static final int BURNT_STEW = 2005;
public static final int SPICE = 2007;
public static final int UNCOOKED_CURRY = 2009;
public static final int CURRY = 2011;
public static final int BURNT_CURRY = 2013;
public static final int VODKA = 2015;
public static final int WHISKY = 2017;
public static final int GIN = 2019;
public static final int BRANDY = 2021;
public static final int COCKTAIL_GUIDE = 2023;
public static final int COCKTAIL_SHAKER = 2025;
public static final int COCKTAIL_GLASS = 2026;
public static final int PREMADE_BLURB_SP = 2028;
public static final int PREMADE_CHOC_SDY = 2030;
public static final int PREMADE_DR_DRAGON = 2032;
public static final int PREMADE_FR_BLAST = 2034;
public static final int PREMADE_P_PUNCH = 2036;
public static final int PREMADE_SGG = 2038;
public static final int PREMADE_WIZ_BLZD = 2040;
public static final int UNFINISHED_COCKTAIL = 2042;
public static final int UNFINISHED_COCKTAIL_2044 = 2044;
public static final int UNFINISHED_COCKTAIL_2046 = 2046;
public static final int PINEAPPLE_PUNCH = 2048;
public static final int UNFINISHED_COCKTAIL_2050 = 2050;
public static final int UNFINISHED_COCKTAIL_2052 = 2052;
public static final int WIZARD_BLIZZARD = 2054;
public static final int UNFINISHED_COCKTAIL_2056 = 2056;
public static final int UNFINISHED_COCKTAIL_2058 = 2058;
public static final int UNFINISHED_COCKTAIL_2060 = 2060;
public static final int UNFINISHED_COCKTAIL_2062 = 2062;
public static final int BLURBERRY_SPECIAL = 2064;
public static final int UNFINISHED_COCKTAIL_2066 = 2066;
public static final int UNFINISHED_COCKTAIL_2068 = 2068;
public static final int UNFINISHED_COCKTAIL_2070 = 2070;
public static final int UNFINISHED_COCKTAIL_2072 = 2072;
public static final int CHOC_SATURDAY = 2074;
public static final int UNFINISHED_COCKTAIL_2076 = 2076;
public static final int UNFINISHED_COCKTAIL_2078 = 2078;
public static final int SHORT_GREEN_GUY = 2080;
public static final int UNFINISHED_COCKTAIL_2082 = 2082;
public static final int FRUIT_BLAST = 2084;
public static final int UNFINISHED_COCKTAIL_2086 = 2086;
public static final int UNFINISHED_COCKTAIL_2088 = 2088;
public static final int UNFINISHED_COCKTAIL_2090 = 2090;
public static final int DRUNK_DRAGON = 2092;
public static final int ODD_COCKTAIL = 2094;
public static final int ODD_COCKTAIL_2096 = 2096;
public static final int ODD_COCKTAIL_2098 = 2098;
public static final int ODD_COCKTAIL_2100 = 2100;
public static final int LEMON = 2102;
public static final int LEMON_CHUNKS = 2104;
public static final int LEMON_SLICES = 2106;
public static final int ORANGE = 2108;
public static final int ORANGE_CHUNKS = 2110;
public static final int ORANGE_SLICES = 2112;
public static final int PINEAPPLE = 2114;
public static final int PINEAPPLE_CHUNKS = 2116;
public static final int PINEAPPLE_RING = 2118;
public static final int LIME = 2120;
public static final int LIME_CHUNKS = 2122;
public static final int LIME_SLICES = 2124;
public static final int DWELLBERRIES = 2126;
public static final int EQUA_LEAVES = 2128;
public static final int POT_OF_CREAM = 2130;
public static final int RAW_BEEF = 2132;
public static final int RAW_RAT_MEAT = 2134;
public static final int RAW_BEAR_MEAT = 2136;
public static final int RAW_CHICKEN = 2138;
public static final int COOKED_CHICKEN = 2140;
public static final int COOKED_MEAT = 2142;
public static final int BURNT_CHICKEN = 2144;
public static final int BURNT_MEAT = 2146;
public static final int RAW_LAVA_EEL = 2148;
public static final int LAVA_EEL = 2149;
public static final int SWAMP_TOAD = 2150;
public static final int TOADS_LEGS = 2152;
public static final int EQUA_TOADS_LEGS = 2154;
public static final int SPICY_TOADS_LEGS = 2156;
public static final int SEASONED_LEGS = 2158;
public static final int SPICY_WORM = 2160;
public static final int KING_WORM = 2162;
public static final int BATTA_TIN = 2164;
public static final int CRUNCHY_TRAY = 2165;
public static final int GNOMEBOWL_MOULD = 2166;
public static final int GIANNES_COOK_BOOK = 2167;
public static final int GNOME_SPICE = 2169;
public static final int GIANNE_DOUGH = 2171;
public static final int ODD_GNOMEBOWL = 2173;
public static final int BURNT_GNOMEBOWL = 2175;
public static final int HALF_BAKED_BOWL = 2177;
public static final int RAW_GNOMEBOWL = 2178;
public static final int UNFINISHED_BOWL = 2179;
public static final int UNFINISHED_BOWL_2181 = 2181;
public static final int UNFINISHED_BOWL_2183 = 2183;
public static final int CHOCOLATE_BOMB = 2185;
public static final int TANGLED_TOADS_LEGS = 2187;
public static final int UNFINISHED_BOWL_2189 = 2189;
public static final int WORM_HOLE = 2191;
public static final int UNFINISHED_BOWL_2193 = 2193;
public static final int VEG_BALL = 2195;
public static final int ODD_CRUNCHIES = 2197;
public static final int BURNT_CRUNCHIES = 2199;
public static final int HALF_BAKED_CRUNCHY = 2201;
public static final int RAW_CRUNCHIES = 2202;
public static final int ROCKCLIMBING_BOOTS = 2203;
public static final int WORM_CRUNCHIES = 2205;
public static final int UNFINISHED_CRUNCHY = 2207;
public static final int CHOCCHIP_CRUNCHIES = 2209;
public static final int UNFINISHED_CRUNCHY_2211 = 2211;
public static final int SPICY_CRUNCHIES = 2213;
public static final int UNFINISHED_CRUNCHY_2215 = 2215;
public static final int TOAD_CRUNCHIES = 2217;
public static final int PREMADE_WM_BATTA = 2219;
public static final int PREMADE_TD_BATTA = 2221;
public static final int PREMADE_CT_BATTA = 2223;
public static final int PREMADE_FRT_BATTA = 2225;
public static final int PREMADE_VEG_BATTA = 2227;
public static final int PREMADE_CHOC_BOMB = 2229;
public static final int PREMADE_TTL = 2231;
public static final int PREMADE_WORM_HOLE = 2233;
public static final int PREMADE_VEG_BALL = 2235;
public static final int PREMADE_WM_CRUN = 2237;
public static final int PREMADE_CH_CRUNCH = 2239;
public static final int PREMADE_SY_CRUNCH = 2241;
public static final int PREMADE_TD_CRUNCH = 2243;
public static final int ODD_BATTA = 2245;
public static final int BURNT_BATTA = 2247;
public static final int HALF_BAKED_BATTA = 2249;
public static final int RAW_BATTA = 2250;
public static final int UNFINISHED_BATTA = 2251;
public static final int WORM_BATTA = 2253;
public static final int TOAD_BATTA = 2255;
public static final int UNFINISHED_BATTA_2257 = 2257;
public static final int CHEESETOM_BATTA = 2259;
public static final int UNFINISHED_BATTA_2261 = 2261;
public static final int UNFINISHED_BATTA_2263 = 2263;
public static final int UNFINISHED_BATTA_2265 = 2265;
public static final int UNFINISHED_BATTA_2267 = 2267;
public static final int UNFINISHED_BATTA_2269 = 2269;
public static final int UNFINISHED_BATTA_2271 = 2271;
public static final int UNFINISHED_BATTA_2273 = 2273;
public static final int UNFINISHED_BATTA_2275 = 2275;
public static final int FRUIT_BATTA = 2277;
public static final int UNFINISHED_BATTA_2279 = 2279;
public static final int VEGETABLE_BATTA = 2281;
public static final int PIZZA_BASE = 2283;
public static final int INCOMPLETE_PIZZA = 2285;
public static final int UNCOOKED_PIZZA = 2287;
public static final int PLAIN_PIZZA = 2289;
public static final int _12_PLAIN_PIZZA = 2291;
public static final int MEAT_PIZZA = 2293;
public static final int _12_MEAT_PIZZA = 2295;
public static final int ANCHOVY_PIZZA = 2297;
public static final int _12_ANCHOVY_PIZZA = 2299;
public static final int PINEAPPLE_PIZZA = 2301;
public static final int _12_PINEAPPLE_PIZZA = 2303;
public static final int BURNT_PIZZA = 2305;
public static final int BREAD_DOUGH = 2307;
public static final int BREAD = 2309;
public static final int BURNT_BREAD = 2311;
public static final int PIE_DISH = 2313;
public static final int PIE_SHELL = 2315;
public static final int UNCOOKED_APPLE_PIE = 2317;
public static final int UNCOOKED_MEAT_PIE = 2319;
public static final int UNCOOKED_BERRY_PIE = 2321;
public static final int APPLE_PIE = 2323;
public static final int REDBERRY_PIE = 2325;
public static final int MEAT_PIE = 2327;
public static final int BURNT_PIE = 2329;
public static final int HALF_A_MEAT_PIE = 2331;
public static final int HALF_A_REDBERRY_PIE = 2333;
public static final int HALF_AN_APPLE_PIE = 2335;
public static final int RAW_OOMLIE = 2337;
public static final int PALM_LEAF = 2339;
public static final int PALM_LEAF_2340 = 2340;
public static final int WRAPPED_OOMLIE = 2341;
public static final int COOKED_OOMLIE_WRAP = 2343;
public static final int BURNT_OOMLIE_WRAP = 2345;
public static final int HAMMER = 2347;
public static final int BRONZE_BAR = 2349;
public static final int IRON_BAR = 2351;
public static final int STEEL_BAR = 2353;
public static final int SILVER_BAR = 2355;
public static final int GOLD_BAR = 2357;
public static final int MITHRIL_BAR = 2359;
public static final int ADAMANTITE_BAR = 2361;
public static final int RUNITE_BAR = 2363;
public static final int PERFECT_GOLD_BAR = 2365;
public static final int SHIELD_LEFT_HALF = 2366;
public static final int SHIELD_RIGHT_HALF = 2368;
public static final int STEEL_STUDS = 2370;
public static final int OGRE_RELIC = 2372;
public static final int RELIC_PART_1 = 2373;
public static final int RELIC_PART_2 = 2374;
public static final int RELIC_PART_3 = 2375;
public static final int SKAVID_MAP = 2376;
public static final int OGRE_TOOTH = 2377;
public static final int TOBANS_KEY = 2378;
public static final int ROCK_CAKE = 2379;
public static final int CRYSTAL = 2380;
public static final int CRYSTAL_2381 = 2381;
public static final int CRYSTAL_2382 = 2382;
public static final int CRYSTAL_2383 = 2383;
public static final int FINGERNAILS = 2384;
public static final int OLD_ROBE = 2385;
public static final int UNUSUAL_ARMOUR = 2386;
public static final int DAMAGED_DAGGER = 2387;
public static final int TATTERED_EYE_PATCH = 2388;
public static final int VIAL_2389 = 2389;
public static final int VIAL_2390 = 2390;
public static final int GROUND_BAT_BONES = 2391;
public static final int TOBANS_GOLD = 2393;
public static final int POTION_2394 = 2394;
public static final int MAGIC_OGRE_POTION = 2395;
public static final int SPELL_SCROLL = 2396;
public static final int SHAMAN_ROBE = 2397;
public static final int CAVE_NIGHTSHADE = 2398;
public static final int SILVERLIGHT_KEY = 2399;
public static final int SILVERLIGHT_KEY_2400 = 2400;
public static final int SILVERLIGHT_KEY_2401 = 2401;
public static final int SILVERLIGHT = 2402;
public static final int HAZEEL_SCROLL = 2403;
public static final int CHEST_KEY_2404 = 2404;
public static final int CARNILLEAN_ARMOUR = 2405;
public static final int HAZEELS_MARK = 2406;
public static final int BALL = 2407;
public static final int DIARY = 2408;
public static final int DOOR_KEY = 2409;
public static final int MAGNET = 2410;
public static final int KEY_2411 = 2411;
public static final int SARADOMIN_CAPE = 2412;
public static final int GUTHIX_CAPE = 2413;
public static final int ZAMORAK_CAPE = 2414;
public static final int SARADOMIN_STAFF = 2415;
public static final int GUTHIX_STAFF = 2416;
public static final int ZAMORAK_STAFF = 2417;
public static final int BRONZE_KEY = 2418;
public static final int WIG = 2419;
public static final int WIG_2421 = 2421;
public static final int BLUE_PARTYHAT_2422 = 2422;
public static final int KEY_PRINT = 2423;
public static final int PASTE = 2424;
public static final int VORKATHS_HEAD = 2425;
public static final int BURNT_OOMLIE = 2426;
public static final int ATTACK_POTION4 = 2428;
public static final int RESTORE_POTION4 = 2430;
public static final int DEFENCE_POTION4 = 2432;
public static final int PRAYER_POTION4 = 2434;
public static final int SUPER_ATTACK4 = 2436;
public static final int FISHING_POTION4 = 2438;
public static final int SUPER_STRENGTH4 = 2440;
public static final int SUPER_DEFENCE4 = 2442;
public static final int RANGING_POTION4 = 2444;
public static final int ANTIPOISON4 = 2446;
public static final int SUPERANTIPOISON4 = 2448;
public static final int ZAMORAK_BREW4 = 2450;
public static final int ANTIFIRE_POTION4 = 2452;
public static final int ANTIFIRE_POTION3 = 2454;
public static final int ANTIFIRE_POTION2 = 2456;
public static final int ANTIFIRE_POTION1 = 2458;
public static final int ASSORTED_FLOWERS = 2460;
public static final int RED_FLOWERS = 2462;
public static final int BLUE_FLOWERS = 2464;
public static final int YELLOW_FLOWERS = 2466;
public static final int PURPLE_FLOWERS = 2468;
public static final int ORANGE_FLOWERS = 2470;
public static final int MIXED_FLOWERS = 2472;
public static final int WHITE_FLOWERS = 2474;
public static final int BLACK_FLOWERS = 2476;
public static final int LANTADYME = 2481;
public static final int LANTADYME_POTION_UNF = 2483;
public static final int GRIMY_LANTADYME = 2485;
public static final int BLUE_DHIDE_VAMBRACES = 2487;
public static final int RED_DHIDE_VAMBRACES = 2489;
public static final int BLACK_DHIDE_VAMBRACES = 2491;
public static final int BLUE_DHIDE_CHAPS = 2493;
public static final int RED_DHIDE_CHAPS = 2495;
public static final int BLACK_DHIDE_CHAPS = 2497;
public static final int BLUE_DHIDE_BODY = 2499;
public static final int RED_DHIDE_BODY = 2501;
public static final int BLACK_DHIDE_BODY = 2503;
public static final int BLUE_DRAGON_LEATHER = 2505;
public static final int RED_DRAGON_LEATHER = 2507;
public static final int BLACK_DRAGON_LEATHER = 2509;
public static final int LOGS_2511 = 2511;
public static final int DRAGON_CHAINBODY = 2513;
public static final int RAW_SHRIMPS_2514 = 2514;
public static final int POT_OF_FLOUR_2516 = 2516;
public static final int ROTTEN_TOMATO = 2518;
public static final int BROWN_TOY_HORSEY = 2520;
public static final int WHITE_TOY_HORSEY = 2522;
public static final int BLACK_TOY_HORSEY = 2524;
public static final int GREY_TOY_HORSEY = 2526;
public static final int LAMP = 2528;
public static final int DEAD_ORB = 2529;
public static final int BONES_2530 = 2530;
public static final int IRON_FIRE_ARROW = 2532;
public static final int IRON_FIRE_ARROW_LIT = 2533;
public static final int STEEL_FIRE_ARROW = 2534;
public static final int STEEL_FIRE_ARROW_LIT = 2535;
public static final int MITHRIL_FIRE_ARROW = 2536;
public static final int MITHRIL_FIRE_ARROW_LIT = 2537;
public static final int ADAMANT_FIRE_ARROW = 2538;
public static final int ADAMANT_FIRE_ARROW_LIT = 2539;
public static final int RUNE_FIRE_ARROW = 2540;
public static final int RUNE_FIRE_ARROW_LIT = 2541;
public static final int RING_OF_RECOIL = 2550;
public static final int RING_OF_DUELING8 = 2552;
public static final int RING_OF_DUELING7 = 2554;
public static final int RING_OF_DUELING6 = 2556;
public static final int RING_OF_DUELING5 = 2558;
public static final int RING_OF_DUELING4 = 2560;
public static final int RING_OF_DUELING3 = 2562;
public static final int RING_OF_DUELING2 = 2564;
public static final int RING_OF_DUELING1 = 2566;
public static final int RING_OF_FORGING = 2568;
public static final int RING_OF_LIFE = 2570;
public static final int RING_OF_WEALTH = 2572;
public static final int SEXTANT = 2574;
public static final int WATCH = 2575;
public static final int CHART = 2576;
public static final int RANGER_BOOTS = 2577;
public static final int WIZARD_BOOTS = 2579;
public static final int ROBIN_HOOD_HAT = 2581;
public static final int BLACK_PLATEBODY_T = 2583;
public static final int BLACK_PLATELEGS_T = 2585;
public static final int BLACK_FULL_HELM_T = 2587;
public static final int BLACK_KITESHIELD_T = 2589;
public static final int BLACK_PLATEBODY_G = 2591;
public static final int BLACK_PLATELEGS_G = 2593;
public static final int BLACK_FULL_HELM_G = 2595;
public static final int BLACK_KITESHIELD_G = 2597;
public static final int ADAMANT_PLATEBODY_T = 2599;
public static final int ADAMANT_PLATELEGS_T = 2601;
public static final int ADAMANT_KITESHIELD_T = 2603;
public static final int ADAMANT_FULL_HELM_T = 2605;
public static final int ADAMANT_PLATEBODY_G = 2607;
public static final int ADAMANT_PLATELEGS_G = 2609;
public static final int ADAMANT_KITESHIELD_G = 2611;
public static final int ADAMANT_FULL_HELM_G = 2613;
public static final int RUNE_PLATEBODY_G = 2615;
public static final int RUNE_PLATELEGS_G = 2617;
public static final int RUNE_FULL_HELM_G = 2619;
public static final int RUNE_KITESHIELD_G = 2621;
public static final int RUNE_PLATEBODY_T = 2623;
public static final int RUNE_PLATELEGS_T = 2625;
public static final int RUNE_FULL_HELM_T = 2627;
public static final int RUNE_KITESHIELD_T = 2629;
public static final int HIGHWAYMAN_MASK = 2631;
public static final int BLUE_BERET = 2633;
public static final int BLACK_BERET = 2635;
public static final int WHITE_BERET = 2637;
public static final int TAN_CAVALIER = 2639;
public static final int DARK_CAVALIER = 2641;
public static final int BLACK_CAVALIER = 2643;
public static final int RED_HEADBAND = 2645;
public static final int BLACK_HEADBAND = 2647;
public static final int BROWN_HEADBAND = 2649;
public static final int PIRATES_HAT = 2651;
public static final int ZAMORAK_PLATEBODY = 2653;
public static final int ZAMORAK_PLATELEGS = 2655;
public static final int ZAMORAK_FULL_HELM = 2657;
public static final int ZAMORAK_KITESHIELD = 2659;
public static final int SARADOMIN_PLATEBODY = 2661;
public static final int SARADOMIN_PLATELEGS = 2663;
public static final int SARADOMIN_FULL_HELM = 2665;
public static final int SARADOMIN_KITESHIELD = 2667;
public static final int GUTHIX_PLATEBODY = 2669;
public static final int GUTHIX_PLATELEGS = 2671;
public static final int GUTHIX_FULL_HELM = 2673;
public static final int GUTHIX_KITESHIELD = 2675;
public static final int CLUE_SCROLL_EASY = 2677;
public static final int CLUE_SCROLL_EASY_2678 = 2678;
public static final int CLUE_SCROLL_EASY_2679 = 2679;
public static final int CLUE_SCROLL_EASY_2680 = 2680;
public static final int CLUE_SCROLL_EASY_2681 = 2681;
public static final int CLUE_SCROLL_EASY_2682 = 2682;
public static final int CLUE_SCROLL_EASY_2683 = 2683;
public static final int CLUE_SCROLL_EASY_2684 = 2684;
public static final int CLUE_SCROLL_EASY_2685 = 2685;
public static final int CLUE_SCROLL_EASY_2686 = 2686;
public static final int CLUE_SCROLL_EASY_2687 = 2687;
public static final int CLUE_SCROLL_EASY_2688 = 2688;
public static final int CLUE_SCROLL_EASY_2689 = 2689;
public static final int CLUE_SCROLL_EASY_2690 = 2690;
public static final int CLUE_SCROLL_EASY_2691 = 2691;
public static final int CLUE_SCROLL_EASY_2692 = 2692;
public static final int CLUE_SCROLL_EASY_2693 = 2693;
public static final int CLUE_SCROLL_EASY_2694 = 2694;
public static final int CLUE_SCROLL_EASY_2695 = 2695;
public static final int CLUE_SCROLL_EASY_2696 = 2696;
public static final int CLUE_SCROLL_EASY_2697 = 2697;
public static final int CLUE_SCROLL_EASY_2698 = 2698;
public static final int CLUE_SCROLL_EASY_2699 = 2699;
public static final int CLUE_SCROLL_EASY_2700 = 2700;
public static final int CLUE_SCROLL_EASY_2701 = 2701;
public static final int CLUE_SCROLL_EASY_2702 = 2702;
public static final int CLUE_SCROLL_EASY_2703 = 2703;
public static final int CLUE_SCROLL_EASY_2704 = 2704;
public static final int CLUE_SCROLL_EASY_2705 = 2705;
public static final int CLUE_SCROLL_EASY_2706 = 2706;
public static final int CLUE_SCROLL_EASY_2707 = 2707;
public static final int CLUE_SCROLL_EASY_2708 = 2708;
public static final int CLUE_SCROLL_EASY_2709 = 2709;
public static final int CLUE_SCROLL_EASY_2710 = 2710;
public static final int CLUE_SCROLL_EASY_2711 = 2711;
public static final int CLUE_SCROLL_EASY_2712 = 2712;
public static final int CLUE_SCROLL_EASY_2713 = 2713;
public static final int CASKET_EASY = 2714;
public static final int CASKET_EASY_2715 = 2715;
public static final int CLUE_SCROLL_EASY_2716 = 2716;
public static final int CASKET_EASY_2717 = 2717;
public static final int CASKET_EASY_2718 = 2718;
public static final int CLUE_SCROLL_EASY_2719 = 2719;
public static final int CASKET_EASY_2720 = 2720;
public static final int CASKET_EASY_2721 = 2721;
public static final int CLUE_SCROLL_HARD = 2722;
public static final int CLUE_SCROLL_HARD_2723 = 2723;
public static final int CASKET_HARD = 2724;
public static final int CLUE_SCROLL_HARD_2725 = 2725;
public static final int CASKET_HARD_2726 = 2726;
public static final int CLUE_SCROLL_HARD_2727 = 2727;
public static final int CASKET_HARD_2728 = 2728;
public static final int CLUE_SCROLL_HARD_2729 = 2729;
public static final int CASKET_HARD_2730 = 2730;
public static final int CLUE_SCROLL_HARD_2731 = 2731;
public static final int CASKET_HARD_2732 = 2732;
public static final int CLUE_SCROLL_HARD_2733 = 2733;
public static final int CASKET_HARD_2734 = 2734;
public static final int CLUE_SCROLL_HARD_2735 = 2735;
public static final int CASKET_HARD_2736 = 2736;
public static final int CLUE_SCROLL_HARD_2737 = 2737;
public static final int CASKET_HARD_2738 = 2738;
public static final int CLUE_SCROLL_HARD_2739 = 2739;
public static final int CASKET_HARD_2740 = 2740;
public static final int CLUE_SCROLL_HARD_2741 = 2741;
public static final int CASKET_HARD_2742 = 2742;
public static final int CLUE_SCROLL_HARD_2743 = 2743;
public static final int CASKET_HARD_2744 = 2744;
public static final int CLUE_SCROLL_HARD_2745 = 2745;
public static final int CASKET_HARD_2746 = 2746;
public static final int CLUE_SCROLL_HARD_2747 = 2747;
public static final int CASKET_HARD_2748 = 2748;
public static final int CLUE_SCROLL_HARD_2773 = 2773;
public static final int CLUE_SCROLL_HARD_2774 = 2774;
public static final int CASKET_HARD_2775 = 2775;
public static final int CLUE_SCROLL_HARD_2776 = 2776;
public static final int CASKET_HARD_2777 = 2777;
public static final int CLUE_SCROLL_HARD_2778 = 2778;
public static final int CASKET_HARD_2779 = 2779;
public static final int CLUE_SCROLL_HARD_2780 = 2780;
public static final int CASKET_HARD_2781 = 2781;
public static final int CLUE_SCROLL_HARD_2782 = 2782;
public static final int CLUE_SCROLL_HARD_2783 = 2783;
public static final int CASKET_HARD_2784 = 2784;
public static final int CLUE_SCROLL_HARD_2785 = 2785;
public static final int CLUE_SCROLL_HARD_2786 = 2786;
public static final int CASKET_HARD_2787 = 2787;
public static final int CLUE_SCROLL_HARD_2788 = 2788;
public static final int CASKET_HARD_2789 = 2789;
public static final int CLUE_SCROLL_HARD_2790 = 2790;
public static final int CASKET_HARD_2791 = 2791;
public static final int CLUE_SCROLL_HARD_2792 = 2792;
public static final int CLUE_SCROLL_HARD_2793 = 2793;
public static final int CLUE_SCROLL_HARD_2794 = 2794;
public static final int PUZZLE_BOX_HARD = 2795;
public static final int CLUE_SCROLL_HARD_2796 = 2796;
public static final int CLUE_SCROLL_HARD_2797 = 2797;
public static final int PUZZLE_BOX_HARD_2798 = 2798;
public static final int CLUE_SCROLL_HARD_2799 = 2799;
public static final int PUZZLE_BOX_HARD_2800 = 2800;
public static final int CLUE_SCROLL_MEDIUM = 2801;
public static final int CASKET_MEDIUM = 2802;
public static final int CLUE_SCROLL_MEDIUM_2803 = 2803;
public static final int CASKET_MEDIUM_2804 = 2804;
public static final int CLUE_SCROLL_MEDIUM_2805 = 2805;
public static final int CASKET_MEDIUM_2806 = 2806;
public static final int CLUE_SCROLL_MEDIUM_2807 = 2807;
public static final int CASKET_MEDIUM_2808 = 2808;
public static final int CLUE_SCROLL_MEDIUM_2809 = 2809;
public static final int CASKET_MEDIUM_2810 = 2810;
public static final int CLUE_SCROLL_MEDIUM_2811 = 2811;
public static final int CASKET_MEDIUM_2812 = 2812;
public static final int CLUE_SCROLL_MEDIUM_2813 = 2813;
public static final int CASKET_MEDIUM_2814 = 2814;
public static final int CLUE_SCROLL_MEDIUM_2815 = 2815;
public static final int CASKET_MEDIUM_2816 = 2816;
public static final int CLUE_SCROLL_MEDIUM_2817 = 2817;
public static final int CASKET_MEDIUM_2818 = 2818;
public static final int CLUE_SCROLL_MEDIUM_2819 = 2819;
public static final int CASKET_MEDIUM_2820 = 2820;
public static final int CLUE_SCROLL_MEDIUM_2821 = 2821;
public static final int CASKET_MEDIUM_2822 = 2822;
public static final int CLUE_SCROLL_MEDIUM_2823 = 2823;
public static final int CASKET_MEDIUM_2824 = 2824;
public static final int CLUE_SCROLL_MEDIUM_2825 = 2825;
public static final int CASKET_MEDIUM_2826 = 2826;
public static final int CLUE_SCROLL_MEDIUM_2827 = 2827;
public static final int CASKET_MEDIUM_2828 = 2828;
public static final int CLUE_SCROLL_MEDIUM_2829 = 2829;
public static final int CASKET_MEDIUM_2830 = 2830;
public static final int CLUE_SCROLL_MEDIUM_2831 = 2831;
public static final int KEY_MEDIUM = 2832;
public static final int CLUE_SCROLL_MEDIUM_2833 = 2833;
public static final int KEY_MEDIUM_2834 = 2834;
public static final int CLUE_SCROLL_MEDIUM_2835 = 2835;
public static final int KEY_MEDIUM_2836 = 2836;
public static final int CLUE_SCROLL_MEDIUM_2837 = 2837;
public static final int KEY_MEDIUM_2838 = 2838;
public static final int CLUE_SCROLL_MEDIUM_2839 = 2839;
public static final int KEY_MEDIUM_2840 = 2840;
public static final int CLUE_SCROLL_MEDIUM_2841 = 2841;
public static final int CHALLENGE_SCROLL_MEDIUM = 2842;
public static final int CLUE_SCROLL_MEDIUM_2843 = 2843;
public static final int CHALLENGE_SCROLL_MEDIUM_2844 = 2844;
public static final int CLUE_SCROLL_MEDIUM_2845 = 2845;
public static final int CHALLENGE_SCROLL_MEDIUM_2846 = 2846;
public static final int CLUE_SCROLL_MEDIUM_2847 = 2847;
public static final int CLUE_SCROLL_MEDIUM_2848 = 2848;
public static final int CLUE_SCROLL_MEDIUM_2849 = 2849;
public static final int CHALLENGE_SCROLL_MEDIUM_2850 = 2850;
public static final int CLUE_SCROLL_MEDIUM_2851 = 2851;
public static final int CHALLENGE_SCROLL_MEDIUM_2852 = 2852;
public static final int CLUE_SCROLL_MEDIUM_2853 = 2853;
public static final int CHALLENGE_SCROLL_MEDIUM_2854 = 2854;
public static final int CLUE_SCROLL_MEDIUM_2855 = 2855;
public static final int CLUE_SCROLL_MEDIUM_2856 = 2856;
public static final int CLUE_SCROLL_MEDIUM_2857 = 2857;
public static final int CLUE_SCROLL_MEDIUM_2858 = 2858;
public static final int WOLF_BONES = 2859;
public static final int WOLFBONE_ARROWTIPS = 2861;
public static final int ACHEY_TREE_LOGS = 2862;
public static final int OGRE_ARROW_SHAFT = 2864;
public static final int FLIGHTED_OGRE_ARROW = 2865;
public static final int OGRE_ARROW = 2866;
public static final int OGRE_BELLOWS = 2871;
public static final int OGRE_BELLOWS_3 = 2872;
public static final int OGRE_BELLOWS_2 = 2873;
public static final int OGRE_BELLOWS_1 = 2874;
public static final int BLOATED_TOAD = 2875;
public static final int RAW_CHOMPY = 2876;
public static final int COOKED_CHOMPY = 2878;
public static final int RUINED_CHOMPY = 2880;
public static final int SEASONED_CHOMPY = 2882;
public static final int OGRE_BOW = 2883;
public static final int BATTERED_BOOK = 2886;
public static final int BATTERED_KEY = 2887;
public static final int A_STONE_BOWL = 2888;
public static final int A_STONE_BOWL_2889 = 2889;
public static final int ELEMENTAL_SHIELD = 2890;
public static final int ELEMENTAL_ORE = 2892;
public static final int ELEMENTAL_METAL = 2893;
public static final int GREY_BOOTS = 2894;
public static final int GREY_ROBE_TOP = 2896;
public static final int GREY_ROBE_BOTTOMS = 2898;
public static final int GREY_HAT = 2900;
public static final int GREY_GLOVES = 2902;
public static final int RED_BOOTS = 2904;
public static final int RED_ROBE_TOP = 2906;
public static final int RED_ROBE_BOTTOMS = 2908;
public static final int RED_HAT = 2910;
public static final int RED_GLOVES = 2912;
public static final int YELLOW_BOOTS = 2914;
public static final int YELLOW_ROBE_TOP = 2916;
public static final int YELLOW_ROBE_BOTTOMS = 2918;
public static final int YELLOW_HAT = 2920;
public static final int YELLOW_GLOVES = 2922;
public static final int TEAL_BOOTS = 2924;
public static final int TEAL_ROBE_TOP = 2926;
public static final int TEAL_ROBE_BOTTOMS = 2928;
public static final int TEAL_HAT = 2930;
public static final int TEAL_GLOVES = 2932;
public static final int PURPLE_BOOTS = 2934;
public static final int PURPLE_ROBE_TOP = 2936;
public static final int PURPLE_ROBE_BOTTOMS = 2938;
public static final int PURPLE_HAT = 2940;
public static final int PURPLE_GLOVES = 2942;
public static final int GOLDEN_KEY = 2944;
public static final int IRON_KEY = 2945;
public static final int GOLDEN_TINDERBOX = 2946;
public static final int GOLDEN_CANDLE = 2947;
public static final int GOLDEN_POT = 2948;
public static final int GOLDEN_HAMMER = 2949;
public static final int GOLDEN_FEATHER = 2950;
public static final int GOLDEN_NEEDLE = 2951;
public static final int WOLFBANE = 2952;
public static final int MURKY_WATER = 2953;
public static final int BLESSED_WATER = 2954;
public static final int MOONLIGHT_MEAD = 2955;
public static final int DRUID_POUCH = 2957;
public static final int DRUID_POUCH_2958 = 2958;
public static final int ROTTEN_FOOD = 2959;
public static final int SILVER_SICKLE = 2961;
public static final int SILVER_SICKLE_B = 2963;
public static final int WASHING_BOWL = 2964;
public static final int MIRROR = 2966;
public static final int JOURNAL = 2967;
public static final int DRUIDIC_SPELL = 2968;
public static final int A_USED_SPELL = 2969;
public static final int MORT_MYRE_FUNGUS = 2970;
public static final int MORT_MYRE_STEM = 2972;
public static final int MORT_MYRE_PEAR = 2974;
public static final int SICKLE_MOULD = 2976;
public static final int CHOMPY_BIRD_HAT = 2978;
public static final int CHOMPY_BIRD_HAT_2979 = 2979;
public static final int CHOMPY_BIRD_HAT_2980 = 2980;
public static final int CHOMPY_BIRD_HAT_2981 = 2981;
public static final int CHOMPY_BIRD_HAT_2982 = 2982;
public static final int CHOMPY_BIRD_HAT_2983 = 2983;
public static final int CHOMPY_BIRD_HAT_2984 = 2984;
public static final int CHOMPY_BIRD_HAT_2985 = 2985;
public static final int CHOMPY_BIRD_HAT_2986 = 2986;
public static final int CHOMPY_BIRD_HAT_2987 = 2987;
public static final int CHOMPY_BIRD_HAT_2988 = 2988;
public static final int CHOMPY_BIRD_HAT_2989 = 2989;
public static final int CHOMPY_BIRD_HAT_2990 = 2990;
public static final int CHOMPY_BIRD_HAT_2991 = 2991;
public static final int CHOMPY_BIRD_HAT_2992 = 2992;
public static final int CHOMPY_BIRD_HAT_2993 = 2993;
public static final int CHOMPY_BIRD_HAT_2994 = 2994;
public static final int CHOMPY_BIRD_HAT_2995 = 2995;
public static final int AGILITY_ARENA_TICKET = 2996;
public static final int PIRATES_HOOK = 2997;
public static final int TOADFLAX = 2998;
public static final int SNAPDRAGON = 3000;
public static final int TOADFLAX_POTION_UNF = 3002;
public static final int SNAPDRAGON_POTION_UNF = 3004;
public static final int FIREWORK = 3006;
public static final int ENERGY_POTION4 = 3008;
public static final int ENERGY_POTION3 = 3010;
public static final int ENERGY_POTION2 = 3012;
public static final int ENERGY_POTION1 = 3014;
public static final int SUPER_ENERGY4 = 3016;
public static final int SUPER_ENERGY3 = 3018;
public static final int SUPER_ENERGY2 = 3020;
public static final int SUPER_ENERGY1 = 3022;
public static final int SUPER_RESTORE4 = 3024;
public static final int SUPER_RESTORE3 = 3026;
public static final int SUPER_RESTORE2 = 3028;
public static final int SUPER_RESTORE1 = 3030;
public static final int AGILITY_POTION4 = 3032;
public static final int AGILITY_POTION3 = 3034;
public static final int AGILITY_POTION2 = 3036;
public static final int AGILITY_POTION1 = 3038;
public static final int MAGIC_POTION4 = 3040;
public static final int MAGIC_POTION3 = 3042;
public static final int MAGIC_POTION2 = 3044;
public static final int MAGIC_POTION1 = 3046;
public static final int GRIMY_TOADFLAX = 3049;
public static final int GRIMY_SNAPDRAGON = 3051;
public static final int LAVA_BATTLESTAFF = 3053;
public static final int MYSTIC_LAVA_STAFF = 3054;
public static final int MIME_MASK = 3057;
public static final int MIME_TOP = 3058;
public static final int MIME_LEGS = 3059;
public static final int MIME_GLOVES = 3060;
public static final int MIME_BOOTS = 3061;
public static final int STRANGE_BOX = 3062;
public static final int BLACK_DART = 3093;
public static final int BLACK_DARTP = 3094;
public static final int BRONZE_CLAWS = 3095;
public static final int IRON_CLAWS = 3096;
public static final int STEEL_CLAWS = 3097;
public static final int BLACK_CLAWS = 3098;
public static final int MITHRIL_CLAWS = 3099;
public static final int ADAMANT_CLAWS = 3100;
public static final int RUNE_CLAWS = 3101;
public static final int COMBINATION = 3102;
public static final int IOU = 3103;
public static final int SECRET_WAY_MAP = 3104;
public static final int CLIMBING_BOOTS = 3105;
public static final int SPIKED_BOOTS = 3107;
public static final int STONE_BALL = 3109;
public static final int STONE_BALL_3110 = 3110;
public static final int STONE_BALL_3111 = 3111;
public static final int STONE_BALL_3112 = 3112;
public static final int STONE_BALL_3113 = 3113;
public static final int CERTIFICATE_3114 = 3114;
public static final int GRANITE_SHIELD = 3122;
public static final int SHAIKAHAN_BONES = 3123;
public static final int JOGRE_BONES = 3125;
public static final int BURNT_JOGRE_BONES = 3127;
public static final int PASTY_JOGRE_BONES = 3128;
public static final int PASTY_JOGRE_BONES_3129 = 3129;
public static final int MARINATED_J_BONES = 3130;
public static final int PASTY_JOGRE_BONES_3131 = 3131;
public static final int PASTY_JOGRE_BONES_3132 = 3132;
public static final int MARINATED_J_BONES_3133 = 3133;
public static final int PRISON_KEY = 3135;
public static final int CELL_KEY_1 = 3136;
public static final int CELL_KEY_2 = 3137;
public static final int POTATO_CACTUS = 3138;
public static final int DRAGON_CHAINBODY_3140 = 3140;
public static final int RAW_KARAMBWAN = 3142;
public static final int COOKED_KARAMBWAN = 3144;
public static final int POISON_KARAMBWAN = 3146;
public static final int COOKED_KARAMBWAN_3147 = 3147;
public static final int BURNT_KARAMBWAN = 3148;
public static final int RAW_KARAMBWANJI = 3150;
public static final int KARAMBWAN_PASTE = 3152;
public static final int KARAMBWAN_PASTE_3153 = 3153;
public static final int KARAMBWAN_PASTE_3154 = 3154;
public static final int KARAMBWANJI_PASTE = 3155;
public static final int KARAMBWANJI_PASTE_3156 = 3156;
public static final int KARAMBWAN_VESSEL = 3157;
public static final int KARAMBWAN_VESSEL_3159 = 3159;
public static final int CRAFTING_MANUAL = 3161;
public static final int SLICED_BANANA = 3162;
public static final int KARAMJAN_RUM_3164 = 3164;
public static final int KARAMJAN_RUM_3165 = 3165;
public static final int MONKEY_CORPSE = 3166;
public static final int MONKEY_SKIN = 3167;
public static final int SEAWEED_SANDWICH = 3168;
public static final int STUFFED_MONKEY = 3169;
public static final int BRONZE_SPEARKP = 3170;
public static final int IRON_SPEARKP = 3171;
public static final int STEEL_SPEARKP = 3172;
public static final int MITHRIL_SPEARKP = 3173;
public static final int ADAMANT_SPEARKP = 3174;
public static final int RUNE_SPEARKP = 3175;
public static final int DRAGON_SPEARKP = 3176;
public static final int LEFTHANDED_BANANA = 3177;
public static final int MONKEY_BONES = 3179;
public static final int MONKEY_BONES_3180 = 3180;
public static final int MONKEY_BONES_3181 = 3181;
public static final int MONKEY_BONES_3182 = 3182;
public static final int MONKEY_BONES_3183 = 3183;
public static final int MONKEY_BONES_3185 = 3185;
public static final int MONKEY_BONES_3186 = 3186;
public static final int BONES_3187 = 3187;
public static final int CLEANING_CLOTH = 3188;
public static final int BRONZE_HALBERD = 3190;
public static final int IRON_HALBERD = 3192;
public static final int STEEL_HALBERD = 3194;
public static final int BLACK_HALBERD = 3196;
public static final int MITHRIL_HALBERD = 3198;
public static final int ADAMANT_HALBERD = 3200;
public static final int RUNE_HALBERD = 3202;
public static final int DRAGON_HALBERD = 3204;
public static final int KINGS_MESSAGE = 3206;
public static final int IORWERTHS_MESSAGE = 3207;
public static final int CRYSTAL_PENDANT = 3208;
public static final int SULPHUR = 3209;
public static final int LIMESTONE = 3211;
public static final int QUICKLIME = 3213;
public static final int POT_OF_QUICKLIME = 3214;
public static final int GROUND_SULPHUR = 3215;
public static final int BARREL_3216 = 3216;
public static final int BARREL_BOMB = 3218;
public static final int BARREL_BOMB_3219 = 3219;
public static final int BARREL_OF_COAL_TAR = 3220;
public static final int BARREL_OF_NAPHTHA = 3221;
public static final int NAPHTHA_MIX = 3222;
public static final int NAPHTHA_MIX_3223 = 3223;
public static final int STRIP_OF_CLOTH = 3224;
public static final int RAW_RABBIT = 3226;
public static final int COOKED_RABBIT = 3228;
public static final int BIG_BOOK_OF_BANGS = 3230;
public static final int SYMBOL = 3231;
public static final int SYMBOL_3233 = 3233;
public static final int SYMBOL_3235 = 3235;
public static final int SYMBOL_3237 = 3237;
public static final int BARK = 3239;
public static final int MAN = 3241;
public static final int FARMER = 3243;
public static final int WARRIOR_WOMAN = 3245;
public static final int ROGUE = 3247;
public static final int GUARD = 3249;
public static final int KNIGHT_OF_ARDOUGNE = 3251;
public static final int WATCHMAN = 3253;
public static final int PALADIN = 3255;
public static final int GNOME = 3257;
public static final int HERO = 3259;
public static final int GOUTWEED = 3261;
public static final int TROLL_THISTLE = 3262;
public static final int DRIED_THISTLE = 3263;
public static final int GROUND_THISTLE = 3264;
public static final int TROLL_POTION = 3265;
public static final int DRUNK_PARROT = 3266;
public static final int DIRTY_ROBE = 3267;
public static final int FAKE_MAN = 3268;
public static final int STOREROOM_KEY = 3269;
public static final int ALCOCHUNKS = 3270;
public static final int COMPOST_BIN = 3271;
public static final int CAVE_KRAKEN = 3272;
public static final int VAMPYRE_DUST = 3325;
public static final int MYRE_SNELM = 3327;
public static final int BLOODNTAR_SNELM = 3329;
public static final int OCHRE_SNELM = 3331;
public static final int BRUISE_BLUE_SNELM = 3333;
public static final int BROKEN_BARK_SNELM = 3335;
public static final int MYRE_SNELM_3337 = 3337;
public static final int BLOODNTAR_SNELM_3339 = 3339;
public static final int OCHRE_SNELM_3341 = 3341;
public static final int BRUISE_BLUE_SNELM_3343 = 3343;
public static final int BLAMISH_MYRE_SHELL = 3345;
public static final int BLAMISH_RED_SHELL = 3347;
public static final int BLAMISH_OCHRE_SHELL = 3349;
public static final int BLAMISH_BLUE_SHELL = 3351;
public static final int BLAMISH_BARK_SHELL = 3353;
public static final int BLAMISH_MYRE_SHELL_3355 = 3355;
public static final int BLAMISH_RED_SHELL_3357 = 3357;
public static final int BLAMISH_OCHRE_SHELL_3359 = 3359;
public static final int BLAMISH_BLUE_SHELL_3361 = 3361;
public static final int THIN_SNAIL = 3363;
public static final int LEAN_SNAIL = 3365;
public static final int FAT_SNAIL = 3367;
public static final int THIN_SNAIL_MEAT = 3369;
public static final int LEAN_SNAIL_MEAT = 3371;
public static final int FAT_SNAIL_MEAT = 3373;
public static final int BURNT_SNAIL = 3375;
public static final int SAMPLE_BOTTLE = 3377;
public static final int RAW_SLIMY_EEL = 3379;
public static final int COOKED_SLIMY_EEL = 3381;
public static final int BURNT_EEL = 3383;
public static final int SPLITBARK_HELM = 3385;
public static final int SPLITBARK_BODY = 3387;
public static final int SPLITBARK_LEGS = 3389;
public static final int SPLITBARK_GAUNTLETS = 3391;
public static final int SPLITBARK_BOOTS = 3393;
public static final int DIARY_3395 = 3395;
public static final int LOAR_REMAINS = 3396;
public static final int PHRIN_REMAINS = 3398;
public static final int RIYL_REMAINS = 3400;
public static final int ASYN_REMAINS = 3402;
public static final int FIYR_REMAINS = 3404;
public static final int UNFINISHED_POTION = 3406;
public static final int SERUM_207_4 = 3408;
public static final int SERUM_207_3 = 3410;
public static final int SERUM_207_2 = 3412;
public static final int SERUM_207_1 = 3414;
public static final int SERUM_208_4 = 3416;
public static final int SERUM_208_3 = 3417;
public static final int SERUM_208_2 = 3418;
public static final int SERUM_208_1 = 3419;
public static final int LIMESTONE_BRICK = 3420;
public static final int OLIVE_OIL4 = 3422;
public static final int OLIVE_OIL3 = 3424;
public static final int OLIVE_OIL2 = 3426;
public static final int OLIVE_OIL1 = 3428;
public static final int SACRED_OIL4 = 3430;
public static final int SACRED_OIL3 = 3432;
public static final int SACRED_OIL2 = 3434;
public static final int SACRED_OIL1 = 3436;
public static final int PYRE_LOGS = 3438;
public static final int OAK_PYRE_LOGS = 3440;
public static final int WILLOW_PYRE_LOGS = 3442;
public static final int MAPLE_PYRE_LOGS = 3444;
public static final int YEW_PYRE_LOGS = 3446;
public static final int MAGIC_PYRE_LOGS = 3448;
public static final int BRONZE_KEY_RED = 3450;
public static final int BRONZE_KEY_BROWN = 3451;
public static final int BRONZE_KEY_CRIMSON = 3452;
public static final int BRONZE_KEY_BLACK = 3453;
public static final int BRONZE_KEY_PURPLE = 3454;
public static final int STEEL_KEY_RED = 3455;
public static final int STEEL_KEY_BROWN = 3456;
public static final int STEEL_KEY_CRIMSON = 3457;
public static final int STEEL_KEY_BLACK = 3458;
public static final int STEEL_KEY_PURPLE = 3459;
public static final int BLACK_KEY_RED = 3460;
public static final int BLACK_KEY_BROWN = 3461;
public static final int BLACK_KEY_CRIMSON = 3462;
public static final int BLACK_KEY_BLACK = 3463;
public static final int BLACK_KEY_PURPLE = 3464;
public static final int SILVER_KEY_RED = 3465;
public static final int SILVER_KEY_BROWN = 3466;
public static final int SILVER_KEY_CRIMSON = 3467;
public static final int SILVER_KEY_BLACK = 3468;
public static final int SILVER_KEY_PURPLE = 3469;
public static final int FINE_CLOTH = 3470;
public static final int BLACK_PLATESKIRT_T = 3472;
public static final int BLACK_PLATESKIRT_G = 3473;
public static final int ADAMANT_PLATESKIRT_T = 3474;
public static final int ADAMANT_PLATESKIRT_G = 3475;
public static final int RUNE_PLATESKIRT_G = 3476;
public static final int RUNE_PLATESKIRT_T = 3477;
public static final int ZAMORAK_PLATESKIRT = 3478;
public static final int SARADOMIN_PLATESKIRT = 3479;
public static final int GUTHIX_PLATESKIRT = 3480;
public static final int GILDED_PLATEBODY = 3481;
public static final int GILDED_PLATELEGS = 3483;
public static final int GILDED_PLATESKIRT = 3485;
public static final int GILDED_FULL_HELM = 3486;
public static final int GILDED_KITESHIELD = 3488;
public static final int CLUE_SCROLL_EASY_3490 = 3490;
public static final int CLUE_SCROLL_EASY_3491 = 3491;
public static final int CLUE_SCROLL_EASY_3492 = 3492;
public static final int CLUE_SCROLL_EASY_3493 = 3493;
public static final int CLUE_SCROLL_EASY_3494 = 3494;
public static final int CLUE_SCROLL_EASY_3495 = 3495;
public static final int CLUE_SCROLL_EASY_3496 = 3496;
public static final int CLUE_SCROLL_EASY_3497 = 3497;
public static final int CLUE_SCROLL_EASY_3498 = 3498;
public static final int CLUE_SCROLL_EASY_3499 = 3499;
public static final int CLUE_SCROLL_EASY_3500 = 3500;
public static final int CLUE_SCROLL_EASY_3501 = 3501;
public static final int CLUE_SCROLL_EASY_3502 = 3502;
public static final int CLUE_SCROLL_EASY_3503 = 3503;
public static final int CLUE_SCROLL_EASY_3504 = 3504;
public static final int CLUE_SCROLL_EASY_3505 = 3505;
public static final int CLUE_SCROLL_EASY_3506 = 3506;
public static final int CLUE_SCROLL_EASY_3507 = 3507;
public static final int CLUE_SCROLL_EASY_3508 = 3508;
public static final int CLUE_SCROLL_EASY_3509 = 3509;
public static final int CLUE_SCROLL_EASY_3510 = 3510;
public static final int CASKET_EASY_3511 = 3511;
public static final int CLUE_SCROLL_EASY_3512 = 3512;
public static final int CLUE_SCROLL_EASY_3513 = 3513;
public static final int CLUE_SCROLL_EASY_3514 = 3514;
public static final int CLUE_SCROLL_EASY_3515 = 3515;
public static final int CLUE_SCROLL_EASY_3516 = 3516;
public static final int CASKET_EASY_3517 = 3517;
public static final int CLUE_SCROLL_EASY_3518 = 3518;
public static final int CASKET_EASY_3519 = 3519;
public static final int CLUE_SCROLL_HARD_3520 = 3520;
public static final int CASKET_HARD_3521 = 3521;
public static final int CLUE_SCROLL_HARD_3522 = 3522;
public static final int CASKET_HARD_3523 = 3523;
public static final int CLUE_SCROLL_HARD_3524 = 3524;
public static final int CLUE_SCROLL_HARD_3525 = 3525;
public static final int CLUE_SCROLL_HARD_3526 = 3526;
public static final int CASKET_HARD_3527 = 3527;
public static final int CLUE_SCROLL_HARD_3528 = 3528;
public static final int CASKET_HARD_3529 = 3529;
public static final int CLUE_SCROLL_HARD_3530 = 3530;
public static final int CASKET_HARD_3531 = 3531;
public static final int CLUE_SCROLL_HARD_3532 = 3532;
public static final int CASKET_HARD_3533 = 3533;
public static final int CLUE_SCROLL_HARD_3534 = 3534;
public static final int CASKET_HARD_3535 = 3535;
public static final int CLUE_SCROLL_HARD_3536 = 3536;
public static final int CASKET_HARD_3537 = 3537;
public static final int CLUE_SCROLL_HARD_3538 = 3538;
public static final int CASKET_HARD_3539 = 3539;
public static final int CLUE_SCROLL_HARD_3540 = 3540;
public static final int CASKET_HARD_3541 = 3541;
public static final int CLUE_SCROLL_HARD_3542 = 3542;
public static final int CASKET_HARD_3543 = 3543;
public static final int CLUE_SCROLL_HARD_3544 = 3544;
public static final int CASKET_HARD_3545 = 3545;
public static final int CLUE_SCROLL_HARD_3546 = 3546;
public static final int CASKET_HARD_3547 = 3547;
public static final int CLUE_SCROLL_HARD_3548 = 3548;
public static final int CASKET_HARD_3549 = 3549;
public static final int CLUE_SCROLL_HARD_3550 = 3550;
public static final int CASKET_HARD_3551 = 3551;
public static final int CLUE_SCROLL_HARD_3552 = 3552;
public static final int CASKET_HARD_3553 = 3553;
public static final int CLUE_SCROLL_HARD_3554 = 3554;
public static final int CASKET_HARD_3555 = 3555;
public static final int CLUE_SCROLL_HARD_3556 = 3556;
public static final int CASKET_HARD_3557 = 3557;
public static final int CLUE_SCROLL_HARD_3558 = 3558;
public static final int CASKET_HARD_3559 = 3559;
public static final int CLUE_SCROLL_HARD_3560 = 3560;
public static final int CASKET_HARD_3561 = 3561;
public static final int CLUE_SCROLL_HARD_3562 = 3562;
public static final int CASKET_HARD_3563 = 3563;
public static final int CLUE_SCROLL_HARD_3564 = 3564;
public static final int PUZZLE_BOX_HARD_3565 = 3565;
public static final int CLUE_SCROLL_HARD_3566 = 3566;
public static final int PUZZLE_BOX_HARD_3567 = 3567;
public static final int CLUE_SCROLL_HARD_3568 = 3568;
public static final int PUZZLE_BOX_HARD_3569 = 3569;
public static final int CLUE_SCROLL_HARD_3570 = 3570;
public static final int PUZZLE_BOX_HARD_3571 = 3571;
public static final int CLUE_SCROLL_HARD_3572 = 3572;
public static final int CLUE_SCROLL_HARD_3573 = 3573;
public static final int CLUE_SCROLL_HARD_3574 = 3574;
public static final int CLUE_SCROLL_HARD_3575 = 3575;
public static final int PUZZLE_BOX_HARD_3576 = 3576;
public static final int CLUE_SCROLL_HARD_3577 = 3577;
public static final int PUZZLE_BOX_HARD_3578 = 3578;
public static final int CLUE_SCROLL_HARD_3579 = 3579;
public static final int CLUE_SCROLL_HARD_3580 = 3580;
public static final int CASKET_HARD_3581 = 3581;
public static final int CLUE_SCROLL_MEDIUM_3582 = 3582;
public static final int CASKET_MEDIUM_3583 = 3583;
public static final int CLUE_SCROLL_MEDIUM_3584 = 3584;
public static final int CASKET_MEDIUM_3585 = 3585;
public static final int CLUE_SCROLL_MEDIUM_3586 = 3586;
public static final int CASKET_MEDIUM_3587 = 3587;
public static final int CLUE_SCROLL_MEDIUM_3588 = 3588;
public static final int CASKET_MEDIUM_3589 = 3589;
public static final int CLUE_SCROLL_MEDIUM_3590 = 3590;
public static final int CASKET_MEDIUM_3591 = 3591;
public static final int CLUE_SCROLL_MEDIUM_3592 = 3592;
public static final int CASKET_MEDIUM_3593 = 3593;
public static final int CLUE_SCROLL_MEDIUM_3594 = 3594;
public static final int CASKET_MEDIUM_3595 = 3595;
public static final int CLUE_SCROLL_MEDIUM_3596 = 3596;
public static final int CASKET_MEDIUM_3597 = 3597;
public static final int CLUE_SCROLL_MEDIUM_3598 = 3598;
public static final int CLUE_SCROLL_MEDIUM_3599 = 3599;
public static final int CASKET_MEDIUM_3600 = 3600;
public static final int CLUE_SCROLL_MEDIUM_3601 = 3601;
public static final int CLUE_SCROLL_MEDIUM_3602 = 3602;
public static final int CASKET_MEDIUM_3603 = 3603;
public static final int CLUE_SCROLL_MEDIUM_3604 = 3604;
public static final int CLUE_SCROLL_MEDIUM_3605 = 3605;
public static final int KEY_MEDIUM_3606 = 3606;
public static final int CLUE_SCROLL_MEDIUM_3607 = 3607;
public static final int KEY_MEDIUM_3608 = 3608;
public static final int CLUE_SCROLL_MEDIUM_3609 = 3609;
public static final int CLUE_SCROLL_MEDIUM_3610 = 3610;
public static final int CLUE_SCROLL_MEDIUM_3611 = 3611;
public static final int CLUE_SCROLL_MEDIUM_3612 = 3612;
public static final int CLUE_SCROLL_MEDIUM_3613 = 3613;
public static final int CLUE_SCROLL_MEDIUM_3614 = 3614;
public static final int CLUE_SCROLL_MEDIUM_3615 = 3615;
public static final int CLUE_SCROLL_MEDIUM_3616 = 3616;
public static final int CLUE_SCROLL_MEDIUM_3617 = 3617;
public static final int CLUE_SCROLL_MEDIUM_3618 = 3618;
public static final int FLAMTAER_HAMMER = 3678;
public static final int SHOE = 3680;
public static final int SHOE_3681 = 3681;
public static final int SHOE_3682 = 3682;
public static final int SHOE_3683 = 3683;
public static final int SHOE_3684 = 3684;
public static final int SHOE_3685 = 3685;
public static final int FREMENNIK = 3686;
public static final int UNSTRUNG_LYRE = 3688;
public static final int LYRE = 3689;
public static final int ENCHANTED_LYRE = 3690;
public static final int ENCHANTED_LYRE1 = 3691;
public static final int BRANCH = 3692;
public static final int GOLDEN_FLEECE = 3693;
public static final int GOLDEN_WOOL = 3694;
public static final int PET_ROCK = 3695;
public static final int HUNTERS_TALISMAN = 3696;
public static final int HUNTERS_TALISMAN_3697 = 3697;
public static final int EXOTIC_FLOWER = 3698;
public static final int FREMENNIK_BALLAD = 3699;
public static final int STURDY_BOOTS = 3700;
public static final int TRACKING_MAP = 3701;
public static final int CUSTOM_BOW_STRING = 3702;
public static final int UNUSUAL_FISH = 3703;
public static final int SEA_FISHING_MAP = 3704;
public static final int WEATHER_FORECAST = 3705;
public static final int CHAMPIONS_TOKEN = 3706;
public static final int LEGENDARY_COCKTAIL = 3707;
public static final int FISCAL_STATEMENT = 3708;
public static final int PROMISSORY_NOTE = 3709;
public static final int WARRIORS_CONTRACT = 3710;
public static final int KEG_OF_BEER = 3711;
public static final int LOW_ALCOHOL_KEG = 3712;
public static final int STRANGE_OBJECT = 3713;
public static final int LIT_STRANGE_OBJECT = 3714;
public static final int RED_DISK = 3715;
public static final int RED_DISK_3716 = 3716;
public static final int MAGNET_3718 = 3718;
public static final int BLUE_THREAD = 3719;
public static final int SMALL_PICK = 3720;
public static final int TOY_SHIP = 3721;
public static final int FULL_BUCKET = 3722;
public static final int _45THS_FULL_BUCKET = 3723;
public static final int _35THS_FULL_BUCKET = 3724;
public static final int _25THS_FULL_BUCKET = 3725;
public static final int _15THS_FULL_BUCKET = 3726;
public static final int EMPTY_BUCKET = 3727;
public static final int FROZEN_BUCKET = 3728;
public static final int FULL_JUG = 3729;
public static final int _23RDS_FULL_JUG = 3730;
public static final int _13RDS_FULL_JUG = 3731;
public static final int EMPTY_JUG = 3732;
public static final int FROZEN_JUG = 3733;
public static final int VASE_3734 = 3734;
public static final int VASE_OF_WATER = 3735;
public static final int FROZEN_VASE = 3736;
public static final int VASE_LID = 3737;
public static final int SEALED_VASE = 3738;
public static final int SEALED_VASE_3739 = 3739;
public static final int SEALED_VASE_3740 = 3740;
public static final int FROZEN_KEY = 3741;
public static final int RED_HERRING = 3742;
public static final int RED_DISK_3743 = 3743;
public static final int WOODEN_DISK = 3744;
public static final int SEERS_KEY = 3745;
public static final int STICKY_RED_GOOP = 3746;
public static final int FREMENNIK_HELM = 3748;
public static final int ARCHER_HELM = 3749;
public static final int BERSERKER_HELM = 3751;
public static final int WARRIOR_HELM = 3753;
public static final int FARSEER_HELM = 3755;
public static final int FREMENNIK_BLADE = 3757;
public static final int FREMENNIK_SHIELD = 3758;
public static final int FREMENNIK_CYAN_CLOAK = 3759;
public static final int FREMENNIK_BROWN_CLOAK = 3761;
public static final int FREMENNIK_BLUE_CLOAK = 3763;
public static final int FREMENNIK_GREEN_CLOAK = 3765;
public static final int FREMENNIK_BROWN_SHIRT = 3767;
public static final int FREMENNIK_GREY_SHIRT = 3769;
public static final int FREMENNIK_BEIGE_SHIRT = 3771;
public static final int FREMENNIK_RED_SHIRT = 3773;
public static final int FREMENNIK_BLUE_SHIRT = 3775;
public static final int FREMENNIK_RED_CLOAK = 3777;
public static final int FREMENNIK_GREY_CLOAK = 3779;
public static final int FREMENNIK_YELLOW_CLOAK = 3781;
public static final int FREMENNIK_TEAL_CLOAK = 3783;
public static final int FREMENNIK_PURPLE_CLOAK = 3785;
public static final int FREMENNIK_PINK_CLOAK = 3787;
public static final int FREMENNIK_BLACK_CLOAK = 3789;
public static final int FREMENNIK_BOOTS = 3791;
public static final int FREMENNIK_ROBE = 3793;
public static final int FREMENNIK_SKIRT = 3795;
public static final int FREMENNIK_HAT = 3797;
public static final int FREMENNIK_GLOVES = 3799;
public static final int KEG_OF_BEER_3801 = 3801;
public static final int BEER_TANKARD = 3803;
public static final int TANKARD = 3805;
public static final int SARADOMIN_PAGE_1 = 3827;
public static final int SARADOMIN_PAGE_2 = 3828;
public static final int SARADOMIN_PAGE_3 = 3829;
public static final int SARADOMIN_PAGE_4 = 3830;
public static final int ZAMORAK_PAGE_1 = 3831;
public static final int ZAMORAK_PAGE_2 = 3832;
public static final int ZAMORAK_PAGE_3 = 3833;
public static final int ZAMORAK_PAGE_4 = 3834;
public static final int GUTHIX_PAGE_1 = 3835;
public static final int GUTHIX_PAGE_2 = 3836;
public static final int GUTHIX_PAGE_3 = 3837;
public static final int GUTHIX_PAGE_4 = 3838;
public static final int DAMAGED_BOOK = 3839;
public static final int HOLY_BOOK = 3840;
public static final int DAMAGED_BOOK_3841 = 3841;
public static final int UNHOLY_BOOK = 3842;
public static final int DAMAGED_BOOK_3843 = 3843;
public static final int BOOK_OF_BALANCE = 3844;
public static final int JOURNAL_3845 = 3845;
public static final int DIARY_3846 = 3846;
public static final int MANUAL = 3847;
public static final int LIGHTHOUSE_KEY = 3848;
public static final int RUSTY_CASKET = 3849;
public static final int GAMES_NECKLACE8 = 3853;
public static final int GAMES_NECKLACE7 = 3855;
public static final int GAMES_NECKLACE6 = 3857;
public static final int GAMES_NECKLACE5 = 3859;
public static final int GAMES_NECKLACE4 = 3861;
public static final int GAMES_NECKLACE3 = 3863;
public static final int GAMES_NECKLACE2 = 3865;
public static final int GAMES_NECKLACE1 = 3867;
public static final int BOARD_GAME_PIECE = 3869;
public static final int BOARD_GAME_PIECE_3870 = 3870;
public static final int BOARD_GAME_PIECE_3871 = 3871;
public static final int BOARD_GAME_PIECE_3872 = 3872;
public static final int BOARD_GAME_PIECE_3873 = 3873;
public static final int BOARD_GAME_PIECE_3874 = 3874;
public static final int BOARD_GAME_PIECE_3875 = 3875;
public static final int BOARD_GAME_PIECE_3876 = 3876;
public static final int BOARD_GAME_PIECE_3877 = 3877;
public static final int BOARD_GAME_PIECE_3878 = 3878;
public static final int BOARD_GAME_PIECE_3879 = 3879;
public static final int BOARD_GAME_PIECE_3880 = 3880;
public static final int BOARD_GAME_PIECE_3881 = 3881;
public static final int BOARD_GAME_PIECE_3882 = 3882;
public static final int BOARD_GAME_PIECE_3883 = 3883;
public static final int BOARD_GAME_PIECE_3884 = 3884;
public static final int BOARD_GAME_PIECE_3885 = 3885;
public static final int BOARD_GAME_PIECE_3886 = 3886;
public static final int BOARD_GAME_PIECE_3887 = 3887;
public static final int BOARD_GAME_PIECE_3888 = 3888;
public static final int BOARD_GAME_PIECE_3889 = 3889;
public static final int BOARD_GAME_PIECE_3890 = 3890;
public static final int BOARD_GAME_PIECE_3891 = 3891;
public static final int BOARD_GAME_PIECE_3892 = 3892;
public static final int STOOL = 3893;
public static final int AWFUL_ANTHEM = 3894;
public static final int GOOD_ANTHEM = 3895;
public static final int TREATY = 3896;
public static final int GIANT_NIB = 3897;
public static final int GIANT_PEN = 3898;
public static final int IRON_SICKLE = 3899;
public static final int GHRIMS_BOOK = 3901;
public static final int WILDERNESS_SWORD = 3981;
public static final int WESTERN_BANNER = 3983;
public static final int HARDY_GOUT_TUBER = 4001;
public static final int SPARE_CONTROLS = 4002;
public static final int GNOME_ROYAL_SEAL = 4004;
public static final int NARNODES_ORDERS = 4005;
public static final int MONKEY_DENTURES = 4006;
public static final int ENCHANTED_BAR = 4007;
public static final int EYE_OF_GNOME = 4008;
public static final int EYE_OF_GNOME_4009 = 4009;
public static final int MONKEY_MAGIC = 4010;
public static final int MONKEY_NUTS = 4012;
public static final int MONKEY_BAR = 4014;
public static final int BANANA_STEW = 4016;
public static final int MONKEY_WRENCH = 4018;
public static final int MAMULET_MOULD = 4020;
public static final int MSPEAK_AMULET = 4021;
public static final int MSPEAK_AMULET_4022 = 4022;
public static final int MONKEY_TALISMAN = 4023;
public static final int NINJA_MONKEY_GREEGREE = 4024;
public static final int NINJA_MONKEY_GREEGREE_4025 = 4025;
public static final int GORILLA_GREEGREE = 4026;
public static final int BEARDED_GORILLA_GREEGREE = 4027;
public static final int ANCIENT_GORILLA_GREEGREE = 4028;
public static final int ZOMBIE_MONKEY_GREEGREE = 4029;
public static final int ZOMBIE_MONKEY_GREEGREE_4030 = 4030;
public static final int KARAMJAN_MONKEY_GREEGREE = 4031;
public static final int MONKEY = 4033;
public static final int MONKEY_SKULL = 4034;
public static final int _10TH_SQUAD_SIGIL = 4035;
public static final int SARADOMIN_BANNER = 4037;
public static final int ZAMORAK_BANNER = 4039;
public static final int HOODED_CLOAK = 4041;
public static final int HOODED_CLOAK_4042 = 4042;
public static final int ROCK_4043 = 4043;
public static final int EXPLOSIVE_POTION = 4045;
public static final int CLIMBING_ROPE = 4047;
public static final int BANDAGES = 4049;
public static final int TOOLKIT_4051 = 4051;
public static final int BARRICADE = 4053;
public static final int CASTLEWARS_MANUAL = 4055;
public static final int CASTLE_WARS_TICKET = 4067;
public static final int DECORATIVE_SWORD = 4068;
public static final int DECORATIVE_ARMOUR = 4069;
public static final int DECORATIVE_ARMOUR_4070 = 4070;
public static final int DECORATIVE_HELM = 4071;
public static final int DECORATIVE_SHIELD = 4072;
public static final int DAMP_TINDERBOX = 4073;
public static final int GLOWING_FUNGUS = 4075;
public static final int CRYSTALMINE_KEY = 4077;
public static final int ZEALOTS_KEY = 4078;
public static final int YOYO = 4079;
public static final int SALVE_AMULET = 4081;
public static final int SALVE_SHARD = 4082;
public static final int SLED = 4083;
public static final int SLED_4084 = 4084;
public static final int WAX = 4085;
public static final int TROLLWEISS = 4086;
public static final int DRAGON_PLATELEGS = 4087;
public static final int MYSTIC_HAT = 4089;
public static final int MYSTIC_ROBE_TOP = 4091;
public static final int MYSTIC_ROBE_BOTTOM = 4093;
public static final int MYSTIC_GLOVES = 4095;
public static final int MYSTIC_BOOTS = 4097;
public static final int MYSTIC_HAT_DARK = 4099;
public static final int MYSTIC_ROBE_TOP_DARK = 4101;
public static final int MYSTIC_ROBE_BOTTOM_DARK = 4103;
public static final int MYSTIC_GLOVES_DARK = 4105;
public static final int MYSTIC_BOOTS_DARK = 4107;
public static final int MYSTIC_HAT_LIGHT = 4109;
public static final int MYSTIC_ROBE_TOP_LIGHT = 4111;
public static final int MYSTIC_ROBE_BOTTOM_LIGHT = 4113;
public static final int MYSTIC_GLOVES_LIGHT = 4115;
public static final int MYSTIC_BOOTS_LIGHT = 4117;
public static final int BRONZE_BOOTS = 4119;
public static final int IRON_BOOTS = 4121;
public static final int STEEL_BOOTS = 4123;
public static final int BLACK_BOOTS = 4125;
public static final int MITHRIL_BOOTS = 4127;
public static final int ADAMANT_BOOTS = 4129;
public static final int RUNE_BOOTS = 4131;
public static final int CRAWLING_HAND = 4133;
public static final int CAVE_CRAWLER = 4134;
public static final int BANSHEE = 4135;
public static final int ROCKSLUG = 4136;
public static final int COCKATRICE = 4137;
public static final int PYREFIEND = 4138;
public static final int BASILISK = 4139;
public static final int INFERNAL_MAGE = 4140;
public static final int BLOODVELD = 4141;
public static final int JELLY = 4142;
public static final int TUROTH = 4143;
public static final int ABERRANT_SPECTRE = 4144;
public static final int DUST_DEVIL = 4145;
public static final int KURASK = 4146;
public static final int GARGOYLE = 4147;
public static final int NECHRYAEL = 4148;
public static final int ABYSSAL_DEMON = 4149;
public static final int BROAD_ARROWS = 4150;
public static final int ABYSSAL_WHIP = 4151;
public static final int GRANITE_MAUL = 4153;
public static final int ENCHANTED_GEM = 4155;
public static final int MIRROR_SHIELD = 4156;
public static final int LEAFBLADED_SPEAR = 4158;
public static final int LEAFBLADED_SPEAR_4159 = 4159;
public static final int BROAD_ARROWS_4160 = 4160;
public static final int BAG_OF_SALT = 4161;
public static final int ROCK_HAMMER = 4162;
public static final int FACEMASK = 4164;
public static final int EARMUFFS = 4166;
public static final int NOSE_PEG = 4168;
public static final int SLAYERS_STAFF = 4170;
public static final int ABYSSAL_WHIP_4178 = 4178;
public static final int STICK = 4179;
public static final int DRAGON_PLATELEGS_4180 = 4180;
public static final int MOUTH_GRIP = 4181;
public static final int GOUTWEED_4182 = 4182;
public static final int STAR_AMULET = 4183;
public static final int CAVERN_KEY = 4184;
public static final int TOWER_KEY = 4185;
public static final int SHED_KEY = 4186;
public static final int MARBLE_AMULET = 4187;
public static final int OBSIDIAN_AMULET = 4188;
public static final int GARDEN_CANE = 4189;
public static final int GARDEN_BRUSH = 4190;
public static final int EXTENDED_BRUSH = 4191;
public static final int EXTENDED_BRUSH_4192 = 4192;
public static final int EXTENDED_BRUSH_4193 = 4193;
public static final int TORSO = 4194;
public static final int ARMS = 4195;
public static final int LEGS = 4196;
public static final int DECAPITATED_HEAD = 4197;
public static final int DECAPITATED_HEAD_4198 = 4198;
public static final int PICKLED_BRAIN = 4199;
public static final int CONDUCTOR_MOULD = 4200;
public static final int CONDUCTOR = 4201;
public static final int RING_OF_CHAROS = 4202;
public static final int JOURNAL_4203 = 4203;
public static final int LETTER = 4204;
public static final int CONSECRATION_SEED = 4205;
public static final int CONSECRATION_SEED_4206 = 4206;
public static final int CRYSTAL_WEAPON_SEED = 4207;
public static final int CADARN_LINEAGE = 4209;
public static final int ELF_CRYSTAL = 4211;
public static final int NEW_CRYSTAL_BOW = 4212;
public static final int NEW_CRYSTAL_BOW_4213 = 4213;
public static final int CRYSTAL_BOW_FULL = 4214;
public static final int CRYSTAL_BOW_910 = 4215;
public static final int CRYSTAL_BOW_810 = 4216;
public static final int CRYSTAL_BOW_710 = 4217;
public static final int CRYSTAL_BOW_610 = 4218;
public static final int CRYSTAL_BOW_510 = 4219;
public static final int CRYSTAL_BOW_410 = 4220;
public static final int CRYSTAL_BOW_310 = 4221;
public static final int CRYSTAL_BOW_210 = 4222;
public static final int CRYSTAL_BOW_110 = 4223;
public static final int NEW_CRYSTAL_SHIELD = 4224;
public static final int CRYSTAL_SHIELD_FULL = 4225;
public static final int CRYSTAL_SHIELD_910 = 4226;
public static final int CRYSTAL_SHIELD_810 = 4227;
public static final int CRYSTAL_SHIELD_710 = 4228;
public static final int CRYSTAL_SHIELD_610 = 4229;
public static final int CRYSTAL_SHIELD_510 = 4230;
public static final int CRYSTAL_SHIELD_410 = 4231;
public static final int CRYSTAL_SHIELD_310 = 4232;
public static final int CRYSTAL_SHIELD_210 = 4233;
public static final int CRYSTAL_SHIELD_110 = 4234;
public static final int NEW_CRYSTAL_SHIELD_4235 = 4235;
public static final int SIGNED_OAK_BOW = 4236;
public static final int NETTLEWATER = 4237;
public static final int PUDDLE_OF_SLIME = 4238;
public static final int NETTLE_TEA = 4239;
public static final int NETTLE_TEA_4240 = 4240;
public static final int NETTLES = 4241;
public static final int CUP_OF_TEA_4242 = 4242;
public static final int CUP_OF_TEA_4243 = 4243;
public static final int PORCELAIN_CUP = 4244;
public static final int CUP_OF_TEA_4245 = 4245;
public static final int CUP_OF_TEA_4246 = 4246;
public static final int MYSTICAL_ROBES = 4247;
public static final int BOOK_OF_HARICANTO = 4248;
public static final int TRANSLATION_MANUAL = 4249;
public static final int GHOSTSPEAK_AMULET_4250 = 4250;
public static final int ECTOPHIAL = 4251;
public static final int ECTOPHIAL_4252 = 4252;
public static final int MODEL_SHIP = 4253;
public static final int MODEL_SHIP_4254 = 4254;
public static final int BONEMEAL = 4255;
public static final int BONEMEAL_4256 = 4256;
public static final int BONEMEAL_4257 = 4257;
public static final int BONEMEAL_4258 = 4258;
public static final int BONEMEAL_4259 = 4259;
public static final int BONEMEAL_4260 = 4260;
public static final int BONEMEAL_4261 = 4261;
public static final int BONEMEAL_4262 = 4262;
public static final int BONEMEAL_4263 = 4263;
public static final int BONEMEAL_4264 = 4264;
public static final int BONEMEAL_4265 = 4265;
public static final int BONEMEAL_4266 = 4266;
public static final int BONEMEAL_4267 = 4267;
public static final int BONEMEAL_4268 = 4268;
public static final int BONEMEAL_4269 = 4269;
public static final int BONEMEAL_4270 = 4270;
public static final int BONEMEAL_4271 = 4271;
public static final int BONE_KEY_4272 = 4272;
public static final int CHEST_KEY_4273 = 4273;
public static final int MAP_SCRAP = 4274;
public static final int MAP_SCRAP_4275 = 4275;
public static final int MAP_SCRAP_4276 = 4276;
public static final int TREASURE_MAP = 4277;
public static final int ECTOTOKEN = 4278;
public static final int PETITION_FORM = 4283;
public static final int BEDSHEET = 4284;
public static final int BEDSHEET_4285 = 4285;
public static final int BUCKET_OF_SLIME = 4286;
public static final int RAW_BEEF_4287 = 4287;
public static final int RAW_CHICKEN_4289 = 4289;
public static final int COOKED_CHICKEN_4291 = 4291;
public static final int COOKED_MEAT_4293 = 4293;
public static final int FEMALE_HAM = 4295;
public static final int MALE_HAM = 4297;
public static final int HAM_SHIRT = 4298;
public static final int HAM_ROBE = 4300;
public static final int HAM_HOOD = 4302;
public static final int HAM_CLOAK = 4304;
public static final int HAM_LOGO = 4306;
public static final int HAM_GLOVES = 4308;
public static final int HAM_BOOTS = 4310;
public static final int CRYSTAL_SINGING_FOR_BEGINNERS = 4313;
public static final int TEAM1_CAPE = 4315;
public static final int TEAM2_CAPE = 4317;
public static final int TEAM3_CAPE = 4319;
public static final int TEAM4_CAPE = 4321;
public static final int TEAM5_CAPE = 4323;
public static final int TEAM6_CAPE = 4325;
public static final int TEAM7_CAPE = 4327;
public static final int TEAM8_CAPE = 4329;
public static final int TEAM9_CAPE = 4331;
public static final int TEAM10_CAPE = 4333;
public static final int TEAM11_CAPE = 4335;
public static final int TEAM12_CAPE = 4337;
public static final int TEAM13_CAPE = 4339;
public static final int TEAM14_CAPE = 4341;
public static final int TEAM15_CAPE = 4343;
public static final int TEAM16_CAPE = 4345;
public static final int TEAM17_CAPE = 4347;
public static final int TEAM18_CAPE = 4349;
public static final int TEAM19_CAPE = 4351;
public static final int TEAM20_CAPE = 4353;
public static final int TEAM21_CAPE = 4355;
public static final int TEAM22_CAPE = 4357;
public static final int TEAM23_CAPE = 4359;
public static final int TEAM24_CAPE = 4361;
public static final int TEAM25_CAPE = 4363;
public static final int TEAM26_CAPE = 4365;
public static final int TEAM27_CAPE = 4367;
public static final int TEAM28_CAPE = 4369;
public static final int TEAM29_CAPE = 4371;
public static final int TEAM30_CAPE = 4373;
public static final int TEAM31_CAPE = 4375;
public static final int TEAM32_CAPE = 4377;
public static final int TEAM33_CAPE = 4379;
public static final int TEAM34_CAPE = 4381;
public static final int TEAM35_CAPE = 4383;
public static final int TEAM36_CAPE = 4385;
public static final int TEAM37_CAPE = 4387;
public static final int TEAM38_CAPE = 4389;
public static final int TEAM39_CAPE = 4391;
public static final int TEAM40_CAPE = 4393;
public static final int TEAM41_CAPE = 4395;
public static final int TEAM42_CAPE = 4397;
public static final int TEAM43_CAPE = 4399;
public static final int TEAM44_CAPE = 4401;
public static final int TEAM45_CAPE = 4403;
public static final int TEAM46_CAPE = 4405;
public static final int TEAM47_CAPE = 4407;
public static final int TEAM48_CAPE = 4409;
public static final int TEAM49_CAPE = 4411;
public static final int TEAM50_CAPE = 4413;
public static final int BLUNT_AXE = 4415;
public static final int HERBAL_TINCTURE = 4416;
public static final int GUTHIX_REST4 = 4417;
public static final int GUTHIX_REST3 = 4419;
public static final int GUTHIX_REST2 = 4421;
public static final int GUTHIX_REST1 = 4423;
public static final int STODGY_MATTRESS = 4425;
public static final int COMFY_MATTRESS = 4426;
public static final int IRON_OXIDE = 4427;
public static final int ANIMATE_ROCK_SCROLL = 4428;
public static final int BROKEN_VANE_PART = 4429;
public static final int DIRECTIONALS = 4430;
public static final int BROKEN_VANE_PART_4431 = 4431;
public static final int ORNAMENT = 4432;
public static final int BROKEN_VANE_PART_4433 = 4433;
public static final int WEATHERVANE_PILLAR = 4434;
public static final int WEATHER_REPORT = 4435;
public static final int AIRTIGHT_POT = 4436;
public static final int UNFIRED_POT_LID = 4438;
public static final int POT_LID = 4440;
public static final int BREATHING_SALTS = 4442;
public static final int CHICKEN_CAGE = 4443;
public static final int SHARPENED_AXE = 4444;
public static final int RED_MAHOGANY_LOG = 4445;
public static final int STEEL_KEY_RING = 4446;
public static final int ANTIQUE_LAMP = 4447;
public static final int BOWL_OF_HOT_WATER = 4456;
public static final int CUP_OF_WATER = 4458;
public static final int CUP_OF_HOT_WATER = 4460;
public static final int RUINED_HERB_TEA = 4462;
public static final int HERB_TEA_MIX = 4464;
public static final int HERB_TEA_MIX_4466 = 4466;
public static final int HERB_TEA_MIX_4468 = 4468;
public static final int HERB_TEA_MIX_4470 = 4470;
public static final int HERB_TEA_MIX_4472 = 4472;
public static final int HERB_TEA_MIX_4474 = 4474;
public static final int HERB_TEA_MIX_4476 = 4476;
public static final int HERB_TEA_MIX_4478 = 4478;
public static final int HERB_TEA_MIX_4480 = 4480;
public static final int HERB_TEA_MIX_4482 = 4482;
public static final int SAFETY_GUARANTEE = 4484;
public static final int WHITE_PEARL = 4485;
public static final int WHITE_PEARL_SEED = 4486;
public static final int HALF_A_ROCK = 4487;
public static final int CORPSE_OF_WOMAN = 4488;
public static final int ASLEIFS_NECKLACE = 4489;
public static final int MUD = 4490;
public static final int MUDDY_ROCK = 4492;
public static final int POLE = 4494;
public static final int BROKEN_POLE = 4496;
public static final int ROPE_4498 = 4498;
public static final int POLE_4500 = 4500;
public static final int BEARHEAD = 4502;
public static final int DECORATIVE_SWORD_4503 = 4503;
public static final int DECORATIVE_ARMOUR_4504 = 4504;
public static final int DECORATIVE_ARMOUR_4505 = 4505;
public static final int DECORATIVE_HELM_4506 = 4506;
public static final int DECORATIVE_SHIELD_4507 = 4507;
public static final int DECORATIVE_SWORD_4508 = 4508;
public static final int DECORATIVE_ARMOUR_4509 = 4509;
public static final int DECORATIVE_ARMOUR_4510 = 4510;
public static final int DECORATIVE_HELM_4511 = 4511;
public static final int DECORATIVE_SHIELD_4512 = 4512;
public static final int CASTLEWARS_HOOD = 4513;
public static final int CASTLEWARS_CLOAK = 4514;
public static final int CASTLEWARS_HOOD_4515 = 4515;
public static final int CASTLEWARS_CLOAK_4516 = 4516;
public static final int GIANT_FROG_LEGS = 4517;
public static final int SWAMP_WALLBEAST = 4519;
public static final int SWAMP_CAVE_SLIME = 4520;
public static final int SWAMP_CAVE_BUG = 4521;
public static final int OIL_LAMP = 4522;
public static final int OIL_LAMP_4524 = 4524;
public static final int EMPTY_OIL_LAMP = 4525;
public static final int EMPTY_CANDLE_LANTERN = 4527;
public static final int CANDLE_LANTERN = 4529;
public static final int CANDLE_LANTERN_4531 = 4531;
public static final int CANDLE_LANTERN_4532 = 4532;
public static final int CANDLE_LANTERN_4534 = 4534;
public static final int EMPTY_OIL_LANTERN = 4535;
public static final int OIL_LANTERN = 4537;
public static final int OIL_LANTERN_4539 = 4539;
public static final int OIL_LANTERN_FRAME = 4540;
public static final int LANTERN_LENS = 4542;
public static final int BULLSEYE_LANTERN_UNF = 4544;
public static final int BULLSEYE_LANTERN_EMPTY = 4546;
public static final int BULLSEYE_LANTERN = 4548;
public static final int BULLSEYE_LANTERN_4550 = 4550;
public static final int SPINY_HELMET = 4551;
public static final int BLUE_SWEETS = 4558;
public static final int DEEP_BLUE_SWEETS = 4559;
public static final int WHITE_SWEETS = 4560;
public static final int PURPLE_SWEETS = 4561;
public static final int RED_SWEETS = 4562;
public static final int GREEN_SWEETS = 4563;
public static final int PINK_SWEETS = 4564;
public static final int EASTER_BASKET = 4565;
public static final int RUBBER_CHICKEN = 4566;
public static final int GOLD_HELMET = 4567;
public static final int DWARVEN_LORE = 4568;
public static final int BOOK_PAGE_1 = 4569;
public static final int BOOK_PAGE_2 = 4570;
public static final int BOOK_PAGE_3 = 4571;
public static final int PAGES = 4572;
public static final int PAGES_4573 = 4573;
public static final int BASE_SCHEMATICS = 4574;
public static final int SCHEMATIC = 4575;
public static final int SCHEMATICS = 4576;
public static final int SCHEMATICS_4577 = 4577;
public static final int SCHEMATIC_4578 = 4578;
public static final int CANNON_BALL = 4579;
public static final int BLACK_SPEAR = 4580;
public static final int BLACK_SPEARP = 4582;
public static final int BLACK_SPEARKP = 4584;
public static final int DRAGON_PLATESKIRT = 4585;
public static final int DRAGON_SCIMITAR = 4587;
public static final int KEYS = 4589;
public static final int JEWELS = 4590;
public static final int KHARIDIAN_HEADPIECE = 4591;
public static final int FAKE_BEARD = 4593;
public static final int KARIDIAN_DISGUISE = 4595;
public static final int NOTE = 4597;
public static final int NOTE_4598 = 4598;
public static final int OAK_BLACKJACK = 4599;
public static final int WILLOW_BLACKJACK = 4600;
public static final int UGTHANKI_DUNG = 4601;
public static final int UGTHANKI_DUNG_4602 = 4602;
public static final int RECEIPT = 4603;
public static final int HAGS_POISON = 4604;
public static final int SNAKE_CHARM = 4605;
public static final int SNAKE_BASKET = 4606;
public static final int SNAKE_BASKET_FULL = 4607;
public static final int SUPER_KEBAB = 4608;
public static final int RED_HOT_SAUCE = 4610;
public static final int DESERT_DISGUISE = 4611;
public static final int SPINNING_PLATE = 4613;
public static final int BROKEN_PLATE = 4614;
public static final int LETTER_4615 = 4615;
public static final int VARMENS_NOTES = 4616;
public static final int DISPLAY_CABINET_KEY = 4617;
public static final int STATUETTE = 4618;
public static final int STRANGE_IMPLEMENT = 4619;
public static final int BLACK_MUSHROOM = 4620;
public static final int PHOENIX_FEATHER = 4621;
public static final int BLACK_MUSHROOM_INK = 4622;
public static final int PHOENIX_QUILL_PEN = 4623;
public static final int GOLEM_PROGRAM = 4624;
public static final int BANDIT = 4625;
public static final int BANDITS_BREW = 4627;
public static final int FIRE = 4653;
public static final int ETCHINGS = 4654;
public static final int TRANSLATION = 4655;
public static final int WARM_KEY = 4656;
public static final int RING_OF_VISIBILITY = 4657;
public static final int SILVER_POT_4658 = 4658;
public static final int BLESSED_POT = 4659;
public static final int SILVER_POT_4660 = 4660;
public static final int BLESSED_POT_4661 = 4661;
public static final int SILVER_POT_4662 = 4662;
public static final int BLESSED_POT_4663 = 4663;
public static final int SILVER_POT_4664 = 4664;
public static final int BLESSED_POT_4665 = 4665;
public static final int SILVER_POT_4666 = 4666;
public static final int BLESSED_POT_4667 = 4667;
public static final int GARLIC_POWDER = 4668;
public static final int BLOOD_DIAMOND = 4670;
public static final int ICE_DIAMOND = 4671;
public static final int SMOKE_DIAMOND = 4672;
public static final int SHADOW_DIAMOND = 4673;
public static final int GILDED_CROSS = 4674;
public static final int ANCIENT_STAFF = 4675;
public static final int CATSPEAK_AMULET = 4677;
public static final int CANOPIC_JAR = 4678;
public static final int CANOPIC_JAR_4679 = 4679;
public static final int CANOPIC_JAR_4680 = 4680;
public static final int CANOPIC_JAR_4681 = 4681;
public static final int HOLY_SYMBOL_4682 = 4682;
public static final int UNHOLY_SYMBOL_4683 = 4683;
public static final int LINEN = 4684;
public static final int EMBALMING_MANUAL = 4686;
public static final int BUCKET_OF_SAP = 4687;
public static final int PILE_OF_SALT = 4689;
public static final int SPHINXS_TOKEN = 4691;
public static final int GOLD_LEAF = 4692;
public static final int FULL_BUCKET_4693 = 4693;
public static final int STEAM_RUNE = 4694;
public static final int MIST_RUNE = 4695;
public static final int DUST_RUNE = 4696;
public static final int SMOKE_RUNE = 4697;
public static final int MUD_RUNE = 4698;
public static final int LAVA_RUNE = 4699;
public static final int SAPPHIRE_LANTERN = 4700;
public static final int SAPPHIRE_LANTERN_4701 = 4701;
public static final int SAPPHIRE_LANTERN_4702 = 4702;
public static final int MAGIC_STONE = 4703;
public static final int STONE_BOWL = 4704;
public static final int CRUMBLING_TOME = 4707;
public static final int AHRIMS_HOOD = 4708;
public static final int AHRIMS_STAFF = 4710;
public static final int AHRIMS_ROBETOP = 4712;
public static final int AHRIMS_ROBESKIRT = 4714;
public static final int DHAROKS_HELM = 4716;
public static final int DHAROKS_GREATAXE = 4718;
public static final int DHAROKS_PLATEBODY = 4720;
public static final int DHAROKS_PLATELEGS = 4722;
public static final int GUTHANS_HELM = 4724;
public static final int GUTHANS_WARSPEAR = 4726;
public static final int GUTHANS_PLATEBODY = 4728;
public static final int GUTHANS_CHAINSKIRT = 4730;
public static final int KARILS_COIF = 4732;
public static final int KARILS_CROSSBOW = 4734;
public static final int KARILS_LEATHERTOP = 4736;
public static final int KARILS_LEATHERSKIRT = 4738;
public static final int BOLT_RACK = 4740;
public static final int TORAGS_HELM = 4745;
public static final int TORAGS_HAMMERS = 4747;
public static final int TORAGS_PLATEBODY = 4749;
public static final int TORAGS_PLATELEGS = 4751;
public static final int VERACS_HELM = 4753;
public static final int VERACS_FLAIL = 4755;
public static final int VERACS_BRASSARD = 4757;
public static final int VERACS_PLATESKIRT = 4759;
public static final int BRONZE_BRUTAL = 4773;
public static final int IRON_BRUTAL = 4778;
public static final int STEEL_BRUTAL = 4783;
public static final int BLACK_BRUTAL = 4788;
public static final int MITHRIL_BRUTAL = 4793;
public static final int ADAMANT_BRUTAL = 4798;
public static final int RUNE_BRUTAL = 4803;
public static final int BLACK_PRISM = 4808;
public static final int TORN_PAGE = 4809;
public static final int RUINED_BACKPACK = 4810;
public static final int DRAGON_INN_TANKARD = 4811;
public static final int ZOGRE_BONES = 4812;
public static final int SITHIK_PORTRAIT = 4814;
public static final int SITHIK_PORTRAIT_4815 = 4815;
public static final int SIGNED_PORTRAIT = 4816;
public static final int BOOK_OF_PORTRAITURE = 4817;
public static final int OGRE_ARTEFACT = 4818;
public static final int BRONZE_NAILS = 4819;
public static final int IRON_NAILS = 4820;
public static final int BLACK_NAILS = 4821;
public static final int MITHRIL_NAILS = 4822;
public static final int ADAMANTITE_NAILS = 4823;
public static final int RUNE_NAILS = 4824;
public static final int UNSTRUNG_COMP_BOW = 4825;
public static final int COMP_OGRE_BOW = 4827;
public static final int BOOK_OF_HAM = 4829;
public static final int FAYRG_BONES = 4830;
public static final int RAURG_BONES = 4832;
public static final int OURG_BONES = 4834;
public static final int STRANGE_POTION = 4836;
public static final int NECROMANCY_BOOK = 4837;
public static final int CUP_OF_TEA_4838 = 4838;
public static final int OGRE_GATE_KEY = 4839;
public static final int UNFINISHED_POTION_4840 = 4840;
public static final int RELICYMS_BALM4 = 4842;
public static final int RELICYMS_BALM3 = 4844;
public static final int RELICYMS_BALM2 = 4846;
public static final int RELICYMS_BALM1 = 4848;
public static final int OGRE_COFFIN_KEY = 4850;
public static final int BONEMEAL_4852 = 4852;
public static final int BONEMEAL_4853 = 4853;
public static final int BONEMEAL_4854 = 4854;
public static final int BONEMEAL_4855 = 4855;
public static final int AHRIMS_HOOD_100 = 4856;
public static final int AHRIMS_HOOD_75 = 4857;
public static final int AHRIMS_HOOD_50 = 4858;
public static final int AHRIMS_HOOD_25 = 4859;
public static final int AHRIMS_HOOD_0 = 4860;
public static final int AHRIMS_STAFF_100 = 4862;
public static final int AHRIMS_STAFF_75 = 4863;
public static final int AHRIMS_STAFF_50 = 4864;
public static final int AHRIMS_STAFF_25 = 4865;
public static final int AHRIMS_STAFF_0 = 4866;
public static final int AHRIMS_ROBETOP_100 = 4868;
public static final int AHRIMS_ROBETOP_75 = 4869;
public static final int AHRIMS_ROBETOP_50 = 4870;
public static final int AHRIMS_ROBETOP_25 = 4871;
public static final int AHRIMS_ROBETOP_0 = 4872;
public static final int AHRIMS_ROBESKIRT_100 = 4874;
public static final int AHRIMS_ROBESKIRT_75 = 4875;
public static final int AHRIMS_ROBESKIRT_50 = 4876;
public static final int AHRIMS_ROBESKIRT_25 = 4877;
public static final int AHRIMS_ROBESKIRT_0 = 4878;
public static final int DHAROKS_HELM_100 = 4880;
public static final int DHAROKS_HELM_75 = 4881;
public static final int DHAROKS_HELM_50 = 4882;
public static final int DHAROKS_HELM_25 = 4883;
public static final int DHAROKS_HELM_0 = 4884;
public static final int DHAROKS_GREATAXE_100 = 4886;
public static final int DHAROKS_GREATAXE_75 = 4887;
public static final int DHAROKS_GREATAXE_50 = 4888;
public static final int DHAROKS_GREATAXE_25 = 4889;
public static final int DHAROKS_GREATAXE_0 = 4890;
public static final int DHAROKS_PLATEBODY_100 = 4892;
public static final int DHAROKS_PLATEBODY_75 = 4893;
public static final int DHAROKS_PLATEBODY_50 = 4894;
public static final int DHAROKS_PLATEBODY_25 = 4895;
public static final int DHAROKS_PLATEBODY_0 = 4896;
public static final int DHAROKS_PLATELEGS_100 = 4898;
public static final int DHAROKS_PLATELEGS_75 = 4899;
public static final int DHAROKS_PLATELEGS_50 = 4900;
public static final int DHAROKS_PLATELEGS_25 = 4901;
public static final int DHAROKS_PLATELEGS_0 = 4902;
public static final int GUTHANS_HELM_100 = 4904;
public static final int GUTHANS_HELM_75 = 4905;
public static final int GUTHANS_HELM_50 = 4906;
public static final int GUTHANS_HELM_25 = 4907;
public static final int GUTHANS_HELM_0 = 4908;
public static final int GUTHANS_WARSPEAR_100 = 4910;
public static final int GUTHANS_WARSPEAR_75 = 4911;
public static final int GUTHANS_WARSPEAR_50 = 4912;
public static final int GUTHANS_WARSPEAR_25 = 4913;
public static final int GUTHANS_WARSPEAR_0 = 4914;
public static final int GUTHANS_PLATEBODY_100 = 4916;
public static final int GUTHANS_PLATEBODY_75 = 4917;
public static final int GUTHANS_PLATEBODY_50 = 4918;
public static final int GUTHANS_PLATEBODY_25 = 4919;
public static final int GUTHANS_PLATEBODY_0 = 4920;
public static final int GUTHANS_CHAINSKIRT_100 = 4922;
public static final int GUTHANS_CHAINSKIRT_75 = 4923;
public static final int GUTHANS_CHAINSKIRT_50 = 4924;
public static final int GUTHANS_CHAINSKIRT_25 = 4925;
public static final int GUTHANS_CHAINSKIRT_0 = 4926;
public static final int KARILS_COIF_100 = 4928;
public static final int KARILS_COIF_75 = 4929;
public static final int KARILS_COIF_50 = 4930;
public static final int KARILS_COIF_25 = 4931;
public static final int KARILS_COIF_0 = 4932;
public static final int KARILS_CROSSBOW_100 = 4934;
public static final int KARILS_CROSSBOW_75 = 4935;
public static final int KARILS_CROSSBOW_50 = 4936;
public static final int KARILS_CROSSBOW_25 = 4937;
public static final int KARILS_CROSSBOW_0 = 4938;
public static final int KARILS_LEATHERTOP_100 = 4940;
public static final int KARILS_LEATHERTOP_75 = 4941;
public static final int KARILS_LEATHERTOP_50 = 4942;
public static final int KARILS_LEATHERTOP_25 = 4943;
public static final int KARILS_LEATHERTOP_0 = 4944;
public static final int KARILS_LEATHERSKIRT_100 = 4946;
public static final int KARILS_LEATHERSKIRT_75 = 4947;
public static final int KARILS_LEATHERSKIRT_50 = 4948;
public static final int KARILS_LEATHERSKIRT_25 = 4949;
public static final int KARILS_LEATHERSKIRT_0 = 4950;
public static final int TORAGS_HELM_100 = 4952;
public static final int TORAGS_HELM_75 = 4953;
public static final int TORAGS_HELM_50 = 4954;
public static final int TORAGS_HELM_25 = 4955;
public static final int TORAGS_HELM_0 = 4956;
public static final int TORAGS_HAMMERS_100 = 4958;
public static final int TORAGS_HAMMERS_75 = 4959;
public static final int TORAGS_HAMMERS_50 = 4960;
public static final int TORAGS_HAMMERS_25 = 4961;
public static final int TORAGS_HAMMERS_0 = 4962;
public static final int TORAGS_PLATEBODY_100 = 4964;
public static final int TORAGS_PLATEBODY_75 = 4965;
public static final int TORAGS_PLATEBODY_50 = 4966;
public static final int TORAGS_PLATEBODY_25 = 4967;
public static final int TORAGS_PLATEBODY_0 = 4968;
public static final int TORAGS_PLATELEGS_100 = 4970;
public static final int TORAGS_PLATELEGS_75 = 4971;
public static final int TORAGS_PLATELEGS_50 = 4972;
public static final int TORAGS_PLATELEGS_25 = 4973;
public static final int TORAGS_PLATELEGS_0 = 4974;
public static final int VERACS_HELM_100 = 4976;
public static final int VERACS_HELM_75 = 4977;
public static final int VERACS_HELM_50 = 4978;
public static final int VERACS_HELM_25 = 4979;
public static final int VERACS_HELM_0 = 4980;
public static final int VERACS_FLAIL_100 = 4982;
public static final int VERACS_FLAIL_75 = 4983;
public static final int VERACS_FLAIL_50 = 4984;
public static final int VERACS_FLAIL_25 = 4985;
public static final int VERACS_FLAIL_0 = 4986;
public static final int VERACS_BRASSARD_100 = 4988;
public static final int VERACS_BRASSARD_75 = 4989;
public static final int VERACS_BRASSARD_50 = 4990;
public static final int VERACS_BRASSARD_25 = 4991;
public static final int VERACS_BRASSARD_0 = 4992;
public static final int VERACS_PLATESKIRT_100 = 4994;
public static final int VERACS_PLATESKIRT_75 = 4995;
public static final int VERACS_PLATESKIRT_50 = 4996;
public static final int VERACS_PLATESKIRT_25 = 4997;
public static final int VERACS_PLATESKIRT_0 = 4998;
public static final int RAW_CAVE_EEL = 5001;
public static final int BURNT_CAVE_EEL = 5002;
public static final int CAVE_EEL = 5003;
public static final int FROG_SPAWN = 5004;
public static final int BROOCH = 5008;
public static final int GOBLIN_SYMBOL_BOOK = 5009;
public static final int KEY_5010 = 5010;
public static final int SILVERWARE = 5011;
public static final int PEACE_TREATY = 5012;
public static final int MINING_HELMET = 5013;
public static final int MINING_HELMET_5014 = 5014;
public static final int BONE_SPEAR = 5016;
public static final int BONE_CLUB = 5018;
public static final int MINECART_TICKET = 5020;
public static final int MINECART_TICKET_5021 = 5021;
public static final int MINECART_TICKET_5022 = 5022;
public static final int MINECART_TICKET_5023 = 5023;
public static final int WOVEN_TOP = 5024;
public static final int WOVEN_TOP_5026 = 5026;
public static final int WOVEN_TOP_5028 = 5028;
public static final int SHIRT = 5030;
public static final int SHIRT_5032 = 5032;
public static final int SHIRT_5034 = 5034;
public static final int TROUSERS = 5036;
public static final int TROUSERS_5038 = 5038;
public static final int TROUSERS_5040 = 5040;
public static final int SHORTS = 5042;
public static final int SHORTS_5044 = 5044;
public static final int SHORTS_5046 = 5046;
public static final int SKIRT = 5048;
public static final int SKIRT_5050 = 5050;
public static final int SKIRT_5052 = 5052;
public static final int DWARF = 5054;
public static final int DWARVEN_BATTLEAXE = 5056;
public static final int DWARVEN_BATTLEAXE_5057 = 5057;
public static final int DWARVEN_BATTLEAXE_5058 = 5058;
public static final int DWARVEN_BATTLEAXE_5059 = 5059;
public static final int DWARVEN_BATTLEAXE_5060 = 5060;
public static final int DWARVEN_BATTLEAXE_5061 = 5061;
public static final int LEFT_BOOT = 5062;
public static final int RIGHT_BOOT = 5063;
public static final int EXQUISITE_BOOTS = 5064;
public static final int BOOK_ON_COSTUMES = 5065;
public static final int MEETING_NOTES = 5066;
public static final int EXQUISITE_CLOTHES = 5067;
public static final int MASTER_FARMER = 5068;
public static final int BIRD_NEST = 5070;
public static final int BIRD_NEST_5071 = 5071;
public static final int BIRD_NEST_5072 = 5072;
public static final int BIRD_NEST_5073 = 5073;
public static final int BIRD_NEST_5074 = 5074;
public static final int BIRD_NEST_5075 = 5075;
public static final int BIRDS_EGG = 5076;
public static final int BIRDS_EGG_5077 = 5077;
public static final int BIRDS_EGG_5078 = 5078;
public static final int VARROCK_ARMOUR = 5087;
public static final int SEA_SNAKE = 5089;
public static final int MORYTANIA_LEGS = 5093;
public static final int EXPLORERS_RING = 5095;
public static final int MARIGOLD_SEED = 5096;
public static final int ROSEMARY_SEED = 5097;
public static final int NASTURTIUM_SEED = 5098;
public static final int WOAD_SEED = 5099;
public static final int LIMPWURT_SEED = 5100;
public static final int REDBERRY_SEED = 5101;
public static final int CADAVABERRY_SEED = 5102;
public static final int DWELLBERRY_SEED = 5103;
public static final int JANGERBERRY_SEED = 5104;
public static final int WHITEBERRY_SEED = 5105;
public static final int POISON_IVY_SEED = 5106;
public static final int SEEDS = 5171;
public static final int CACTUS_SEED = 5280;
public static final int BELLADONNA_SEED = 5281;
public static final int MUSHROOM_SPORE = 5282;
public static final int APPLE_TREE_SEED = 5283;
public static final int BANANA_TREE_SEED = 5284;
public static final int ORANGE_TREE_SEED = 5285;
public static final int CURRY_TREE_SEED = 5286;
public static final int PINEAPPLE_SEED = 5287;
public static final int PAPAYA_TREE_SEED = 5288;
public static final int PALM_TREE_SEED = 5289;
public static final int CALQUAT_TREE_SEED = 5290;
public static final int GUAM_SEED = 5291;
public static final int MARRENTILL_SEED = 5292;
public static final int TARROMIN_SEED = 5293;
public static final int HARRALANDER_SEED = 5294;
public static final int RANARR_SEED = 5295;
public static final int TOADFLAX_SEED = 5296;
public static final int IRIT_SEED = 5297;
public static final int AVANTOE_SEED = 5298;
public static final int KWUARM_SEED = 5299;
public static final int SNAPDRAGON_SEED = 5300;
public static final int CADANTINE_SEED = 5301;
public static final int LANTADYME_SEED = 5302;
public static final int DWARF_WEED_SEED = 5303;
public static final int TORSTOL_SEED = 5304;
public static final int BARLEY_SEED = 5305;
public static final int JUTE_SEED = 5306;
public static final int HAMMERSTONE_SEED = 5307;
public static final int ASGARNIAN_SEED = 5308;
public static final int YANILLIAN_SEED = 5309;
public static final int KRANDORIAN_SEED = 5310;
public static final int WILDBLOOD_SEED = 5311;
public static final int ACORN = 5312;
public static final int WILLOW_SEED = 5313;
public static final int MAPLE_SEED = 5314;
public static final int YEW_SEED = 5315;
public static final int MAGIC_SEED = 5316;
public static final int SPIRIT_SEED = 5317;
public static final int POTATO_SEED = 5318;
public static final int ONION_SEED = 5319;
public static final int SWEETCORN_SEED = 5320;
public static final int WATERMELON_SEED = 5321;
public static final int TOMATO_SEED = 5322;
public static final int STRAWBERRY_SEED = 5323;
public static final int CABBAGE_SEED = 5324;
public static final int GARDENING_TROWEL = 5325;
public static final int SPADE_HANDLE = 5327;
public static final int SPADE_HEAD = 5328;
public static final int SECATEURS = 5329;
public static final int WATERING_CAN = 5331;
public static final int WATERING_CAN1 = 5333;
public static final int WATERING_CAN2 = 5334;
public static final int WATERING_CAN3 = 5335;
public static final int WATERING_CAN4 = 5336;
public static final int WATERING_CAN5 = 5337;
public static final int WATERING_CAN6 = 5338;
public static final int WATERING_CAN7 = 5339;
public static final int WATERING_CAN8 = 5340;
public static final int RAKE = 5341;
public static final int SEED_DIBBER = 5343;
public static final int GARDENING_BOOTS = 5345;
public static final int RAKE_HANDLE = 5347;
public static final int RAKE_HEAD = 5348;
public static final int SMOKE_DEVIL = 5349;
public static final int EMPTY_PLANT_POT = 5350;
public static final int UNFIRED_PLANT_POT = 5352;
public static final int FILLED_PLANT_POT = 5354;
public static final int PLANT_POT = 5356;
public static final int OAK_SEEDLING = 5358;
public static final int WILLOW_SEEDLING = 5359;
public static final int MAPLE_SEEDLING = 5360;
public static final int YEW_SEEDLING = 5361;
public static final int MAGIC_SEEDLING = 5362;
public static final int SPIRIT_SEEDLING = 5363;
public static final int OAK_SEEDLING_W = 5364;
public static final int WILLOW_SEEDLING_W = 5365;
public static final int MAPLE_SEEDLING_W = 5366;
public static final int YEW_SEEDLING_W = 5367;
public static final int MAGIC_SEEDLING_W = 5368;
public static final int SPIRIT_SEEDLING_W = 5369;
public static final int OAK_SAPLING = 5370;
public static final int WILLOW_SAPLING = 5371;
public static final int MAPLE_SAPLING = 5372;
public static final int YEW_SAPLING = 5373;
public static final int MAGIC_SAPLING = 5374;
public static final int SPIRIT_SAPLING = 5375;
public static final int BASKET = 5376;
public static final int APPLES1 = 5378;
public static final int APPLES2 = 5380;
public static final int APPLES3 = 5382;
public static final int APPLES4 = 5384;
public static final int APPLES5 = 5386;
public static final int ORANGES1 = 5388;
public static final int ORANGES2 = 5390;
public static final int ORANGES3 = 5392;
public static final int ORANGES4 = 5394;
public static final int ORANGES5 = 5396;
public static final int STRAWBERRIES1 = 5398;
public static final int STRAWBERRIES2 = 5400;
public static final int STRAWBERRIES3 = 5402;
public static final int STRAWBERRIES4 = 5404;
public static final int STRAWBERRIES5 = 5406;
public static final int BANANAS1 = 5408;
public static final int BANANAS2 = 5410;
public static final int BANANAS3 = 5412;
public static final int BANANAS4 = 5414;
public static final int BANANAS5 = 5416;
public static final int EMPTY_SACK = 5418;
public static final int POTATOES1 = 5420;
public static final int POTATOES2 = 5422;
public static final int POTATOES3 = 5424;
public static final int POTATOES4 = 5426;
public static final int POTATOES5 = 5428;
public static final int POTATOES6 = 5430;
public static final int POTATOES7 = 5432;
public static final int POTATOES8 = 5434;
public static final int POTATOES9 = 5436;
public static final int POTATOES10 = 5438;
public static final int ONIONS1 = 5440;
public static final int ONIONS2 = 5442;
public static final int ONIONS3 = 5444;
public static final int ONIONS4 = 5446;
public static final int ONIONS5 = 5448;
public static final int ONIONS6 = 5450;
public static final int ONIONS7 = 5452;
public static final int ONIONS8 = 5454;
public static final int ONIONS9 = 5456;
public static final int ONIONS10 = 5458;
public static final int CABBAGES1 = 5460;
public static final int CABBAGES2 = 5462;
public static final int CABBAGES3 = 5464;
public static final int CABBAGES4 = 5466;
public static final int CABBAGES5 = 5468;
public static final int CABBAGES6 = 5470;
public static final int CABBAGES7 = 5472;
public static final int CABBAGES8 = 5474;
public static final int CABBAGES9 = 5476;
public static final int CABBAGES10 = 5478;
public static final int APPLE_SEEDLING = 5480;
public static final int BANANA_SEEDLING = 5481;
public static final int ORANGE_SEEDLING = 5482;
public static final int CURRY_SEEDLING = 5483;
public static final int PINEAPPLE_SEEDLING = 5484;
public static final int PAPAYA_SEEDLING = 5485;
public static final int PALM_SEEDLING = 5486;
public static final int CALQUAT_SEEDLING = 5487;
public static final int APPLE_SEEDLING_W = 5488;
public static final int BANANA_SEEDLING_W = 5489;
public static final int ORANGE_SEEDLING_W = 5490;
public static final int CURRY_SEEDLING_W = 5491;
public static final int PINEAPPLE_SEEDLING_W = 5492;
public static final int PAPAYA_SEEDLING_W = 5493;
public static final int PALM_SEEDLING_W = 5494;
public static final int CALQUAT_SEEDLING_W = 5495;
public static final int APPLE_SAPLING = 5496;
public static final int BANANA_SAPLING = 5497;
public static final int ORANGE_SAPLING = 5498;
public static final int CURRY_SAPLING = 5499;
public static final int PINEAPPLE_SAPLING = 5500;
public static final int PAPAYA_SAPLING = 5501;
public static final int PALM_SAPLING = 5502;
public static final int CALQUAT_SAPLING = 5503;
public static final int STRAWBERRY = 5504;
public static final int OLD_MANS_MESSAGE = 5506;
public static final int STRANGE_BOOK = 5507;
public static final int BOOK_OF_FOLKLORE = 5508;
public static final int SMALL_POUCH = 5509;
public static final int MEDIUM_POUCH = 5510;
public static final int MEDIUM_POUCH_5511 = 5511;
public static final int LARGE_POUCH = 5512;
public static final int LARGE_POUCH_5513 = 5513;
public static final int GIANT_POUCH = 5514;
public static final int GIANT_POUCH_5515 = 5515;
public static final int ELEMENTAL_TALISMAN = 5516;
public static final int SCRYING_ORB = 5518;
public static final int SCRYING_ORB_5519 = 5519;
public static final int ABYSSAL_BOOK = 5520;
public static final int BINDING_NECKLACE = 5521;
public static final int TIARA_MOULD = 5523;
public static final int TIARA = 5525;
public static final int AIR_TIARA = 5527;
public static final int MIND_TIARA = 5529;
public static final int WATER_TIARA = 5531;
public static final int BODY_TIARA = 5533;
public static final int EARTH_TIARA = 5535;
public static final int FIRE_TIARA = 5537;
public static final int COSMIC_TIARA = 5539;
public static final int NATURE_TIARA = 5541;
public static final int CHAOS_TIARA = 5543;
public static final int LAW_TIARA = 5545;
public static final int DEATH_TIARA = 5547;
public static final int ROGUE_TOP = 5553;
public static final int ROGUE_MASK = 5554;
public static final int ROGUE_TROUSERS = 5555;
public static final int ROGUE_GLOVES = 5556;
public static final int ROGUE_BOOTS = 5557;
public static final int ROGUE_KIT = 5558;
public static final int FLASH_POWDER = 5559;
public static final int STETHOSCOPE = 5560;
public static final int MYSTIC_JEWEL = 5561;
public static final int GEAR = 5562;
public static final int GEAR_5563 = 5563;
public static final int GEAR_5564 = 5564;
public static final int GEAR_5565 = 5565;
public static final int GEAR_5566 = 5566;
public static final int GEAR_5567 = 5567;
public static final int TILE_5568 = 5568;
public static final int TILES = 5569;
public static final int TILES_5570 = 5570;
public static final int TILES_5571 = 5571;
public static final int DIAL = 5572;
public static final int DESERT_AMULET = 5573;
public static final int INITIATE_SALLET = 5574;
public static final int INITIATE_HAUBERK = 5575;
public static final int INITIATE_CUISSE = 5576;
public static final int CUPRIC_SULFATE = 5577;
public static final int ACETIC_ACID = 5578;
public static final int GYPSUM = 5579;
public static final int SODIUM_CHLORIDE = 5580;
public static final int NITROUS_OXIDE = 5581;
public static final int VIAL_OF_LIQUID = 5582;
public static final int TIN_ORE_POWDER = 5583;
public static final int CUPRIC_ORE_POWDER = 5584;
public static final int BRONZE_KEY_5585 = 5585;
public static final int METAL_SPADE = 5586;
public static final int METAL_SPADE_5587 = 5587;
public static final int ALCHEMICAL_NOTES = 5588;
public static final int _MIXTURE = 5589;
public static final int _MIXTURE_5590 = 5590;
public static final int _MIXTURE_5591 = 5591;
public static final int TIN = 5592;
public static final int TIN_5593 = 5593;
public static final int TIN_5594 = 5594;
public static final int TIN_5595 = 5595;
public static final int TIN_5596 = 5596;
public static final int TIN_5597 = 5597;
public static final int TIN_5598 = 5598;
public static final int TIN_5599 = 5599;
public static final int TIN_5600 = 5600;
public static final int CHISEL_5601 = 5601;
public static final int BRONZE_WIRE_5602 = 5602;
public static final int SHEARS_5603 = 5603;
public static final int MAGNET_5604 = 5604;
public static final int KNIFE_5605 = 5605;
public static final int MAKEOVER_VOUCHER = 5606;
public static final int GRAIN_5607 = 5607;
public static final int FOX = 5608;
public static final int CHICKEN = 5609;
public static final int HOURGLASS = 5610;
public static final int MAGIC_CARPET = 5614;
public static final int BONEMEAL_5615 = 5615;
public static final int BRONZE_ARROWP_5616 = 5616;
public static final int IRON_ARROWP_5617 = 5617;
public static final int STEEL_ARROWP_5618 = 5618;
public static final int MITHRIL_ARROWP_5619 = 5619;
public static final int ADAMANT_ARROWP_5620 = 5620;
public static final int RUNE_ARROWP_5621 = 5621;
public static final int BRONZE_ARROWP_5622 = 5622;
public static final int IRON_ARROWP_5623 = 5623;
public static final int STEEL_ARROWP_5624 = 5624;
public static final int MITHRIL_ARROWP_5625 = 5625;
public static final int ADAMANT_ARROWP_5626 = 5626;
public static final int RUNE_ARROWP_5627 = 5627;
public static final int BRONZE_DARTP_5628 = 5628;
public static final int IRON_DARTP_5629 = 5629;
public static final int STEEL_DARTP_5630 = 5630;
public static final int BLACK_DARTP_5631 = 5631;
public static final int MITHRIL_DARTP_5632 = 5632;
public static final int ADAMANT_DARTP_5633 = 5633;
public static final int RUNE_DARTP_5634 = 5634;
public static final int BRONZE_DARTP_5635 = 5635;
public static final int IRON_DARTP_5636 = 5636;
public static final int STEEL_DARTP_5637 = 5637;
public static final int BLACK_DARTP_5638 = 5638;
public static final int MITHRIL_DARTP_5639 = 5639;
public static final int ADAMANT_DARTP_5640 = 5640;
public static final int RUNE_DARTP_5641 = 5641;
public static final int BRONZE_JAVELINP_5642 = 5642;
public static final int IRON_JAVELINP_5643 = 5643;
public static final int STEEL_JAVELINP_5644 = 5644;
public static final int MITHRIL_JAVELINP_5645 = 5645;
public static final int ADAMANT_JAVELINP_5646 = 5646;
public static final int RUNE_JAVELINP_5647 = 5647;
public static final int BRONZE_JAVELINP_5648 = 5648;
public static final int IRON_JAVELINP_5649 = 5649;
public static final int STEEL_JAVELINP_5650 = 5650;
public static final int MITHRIL_JAVELINP_5651 = 5651;
public static final int ADAMANT_JAVELINP_5652 = 5652;
public static final int RUNE_JAVELINP_5653 = 5653;
public static final int BRONZE_KNIFEP_5654 = 5654;
public static final int IRON_KNIFEP_5655 = 5655;
public static final int STEEL_KNIFEP_5656 = 5656;
public static final int MITHRIL_KNIFEP_5657 = 5657;
public static final int BLACK_KNIFEP_5658 = 5658;
public static final int ADAMANT_KNIFEP_5659 = 5659;
public static final int RUNE_KNIFEP_5660 = 5660;
public static final int BRONZE_KNIFEP_5661 = 5661;
public static final int IRON_KNIFEP_5662 = 5662;
public static final int STEEL_KNIFEP_5663 = 5663;
public static final int MITHRIL_KNIFEP_5664 = 5664;
public static final int BLACK_KNIFEP_5665 = 5665;
public static final int ADAMANT_KNIFEP_5666 = 5666;
public static final int RUNE_KNIFEP_5667 = 5667;
public static final int IRON_DAGGERP_5668 = 5668;
public static final int BRONZE_DAGGERP_5670 = 5670;
public static final int STEEL_DAGGERP_5672 = 5672;
public static final int MITHRIL_DAGGERP_5674 = 5674;
public static final int ADAMANT_DAGGERP_5676 = 5676;
public static final int RUNE_DAGGERP_5678 = 5678;
public static final int DRAGON_DAGGERP_5680 = 5680;
public static final int BLACK_DAGGERP_5682 = 5682;
public static final int POISON_DAGGERP = 5684;
public static final int IRON_DAGGERP_5686 = 5686;
public static final int BRONZE_DAGGERP_5688 = 5688;
public static final int STEEL_DAGGERP_5690 = 5690;
public static final int MITHRIL_DAGGERP_5692 = 5692;
public static final int ADAMANT_DAGGERP_5694 = 5694;
public static final int RUNE_DAGGERP_5696 = 5696;
public static final int DRAGON_DAGGERP_5698 = 5698;
public static final int BLACK_DAGGERP_5700 = 5700;
public static final int POISON_DAGGERP_5702 = 5702;
public static final int BRONZE_SPEARP_5704 = 5704;
public static final int IRON_SPEARP_5706 = 5706;
public static final int STEEL_SPEARP_5708 = 5708;
public static final int MITHRIL_SPEARP_5710 = 5710;
public static final int ADAMANT_SPEARP_5712 = 5712;
public static final int RUNE_SPEARP_5714 = 5714;
public static final int DRAGON_SPEARP_5716 = 5716;
public static final int BRONZE_SPEARP_5718 = 5718;
public static final int IRON_SPEARP_5720 = 5720;
public static final int STEEL_SPEARP_5722 = 5722;
public static final int MITHRIL_SPEARP_5724 = 5724;
public static final int ADAMANT_SPEARP_5726 = 5726;
public static final int RUNE_SPEARP_5728 = 5728;
public static final int DRAGON_SPEARP_5730 = 5730;
public static final int STOOL_5732 = 5732;
public static final int ROTTEN_POTATO = 5733;
public static final int BLACK_SPEARP_5734 = 5734;
public static final int BLACK_SPEARP_5736 = 5736;
public static final int WOAD_LEAF_5738 = 5738;
public static final int ASGARNIAN_ALEM = 5739;
public static final int MATURE_WMB = 5741;
public static final int GREENMANS_ALEM = 5743;
public static final int DRAGON_BITTERM = 5745;
public static final int DWARVEN_STOUTM = 5747;
public static final int MOONLIGHT_MEADM = 5749;
public static final int AXEMANS_FOLLY = 5751;
public static final int AXEMANS_FOLLYM = 5753;
public static final int CHEFS_DELIGHT = 5755;
public static final int CHEFS_DELIGHTM = 5757;
public static final int SLAYERS_RESPITE = 5759;
public static final int SLAYERS_RESPITEM = 5761;
public static final int CIDER = 5763;
public static final int MATURE_CIDER = 5765;
public static final int ALE_YEAST = 5767;
public static final int CALQUAT_KEG = 5769;
public static final int DWARVEN_STOUT1 = 5771;
public static final int DWARVEN_STOUT2 = 5773;
public static final int DWARVEN_STOUT3 = 5775;
public static final int DWARVEN_STOUT4 = 5777;
public static final int ASGARNIAN_ALE1 = 5779;
public static final int ASGARNIAN_ALE2 = 5781;
public static final int ASGARNIAN_ALE3 = 5783;
public static final int ASGARNIAN_ALE4 = 5785;
public static final int GREENMANS_ALE1 = 5787;
public static final int GREENMANS_ALE2 = 5789;
public static final int GREENMANS_ALE3 = 5791;
public static final int GREENMANS_ALE4 = 5793;
public static final int MIND_BOMB1 = 5795;
public static final int MIND_BOMB2 = 5797;
public static final int MIND_BOMB3 = 5799;
public static final int MIND_BOMB4 = 5801;
public static final int DRAGON_BITTER1 = 5803;
public static final int DRAGON_BITTER2 = 5805;
public static final int DRAGON_BITTER3 = 5807;
public static final int DRAGON_BITTER4 = 5809;
public static final int MOONLIGHT_MEAD1 = 5811;
public static final int MOONLIGHT_MEAD2 = 5813;
public static final int MOONLIGHT_MEAD3 = 5815;
public static final int MOONLIGHT_MEAD4 = 5817;
public static final int AXEMANS_FOLLY1 = 5819;
public static final int AXEMANS_FOLLY2 = 5821;
public static final int AXEMANS_FOLLY3 = 5823;
public static final int AXEMANS_FOLLY4 = 5825;
public static final int CHEFS_DELIGHT1 = 5827;
public static final int CHEFS_DELIGHT2 = 5829;
public static final int CHEFS_DELIGHT3 = 5831;
public static final int CHEFS_DELIGHT4 = 5833;
public static final int SLAYERS_RESPITE1 = 5835;
public static final int SLAYERS_RESPITE2 = 5837;
public static final int SLAYERS_RESPITE3 = 5839;
public static final int SLAYERS_RESPITE4 = 5841;
public static final int CIDER1 = 5843;
public static final int CIDER2 = 5845;
public static final int CIDER3 = 5847;
public static final int CIDER4 = 5849;
public static final int DWARVEN_STOUTM1 = 5851;
public static final int DWARVEN_STOUTM2 = 5853;
public static final int DWARVEN_STOUTM3 = 5855;
public static final int DWARVEN_STOUTM4 = 5857;
public static final int ASGARNIAN_ALEM1 = 5859;
public static final int ASGARNIAN_ALEM2 = 5861;
public static final int ASGARNIAN_ALEM3 = 5863;
public static final int ASGARNIAN_ALEM4 = 5865;
public static final int GREENMANS_ALEM1 = 5867;
public static final int GREENMANS_ALEM2 = 5869;
public static final int GREENMANS_ALEM3 = 5871;
public static final int GREENMANS_ALEM4 = 5873;
public static final int MIND_BOMBM1 = 5875;
public static final int MIND_BOMBM2 = 5877;
public static final int MIND_BOMBM3 = 5879;
public static final int MIND_BOMBM4 = 5881;
public static final int DRAGON_BITTERM1 = 5883;
public static final int DRAGON_BITTERM2 = 5885;
public static final int DRAGON_BITTERM3 = 5887;
public static final int DRAGON_BITTERM4 = 5889;
public static final int MOONLIGHT_MEADM1 = 5891;
public static final int MOONLIGHT_MEADM2 = 5893;
public static final int MOONLIGHT_MEADM3 = 5895;
public static final int MOONLIGHT_MEADM4 = 5897;
public static final int AXEMANS_FOLLYM1 = 5899;
public static final int AXEMANS_FOLLYM2 = 5901;
public static final int AXEMANS_FOLLYM3 = 5903;
public static final int AXEMANS_FOLLYM4 = 5905;
public static final int CHEFS_DELIGHTM1 = 5907;
public static final int CHEFS_DELIGHTM2 = 5909;
public static final int CHEFS_DELIGHTM3 = 5911;
public static final int CHEFS_DELIGHTM4 = 5913;
public static final int SLAYERS_RESPITEM1 = 5915;
public static final int SLAYERS_RESPITEM2 = 5917;
public static final int SLAYERS_RESPITEM3 = 5919;
public static final int SLAYERS_RESPITEM4 = 5921;
public static final int CIDERM1 = 5923;
public static final int CIDERM2 = 5925;
public static final int CIDERM3 = 5927;
public static final int CIDERM4 = 5929;
public static final int JUTE_FIBRE = 5931;
public static final int WILLOW_BRANCH = 5933;
public static final int COCONUT_MILK = 5935;
public static final int WEAPON_POISON_UNF = 5936;
public static final int WEAPON_POISON_5937 = 5937;
public static final int WEAPON_POISON_UNF_5939 = 5939;
public static final int WEAPON_POISON_5940 = 5940;
public static final int ANTIDOTE_UNF = 5942;
public static final int ANTIDOTE4 = 5943;
public static final int ANTIDOTE3 = 5945;
public static final int ANTIDOTE2 = 5947;
public static final int ANTIDOTE1 = 5949;
public static final int ANTIDOTE_UNF_5951 = 5951;
public static final int ANTIDOTE4_5952 = 5952;
public static final int ANTIDOTE3_5954 = 5954;
public static final int ANTIDOTE2_5956 = 5956;
public static final int ANTIDOTE1_5958 = 5958;
public static final int TOMATOES1 = 5960;
public static final int TOMATOES2 = 5962;
public static final int TOMATOES3 = 5964;
public static final int TOMATOES4 = 5966;
public static final int TOMATOES5 = 5968;
public static final int CURRY_LEAF = 5970;
public static final int PAPAYA_FRUIT = 5972;
public static final int COCONUT = 5974;
public static final int HALF_COCONUT = 5976;
public static final int COCONUT_SHELL = 5978;
public static final int CALQUAT_FRUIT = 5980;
public static final int WATERMELON = 5982;
public static final int WATERMELON_SLICE = 5984;
public static final int SWEETCORN = 5986;
public static final int COOKED_SWEETCORN = 5988;
public static final int BURNT_SWEETCORN = 5990;
public static final int APPLE_MUSH = 5992;
public static final int HAMMERSTONE_HOPS = 5994;
public static final int ASGARNIAN_HOPS = 5996;
public static final int YANILLIAN_HOPS = 5998;
public static final int KRANDORIAN_HOPS = 6000;
public static final int WILDBLOOD_HOPS = 6002;
public static final int MUSHROOM = 6004;
public static final int BARLEY = 6006;
public static final int BARLEY_MALT = 6008;
public static final int MARIGOLDS = 6010;
public static final int NASTURTIUMS = 6012;
public static final int ROSEMARY = 6014;
public static final int CACTUS_SPINE = 6016;
public static final int POISON_IVY_BERRIES = 6018;
public static final int LEAVES = 6020;
public static final int LEAVES_6022 = 6022;
public static final int LEAVES_6024 = 6024;
public static final int LEAVES_6026 = 6026;
public static final int LEAVES_6028 = 6028;
public static final int LEAVES_6030 = 6030;
public static final int COMPOST = 6032;
public static final int SUPERCOMPOST = 6034;
public static final int PLANT_CURE = 6036;
public static final int MAGIC_STRING = 6038;
public static final int AMULET_OF_NATURE = 6040;
public static final int PRENATURE_AMULET = 6041;
public static final int OAK_ROOTS = 6043;
public static final int WILLOW_ROOTS = 6045;
public static final int MAPLE_ROOTS = 6047;
public static final int YEW_ROOTS = 6049;
public static final int MAGIC_ROOTS = 6051;
public static final int SPIRIT_ROOTS = 6053;
public static final int WEEDS = 6055;
public static final int HAY_SACK = 6057;
public static final int HAY_SACK_6058 = 6058;
public static final int SCARECROW = 6059;
public static final int BRONZE_BOLTS_P_6061 = 6061;
public static final int BRONZE_BOLTS_P_6062 = 6062;
public static final int SPIRIT_TREE = 6063;
public static final int BLOODY_MOURNER_TOP = 6064;
public static final int MOURNER_TOP = 6065;
public static final int RIPPED_MOURNER_TROUSERS = 6066;
public static final int MOURNER_TROUSERS = 6067;
public static final int MOURNER_GLOVES = 6068;
public static final int MOURNER_BOOTS = 6069;
public static final int MOURNER_CLOAK = 6070;
public static final int MOURNER_LETTER = 6071;
public static final int TEGIDS_SOAP = 6072;
public static final int PRIFDDINAS_HISTORY = 6073;
public static final int EASTERN_DISCOVERY = 6075;
public static final int EASTERN_SETTLEMENT = 6077;
public static final int THE_GREAT_DIVIDE = 6079;
public static final int BROKEN_DEVICE = 6081;
public static final int FIXED_DEVICE = 6082;
public static final int TARNISHED_KEY = 6083;
public static final int WORN_KEY = 6084;
public static final int RED_DYE_BELLOWS = 6085;
public static final int BLUE_DYE_BELLOWS = 6086;
public static final int YELLOW_DYE_BELLOWS = 6087;
public static final int GREEN_DYE_BELLOWS = 6088;
public static final int BLUE_TOAD = 6089;
public static final int RED_TOAD = 6090;
public static final int YELLOW_TOAD = 6091;
public static final int GREEN_TOAD = 6092;
public static final int ROTTEN_APPLES = 6093;
public static final int APPLE_BARREL = 6094;
public static final int NAPHTHA_APPLE_MIX = 6095;
public static final int TOXIC_NAPHTHA = 6096;
public static final int SIEVE = 6097;
public static final int TOXIC_POWDER = 6098;
public static final int TELEPORT_CRYSTAL_4 = 6099;
public static final int TELEPORT_CRYSTAL_3 = 6100;
public static final int TELEPORT_CRYSTAL_2 = 6101;
public static final int TELEPORT_CRYSTAL_1 = 6102;
public static final int CRYSTAL_TELEPORT_SEED = 6103;
public static final int NEW_KEY = 6104;
public static final int ELF = 6105;
public static final int GHOSTLY_BOOTS = 6106;
public static final int GHOSTLY_ROBE = 6107;
public static final int GHOSTLY_ROBE_6108 = 6108;
public static final int GHOSTLY_HOOD = 6109;
public static final int GHOSTLY_GLOVES = 6110;
public static final int GHOSTLY_CLOAK = 6111;
public static final int KELDA_SEED = 6112;
public static final int KELDA_HOPS = 6113;
public static final int KELDA_STOUT = 6118;
public static final int SQUARE_STONE = 6119;
public static final int SQUARE_STONE_6120 = 6120;
public static final int LETTER_6121 = 6121;
public static final int A_CHAIR = 6122;
public static final int BEER_GLASS_6123 = 6123;
public static final int ENCHANTED_LYRE2 = 6125;
public static final int ENCHANTED_LYRE3 = 6126;
public static final int ENCHANTED_LYRE4 = 6127;
public static final int ROCKSHELL_HELM = 6128;
public static final int ROCKSHELL_PLATE = 6129;
public static final int ROCKSHELL_LEGS = 6130;
public static final int SPINED_HELM = 6131;
public static final int SPINED_BODY = 6133;
public static final int SPINED_CHAPS = 6135;
public static final int SKELETAL_HELM = 6137;
public static final int SKELETAL_TOP = 6139;
public static final int SKELETAL_BOTTOMS = 6141;
public static final int SPINED_BOOTS = 6143;
public static final int ROCKSHELL_BOOTS = 6145;
public static final int SKELETAL_BOOTS = 6147;
public static final int SPINED_GLOVES = 6149;
public static final int ROCKSHELL_GLOVES = 6151;
public static final int SKELETAL_GLOVES = 6153;
public static final int DAGANNOTH_HIDE = 6155;
public static final int ROCKSHELL_CHUNK = 6157;
public static final int ROCKSHELL_SHARD = 6159;
public static final int ROCKSHELL_SPLINTER = 6161;
public static final int SKULL_PIECE = 6163;
public static final int RIBCAGE_PIECE = 6165;
public static final int FIBULA_PIECE = 6167;
public static final int CIRCULAR_HIDE = 6169;
public static final int FLATTENED_HIDE = 6171;
public static final int STRETCHED_HIDE = 6173;
public static final int RAW_PHEASANT = 6178;
public static final int RAW_PHEASANT_6179 = 6179;
public static final int LEDERHOSEN_TOP = 6180;
public static final int LEDERHOSEN_SHORTS = 6181;
public static final int LEDERHOSEN_HAT = 6182;
public static final int FROG_TOKEN = 6183;
public static final int PRINCE_TUNIC = 6184;
public static final int PRINCE_LEGGINGS = 6185;
public static final int PRINCESS_BLOUSE = 6186;
public static final int PRINCESS_SKIRT = 6187;
public static final int FROG_MASK = 6188;
public static final int MYSTERY_BOX = 6199;
public static final int RAW_FISHLIKE_THING = 6200;
public static final int FISHLIKE_THING = 6202;
public static final int RAW_FISHLIKE_THING_6204 = 6204;
public static final int FISHLIKE_THING_6206 = 6206;
public static final int SMALL_FISHING_NET_6209 = 6209;
public static final int TEAK_PYRE_LOGS = 6211;
public static final int MAHOGANY_PYRE_LOG = 6213;
public static final int BROODOO_SHIELD_10 = 6215;
public static final int BROODOO_SHIELD_9 = 6217;
public static final int BROODOO_SHIELD_8 = 6219;
public static final int BROODOO_SHIELD_7 = 6221;
public static final int BROODOO_SHIELD_6 = 6223;
public static final int BROODOO_SHIELD_5 = 6225;
public static final int BROODOO_SHIELD_4 = 6227;
public static final int BROODOO_SHIELD_3 = 6229;
public static final int BROODOO_SHIELD_2 = 6231;
public static final int BROODOO_SHIELD_1 = 6233;
public static final int BROODOO_SHIELD = 6235;
public static final int BROODOO_SHIELD_10_6237 = 6237;
public static final int BROODOO_SHIELD_9_6239 = 6239;
public static final int BROODOO_SHIELD_8_6241 = 6241;
public static final int BROODOO_SHIELD_7_6243 = 6243;
public static final int BROODOO_SHIELD_6_6245 = 6245;
public static final int BROODOO_SHIELD_5_6247 = 6247;
public static final int BROODOO_SHIELD_4_6249 = 6249;
public static final int BROODOO_SHIELD_3_6251 = 6251;
public static final int BROODOO_SHIELD_2_6253 = 6253;
public static final int BROODOO_SHIELD_1_6255 = 6255;
public static final int BROODOO_SHIELD_6257 = 6257;
public static final int BROODOO_SHIELD_10_6259 = 6259;
public static final int BROODOO_SHIELD_9_6261 = 6261;
public static final int BROODOO_SHIELD_8_6263 = 6263;
public static final int BROODOO_SHIELD_7_6265 = 6265;
public static final int BROODOO_SHIELD_6_6267 = 6267;
public static final int BROODOO_SHIELD_5_6269 = 6269;
public static final int BROODOO_SHIELD_4_6271 = 6271;
public static final int BROODOO_SHIELD_3_6273 = 6273;
public static final int BROODOO_SHIELD_2_6275 = 6275;
public static final int BROODOO_SHIELD_1_6277 = 6277;
public static final int BROODOO_SHIELD_6279 = 6279;
public static final int THATCH_SPAR_LIGHT = 6281;
public static final int THATCH_SPAR_MED = 6283;
public static final int THATCH_SPAR_DENSE = 6285;
public static final int SNAKE_HIDE = 6287;
public static final int SNAKESKIN = 6289;
public static final int SPIDER_CARCASS = 6291;
public static final int SPIDER_ON_STICK = 6293;
public static final int SPIDER_ON_SHAFT = 6295;
public static final int SPIDER_ON_STICK_6297 = 6297;
public static final int SPIDER_ON_SHAFT_6299 = 6299;
public static final int BURNT_SPIDER = 6301;
public static final int SPIDER_ON_SHAFT_6303 = 6303;
public static final int SKEWER_STICK = 6305;
public static final int TRADING_STICKS = 6306;
public static final int GOUT_TUBER = 6311;
public static final int OPAL_MACHETE = 6313;
public static final int JADE_MACHETE = 6315;
public static final int RED_TOPAZ_MACHETE = 6317;
public static final int PROBOSCIS = 6319;
public static final int SNAKESKIN_BODY = 6322;
public static final int SNAKESKIN_CHAPS = 6324;
public static final int SNAKESKIN_BANDANA = 6326;
public static final int SNAKESKIN_BOOTS = 6328;
public static final int SNAKESKIN_VAMBRACES = 6330;
public static final int MAHOGANY_LOGS = 6332;
public static final int TEAK_LOGS = 6333;
public static final int TRIBAL_MASK = 6335;
public static final int TRIBAL_MASK_6337 = 6337;
public static final int TRIBAL_MASK_6339 = 6339;
public static final int TRIBAL_TOP = 6341;
public static final int VILLAGER_ROBE = 6343;
public static final int VILLAGER_HAT = 6345;
public static final int VILLAGER_ARMBAND = 6347;
public static final int VILLAGER_SANDALS = 6349;
public static final int TRIBAL_TOP_6351 = 6351;
public static final int VILLAGER_ROBE_6353 = 6353;
public static final int VILLAGER_HAT_6355 = 6355;
public static final int VILLAGER_SANDALS_6357 = 6357;
public static final int VILLAGER_ARMBAND_6359 = 6359;
public static final int TRIBAL_TOP_6361 = 6361;
public static final int VILLAGER_ROBE_6363 = 6363;
public static final int VILLAGER_HAT_6365 = 6365;
public static final int VILLAGER_SANDALS_6367 = 6367;
public static final int VILLAGER_ARMBAND_6369 = 6369;
public static final int TRIBAL_TOP_6371 = 6371;
public static final int VILLAGER_ROBE_6373 = 6373;
public static final int VILLAGER_HAT_6375 = 6375;
public static final int VILLAGER_SANDALS_6377 = 6377;
public static final int VILLAGER_ARMBAND_6379 = 6379;
public static final int FEZ = 6382;
public static final int DESERT_TOP = 6384;
public static final int DESERT_ROBES = 6386;
public static final int DESERT_TOP_6388 = 6388;
public static final int DESERT_LEGS = 6390;
public static final int MENAPHITE_PURPLE_HAT = 6392;
public static final int MENAPHITE_PURPLE_TOP = 6394;
public static final int MENAPHITE_PURPLE_ROBE = 6396;
public static final int MENAPHITE_PURPLE_KILT = 6398;
public static final int MENAPHITE_RED_HAT = 6400;
public static final int MENAPHITE_RED_TOP = 6402;
public static final int MENAPHITE_RED_ROBE = 6404;
public static final int MENAPHITE_RED_KILT = 6406;
public static final int OAK_BLACKJACKO = 6408;
public static final int OAK_BLACKJACKD = 6410;
public static final int WILLOW_BLACKJACKO = 6412;
public static final int WILLOW_BLACKJACKD = 6414;
public static final int MAPLE_BLACKJACK = 6416;
public static final int MAPLE_BLACKJACKO = 6418;
public static final int MAPLE_BLACKJACKD = 6420;
public static final int AIR_RUNE_6422 = 6422;
public static final int WATER_RUNE_6424 = 6424;
public static final int EARTH_RUNE_6426 = 6426;
public static final int FIRE_RUNE_6428 = 6428;
public static final int CHAOS_RUNE_6430 = 6430;
public static final int DEATH_RUNE_6432 = 6432;
public static final int LAW_RUNE_6434 = 6434;
public static final int MIND_RUNE_6436 = 6436;
public static final int BODY_RUNE_6438 = 6438;
public static final int SPADEFUL_OF_COKE = 6448;
public static final int KANDARIN_HEADGEAR = 6450;
public static final int MAGE_ARENA_CAPE = 6452;
public static final int WHITE_ROSE_SEED = 6453;
public static final int RED_ROSE_SEED = 6454;
public static final int PINK_ROSE_SEED = 6455;
public static final int VINE_SEED = 6456;
public static final int DELPHINIUM_SEED = 6457;
public static final int ORCHID_SEED = 6458;
public static final int ORCHID_SEED_6459 = 6459;
public static final int SNOWDROP_SEED = 6460;
public static final int WHITE_TREE_SHOOT = 6461;
public static final int WHITE_TREE_SHOOT_6462 = 6462;
public static final int WHITE_TREE_SHOOT_W = 6463;
public static final int WHITE_TREE_SAPLING = 6464;
public static final int RING_OF_CHAROSA = 6465;
public static final int RUNE_SHARDS = 6466;
public static final int RUNE_DUST = 6467;
public static final int PLANT_CURE_6468 = 6468;
public static final int WHITE_TREE_FRUIT = 6469;
public static final int COMPOST_POTION4 = 6470;
public static final int COMPOST_POTION3 = 6472;
public static final int COMPOST_POTION2 = 6474;
public static final int COMPOST_POTION1 = 6476;
public static final int TROLLEY = 6478;
public static final int LIST = 6479;
public static final int AGILITY_JUMP = 6514;
public static final int AGILITY_BALANCE = 6515;
public static final int AGILITY_CONTORTION = 6516;
public static final int AGILITY_CLIMB = 6517;
public static final int AGILITY_JUMP_6518 = 6518;
public static final int AGILITY_BALANCE_6519 = 6519;
public static final int AGILITY_CONTORTION_6520 = 6520;
public static final int AGILITY_CLIMB_6521 = 6521;
public static final int TOKTZXILUL = 6522;
public static final int TOKTZXILAK = 6523;
public static final int TOKTZKETXIL = 6524;
public static final int TOKTZXILEK = 6525;
public static final int TOKTZMEJTAL = 6526;
public static final int TZHAARKETEM = 6527;
public static final int TZHAARKETOM = 6528;
public static final int TOKKUL = 6529;
public static final int MOUSE_TOY = 6541;
public static final int PRESENT = 6542;
public static final int ANTIQUE_LAMP_6543 = 6543;
public static final int CATSPEAK_AMULETE = 6544;
public static final int CHORES = 6545;
public static final int RECIPE = 6546;
public static final int DOCTORS_HAT = 6547;
public static final int NURSE_HAT = 6548;
public static final int LAZY_CAT = 6549;
public static final int LAZY_CAT_6550 = 6550;
public static final int LAZY_CAT_6551 = 6551;
public static final int LAZY_CAT_6552 = 6552;
public static final int LAZY_CAT_6553 = 6553;
public static final int LAZY_CAT_6554 = 6554;
public static final int WILY_CAT = 6555;
public static final int WILY_CAT_6556 = 6556;
public static final int WILY_CAT_6557 = 6557;
public static final int WILY_CAT_6558 = 6558;
public static final int WILY_CAT_6559 = 6559;
public static final int WILY_CAT_6560 = 6560;
public static final int AHABS_BEER = 6561;
public static final int MUD_BATTLESTAFF = 6562;
public static final int MYSTIC_MUD_STAFF = 6563;
public static final int OBSIDIAN_CAPE = 6568;
public static final int FIRE_CAPE = 6570;
public static final int UNCUT_ONYX = 6571;
public static final int ONYX = 6573;
public static final int ONYX_RING = 6575;
public static final int ONYX_NECKLACE = 6577;
public static final int ONYX_AMULET_U = 6579;
public static final int ONYX_AMULET = 6581;
public static final int RING_OF_STONE = 6583;
public static final int AMULET_OF_FURY = 6585;
public static final int WHITE_CLAWS = 6587;
public static final int WHITE_BATTLEAXE = 6589;
public static final int WHITE_DAGGER = 6591;
public static final int WHITE_DAGGERP = 6593;
public static final int WHITE_DAGGERP_6595 = 6595;
public static final int WHITE_DAGGERP_6597 = 6597;
public static final int WHITE_HALBERD = 6599;
public static final int WHITE_MACE = 6601;
public static final int WHITE_MAGIC_STAFF = 6603;
public static final int WHITE_SWORD = 6605;
public static final int WHITE_LONGSWORD = 6607;
public static final int WHITE_2H_SWORD = 6609;
public static final int WHITE_SCIMITAR = 6611;
public static final int WHITE_WARHAMMER = 6613;
public static final int WHITE_CHAINBODY = 6615;
public static final int WHITE_PLATEBODY = 6617;
public static final int WHITE_BOOTS = 6619;
public static final int WHITE_MED_HELM = 6621;
public static final int WHITE_FULL_HELM = 6623;
public static final int WHITE_PLATELEGS = 6625;
public static final int WHITE_PLATESKIRT = 6627;
public static final int WHITE_GLOVES = 6629;
public static final int WHITE_SQ_SHIELD = 6631;
public static final int WHITE_KITESHIELD = 6633;
public static final int COMMORB = 6635;
public static final int SOLUSS_HAT = 6636;
public static final int DARK_BEAST = 6637;
public static final int COLOUR_WHEEL = 6638;
public static final int HAND_MIRROR = 6639;
public static final int RED_CRYSTAL = 6640;
public static final int YELLOW_CRYSTAL = 6641;
public static final int GREEN_CRYSTAL = 6642;
public static final int CYAN_CRYSTAL = 6643;
public static final int BLUE_CRYSTAL = 6644;
public static final int MAGENTA_CRYSTAL = 6645;
public static final int FRACTURED_CRYSTAL = 6646;
public static final int FRACTURED_CRYSTAL_6647 = 6647;
public static final int ITEM_LIST = 6648;
public static final int EDERNS_JOURNAL = 6649;
public static final int BLACKENED_CRYSTAL = 6650;
public static final int NEWLY_MADE_CRYSTAL = 6651;
public static final int NEWLY_MADE_CRYSTAL_6652 = 6652;
public static final int CRYSTAL_TRINKET = 6653;
public static final int CAMO_TOP = 6654;
public static final int CAMO_BOTTOMS = 6655;
public static final int CAMO_HELMET = 6656;
public static final int CAMO_TOP_6657 = 6657;
public static final int CAMO_BOTTOMS_6658 = 6658;
public static final int CAMO_HELMET_6659 = 6659;
public static final int FISHING_EXPLOSIVE = 6660;
public static final int MOGRE = 6661;
public static final int BROKEN_FISHING_ROD = 6662;
public static final int FORLORN_BOOT = 6663;
public static final int FISHING_EXPLOSIVE_6664 = 6664;
public static final int MUDSKIPPER_HAT = 6665;
public static final int FLIPPERS = 6666;
public static final int EMPTY_FISHBOWL = 6667;
public static final int FISHBOWL = 6668;
public static final int FISHBOWL_6669 = 6669;
public static final int FISHBOWL_6670 = 6670;
public static final int FISHBOWL_6671 = 6671;
public static final int FISHBOWL_6672 = 6672;
public static final int FISHBOWL_AND_NET = 6673;
public static final int TINY_NET = 6674;
public static final int AN_EMPTY_BOX = 6675;
public static final int GUAM_IN_A_BOX = 6677;
public static final int GUAM_IN_A_BOX_6678 = 6678;
public static final int SEAWEED_IN_A_BOX = 6679;
public static final int SEAWEED_IN_A_BOX_6680 = 6680;
public static final int GROUND_GUAM = 6681;
public static final int GROUND_SEAWEED = 6683;
public static final int SARADOMIN_BREW4 = 6685;
public static final int SARADOMIN_BREW3 = 6687;
public static final int SARADOMIN_BREW2 = 6689;
public static final int SARADOMIN_BREW1 = 6691;
public static final int CRUSHED_NEST = 6693;
public static final int DESERT_LIZARD = 6695;
public static final int ICE_COOLER = 6696;
public static final int PAT_OF_BUTTER = 6697;
public static final int BURNT_POTATO = 6699;
public static final int BAKED_POTATO = 6701;
public static final int POTATO_WITH_BUTTER = 6703;
public static final int POTATO_WITH_CHEESE = 6705;
public static final int CAMULET = 6707;
public static final int SLAYER_GLOVES = 6708;
public static final int FEVER_SPIDER = 6709;
public static final int BLINDWEED_SEED = 6710;
public static final int BLINDWEED = 6711;
public static final int BUCKET_OF_WATER_6712 = 6712;
public static final int WRENCH = 6713;
public static final int HOLY_WRENCH = 6714;
public static final int SLUGLINGS = 6715;
public static final int KARAMTHULHU = 6716;
public static final int KARAMTHULHU_6717 = 6717;
public static final int FEVER_SPIDER_BODY = 6718;
public static final int UNSANITARY_SWILL = 6719;
public static final int SLAYER_GLOVES_6720 = 6720;
public static final int RUSTY_SCIMITAR = 6721;
public static final int ZOMBIE_HEAD = 6722;
public static final int SEERCULL = 6724;
public static final int BONEMEAL_6728 = 6728;
public static final int DAGANNOTH_BONES = 6729;
public static final int SEERS_RING = 6731;
public static final int ARCHERS_RING = 6733;
public static final int WARRIOR_RING = 6735;
public static final int BERSERKER_RING = 6737;
public static final int DRAGON_AXE = 6739;
public static final int BROKEN_AXE_6741 = 6741;
public static final int DRAGON_AXE_HEAD = 6743;
public static final int SILVERLIGHT_6745 = 6745;
public static final int DARKLIGHT = 6746;
public static final int DEMONIC_SIGIL_MOULD = 6747;
public static final int DEMONIC_SIGIL = 6748;
public static final int DEMONIC_TOME = 6749;
public static final int BLACK_DESERT_SHIRT = 6750;
public static final int BLACK_DESERT_ROBE = 6752;
public static final int ENCHANTED_KEY = 6754;
public static final int JOURNAL_6755 = 6755;
public static final int LETTER_6756 = 6756;
public static final int LETTER_6757 = 6757;
public static final int SCROLL = 6758;
public static final int CHEST = 6759;
public static final int GUTHIX_MJOLNIR = 6760;
public static final int SARADOMIN_MJOLNIR = 6762;
public static final int ZAMORAK_MJOLNIR = 6764;
public static final int CAT_ANTIPOISON = 6766;
public static final int BOOK_6767 = 6767;
public static final int POISONED_CHEESE = 6768;
public static final int MUSIC_SCROLL = 6769;
public static final int DIRECTIONS = 6770;
public static final int POT_OF_WEEDS = 6771;
public static final int SMOULDERING_POT = 6772;
public static final int RAT_POLE = 6773;
public static final int RAT_POLE_6774 = 6774;
public static final int RAT_POLE_6775 = 6775;
public static final int RAT_POLE_6776 = 6776;
public static final int RAT_POLE_6777 = 6777;
public static final int RAT_POLE_6778 = 6778;
public static final int RAT_POLE_6779 = 6779;
public static final int MENAPHITE_THUG = 6780;
public static final int BANDIT_6781 = 6781;
public static final int BANDIT_6782 = 6782;
public static final int STATUETTE_6785 = 6785;
public static final int ROBE_OF_ELIDINIS = 6786;
public static final int ROBE_OF_ELIDINIS_6787 = 6787;
public static final int TORN_ROBE = 6788;
public static final int TORN_ROBE_6789 = 6789;
public static final int SHOES = 6790;
public static final int SOLE = 6791;
public static final int ANCESTRAL_KEY = 6792;
public static final int BALLAD = 6793;
public static final int CHOCICE = 6794;
public static final int LAMP_6796 = 6796;
public static final int WATERING_CAN_6797 = 6797;
public static final int EARTH_WARRIOR_CHAMPION_SCROLL = 6798;
public static final int GHOUL_CHAMPION_SCROLL = 6799;
public static final int GIANT_CHAMPION_SCROLL = 6800;
public static final int GOBLIN_CHAMPION_SCROLL = 6801;
public static final int HOBGOBLIN_CHAMPION_SCROLL = 6802;
public static final int IMP_CHAMPION_SCROLL = 6803;
public static final int JOGRE_CHAMPION_SCROLL = 6804;
public static final int LESSER_DEMON_CHAMPION_SCROLL = 6805;
public static final int SKELETON_CHAMPION_SCROLL = 6806;
public static final int ZOMBIE_CHAMPION_SCROLL = 6807;
public static final int LEONS_CHAMPION_SCROLL = 6808;
public static final int GRANITE_LEGS = 6809;
public static final int BONEMEAL_6810 = 6810;
public static final int SKELETAL_WYVERN = 6811;
public static final int WYVERN_BONES = 6812;
public static final int FUR = 6814;
public static final int SLENDER_BLADE = 6817;
public static final int BOWSWORD = 6818;
public static final int LARGE_POUCH_6819 = 6819;
public static final int RELIC = 6820;
public static final int ORB = 6821;
public static final int STAR_BAUBLE = 6822;
public static final int STAR_BAUBLE_6823 = 6823;
public static final int STAR_BAUBLE_6824 = 6824;
public static final int STAR_BAUBLE_6825 = 6825;
public static final int STAR_BAUBLE_6826 = 6826;
public static final int STAR_BAUBLE_6827 = 6827;
public static final int BOX_BAUBLE = 6828;
public static final int BOX_BAUBLE_6829 = 6829;
public static final int BOX_BAUBLE_6830 = 6830;
public static final int BOX_BAUBLE_6831 = 6831;
public static final int BOX_BAUBLE_6832 = 6832;
public static final int BOX_BAUBLE_6833 = 6833;
public static final int DIAMOND_BAUBLE = 6834;
public static final int DIAMOND_BAUBLE_6835 = 6835;
public static final int DIAMOND_BAUBLE_6836 = 6836;
public static final int DIAMOND_BAUBLE_6837 = 6837;
public static final int DIAMOND_BAUBLE_6838 = 6838;
public static final int DIAMOND_BAUBLE_6839 = 6839;
public static final int TREE_BAUBLE = 6840;
public static final int TREE_BAUBLE_6841 = 6841;
public static final int TREE_BAUBLE_6842 = 6842;
public static final int TREE_BAUBLE_6843 = 6843;
public static final int TREE_BAUBLE_6844 = 6844;
public static final int TREE_BAUBLE_6845 = 6845;
public static final int BELL_BAUBLE = 6846;
public static final int BELL_BAUBLE_6847 = 6847;
public static final int BELL_BAUBLE_6848 = 6848;
public static final int BELL_BAUBLE_6849 = 6849;
public static final int BELL_BAUBLE_6850 = 6850;
public static final int BELL_BAUBLE_6851 = 6851;
public static final int PUPPET_BOX = 6852;
public static final int BAUBLE_BOX = 6853;
public static final int PUPPET_BOX_6854 = 6854;
public static final int BAUBLE_BOX_6855 = 6855;
public static final int BOBBLE_HAT = 6856;
public static final int BOBBLE_SCARF = 6857;
public static final int JESTER_HAT = 6858;
public static final int JESTER_SCARF = 6859;
public static final int TRIJESTER_HAT = 6860;
public static final int TRIJESTER_SCARF = 6861;
public static final int WOOLLY_HAT = 6862;
public static final int WOOLLY_SCARF = 6863;
public static final int MARIONETTE_HANDLE = 6864;
public static final int BLUE_MARIONETTE = 6865;
public static final int GREEN_MARIONETTE = 6866;
public static final int RED_MARIONETTE = 6867;
public static final int BLUE_MARIONETTE_6868 = 6868;
public static final int GREEN_MARIONETTE_6869 = 6869;
public static final int RED_MARIONETTE_6870 = 6870;
public static final int RED_MARIONETTE_6871 = 6871;
public static final int RED_MARIONETTE_6872 = 6872;
public static final int RED_MARIONETTE_6873 = 6873;
public static final int RED_MARIONETTE_6874 = 6874;
public static final int BLUE_MARIONETTE_6875 = 6875;
public static final int BLUE_MARIONETTE_6876 = 6876;
public static final int BLUE_MARIONETTE_6877 = 6877;
public static final int BLUE_MARIONETTE_6878 = 6878;
public static final int GREEN_MARIONETTE_6879 = 6879;
public static final int GREEN_MARIONETTE_6880 = 6880;
public static final int GREEN_MARIONETTE_6881 = 6881;
public static final int GREEN_MARIONETTE_6882 = 6882;
public static final int PEACH = 6883;
public static final int PROGRESS_HAT = 6885;
public static final int PROGRESS_HAT_6886 = 6886;
public static final int PROGRESS_HAT_6887 = 6887;
public static final int MAGES_BOOK = 6889;
public static final int ARENA_BOOK = 6891;
public static final int LEATHER_BOOTS_6893 = 6893;
public static final int ADAMANT_KITESHIELD_6894 = 6894;
public static final int ADAMANT_MED_HELM_6895 = 6895;
public static final int EMERALD_6896 = 6896;
public static final int RUNE_LONGSWORD_6897 = 6897;
public static final int CYLINDER = 6898;
public static final int CUBE = 6899;
public static final int ICOSAHEDRON = 6900;
public static final int PENTAMID = 6901;
public static final int ORB_6902 = 6902;
public static final int DRAGONSTONE_6903 = 6903;
public static final int ANIMALS_BONES = 6904;
public static final int ANIMALS_BONES_6905 = 6905;
public static final int ANIMALS_BONES_6906 = 6906;
public static final int ANIMALS_BONES_6907 = 6907;
public static final int BEGINNER_WAND = 6908;
public static final int APPRENTICE_WAND = 6910;
public static final int TEACHER_WAND = 6912;
public static final int MASTER_WAND = 6914;
public static final int INFINITY_TOP = 6916;
public static final int INFINITY_HAT = 6918;
public static final int INFINITY_BOOTS = 6920;
public static final int INFINITY_GLOVES = 6922;
public static final int INFINITY_BOTTOMS = 6924;
public static final int BONES_TO_PEACHES = 6926;
public static final int SANDY_HAND = 6945;
public static final int BEER_SOAKED_HAND = 6946;
public static final int BERTS_ROTA = 6947;
public static final int SANDYS_ROTA = 6948;
public static final int A_MAGIC_SCROLL = 6949;
public static final int MAGICAL_ORB = 6950;
public static final int MAGICAL_ORB_A = 6951;
public static final int TRUTH_SERUM = 6952;
public static final int BOTTLED_WATER = 6953;
public static final int REDBERRY_JUICE = 6954;
public static final int PINK_DYE = 6955;
public static final int ROSE_TINTED_LENS = 6956;
public static final int WIZARDS_HEAD = 6957;
public static final int SAND = 6958;
public static final int PINK_CAPE = 6959;
public static final int BAGUETTE = 6961;
public static final int TRIANGLE_SANDWICH = 6962;
public static final int ROLL = 6963;
public static final int COINS_6964 = 6964;
public static final int SQUARE_SANDWICH = 6965;
public static final int PRISON_KEY_6966 = 6966;
public static final int DRAGON_MED_HELM_6967 = 6967;
public static final int SHARK_6969 = 6969;
public static final int PYRAMID_TOP = 6970;
public static final int SANDSTONE_1KG = 6971;
public static final int SANDSTONE_2KG = 6973;
public static final int SANDSTONE_5KG = 6975;
public static final int SANDSTONE_10KG = 6977;
public static final int GRANITE_500G = 6979;
public static final int GRANITE_2KG = 6981;
public static final int GRANITE_5KG = 6983;
public static final int SANDSTONE_20KG = 6985;
public static final int SANDSTONE_32KG = 6986;
public static final int SANDSTONE_BODY = 6987;
public static final int SANDSTONE_BASE = 6988;
public static final int STONE_HEAD = 6989;
public static final int STONE_HEAD_6990 = 6990;
public static final int STONE_HEAD_6991 = 6991;
public static final int STONE_HEAD_6992 = 6992;
public static final int Z_SIGIL = 6993;
public static final int M_SIGIL = 6994;
public static final int R_SIGIL = 6995;
public static final int K_SIGIL = 6996;
public static final int STONE_LEFT_ARM = 6997;
public static final int STONE_RIGHT_ARM = 6998;
public static final int STONE_LEFT_LEG = 6999;
public static final int STONE_RIGHT_LEG = 7000;
public static final int CAMEL_MOULD_P = 7001;
public static final int STONE_HEAD_7002 = 7002;
public static final int CAMEL_MASK = 7003;
public static final int SWARM = 7050;
public static final int UNLIT_BUG_LANTERN = 7051;
public static final int LIT_BUG_LANTERN = 7053;
public static final int CHILLI_POTATO = 7054;
public static final int EGG_POTATO = 7056;
public static final int MUSHROOM_POTATO = 7058;
public static final int TUNA_POTATO = 7060;
public static final int CHILLI_CON_CARNE = 7062;
public static final int EGG_AND_TOMATO = 7064;
public static final int MUSHROOM__ONION = 7066;
public static final int TUNA_AND_CORN = 7068;
public static final int MINCED_MEAT = 7070;
public static final int SPICY_SAUCE = 7072;
public static final int CHOPPED_GARLIC = 7074;
public static final int UNCOOKED_EGG = 7076;
public static final int SCRAMBLED_EGG = 7078;
public static final int SLICED_MUSHROOMS = 7080;
public static final int FRIED_MUSHROOMS = 7082;
public static final int FRIED_ONIONS = 7084;
public static final int CHOPPED_TUNA = 7086;
public static final int SWEETCORN_7088 = 7088;
public static final int BURNT_EGG = 7090;
public static final int BURNT_ONION = 7092;
public static final int BURNT_MUSHROOM = 7094;
public static final int BOARD_GAME_PIECE_7096 = 7096;
public static final int BOARD_GAME_PIECE_7097 = 7097;
public static final int BOARD_GAME_PIECE_7098 = 7098;
public static final int BOARD_GAME_PIECE_7099 = 7099;
public static final int BOARD_GAME_PIECE_7100 = 7100;
public static final int BOARD_GAME_PIECE_7101 = 7101;
public static final int BOARD_GAME_PIECE_7102 = 7102;
public static final int BOARD_GAME_PIECE_7103 = 7103;
public static final int BOARD_GAME_PIECE_7104 = 7104;
public static final int BOARD_GAME_PIECE_7105 = 7105;
public static final int BOARD_GAME_PIECE_7106 = 7106;
public static final int BOARD_GAME_PIECE_7107 = 7107;
public static final int GUNPOWDER = 7108;
public static final int FUSE = 7109;
public static final int STRIPY_PIRATE_SHIRT = 7110;
public static final int PIRATE_BANDANA = 7112;
public static final int PIRATE_BOOTS = 7114;
public static final int PIRATE_LEGGINGS = 7116;
public static final int CANISTER = 7118;
public static final int CANNON_BALL_7119 = 7119;
public static final int RAMROD = 7120;
public static final int REPAIR_PLANK = 7121;
public static final int STRIPY_PIRATE_SHIRT_7122 = 7122;
public static final int PIRATE_BANDANA_7124 = 7124;
public static final int PIRATE_LEGGINGS_7126 = 7126;
public static final int STRIPY_PIRATE_SHIRT_7128 = 7128;
public static final int PIRATE_BANDANA_7130 = 7130;
public static final int PIRATE_LEGGINGS_7132 = 7132;
public static final int STRIPY_PIRATE_SHIRT_7134 = 7134;
public static final int PIRATE_BANDANA_7136 = 7136;
public static final int PIRATE_LEGGINGS_7138 = 7138;
public static final int LUCKY_CUTLASS = 7140;
public static final int HARRYS_CUTLASS = 7141;
public static final int RAPIER = 7142;
public static final int PLUNDER = 7143;
public static final int BOOK_O_PIRACY = 7144;
public static final int CANNON_BARREL = 7145;
public static final int BROKEN_CANNON = 7146;
public static final int CANNON_BALLS = 7147;
public static final int REPAIR_PLANK_7148 = 7148;
public static final int CANISTER_7149 = 7149;
public static final int TACKS = 7150;
public static final int ROPE_7155 = 7155;
public static final int TINDERBOX_7156 = 7156;
public static final int BRAINDEATH_RUM = 7157;
public static final int DRAGON_2H_SWORD = 7158;
public static final int INSULATED_BOOTS = 7159;
public static final int KILLERWATT = 7160;
public static final int PIE_RECIPE_BOOK = 7162;
public static final int PART_MUD_PIE = 7164;
public static final int PART_MUD_PIE_7166 = 7166;
public static final int RAW_MUD_PIE = 7168;
public static final int MUD_PIE = 7170;
public static final int PART_GARDEN_PIE = 7172;
public static final int PART_GARDEN_PIE_7174 = 7174;
public static final int RAW_GARDEN_PIE = 7176;
public static final int GARDEN_PIE = 7178;
public static final int HALF_A_GARDEN_PIE = 7180;
public static final int PART_FISH_PIE = 7182;
public static final int PART_FISH_PIE_7184 = 7184;
public static final int RAW_FISH_PIE = 7186;
public static final int FISH_PIE = 7188;
public static final int HALF_A_FISH_PIE = 7190;
public static final int PART_ADMIRAL_PIE = 7192;
public static final int PART_ADMIRAL_PIE_7194 = 7194;
public static final int RAW_ADMIRAL_PIE = 7196;
public static final int ADMIRAL_PIE = 7198;
public static final int HALF_AN_ADMIRAL_PIE = 7200;
public static final int PART_WILD_PIE = 7202;
public static final int PART_WILD_PIE_7204 = 7204;
public static final int RAW_WILD_PIE = 7206;
public static final int WILD_PIE = 7208;
public static final int HALF_A_WILD_PIE = 7210;
public static final int PART_SUMMER_PIE = 7212;
public static final int PART_SUMMER_PIE_7214 = 7214;
public static final int RAW_SUMMER_PIE = 7216;
public static final int SUMMER_PIE = 7218;
public static final int HALF_A_SUMMER_PIE = 7220;
public static final int BURNT_RABBIT = 7222;
public static final int ROAST_RABBIT = 7223;
public static final int SKEWERED_RABBIT = 7224;
public static final int IRON_SPIT = 7225;
public static final int BURNT_CHOMPY = 7226;
public static final int COOKED_CHOMPY_7228 = 7228;
public static final int SKEWERED_CHOMPY = 7230;
public static final int CLUE_SCROLL_EASY_7236 = 7236;
public static final int CASKET_EASY_7237 = 7237;
public static final int CLUE_SCROLL_EASY_7238 = 7238;
public static final int CLUE_SCROLL_HARD_7239 = 7239;
public static final int CASKET_HARD_7240 = 7240;
public static final int CLUE_SCROLL_HARD_7241 = 7241;
public static final int CASKET_HARD_7242 = 7242;
public static final int CLUE_SCROLL_HARD_7243 = 7243;
public static final int CASKET_HARD_7244 = 7244;
public static final int CLUE_SCROLL_HARD_7245 = 7245;
public static final int CASKET_HARD_7246 = 7246;
public static final int CLUE_SCROLL_HARD_7247 = 7247;
public static final int CLUE_SCROLL_HARD_7248 = 7248;
public static final int CLUE_SCROLL_HARD_7249 = 7249;
public static final int CLUE_SCROLL_HARD_7250 = 7250;
public static final int CLUE_SCROLL_HARD_7251 = 7251;
public static final int CLUE_SCROLL_HARD_7252 = 7252;
public static final int CLUE_SCROLL_HARD_7253 = 7253;
public static final int CLUE_SCROLL_HARD_7254 = 7254;
public static final int CLUE_SCROLL_HARD_7255 = 7255;
public static final int CLUE_SCROLL_HARD_7256 = 7256;
public static final int CASKET_HARD_7257 = 7257;
public static final int CLUE_SCROLL_HARD_7258 = 7258;
public static final int CASKET_HARD_7259 = 7259;
public static final int CLUE_SCROLL_HARD_7260 = 7260;
public static final int CASKET_HARD_7261 = 7261;
public static final int CLUE_SCROLL_HARD_7262 = 7262;
public static final int CASKET_HARD_7263 = 7263;
public static final int CLUE_SCROLL_HARD_7264 = 7264;
public static final int CASKET_HARD_7265 = 7265;
public static final int CLUE_SCROLL_HARD_7266 = 7266;
public static final int CASKET_HARD_7267 = 7267;
public static final int CLUE_SCROLL_HARD_7268 = 7268;
public static final int CHALLENGE_SCROLL_HARD = 7269;
public static final int CLUE_SCROLL_HARD_7270 = 7270;
public static final int CHALLENGE_SCROLL_HARD_7271 = 7271;
public static final int CLUE_SCROLL_HARD_7272 = 7272;
public static final int CHALLENGE_SCROLL_HARD_7273 = 7273;
public static final int CLUE_SCROLL_MEDIUM_7274 = 7274;
public static final int CHALLENGE_SCROLL_MEDIUM_7275 = 7275;
public static final int CLUE_SCROLL_MEDIUM_7276 = 7276;
public static final int CHALLENGE_SCROLL_MEDIUM_7277 = 7277;
public static final int CLUE_SCROLL_MEDIUM_7278 = 7278;
public static final int CHALLENGE_SCROLL_MEDIUM_7279 = 7279;
public static final int CLUE_SCROLL_MEDIUM_7280 = 7280;
public static final int CHALLENGE_SCROLL_MEDIUM_7281 = 7281;
public static final int CLUE_SCROLL_MEDIUM_7282 = 7282;
public static final int CHALLENGE_SCROLL_MEDIUM_7283 = 7283;
public static final int CLUE_SCROLL_MEDIUM_7284 = 7284;
public static final int CHALLENGE_SCROLL_MEDIUM_7285 = 7285;
public static final int CLUE_SCROLL_MEDIUM_7286 = 7286;
public static final int CASKET_MEDIUM_7287 = 7287;
public static final int CLUE_SCROLL_MEDIUM_7288 = 7288;
public static final int CASKET_MEDIUM_7289 = 7289;
public static final int CLUE_SCROLL_MEDIUM_7290 = 7290;
public static final int CASKET_MEDIUM_7291 = 7291;
public static final int CLUE_SCROLL_MEDIUM_7292 = 7292;
public static final int CASKET_MEDIUM_7293 = 7293;
public static final int CLUE_SCROLL_MEDIUM_7294 = 7294;
public static final int CASKET_MEDIUM_7295 = 7295;
public static final int CLUE_SCROLL_MEDIUM_7296 = 7296;
public static final int KEY_MEDIUM_7297 = 7297;
public static final int CLUE_SCROLL_MEDIUM_7298 = 7298;
public static final int KEY_MEDIUM_7299 = 7299;
public static final int CLUE_SCROLL_MEDIUM_7300 = 7300;
public static final int CLUE_SCROLL_MEDIUM_7301 = 7301;
public static final int KEY_MEDIUM_7302 = 7302;
public static final int CLUE_SCROLL_MEDIUM_7303 = 7303;
public static final int CLUE_SCROLL_MEDIUM_7304 = 7304;
public static final int CLUE_SCROLL_MEDIUM_7305 = 7305;
public static final int CASKET_MEDIUM_7306 = 7306;
public static final int CLUE_SCROLL_MEDIUM_7307 = 7307;
public static final int CASKET_MEDIUM_7308 = 7308;
public static final int CLUE_SCROLL_MEDIUM_7309 = 7309;
public static final int CASKET_MEDIUM_7310 = 7310;
public static final int CLUE_SCROLL_MEDIUM_7311 = 7311;
public static final int CASKET_MEDIUM_7312 = 7312;
public static final int CLUE_SCROLL_MEDIUM_7313 = 7313;
public static final int CASKET_MEDIUM_7314 = 7314;
public static final int CLUE_SCROLL_MEDIUM_7315 = 7315;
public static final int CASKET_MEDIUM_7316 = 7316;
public static final int CLUE_SCROLL_MEDIUM_7317 = 7317;
public static final int CASKET_MEDIUM_7318 = 7318;
public static final int RED_BOATER = 7319;
public static final int ORANGE_BOATER = 7321;
public static final int GREEN_BOATER = 7323;
public static final int BLUE_BOATER = 7325;
public static final int BLACK_BOATER = 7327;
public static final int RED_FIRELIGHTER = 7329;
public static final int GREEN_FIRELIGHTER = 7330;
public static final int BLUE_FIRELIGHTER = 7331;
public static final int BLACK_SHIELD_H1 = 7332;
public static final int ADAMANT_SHIELD_H1 = 7334;
public static final int RUNE_SHIELD_H1 = 7336;
public static final int BLACK_SHIELD_H2 = 7338;
public static final int ADAMANT_SHIELD_H2 = 7340;
public static final int RUNE_SHIELD_H2 = 7342;
public static final int BLACK_SHIELD_H3 = 7344;
public static final int ADAMANT_SHIELD_H3 = 7346;
public static final int RUNE_SHIELD_H3 = 7348;
public static final int BLACK_SHIELD_H4 = 7350;
public static final int ADAMANT_SHIELD_H4 = 7352;
public static final int RUNE_SHIELD_H4 = 7354;
public static final int BLACK_SHIELD_H5 = 7356;
public static final int ADAMANT_SHIELD_H5 = 7358;
public static final int RUNE_SHIELD_H5 = 7360;
public static final int STUDDED_BODY_G = 7362;
public static final int STUDDED_BODY_T = 7364;
public static final int STUDDED_CHAPS_G = 7366;
public static final int STUDDED_CHAPS_T = 7368;
public static final int GREEN_DHIDE_BODY_G = 7370;
public static final int GREEN_DHIDE_BODY_T = 7372;
public static final int BLUE_DHIDE_BODY_G = 7374;
public static final int BLUE_DHIDE_BODY_T = 7376;
public static final int GREEN_DHIDE_CHAPS_G = 7378;
public static final int GREEN_DHIDE_CHAPS_T = 7380;
public static final int BLUE_DHIDE_CHAPS_G = 7382;
public static final int BLUE_DHIDE_CHAPS_T = 7384;
public static final int BLUE_SKIRT_G = 7386;
public static final int BLUE_SKIRT_T = 7388;
public static final int BLUE_WIZARD_ROBE_G = 7390;
public static final int BLUE_WIZARD_ROBE_T = 7392;
public static final int BLUE_WIZARD_HAT_G = 7394;
public static final int BLUE_WIZARD_HAT_T = 7396;
public static final int ENCHANTED_ROBE = 7398;
public static final int ENCHANTED_TOP = 7399;
public static final int ENCHANTED_HAT = 7400;
public static final int RED_LOGS = 7404;
public static final int GREEN_LOGS = 7405;
public static final int BLUE_LOGS = 7406;
public static final int DRAYNOR_SKULL = 7408;
public static final int MAGIC_SECATEURS = 7409;
public static final int QUEENS_SECATEURS = 7410;
public static final int SYMPTOMS_LIST = 7411;
public static final int BIRD_NEST_7413 = 7413;
public static final int PADDLE = 7414;
public static final int MOLE_CLAW = 7416;
public static final int MOLE_SKIN = 7418;
public static final int MUTATED_ZYGOMITE = 7420;
public static final int FUNGICIDE_SPRAY_10 = 7421;
public static final int FUNGICIDE_SPRAY_9 = 7422;
public static final int FUNGICIDE_SPRAY_8 = 7423;
public static final int FUNGICIDE_SPRAY_7 = 7424;
public static final int FUNGICIDE_SPRAY_6 = 7425;
public static final int FUNGICIDE_SPRAY_5 = 7426;
public static final int FUNGICIDE_SPRAY_4 = 7427;
public static final int FUNGICIDE_SPRAY_3 = 7428;
public static final int FUNGICIDE_SPRAY_2 = 7429;
public static final int FUNGICIDE_SPRAY_1 = 7430;
public static final int FUNGICIDE_SPRAY_0 = 7431;
public static final int FUNGICIDE = 7432;
public static final int WOODEN_SPOON = 7433;
public static final int EGG_WHISK = 7435;
public static final int SPORK = 7437;
public static final int SPATULA = 7439;
public static final int FRYING_PAN = 7441;
public static final int SKEWER = 7443;
public static final int ROLLING_PIN = 7445;
public static final int KITCHEN_KNIFE = 7447;
public static final int MEAT_TENDERISER = 7449;
public static final int CLEAVER = 7451;
public static final int HARDLEATHER_GLOVES = 7453;
public static final int BRONZE_GLOVES = 7454;
public static final int IRON_GLOVES = 7455;
public static final int STEEL_GLOVES = 7456;
public static final int BLACK_GLOVES = 7457;
public static final int MITHRIL_GLOVES = 7458;
public static final int ADAMANT_GLOVES = 7459;
public static final int RUNE_GLOVES = 7460;
public static final int DRAGON_GLOVES = 7461;
public static final int BARROWS_GLOVES = 7462;
public static final int CORNFLOUR = 7463;
public static final int BOOK_ON_CHICKENS = 7464;
public static final int VANILLA_POD = 7465;
public static final int CORNFLOUR_7466 = 7466;
public static final int POT_OF_CORNFLOUR = 7468;
public static final int CORNFLOUR_MIXTURE = 7470;
public static final int MILKY_MIXTURE = 7471;
public static final int CINNAMON = 7472;
public static final int BRULEE = 7473;
public static final int BRULEE_7474 = 7474;
public static final int BRULEE_7475 = 7475;
public static final int BRULEE_SUPREME = 7476;
public static final int EVIL_CHICKENS_EGG = 7477;
public static final int DRAGON_TOKEN = 7478;
public static final int SPICY_STEW = 7479;
public static final int RED_SPICE_4 = 7480;
public static final int RED_SPICE_3 = 7481;
public static final int RED_SPICE_2 = 7482;
public static final int RED_SPICE_1 = 7483;
public static final int ORANGE_SPICE_4 = 7484;
public static final int ORANGE_SPICE_3 = 7485;
public static final int ORANGE_SPICE_2 = 7486;
public static final int ORANGE_SPICE_1 = 7487;
public static final int BROWN_SPICE_4 = 7488;
public static final int BROWN_SPICE_3 = 7489;
public static final int BROWN_SPICE_2 = 7490;
public static final int BROWN_SPICE_1 = 7491;
public static final int YELLOW_SPICE_4 = 7492;
public static final int YELLOW_SPICE_3 = 7493;
public static final int YELLOW_SPICE_2 = 7494;
public static final int YELLOW_SPICE_1 = 7495;
public static final int EMPTY_SPICE_SHAKER = 7496;
public static final int DIRTY_BLAST = 7497;
public static final int ANTIQUE_LAMP_7498 = 7498;
public static final int EVIL_DAVE = 7499;
public static final int DWARF_7500 = 7500;
public static final int GOBLINS = 7501;
public static final int LUMBRIDGE_GUIDE = 7502;
public static final int MONKEY_7503 = 7503;
public static final int OSMAN = 7504;
public static final int PIRATE_PETE = 7505;
public static final int SIR_AMIK_VARZE = 7506;
public static final int SKRACH = 7507;
public static final int ASGOLDIAN_ALE = 7508;
public static final int DWARVEN_ROCK_CAKE = 7509;
public static final int DWARVEN_ROCK_CAKE_7510 = 7510;
public static final int SLOP_OF_COMPROMISE = 7511;
public static final int SOGGY_BREAD = 7512;
public static final int SPICY_MAGGOTS = 7513;
public static final int DYED_ORANGE = 7514;
public static final int BREADCRUMBS = 7515;
public static final int KELP = 7516;
public static final int GROUND_KELP = 7517;
public static final int CRAB_MEAT = 7518;
public static final int CRAB_MEAT_7519 = 7519;
public static final int BURNT_CRAB_MEAT = 7520;
public static final int COOKED_CRAB_MEAT = 7521;
public static final int COOKED_CRAB_MEAT_7523 = 7523;
public static final int COOKED_CRAB_MEAT_7524 = 7524;
public static final int COOKED_CRAB_MEAT_7525 = 7525;
public static final int COOKED_CRAB_MEAT_7526 = 7526;
public static final int GROUND_CRAB_MEAT = 7527;
public static final int GROUND_COD = 7528;
public static final int RAW_FISHCAKE = 7529;
public static final int COOKED_FISHCAKE = 7530;
public static final int BURNT_FISHCAKE = 7531;
public static final int MUDSKIPPER_HIDE = 7532;
public static final int ROCK_7533 = 7533;
public static final int FISHBOWL_HELMET = 7534;
public static final int DIVING_APPARATUS = 7535;
public static final int FRESH_CRAB_CLAW = 7536;
public static final int CRAB_CLAW = 7537;
public static final int FRESH_CRAB_SHELL = 7538;
public static final int CRAB_HELMET = 7539;
public static final int BROKEN_CRAB_CLAW = 7540;
public static final int BROKEN_CRAB_SHELL = 7541;
public static final int CAKE_OF_GUIDANCE = 7542;
public static final int RAW_GUIDE_CAKE = 7543;
public static final int ENCHANTED_EGG = 7544;
public static final int ENCHANTED_MILK = 7545;
public static final int ENCHANTED_FLOUR = 7546;
public static final int DRUID_POUCH_7547 = 7547;
public static final int POTATO_SEED_7548 = 7548;
public static final int ONION_SEED_7550 = 7550;
public static final int MITHRIL_ARROW_7552 = 7552;
public static final int FIRE_RUNE_7554 = 7554;
public static final int WATER_RUNE_7556 = 7556;
public static final int AIR_RUNE_7558 = 7558;
public static final int CHAOS_RUNE_7560 = 7560;
public static final int TOMATO_SEED_7562 = 7562;
public static final int BALLOON_TOAD = 7564;
public static final int BALLOON_TOAD_7565 = 7565;
public static final int RAW_JUBBLY = 7566;
public static final int COOKED_JUBBLY = 7568;
public static final int BURNT_JUBBLY = 7570;
public static final int RED_BANANA = 7572;
public static final int TCHIKI_MONKEY_NUTS = 7573;
public static final int SLICED_RED_BANANA = 7574;
public static final int TCHIKI_NUT_PASTE = 7575;
public static final int SNAKE_CORPSE = 7576;
public static final int RAW_STUFFED_SNAKE = 7577;
public static final int ODD_STUFFED_SNAKE = 7578;
public static final int STUFFED_SNAKE = 7579;
public static final int SNAKE_OVERCOOKED = 7580;
public static final int OVERGROWN_HELLCAT = 7581;
public static final int HELL_CAT = 7582;
public static final int HELLKITTEN = 7583;
public static final int LAZY_HELL_CAT = 7584;
public static final int WILY_HELLCAT = 7585;
public static final int DUMMY = 7586;
public static final int COFFIN = 7587;
public static final int COFFIN_7588 = 7588;
public static final int COFFIN_7589 = 7589;
public static final int COFFIN_7590 = 7590;
public static final int COFFIN_7591 = 7591;
public static final int ZOMBIE_SHIRT = 7592;
public static final int ZOMBIE_TROUSERS = 7593;
public static final int ZOMBIE_MASK = 7594;
public static final int ZOMBIE_GLOVES = 7595;
public static final int ZOMBIE_BOOTS = 7596;
public static final int ITEM = 7597;
public static final int ITEM_7598 = 7598;
public static final int ITEM_7599 = 7599;
public static final int ITEM_7600 = 7600;
public static final int ITEM_7601 = 7601;
public static final int ITEM_7602 = 7602;
public static final int ITEM_7603 = 7603;
public static final int ITEM_7604 = 7604;
public static final int ITEM_7605 = 7605;
public static final int ITEM_7606 = 7606;
public static final int ITEM_7607 = 7607;
public static final int ITEM_7608 = 7608;
public static final int ITEM_7609 = 7609;
public static final int ITEM_7610 = 7610;
public static final int ITEM_7611 = 7611;
public static final int ITEM_7612 = 7612;
public static final int ITEM_7613 = 7613;
public static final int ITEM_7614 = 7614;
public static final int ITEM_7615 = 7615;
public static final int ITEM_7616 = 7616;
public static final int ITEM_7617 = 7617;
public static final int ITEM_7618 = 7618;
public static final int BUCKET_OF_RUBBLE = 7622;
public static final int BUCKET_OF_RUBBLE_7624 = 7624;
public static final int BUCKET_OF_RUBBLE_7626 = 7626;
public static final int PLASTER_FRAGMENT = 7628;
public static final int DUSTY_SCROLL = 7629;
public static final int CRATE = 7630;
public static final int TEMPLE_LIBRARY_KEY = 7632;
public static final int THE_SLEEPING_SEVEN = 7633;
public static final int HISTORIES_OF_THE_HALLOWLAND = 7634;
public static final int MODERN_DAY_MORYTANIA = 7635;
public static final int ROD_DUST = 7636;
public static final int SILVTHRILL_ROD = 7637;
public static final int SILVTHRILL_ROD_7638 = 7638;
public static final int ROD_OF_IVANDIS_10 = 7639;
public static final int ROD_OF_IVANDIS_9 = 7640;
public static final int ROD_OF_IVANDIS_8 = 7641;
public static final int ROD_OF_IVANDIS_7 = 7642;
public static final int ROD_OF_IVANDIS_6 = 7643;
public static final int ROD_OF_IVANDIS_5 = 7644;
public static final int ROD_OF_IVANDIS_4 = 7645;
public static final int ROD_OF_IVANDIS_3 = 7646;
public static final int ROD_OF_IVANDIS_2 = 7647;
public static final int ROD_OF_IVANDIS_1 = 7648;
public static final int ROD_MOULD = 7649;
public static final int SILVER_DUST = 7650;
public static final int GUTHIX_BALANCE_UNF = 7652;
public static final int GUTHIX_BALANCE_UNF_7654 = 7654;
public static final int GUTHIX_BALANCE_UNF_7656 = 7656;
public static final int GUTHIX_BALANCE_UNF_7658 = 7658;
public static final int GUTHIX_BALANCE4 = 7660;
public static final int GUTHIX_BALANCE3 = 7662;
public static final int GUTHIX_BALANCE2 = 7664;
public static final int GUTHIX_BALANCE1 = 7666;
public static final int GADDERHAMMER = 7668;
public static final int BOXING_GLOVES = 7671;
public static final int BOXING_GLOVES_7673 = 7673;
public static final int WOODEN_SWORD = 7675;
public static final int WOODEN_SHIELD_7676 = 7676;
public static final int TREASURE_STONE = 7677;
public static final int PRIZE_KEY = 7678;
public static final int PUGEL = 7679;
public static final int GAME_BOOK = 7681;
public static final int HOOP = 7682;
public static final int DART = 7684;
public static final int BOW_AND_ARROW = 7686;
public static final int KETTLE = 7688;
public static final int FULL_KETTLE = 7690;
public static final int HOT_KETTLE = 7691;
public static final int POT_OF_TEA_4 = 7692;
public static final int POT_OF_TEA_3 = 7694;
public static final int POT_OF_TEA_2 = 7696;
public static final int POT_OF_TEA_1 = 7698;
public static final int TEAPOT_WITH_LEAVES = 7700;
public static final int TEAPOT = 7702;
public static final int POT_OF_TEA_4_7704 = 7704;
public static final int POT_OF_TEA_3_7706 = 7706;
public static final int POT_OF_TEA_2_7708 = 7708;
public static final int POT_OF_TEA_1_7710 = 7710;
public static final int TEAPOT_WITH_LEAVES_7712 = 7712;
public static final int TEAPOT_7714 = 7714;
public static final int POT_OF_TEA_4_7716 = 7716;
public static final int POT_OF_TEA_3_7718 = 7718;
public static final int POT_OF_TEA_2_7720 = 7720;
public static final int POT_OF_TEA_1_7722 = 7722;
public static final int TEAPOT_WITH_LEAVES_7724 = 7724;
public static final int TEAPOT_7726 = 7726;
public static final int EMPTY_CUP_7728 = 7728;
public static final int CUP_OF_TEA_7730 = 7730;
public static final int CUP_OF_TEA_7731 = 7731;
public static final int PORCELAIN_CUP_7732 = 7732;
public static final int CUP_OF_TEA_7733 = 7733;
public static final int CUP_OF_TEA_7734 = 7734;
public static final int PORCELAIN_CUP_7735 = 7735;
public static final int CUP_OF_TEA_7736 = 7736;
public static final int CUP_OF_TEA_7737 = 7737;
public static final int TEA_LEAVES = 7738;
public static final int BEER_7740 = 7740;
public static final int BEER_GLASS_7742 = 7742;
public static final int ASGARNIAN_ALE_7744 = 7744;
public static final int GREENMANS_ALE_7746 = 7746;
public static final int DRAGON_BITTER_7748 = 7748;
public static final int MOONLIGHT_MEAD_7750 = 7750;
public static final int CIDER_7752 = 7752;
public static final int CHEFS_DELIGHT_7754 = 7754;
public static final int PAINTBRUSH = 7756;
public static final int TOY_SOLDIER = 7759;
public static final int TOY_SOLDIER_WOUND = 7761;
public static final int TOY_DOLL = 7763;
public static final int TOY_DOLL_WOUND = 7765;
public static final int TOY_MOUSE = 7767;
public static final int TOY_MOUSE_WOUND = 7769;
public static final int TOY_CAT = 7771;
public static final int BRANCH_7773 = 7773;
public static final int REWARD_TOKEN = 7774;
public static final int REWARD_TOKEN_7775 = 7775;
public static final int REWARD_TOKEN_7776 = 7776;
public static final int LONG_VINE = 7777;
public static final int SHORT_VINE = 7778;
public static final int FISHING_TOME = 7779;
public static final int FISHING_TOME_7780 = 7780;
public static final int FISHING_TOME_7781 = 7781;
public static final int AGILITY_TOME = 7782;
public static final int AGILITY_TOME_7783 = 7783;
public static final int AGILITY_TOME_7784 = 7784;
public static final int THIEVING_TOME = 7785;
public static final int THIEVING_TOME_7786 = 7786;
public static final int THIEVING_TOME_7787 = 7787;
public static final int SLAYER_TOME = 7788;
public static final int SLAYER_TOME_7789 = 7789;
public static final int SLAYER_TOME_7790 = 7790;
public static final int MINING_TOME = 7791;
public static final int MINING_TOME_7792 = 7792;
public static final int MINING_TOME_7793 = 7793;
public static final int FIREMAKING_TOME = 7794;
public static final int FIREMAKING_TOME_7795 = 7795;
public static final int FIREMAKING_TOME_7796 = 7796;
public static final int WOODCUTTING_TOME = 7797;
public static final int WOODCUTTING_TOME_7798 = 7798;
public static final int WOODCUTTING_TOME_7799 = 7799;
public static final int SNAIL_SHELL = 7800;
public static final int SNAKE_HIDE_7801 = 7801;
public static final int YIN_YANG_AMULET = 7803;
public static final int ZAROS_MJOLNIR = 7804;
public static final int ANGER_SWORD = 7806;
public static final int ANGER_BATTLEAXE = 7807;
public static final int ANGER_MACE = 7808;
public static final int ANGER_SPEAR = 7809;
public static final int JUG_OF_VINEGAR = 7810;
public static final int POT_OF_VINEGAR = 7811;
public static final int GOBLIN_SKULL = 7812;
public static final int BONE_IN_VINEGAR = 7813;
public static final int GOBLIN_SKULL_7814 = 7814;
public static final int BEAR_RIBS = 7815;
public static final int BONE_IN_VINEGAR_7816 = 7816;
public static final int BEAR_RIBS_7817 = 7817;
public static final int RAM_SKULL = 7818;
public static final int BONE_IN_VINEGAR_7819 = 7819;
public static final int RAM_SKULL_7820 = 7820;
public static final int UNICORN_BONE = 7821;
public static final int BONE_IN_VINEGAR_7822 = 7822;
public static final int UNICORN_BONE_7823 = 7823;
public static final int GIANT_RAT_BONE = 7824;
public static final int BONE_IN_VINEGAR_7825 = 7825;
public static final int GIANT_RAT_BONE_7826 = 7826;
public static final int GIANT_BAT_WING = 7827;
public static final int BONE_IN_VINEGAR_7828 = 7828;
public static final int GIANT_BAT_WING_7829 = 7829;
public static final int WOLF_BONE = 7830;
public static final int BONE_IN_VINEGAR_7831 = 7831;
public static final int WOLF_BONE_7832 = 7832;
public static final int BAT_WING = 7833;
public static final int BONE_IN_VINEGAR_7834 = 7834;
public static final int BAT_WING_7835 = 7835;
public static final int RAT_BONE = 7836;
public static final int BONE_IN_VINEGAR_7837 = 7837;
public static final int RAT_BONE_7838 = 7838;
public static final int BABY_DRAGON_BONE = 7839;
public static final int BONE_IN_VINEGAR_7840 = 7840;
public static final int BABY_DRAGON_BONE_7841 = 7841;
public static final int OGRE_RIBS = 7842;
public static final int BONE_IN_VINEGAR_7843 = 7843;
public static final int OGRE_RIBS_7844 = 7844;
public static final int JOGRE_BONE = 7845;
public static final int BONE_IN_VINEGAR_7846 = 7846;
public static final int JOGRE_BONE_7847 = 7847;
public static final int ZOGRE_BONE = 7848;
public static final int BONE_IN_VINEGAR_7849 = 7849;
public static final int ZOGRE_BONE_7850 = 7850;
public static final int MOGRE_BONE = 7851;
public static final int BONE_IN_VINEGAR_7852 = 7852;
public static final int MOGRE_BONE_7853 = 7853;
public static final int MONKEY_PAW = 7854;
public static final int BONE_IN_VINEGAR_7855 = 7855;
public static final int MONKEY_PAW_7856 = 7856;
public static final int DAGANNOTH_RIBS = 7857;
public static final int BONE_IN_VINEGAR_7858 = 7858;
public static final int DAGANNOTH_RIBS_7859 = 7859;
public static final int SNAKE_SPINE = 7860;
public static final int BONE_IN_VINEGAR_7861 = 7861;
public static final int SNAKE_SPINE_7862 = 7862;
public static final int ZOMBIE_BONE = 7863;
public static final int BONE_IN_VINEGAR_7864 = 7864;
public static final int ZOMBIE_BONE_7865 = 7865;
public static final int WEREWOLF_BONE = 7866;
public static final int BONE_IN_VINEGAR_7867 = 7867;
public static final int WEREWOLF_BONE_7868 = 7868;
public static final int MOSS_GIANT_BONE = 7869;
public static final int BONE_IN_VINEGAR_7870 = 7870;
public static final int MOSS_GIANT_BONE_7871 = 7871;
public static final int FIRE_GIANT_BONE = 7872;
public static final int BONE_IN_VINEGAR_7873 = 7873;
public static final int FIRE_GIANT_BONE_7874 = 7874;
public static final int ICE_GIANT_RIBS = 7875;
public static final int BONE_IN_VINEGAR_7876 = 7876;
public static final int ICE_GIANT_RIBS_7877 = 7877;
public static final int TERRORBIRD_WING = 7878;
public static final int BONE_IN_VINEGAR_7879 = 7879;
public static final int TERRORBIRD_WING_7880 = 7880;
public static final int GHOUL_BONE = 7881;
public static final int BONE_IN_VINEGAR_7882 = 7882;
public static final int GHOUL_BONE_7883 = 7883;
public static final int TROLL_BONE = 7884;
public static final int BONE_IN_VINEGAR_7885 = 7885;
public static final int TROLL_BONE_7886 = 7886;
public static final int SEAGULL_WING = 7887;
public static final int BONE_IN_VINEGAR_7888 = 7888;
public static final int SEAGULL_WING_7889 = 7889;
public static final int UNDEAD_COW_RIBS = 7890;
public static final int BONE_IN_VINEGAR_7891 = 7891;
public static final int UNDEAD_COW_RIBS_7892 = 7892;
public static final int EXPERIMENT_BONE = 7893;
public static final int BONE_IN_VINEGAR_7894 = 7894;
public static final int EXPERIMENT_BONE_7895 = 7895;
public static final int RABBIT_BONE = 7896;
public static final int BONE_IN_VINEGAR_7897 = 7897;
public static final int RABBIT_BONE_7898 = 7898;
public static final int BASILISK_BONE = 7899;
public static final int BONE_IN_VINEGAR_7900 = 7900;
public static final int BASILISK_BONE_7901 = 7901;
public static final int DESERT_LIZARD_BONE = 7902;
public static final int BONE_IN_VINEGAR_7903 = 7903;
public static final int DESERT_LIZARD_BONE_7904 = 7904;
public static final int CAVE_GOBLIN_SKULL = 7905;
public static final int BONE_IN_VINEGAR_7906 = 7906;
public static final int CAVE_GOBLIN_SKULL_7907 = 7907;
public static final int BIG_FROG_LEG = 7908;
public static final int BONE_IN_VINEGAR_7909 = 7909;
public static final int BIG_FROG_LEG_7910 = 7910;
public static final int VULTURE_WING = 7911;
public static final int BONE_IN_VINEGAR_7912 = 7912;
public static final int VULTURE_WING_7913 = 7913;
public static final int JACKAL_BONE = 7914;
public static final int BONE_IN_VINEGAR_7915 = 7915;
public static final int JACKAL_BONE_7916 = 7916;
public static final int RAM_SKULL_HELM = 7917;
public static final int BONESACK = 7918;
public static final int BOTTLE_OF_WINE = 7919;
public static final int EMPTY_WINE_BOTTLE = 7921;
public static final int AL_KHARID_FLYER = 7922;
public static final int EASTER_RING = 7927;
public static final int EASTER_EGG_7928 = 7928;
public static final int EASTER_EGG_7929 = 7929;
public static final int EASTER_EGG_7930 = 7930;
public static final int EASTER_EGG_7931 = 7931;
public static final int EASTER_EGG_7932 = 7932;
public static final int EASTER_EGG_7933 = 7933;
public static final int FIELD_RATION = 7934;
public static final int PURE_ESSENCE = 7936;
public static final int DARK_ESSENCE_FRAGMENTS = 7938;
public static final int TORTOISE_SHELL = 7939;
public static final int IRON_SHEET = 7941;
public static final int FRESH_MONKFISH = 7942;
public static final int FRESH_MONKFISH_7943 = 7943;
public static final int RAW_MONKFISH = 7944;
public static final int MONKFISH = 7946;
public static final int BURNT_MONKFISH = 7948;
public static final int BONE_SEEDS = 7950;
public static final int HERMANS_BOOK = 7951;
public static final int AXE_HANDLE_7952 = 7952;
public static final int BURNT_SHRIMP = 7954;
public static final int CASKET_7956 = 7956;
public static final int WHITE_APRON_7957 = 7957;
public static final int MINING_PROP = 7958;
public static final int HEAVY_BOX = 7959;
public static final int EMPTY_BOX = 7960;
public static final int BURNT_DIARY = 7961;
public static final int BURNT_DIARY_7962 = 7962;
public static final int BURNT_DIARY_7963 = 7963;
public static final int BURNT_DIARY_7964 = 7964;
public static final int BURNT_DIARY_7965 = 7965;
public static final int LETTER_7966 = 7966;
public static final int ENGINE = 7967;
public static final int SCROLL_7968 = 7968;
public static final int PULLEY_BEAM = 7969;
public static final int LONG_PULLEY_BEAM = 7970;
public static final int LONGER_PULLEY_BEAM = 7971;
public static final int LIFT_MANUAL = 7972;
public static final int BEAM = 7973;
public static final int SERVANT_BELL = 7974;
public static final int CRAWLING_HAND_7975 = 7975;
public static final int COCKATRICE_HEAD = 7976;
public static final int BASILISK_HEAD = 7977;
public static final int KURASK_HEAD = 7978;
public static final int ABYSSAL_HEAD = 7979;
public static final int KBD_HEADS = 7980;
public static final int KQ_HEAD = 7981;
public static final int STUFFED_CRAWLING_HAND = 7982;
public static final int STUFFED_COCKATRICE_HEAD = 7983;
public static final int STUFFED_BASILISK_HEAD = 7984;
public static final int STUFFED_KURASK_HEAD = 7985;
public static final int STUFFED_ABYSSAL_HEAD = 7986;
public static final int STUFFED_KBD_HEADS = 7987;
public static final int STUFFED_KQ_HEAD = 7988;
public static final int BIG_BASS = 7989;
public static final int STUFFED_BIG_BASS = 7990;
public static final int BIG_SWORDFISH = 7991;
public static final int STUFFED_BIG_SWORDFISH = 7992;
public static final int BIG_SHARK = 7993;
public static final int STUFFED_BIG_SHARK = 7994;
public static final int ARTHUR_PORTRAIT = 7995;
public static final int ELENA_PORTRAIT = 7996;
public static final int KELDAGRIM_PORTRAIT = 7997;
public static final int MISC_PORTRAIT = 7998;
public static final int DESERT_PAINTING = 7999;
public static final int ISAFDAR_PAINTING = 8000;
public static final int KARAMJA_PAINTING = 8001;
public static final int LUMBRIDGE_PAINTING = 8002;
public static final int MORYTANIA_PAINTING = 8003;
public static final int SMALL_MAP = 8004;
public static final int MEDIUM_MAP = 8005;
public static final int LARGE_MAP = 8006;
public static final int VARROCK_TELEPORT = 8007;
public static final int LUMBRIDGE_TELEPORT = 8008;
public static final int FALADOR_TELEPORT = 8009;
public static final int CAMELOT_TELEPORT = 8010;
public static final int ARDOUGNE_TELEPORT = 8011;
public static final int WATCHTOWER_TELEPORT = 8012;
public static final int TELEPORT_TO_HOUSE = 8013;
public static final int BONES_TO_BANANAS = 8014;
public static final int BONES_TO_PEACHES_8015 = 8015;
public static final int ENCHANT_SAPPHIRE_OR_OPAL = 8016;
public static final int ENCHANT_EMERALD_OR_JADE = 8017;
public static final int ENCHANT_RUBY_OR_TOPAZ = 8018;
public static final int ENCHANT_DIAMOND = 8019;
public static final int ENCHANT_DRAGONSTONE = 8020;
public static final int ENCHANT_ONYX = 8021;
public static final int TELEKINETIC_GRAB = 8022;
public static final int BOXING_RING = 8023;
public static final int FENCING_RING = 8024;
public static final int COMBAT_RING = 8025;
public static final int RANGING_PEDESTALS = 8026;
public static final int BALANCE_BEAM = 8027;
public static final int GLOVE_RACK = 8028;
public static final int WEAPONS_RACK = 8029;
public static final int EXTRA_WEAPONS_RACK = 8030;
public static final int WOODEN_BED = 8031;
public static final int OAK_BED = 8032;
public static final int LARGE_OAK_BED = 8033;
public static final int TEAK_BED = 8034;
public static final int LARGE_TEAK_BED = 8035;
public static final int _4POSTER = 8036;
public static final int GILDED_4POSTER = 8037;
public static final int SHOE_BOX = 8038;
public static final int OAK_DRAWERS = 8039;
public static final int OAK_WARDROBE = 8040;
public static final int TEAK_DRAWERS = 8041;
public static final int TEAK_WARDROBE = 8042;
public static final int MAHOGANY_WARDROBE = 8043;
public static final int GILDED_WARDROBE = 8044;
public static final int SHAVING_STAND = 8045;
public static final int OAK_SHAVING_STAND = 8046;
public static final int OAK_DRESSER = 8047;
public static final int TEAK_DRESSER = 8048;
public static final int FANCY_TEAK_DRESSER = 8049;
public static final int MAHOGANY_DRESSER = 8050;
public static final int GILDED_DRESSER = 8051;
public static final int OAK_CLOCK = 8052;
public static final int TEAK_CLOCK = 8053;
public static final int GILDED_CLOCK = 8054;
public static final int SARADOMIN_SYMBOL = 8055;
public static final int ZAMORAK_SYMBOL = 8056;
public static final int GUTHIX_SYMBOL = 8057;
public static final int SARADOMIN_ICON = 8058;
public static final int ZAMORAK_ICON = 8059;
public static final int GUTHIX_ICON = 8060;
public static final int ICON_OF_BOB = 8061;
public static final int OAK_ALTAR = 8062;
public static final int TEAK_ALTAR = 8063;
public static final int CLOTHCOVERED_ALTAR = 8064;
public static final int MAHOGANY_ALTAR = 8065;
public static final int LIMESTONE_ALTAR = 8066;
public static final int MARBLE_ALTAR = 8067;
public static final int GILDED_ALTAR = 8068;
public static final int WOODEN_TORCHES = 8069;
public static final int STEEL_TORCHES = 8070;
public static final int STEEL_CANDLESTICKS = 8071;
public static final int GOLD_CANDLESTICKS = 8072;
public static final int INCENSE_BURNERS = 8073;
public static final int MAHOGANY_BURNERS = 8074;
public static final int MARBLE_BURNERS = 8075;
public static final int SHUTTERED_WINDOW = 8076;
public static final int DECORATIVE_WINDOW = 8077;
public static final int STAINED_GLASS = 8078;
public static final int WINDCHIMES = 8079;
public static final int BELLS = 8080;
public static final int ORGAN = 8081;
public static final int SMALL_STATUES = 8082;
public static final int MEDIUM_STATUES = 8083;
public static final int LARGE_STATUES = 8084;
public static final int SUIT_OF_ARMOUR = 8085;
public static final int SMALL_PORTRAIT = 8086;
public static final int MINOR_HEAD = 8087;
public static final int MEDIUM_HEAD = 8088;
public static final int MAJOR_HEAD = 8089;
public static final int MOUNTED_SWORD = 8090;
public static final int SMALL_LANDSCAPE = 8091;
public static final int LARGE_PORTRAIT = 8093;
public static final int LARGE_LANDSCAPE = 8094;
public static final int RUNE_DISPLAY_CASE = 8095;
public static final int LOWLEVEL_PLANTS = 8096;
public static final int MIDLEVEL_PLANTS = 8097;
public static final int HIGHLEVEL_PLANTS = 8098;
public static final int ROPE_BELLPULL = 8099;
public static final int BELLPULL = 8100;
public static final int POSH_BELLPULL = 8101;
public static final int OAK_DECORATION = 8102;
public static final int TEAK_DECORATION = 8103;
public static final int GILDED_DECORATION = 8104;
public static final int ROUND_SHIELD = 8105;
public static final int SQUARE_SHIELD = 8106;
public static final int KITE_SHIELD = 8107;
public static final int WOODEN_BENCH = 8108;
public static final int OAK_BENCH = 8109;
public static final int CARVED_OAK_BENCH = 8110;
public static final int TEAK_DINING_BENCH = 8111;
public static final int CARVED_TEAK_BENCH = 8112;
public static final int MAHOGANY_BENCH = 8113;
public static final int GILDED_BENCH = 8114;
public static final int WOOD_DINING_TABLE = 8115;
public static final int OAK_DINING_TABLE = 8116;
public static final int CARVED_OAK_TABLE = 8117;
public static final int TEAK_TABLE = 8118;
public static final int CARVED_TEAK_TABLE = 8119;
public static final int MAHOGANY_TABLE = 8120;
public static final int OPULENT_TABLE = 8121;
public static final int OAK_DOOR = 8122;
public static final int STEELPLATED_DOOR = 8123;
public static final int MARBLE_DOOR = 8124;
public static final int DECORATIVE_BLOOD = 8125;
public static final int DECORATIVE_PIPE = 8126;
public static final int HANGING_SKELETON = 8127;
public static final int CANDLES = 8128;
public static final int TORCHES = 8129;
public static final int SKULL_TORCHES = 8130;
public static final int SKELETON_GUARD = 8131;
public static final int GUARD_DOG = 8132;
public static final int HOBGOBLIN_GUARD = 8133;
public static final int BABY_RED_DRAGON = 8134;
public static final int HUGE_SPIDER = 8135;
public static final int TROLL_GUARD = 8136;
public static final int HELLHOUND = 8137;
public static final int DEMON = 8138;
public static final int KALPHITE_SOLDIER = 8139;
public static final int TOKXIL = 8140;
public static final int DAGANNOTH = 8141;
public static final int STEEL_DRAGON = 8142;
public static final int SPIKE_TRAP = 8143;
public static final int MAN_TRAP = 8144;
public static final int TANGLE_VINE = 8145;
public static final int MARBLE_TRAP = 8146;
public static final int TELEPORT_TRAP = 8147;
public static final int WOODEN_CRATE = 8148;
public static final int OAK_CHEST = 8149;
public static final int TEAK_CHEST = 8150;
public static final int MAHOGANY_CHEST = 8151;
public static final int MAGIC_CHEST = 8152;
public static final int CLAY_ATTACK_STONE = 8153;
public static final int ATTACK_STONE = 8154;
public static final int MARBLE_ATT_STONE = 8155;
public static final int MAGICAL_BALANCE_1 = 8156;
public static final int MAGICAL_BALANCE_2 = 8157;
public static final int MAGICAL_BALANCE_3 = 8158;
public static final int JESTER = 8159;
public static final int TREASURE_HUNT = 8160;
public static final int HANGMAN_GAME = 8161;
public static final int HOOP_AND_STICK = 8162;
public static final int DARTBOARD = 8163;
public static final int ARCHERY_TARGET = 8164;
public static final int OAK_PRIZE_CHEST = 8165;
public static final int TEAK_PRIZE_CHEST = 8166;
public static final int MAHOGANY_CHEST_8167 = 8167;
public static final int EXIT_PORTAL = 8168;
public static final int DECORATIVE_ROCK = 8169;
public static final int POND = 8170;
public static final int IMP_STATUE = 8171;
public static final int DUNGEON_ENTRANCE = 8172;
public static final int TREE = 8173;
public static final int NICE_TREE = 8174;
public static final int OAK_TREE = 8175;
public static final int WILLOW_TREE = 8176;
public static final int MAPLE_TREE = 8177;
public static final int YEW_TREE = 8178;
public static final int MAGIC_TREE = 8179;
public static final int PLANT = 8180;
public static final int SMALL_FERN = 8181;
public static final int FERN = 8182;
public static final int DOCK_LEAF = 8183;
public static final int THISTLE = 8184;
public static final int REEDS = 8185;
public static final int FERN_8186 = 8186;
public static final int BUSH = 8187;
public static final int TALL_PLANT = 8188;
public static final int SHORT_PLANT = 8189;
public static final int LARGELEAF_PLANT = 8190;
public static final int HUGE_PLANT = 8191;
public static final int GAZEBO = 8192;
public static final int SMALL_FOUNTAIN = 8193;
public static final int LARGE_FOUNTAIN = 8194;
public static final int POSH_FOUNTAIN = 8195;
public static final int BOUNDARY_STONES = 8196;
public static final int WOODEN_FENCE = 8197;
public static final int STONE_WALL = 8198;
public static final int IRON_RAILINGS = 8199;
public static final int PICKET_FENCE = 8200;
public static final int GARDEN_FENCE = 8201;
public static final int MARBLE_WALL = 8202;
public static final int THORNY_HEDGE = 8203;
public static final int NICE_HEDGE = 8204;
public static final int SMALL_BOX_HEDGE = 8205;
public static final int TOPIARY_HEDGE = 8206;
public static final int FANCY_HEDGE = 8207;
public static final int TALL_FANCY_HEDGE = 8208;
public static final int TALL_BOX_HEDGE = 8209;
public static final int ROSEMARY_8210 = 8210;
public static final int DAFFODILS = 8211;
public static final int BLUEBELLS = 8212;
public static final int SUNFLOWER = 8213;
public static final int MARIGOLDS_8214 = 8214;
public static final int ROSES = 8215;
public static final int FIREPIT = 8216;
public static final int FIREPIT_WITH_HOOK = 8217;
public static final int FIREPIT_WITH_POT = 8218;
public static final int SMALL_OVEN = 8219;
public static final int LARGE_OVEN = 8220;
public static final int STEEL_RANGE = 8221;
public static final int FANCY_RANGE = 8222;
public static final int WOODEN_SHELVES_1 = 8223;
public static final int WOODEN_SHELVES_2 = 8224;
public static final int WOODEN_SHELVES_3 = 8225;
public static final int OAK_SHELVES_1 = 8226;
public static final int OAK_SHELVES_2 = 8227;
public static final int TEAK_SHELVES_1 = 8228;
public static final int TEAK_SHELVES_2 = 8229;
public static final int PUMP_AND_DRAIN = 8230;
public static final int PUMP_AND_TUB = 8231;
public static final int SINK = 8232;
public static final int WOODEN_LARDER = 8233;
public static final int OAK_LARDER = 8234;
public static final int TEAK_LARDER = 8235;
public static final int CAT_BLANKET = 8236;
public static final int CAT_BASKET = 8237;
public static final int CUSHIONED_BASKET = 8238;
public static final int BEER_BARREL = 8239;
public static final int CIDER_BARREL = 8240;
public static final int ASGARNIAN_ALE_8241 = 8241;
public static final int GREENMANS_ALE_8242 = 8242;
public static final int DRAGON_BITTER_8243 = 8243;
public static final int CHEFS_DELIGHT_8244 = 8244;
public static final int WOOD_KITCHEN_TABLE = 8246;
public static final int OAK_KITCHEN_TABLE = 8247;
public static final int TEAK_KITCHEN_TABLE = 8248;
public static final int OAK_STAIRCASE = 8249;
public static final int OAK_STAIRCASE_8250 = 8250;
public static final int OAK_STAIRCASE_8251 = 8251;
public static final int TEAK_STAIRCASE = 8252;
public static final int TEAK_STAIRCASE_8253 = 8253;
public static final int TEAK_STAIRCASE_8254 = 8254;
public static final int MARBLE_STAIRCASE = 8255;
public static final int MARBLE_STAIRCASE_8256 = 8256;
public static final int MARBLE_STAIRCASE_8257 = 8257;
public static final int SPIRAL_STAIRCASE = 8258;
public static final int MARBLE_SPIRAL = 8259;
public static final int CRAWLING_HAND_8260 = 8260;
public static final int COCKATRICE_HEAD_8261 = 8261;
public static final int BASILISK_HEAD_8262 = 8262;
public static final int KURASK_HEAD_8263 = 8263;
public static final int ABYSSAL_HEAD_8264 = 8264;
public static final int KBD_HEADS_8265 = 8265;
public static final int KQ_HEAD_8266 = 8266;
public static final int MOUNTED_BASS = 8267;
public static final int MOUNTED_SWORDFISH = 8268;
public static final int MOUNTED_SHARK = 8269;
public static final int MITHRIL_ARMOUR = 8270;
public static final int ADAMANTITE_ARMOUR = 8271;
public static final int RUNITE_ARMOUR = 8272;
public static final int CW_ARMOUR_1 = 8273;
public static final int CW_ARMOUR_2 = 8274;
public static final int CW_ARMOUR_3 = 8275;
public static final int RUNE_CASE_1 = 8276;
public static final int RUNE_CASE_2 = 8277;
public static final int RUNE_CASE_3 = 8278;
public static final int SILVERLIGHT_8279 = 8279;
public static final int EXCALIBUR_8280 = 8280;
public static final int DARKLIGHT_8281 = 8281;
public static final int ANTIDRAGON_SHIELD_8282 = 8282;
public static final int AMULET_OF_GLORY_8283 = 8283;
public static final int CAPE_OF_LEGENDS_8284 = 8284;
public static final int KING_ARTHUR = 8285;
public static final int ELENA = 8286;
public static final int GIANT_DWARF = 8287;
public static final int MISCELLANIANS = 8288;
public static final int LUMBRIDGE = 8289;
public static final int THE_DESERT = 8290;
public static final int MORYTANIA = 8291;
public static final int KARAMJA = 8292;
public static final int ISAFDAR = 8293;
public static final int SMALL_MAP_8294 = 8294;
public static final int MEDIUM_MAP_8295 = 8295;
public static final int LARGE_MAP_8296 = 8296;
public static final int OAK_CAGE = 8297;
public static final int OAK_AND_STEEL_CAGE = 8298;
public static final int STEEL_CAGE = 8299;
public static final int SPIKED_CAGE = 8300;
public static final int BONE_CAGE = 8301;
public static final int SPIKES = 8302;
public static final int TENTACLE_POOL = 8303;
public static final int FLAME_PIT = 8304;
public static final int ROCNAR = 8305;
public static final int OAK_LADDER = 8306;
public static final int TEAK_LADDER = 8307;
public static final int MAHOGANY_LADDER = 8308;
public static final int CRUDE_WOODEN_CHAIR = 8309;
public static final int WOODEN_CHAIR = 8310;
public static final int ROCKING_CHAIR = 8311;
public static final int OAK_CHAIR = 8312;
public static final int OAK_ARMCHAIR = 8313;
public static final int TEAK_ARMCHAIR = 8314;
public static final int MAHOGANY_ARMCHAIR = 8315;
public static final int BROWN_RUG = 8316;
public static final int RUG = 8317;
public static final int OPULENT_RUG = 8318;
public static final int WOODEN_BOOKCASE = 8319;
public static final int OAK_BOOKCASE = 8320;
public static final int MAHOGANY_BOOKCASE = 8321;
public static final int TORN_CURTAINS = 8322;
public static final int CURTAINS = 8323;
public static final int OPULENT_CURTAINS = 8324;
public static final int CLAY_FIREPLACE = 8325;
public static final int STONE_FIREPLACE = 8326;
public static final int MARBLE_FIREPLACE = 8327;
public static final int TEAK_PORTAL = 8328;
public static final int MAHOGANY_PORTAL = 8329;
public static final int MARBLE_PORTAL = 8330;
public static final int TELEPORT_FOCUS = 8331;
public static final int GREATER_FOCUS = 8332;
public static final int SCRYING_POOL = 8333;
public static final int OAK_LECTERN = 8334;
public static final int EAGLE_LECTERN = 8335;
public static final int DEMON_LECTERN = 8336;
public static final int TEAK_EAGLE_LECTERN = 8337;
public static final int TEAK_DEMON_LECTERN = 8338;
public static final int MAHOGANY_EAGLE = 8339;
public static final int MAHOGANY_DEMON = 8340;
public static final int GLOBE = 8341;
public static final int ORNAMENTAL_GLOBE = 8342;
public static final int LUNAR_GLOBE = 8343;
public static final int CELESTIAL_GLOBE = 8344;
public static final int ARMILLARY_SPHERE = 8345;
public static final int SMALL_ORRERY = 8346;
public static final int LARGE_ORRERY = 8347;
public static final int WOODEN_TELESCOPE = 8348;
public static final int TEAK_TELESCOPE = 8349;
public static final int MAHOGANY_TELESCOPE = 8350;
public static final int CRYSTAL_BALL = 8351;
public static final int ELEMENTAL_SPHERE = 8352;
public static final int CRYSTAL_OF_POWER = 8353;
public static final int ALCHEMICAL_CHART = 8354;
public static final int ASTRONOMICAL_CHART = 8355;
public static final int INFERNAL_CHART = 8356;
public static final int OAK_THRONE = 8357;
public static final int TEAK_THRONE = 8358;
public static final int MAHOGANY_THRONE = 8359;
public static final int GILDED_THRONE = 8360;
public static final int SKELETON_THRONE = 8361;
public static final int CRYSTAL_THRONE = 8362;
public static final int DEMONIC_THRONE = 8363;
public static final int OAK_LEVER = 8364;
public static final int TEAK_LEVER = 8365;
public static final int MAHOGANY_LEVER = 8366;
public static final int TRAPDOOR = 8367;
public static final int TRAPDOOR_8368 = 8368;
public static final int TRAPDOOR_8369 = 8369;
public static final int FLOOR_DECORATION = 8370;
public static final int STEEL_CAGE_8371 = 8371;
public static final int TRAPDOOR_8372 = 8372;
public static final int LESSER_MAGIC_CAGE = 8373;
public static final int GREATER_MAGIC_CAGE = 8374;
public static final int WOODEN_WORKBENCH = 8375;
public static final int OAK_WORKBENCH = 8376;
public static final int STEEL_FRAMED_BENCH = 8377;
public static final int BENCH_WITH_VICE = 8378;
public static final int BENCH_WITH_LATHE = 8379;
public static final int CRAFTING_TABLE_1 = 8380;
public static final int CRAFTING_TABLE_2 = 8381;
public static final int CRAFTING_TABLE_3 = 8382;
public static final int CRAFTING_TABLE_4 = 8383;
public static final int TOOL_STORE_1 = 8384;
public static final int TOOL_STORE_2 = 8385;
public static final int TOOL_STORE_3 = 8386;
public static final int TOOL_STORE_4 = 8387;
public static final int TOOL_STORE_5 = 8388;
public static final int REPAIR_BENCH = 8389;
public static final int WHETSTONE = 8390;
public static final int ARMOUR_STAND = 8391;
public static final int PLUMING_STAND = 8392;
public static final int SHIELD_EASEL = 8393;
public static final int BANNER_EASEL = 8394;
public static final int PARLOUR = 8395;
public static final int KITCHEN = 8396;
public static final int DINING_ROOM = 8397;
public static final int BEDROOM = 8398;
public static final int GAMES_ROOM = 8399;
public static final int COMBAT_ROOM = 8400;
public static final int HALL = 8401;
public static final int HALL_8402 = 8402;
public static final int HALL_8403 = 8403;
public static final int HALL_8404 = 8404;
public static final int CHAPEL = 8405;
public static final int WORKSHOP = 8406;
public static final int STUDY = 8407;
public static final int PORTAL_CHAMBER = 8408;
public static final int THRONE_ROOM = 8409;
public static final int OUBLIETTE = 8410;
public static final int DUNGEON_CORRIDOR = 8411;
public static final int DUNGEON_CROSS = 8412;
public static final int DUNGEON_STAIRS = 8413;
public static final int TREASURE_ROOM = 8414;
public static final int GARDEN = 8415;
public static final int FORMAL_GARDEN = 8416;
public static final int BAGGED_DEAD_TREE = 8417;
public static final int BAGGED_NICE_TREE = 8419;
public static final int BAGGED_OAK_TREE = 8421;
public static final int BAGGED_WILLOW_TREE = 8423;
public static final int BAGGED_MAPLE_TREE = 8425;
public static final int BAGGED_YEW_TREE = 8427;
public static final int BAGGED_MAGIC_TREE = 8429;
public static final int BAGGED_PLANT_1 = 8431;
public static final int BAGGED_PLANT_2 = 8433;
public static final int BAGGED_PLANT_3 = 8435;
public static final int THORNY_HEDGE_8437 = 8437;
public static final int NICE_HEDGE_8439 = 8439;
public static final int SMALL_BOX_HEDGE_8441 = 8441;
public static final int TOPIARY_HEDGE_8443 = 8443;
public static final int FANCY_HEDGE_8445 = 8445;
public static final int TALL_FANCY_HEDGE_8447 = 8447;
public static final int TALL_BOX_HEDGE_8449 = 8449;
public static final int BAGGED_FLOWER = 8451;
public static final int BAGGED_DAFFODILS = 8453;
public static final int BAGGED_BLUEBELLS = 8455;
public static final int BAGGED_SUNFLOWER = 8457;
public static final int BAGGED_MARIGOLDS = 8459;
public static final int BAGGED_ROSES = 8461;
public static final int CONSTRUCTION_GUIDE = 8463;
public static final int RUNE_HERALDIC_HELM = 8464;
public static final int RUNE_HERALDIC_HELM_8466 = 8466;
public static final int RUNE_HERALDIC_HELM_8468 = 8468;
public static final int RUNE_HERALDIC_HELM_8470 = 8470;
public static final int RUNE_HERALDIC_HELM_8472 = 8472;
public static final int RUNE_HERALDIC_HELM_8474 = 8474;
public static final int RUNE_HERALDIC_HELM_8476 = 8476;
public static final int RUNE_HERALDIC_HELM_8478 = 8478;
public static final int RUNE_HERALDIC_HELM_8480 = 8480;
public static final int RUNE_HERALDIC_HELM_8482 = 8482;
public static final int RUNE_HERALDIC_HELM_8484 = 8484;
public static final int RUNE_HERALDIC_HELM_8486 = 8486;
public static final int RUNE_HERALDIC_HELM_8488 = 8488;
public static final int RUNE_HERALDIC_HELM_8490 = 8490;
public static final int RUNE_HERALDIC_HELM_8492 = 8492;
public static final int RUNE_HERALDIC_HELM_8494 = 8494;
public static final int CRUDE_CHAIR = 8496;
public static final int WOODEN_CHAIR_8498 = 8498;
public static final int ROCKING_CHAIR_8500 = 8500;
public static final int OAK_CHAIR_8502 = 8502;
public static final int OAK_ARMCHAIR_8504 = 8504;
public static final int TEAK_ARMCHAIR_8506 = 8506;
public static final int MAHOGANY_ARMCHAIR_8508 = 8508;
public static final int BOOKCASE = 8510;
public static final int OAK_BOOKCASE_8512 = 8512;
public static final int MAHOGANY_BOOKCASE_8514 = 8514;
public static final int BEER_BARREL_8516 = 8516;
public static final int CIDER_BARREL_8518 = 8518;
public static final int ASGARNIAN_ALE_8520 = 8520;
public static final int GREENMANS_ALE_8522 = 8522;
public static final int DRAGON_BITTER_8524 = 8524;
public static final int CHEFS_DELIGHT_8526 = 8526;
public static final int KITCHEN_TABLE = 8528;
public static final int OAK_KITCHEN_TABLE_8530 = 8530;
public static final int TEAK_KITCHEN_TABLE_8532 = 8532;
public static final int OAK_LECTERN_8534 = 8534;
public static final int EAGLE_LECTERN_8536 = 8536;
public static final int DEMON_LECTERN_8538 = 8538;
public static final int TEAK_EAGLE_LECTERN_8540 = 8540;
public static final int TEAK_DEMON_LECTERN_8542 = 8542;
public static final int MAHOGANY_EAGLE_8544 = 8544;
public static final int MAHOGANY_DEMON_8546 = 8546;
public static final int WOOD_DINING_TABLE_8548 = 8548;
public static final int OAK_DINING_TABLE_8550 = 8550;
public static final int CARVED_OAK_TABLE_8552 = 8552;
public static final int TEAK_TABLE_8554 = 8554;
public static final int CARVED_TEAK_TABLE_8556 = 8556;
public static final int MAHOGANY_TABLE_8558 = 8558;
public static final int OPULENT_TABLE_8560 = 8560;
public static final int WOODEN_BENCH_8562 = 8562;
public static final int OAK_BENCH_8564 = 8564;
public static final int CARVED_OAK_BENCH_8566 = 8566;
public static final int TEAK_DINING_BENCH_8568 = 8568;
public static final int CARVED_TEAK_BENCH_8570 = 8570;
public static final int MAHOGANY_BENCH_8572 = 8572;
public static final int GILDED_BENCH_8574 = 8574;
public static final int WOODEN_BED_8576 = 8576;
public static final int OAK_BED_8578 = 8578;
public static final int LARGE_OAK_BED_8580 = 8580;
public static final int TEAK_BED_8582 = 8582;
public static final int LARGE_TEAK_BED_8584 = 8584;
public static final int FOURPOSTER_BED = 8586;
public static final int GILDED_FOURPOSTER = 8588;
public static final int OAK_CLOCK_8590 = 8590;
public static final int TEAK_CLOCK_8592 = 8592;
public static final int GILDED_CLOCK_8594 = 8594;
public static final int SHAVING_STAND_8596 = 8596;
public static final int OAK_SHAVING_STAND_8598 = 8598;
public static final int OAK_DRESSER_8600 = 8600;
public static final int TEAK_DRESSER_8602 = 8602;
public static final int FANCY_TEAK_DRESSER_8604 = 8604;
public static final int MAHOGANY_DRESSER_8606 = 8606;
public static final int GILDED_DRESSER_8608 = 8608;
public static final int SHOE_BOX_8610 = 8610;
public static final int OAK_DRAWERS_8612 = 8612;
public static final int OAK_WARDROBE_8614 = 8614;
public static final int TEAK_DRAWERS_8616 = 8616;
public static final int TEAK_WARDROBE_8618 = 8618;
public static final int MAHOGANY_WARDROBE_8620 = 8620;
public static final int GILDED_WARDROBE_8622 = 8622;
public static final int CRYSTAL_BALL_8624 = 8624;
public static final int ELEMENTAL_SPHERE_8626 = 8626;
public static final int CRYSTAL_OF_POWER_8628 = 8628;
public static final int GLOBE_8630 = 8630;
public static final int ORNAMENTAL_GLOBE_8632 = 8632;
public static final int LUNAR_GLOBE_8634 = 8634;
public static final int CELESTIAL_GLOBE_8636 = 8636;
public static final int ARMILLARY_SPHERE_8638 = 8638;
public static final int SMALL_ORRERY_8640 = 8640;
public static final int LARGE_ORRERY_8642 = 8642;
public static final int WOODEN_TELESCOPE_8644 = 8644;
public static final int TEAK_TELESCOPE_8646 = 8646;
public static final int MAHOGANY_TELESCOPE_8648 = 8648;
public static final int BANNER = 8650;
public static final int BANNER_8652 = 8652;
public static final int BANNER_8654 = 8654;
public static final int BANNER_8656 = 8656;
public static final int BANNER_8658 = 8658;
public static final int BANNER_8660 = 8660;
public static final int BANNER_8662 = 8662;
public static final int BANNER_8664 = 8664;
public static final int BANNER_8666 = 8666;
public static final int BANNER_8668 = 8668;
public static final int BANNER_8670 = 8670;
public static final int BANNER_8672 = 8672;
public static final int BANNER_8674 = 8674;
public static final int BANNER_8676 = 8676;
public static final int BANNER_8678 = 8678;
public static final int BANNER_8680 = 8680;
public static final int STEEL_HERALDIC_HELM = 8682;
public static final int STEEL_HERALDIC_HELM_8684 = 8684;
public static final int STEEL_HERALDIC_HELM_8686 = 8686;
public static final int STEEL_HERALDIC_HELM_8688 = 8688;
public static final int STEEL_HERALDIC_HELM_8690 = 8690;
public static final int STEEL_HERALDIC_HELM_8692 = 8692;
public static final int STEEL_HERALDIC_HELM_8694 = 8694;
public static final int STEEL_HERALDIC_HELM_8696 = 8696;
public static final int STEEL_HERALDIC_HELM_8698 = 8698;
public static final int STEEL_HERALDIC_HELM_8700 = 8700;
public static final int STEEL_HERALDIC_HELM_8702 = 8702;
public static final int STEEL_HERALDIC_HELM_8704 = 8704;
public static final int STEEL_HERALDIC_HELM_8706 = 8706;
public static final int STEEL_HERALDIC_HELM_8708 = 8708;
public static final int STEEL_HERALDIC_HELM_8710 = 8710;
public static final int STEEL_HERALDIC_HELM_8712 = 8712;
public static final int RUNE_KITESHIELD_8714 = 8714;
public static final int RUNE_KITESHIELD_8716 = 8716;
public static final int RUNE_KITESHIELD_8718 = 8718;
public static final int RUNE_KITESHIELD_8720 = 8720;
public static final int RUNE_KITESHIELD_8722 = 8722;
public static final int RUNE_KITESHIELD_8724 = 8724;
public static final int RUNE_KITESHIELD_8726 = 8726;
public static final int RUNE_KITESHIELD_8728 = 8728;
public static final int RUNE_KITESHIELD_8730 = 8730;
public static final int RUNE_KITESHIELD_8732 = 8732;
public static final int RUNE_KITESHIELD_8734 = 8734;
public static final int RUNE_KITESHIELD_8736 = 8736;
public static final int RUNE_KITESHIELD_8738 = 8738;
public static final int RUNE_KITESHIELD_8740 = 8740;
public static final int RUNE_KITESHIELD_8742 = 8742;
public static final int RUNE_KITESHIELD_8744 = 8744;
public static final int STEEL_KITESHIELD_8746 = 8746;
public static final int STEEL_KITESHIELD_8748 = 8748;
public static final int STEEL_KITESHIELD_8750 = 8750;
public static final int STEEL_KITESHIELD_8752 = 8752;
public static final int STEEL_KITESHIELD_8754 = 8754;
public static final int STEEL_KITESHIELD_8756 = 8756;
public static final int STEEL_KITESHIELD_8758 = 8758;
public static final int STEEL_KITESHIELD_8760 = 8760;
public static final int STEEL_KITESHIELD_8762 = 8762;
public static final int STEEL_KITESHIELD_8764 = 8764;
public static final int STEEL_KITESHIELD_8766 = 8766;
public static final int STEEL_KITESHIELD_8768 = 8768;
public static final int STEEL_KITESHIELD_8770 = 8770;
public static final int STEEL_KITESHIELD_8772 = 8772;
public static final int STEEL_KITESHIELD_8774 = 8774;
public static final int STEEL_KITESHIELD_8776 = 8776;
public static final int OAK_PLANK = 8778;
public static final int TEAK_PLANK = 8780;
public static final int MAHOGANY_PLANK = 8782;
public static final int GOLD_LEAF_8784 = 8784;
public static final int MARBLE_BLOCK = 8786;
public static final int MAGIC_STONE_8788 = 8788;
public static final int BOLT_OF_CLOTH = 8790;
public static final int CLOCKWORK = 8792;
public static final int SAW = 8794;
public static final int TIMBER_BEAM = 8837;
public static final int VOID_KNIGHT_TOP = 8839;
public static final int VOID_KNIGHT_ROBE = 8840;
public static final int VOID_KNIGHT_MACE = 8841;
public static final int VOID_KNIGHT_GLOVES = 8842;
public static final int BRONZE_DEFENDER = 8844;
public static final int IRON_DEFENDER = 8845;
public static final int STEEL_DEFENDER = 8846;
public static final int BLACK_DEFENDER = 8847;
public static final int MITHRIL_DEFENDER = 8848;
public static final int ADAMANT_DEFENDER = 8849;
public static final int RUNE_DEFENDER = 8850;
public static final int WARRIOR_GUILD_TOKEN = 8851;
public static final int DEFENSIVE_SHIELD = 8856;
public static final int SHOT = 8857;
public static final int _18LB_SHOT = 8858;
public static final int _22LB_SHOT = 8859;
public static final int ONE_BARREL = 8860;
public static final int TWO_BARRELS = 8861;
public static final int THREE_BARRELS = 8862;
public static final int FOUR_BARRELS = 8863;
public static final int FIVE_BARRELS = 8864;
public static final int GROUND_ASHES = 8865;
public static final int STEEL_KEY = 8866;
public static final int BRONZE_KEY_8867 = 8867;
public static final int SILVER_KEY = 8868;
public static final int IRON_KEY_8869 = 8869;
public static final int ZANIK = 8870;
public static final int CRATE_WITH_ZANIK = 8871;
public static final int BONE_DAGGER = 8872;
public static final int BONE_DAGGER_P = 8874;
public static final int BONE_DAGGER_P_8876 = 8876;
public static final int BONE_DAGGER_P_8878 = 8878;
public static final int DORGESHUUN_CROSSBOW = 8880;
public static final int BONE_BOLTS = 8882;
public static final int ZANIK_8887 = 8887;
public static final int ZANIK_HAM = 8888;
public static final int ZANIK_SHOWDOWN = 8889;
public static final int COINS_8890 = 8890;
public static final int CAVE_HORROR = 8900;
public static final int BLACK_MASK_10 = 8901;
public static final int BLACK_MASK_9 = 8903;
public static final int BLACK_MASK_8 = 8905;
public static final int BLACK_MASK_7 = 8907;
public static final int BLACK_MASK_6 = 8909;
public static final int BLACK_MASK_5 = 8911;
public static final int BLACK_MASK_4 = 8913;
public static final int BLACK_MASK_3 = 8915;
public static final int BLACK_MASK_2 = 8917;
public static final int BLACK_MASK_1 = 8919;
public static final int BLACK_MASK = 8921;
public static final int WITCHWOOD_ICON = 8923;
public static final int BANDANA_EYEPATCH = 8924;
public static final int BANDANA_EYEPATCH_8925 = 8925;
public static final int BANDANA_EYEPATCH_8926 = 8926;
public static final int BANDANA_EYEPATCH_8927 = 8927;
public static final int HAT_EYEPATCH = 8928;
public static final int CRABCLAW_HOOK = 8929;
public static final int PIPE_SECTION = 8930;
public static final int LUMBER_PATCH = 8932;
public static final int SCRAPEY_TREE_LOGS = 8934;
public static final int BLUE_FLOWERS_8936 = 8936;
public static final int RED_FLOWERS_8938 = 8938;
public static final int RUM = 8940;
public static final int RUM_8941 = 8941;
public static final int MONKEY_8942 = 8942;
public static final int BLUE_MONKEY = 8943;
public static final int BLUE_MONKEY_8944 = 8944;
public static final int BLUE_MONKEY_8945 = 8945;
public static final int RED_MONKEY = 8946;
public static final int RED_MONKEY_8947 = 8947;
public static final int RED_MONKEY_8948 = 8948;
public static final int PIRATE_BANDANA_8949 = 8949;
public static final int PIRATE_HAT = 8950;
public static final int PIECES_OF_EIGHT = 8951;
public static final int BLUE_NAVAL_SHIRT = 8952;
public static final int GREEN_NAVAL_SHIRT = 8953;
public static final int RED_NAVAL_SHIRT = 8954;
public static final int BROWN_NAVAL_SHIRT = 8955;
public static final int BLACK_NAVAL_SHIRT = 8956;
public static final int PURPLE_NAVAL_SHIRT = 8957;
public static final int GREY_NAVAL_SHIRT = 8958;
public static final int BLUE_TRICORN_HAT = 8959;
public static final int GREEN_TRICORN_HAT = 8960;
public static final int RED_TRICORN_HAT = 8961;
public static final int BROWN_TRICORN_HAT = 8962;
public static final int BLACK_TRICORN_HAT = 8963;
public static final int PURPLE_TRICORN_HAT = 8964;
public static final int GREY_TRICORN_HAT = 8965;
public static final int CUTTHROAT_FLAG = 8966;
public static final int GUILDED_SMILE_FLAG = 8967;
public static final int BRONZE_FIST_FLAG = 8968;
public static final int LUCKY_SHOT_FLAG = 8969;
public static final int TREASURE_FLAG = 8970;
public static final int PHASMATYS_FLAG = 8971;
public static final int BOWL_OF_RED_WATER = 8972;
public static final int BOWL_OF_BLUE_WATER = 8974;
public static final int BITTERNUT = 8976;
public static final int SCRAPEY_BARK = 8977;
public static final int BRIDGE_SECTION = 8979;
public static final int SWEETGRUBS = 8981;
public static final int BUCKET_8986 = 8986;
public static final int TORCH_8987 = 8987;
public static final int THE_STUFF = 8988;
public static final int BREWIN_GUIDE = 8989;
public static final int BREWIN_GUIDE_8990 = 8990;
public static final int BLUE_NAVY_SLACKS = 8991;
public static final int GREEN_NAVY_SLACKS = 8992;
public static final int RED_NAVY_SLACKS = 8993;
public static final int BROWN_NAVY_SLACKS = 8994;
public static final int BLACK_NAVY_SLACKS = 8995;
public static final int PURPLE_NAVY_SLACKS = 8996;
public static final int GREY_NAVY_SLACKS = 8997;
public static final int SECURITY_BOOK = 9003;
public static final int STRONGHOLD_NOTES = 9004;
public static final int FANCY_BOOTS = 9005;
public static final int FIGHTING_BOOTS = 9006;
public static final int RIGHT_SKULL_HALF = 9007;
public static final int LEFT_SKULL_HALF = 9008;
public static final int STRANGE_SKULL = 9009;
public static final int TOP_OF_SCEPTRE = 9010;
public static final int BOTTOM_OF_SCEPTRE = 9011;
public static final int RUNED_SCEPTRE = 9012;
public static final int SKULL_SCEPTRE = 9013;
public static final int GORAK_CLAWS = 9016;
public static final int STAR_FLOWER = 9017;
public static final int GORAK_CLAW_POWDER = 9018;
public static final int MAGIC_ESSENCE_UNF = 9019;
public static final int QUEENS_SECATEURS_9020 = 9020;
public static final int MAGIC_ESSENCE4 = 9021;
public static final int MAGIC_ESSENCE3 = 9022;
public static final int MAGIC_ESSENCE2 = 9023;
public static final int MAGIC_ESSENCE1 = 9024;
public static final int NUFFS_CERTIFICATE = 9025;
public static final int IVORY_COMB = 9026;
public static final int GOLDEN_SCARAB = 9028;
public static final int STONE_SCARAB = 9030;
public static final int POTTERY_SCARAB = 9032;
public static final int GOLDEN_STATUETTE = 9034;
public static final int POTTERY_STATUETTE = 9036;
public static final int STONE_STATUETTE = 9038;
public static final int GOLD_SEAL = 9040;
public static final int STONE_SEAL = 9042;
public static final int PHARAOHS_SCEPTRE_3 = 9044;
public static final int PHARAOHS_SCEPTRE_2 = 9046;
public static final int PHARAOHS_SCEPTRE_1 = 9048;
public static final int PHARAOHS_SCEPTRE = 9050;
public static final int LOCUST_MEAT = 9052;
public static final int RED_GOBLIN_MAIL = 9054;
public static final int BLACK_GOBLIN_MAIL = 9055;
public static final int YELLOW_GOBLIN_MAIL = 9056;
public static final int GREEN_GOBLIN_MAIL = 9057;
public static final int PURPLE_GOBLIN_MAIL = 9058;
public static final int PINK_GOBLIN_MAIL = 9059;
public static final int EMERALD_LANTERN = 9064;
public static final int EMERALD_LANTERN_9065 = 9065;
public static final int EMERALD_LENS = 9066;
public static final int DREAM_LOG = 9067;
public static final int MOONCLAN_HELM = 9068;
public static final int MOONCLAN_HAT = 9069;
public static final int MOONCLAN_ARMOUR = 9070;
public static final int MOONCLAN_SKIRT = 9071;
public static final int MOONCLAN_GLOVES = 9072;
public static final int MOONCLAN_BOOTS = 9073;
public static final int MOONCLAN_CAPE = 9074;
public static final int ASTRAL_RUNE = 9075;
public static final int LUNAR_ORE = 9076;
public static final int LUNAR_BAR = 9077;
public static final int MOONCLAN_MANUAL = 9078;
public static final int SUQAH_TOOTH = 9079;
public static final int SUQAH_HIDE = 9080;
public static final int SUQAH_LEATHER = 9081;
public static final int GROUND_TOOTH = 9082;
public static final int SEAL_OF_PASSAGE = 9083;
public static final int LUNAR_STAFF = 9084;
public static final int EMPTY_VIAL = 9085;
public static final int VIAL_OF_WATER_9086 = 9086;
public static final int WAKING_SLEEP_VIAL = 9087;
public static final int GUAM_VIAL = 9088;
public static final int MARR_VIAL = 9089;
public static final int GUAMMARR_VIAL = 9090;
public static final int LUNAR_STAFF__PT1 = 9091;
public static final int LUNAR_STAFF__PT2 = 9092;
public static final int LUNAR_STAFF__PT3 = 9093;
public static final int KINDLING = 9094;
public static final int SOAKED_KINDLING = 9095;
public static final int LUNAR_HELM = 9096;
public static final int LUNAR_TORSO = 9097;
public static final int LUNAR_LEGS = 9098;
public static final int LUNAR_GLOVES = 9099;
public static final int LUNAR_BOOTS = 9100;
public static final int LUNAR_CAPE = 9101;
public static final int LUNAR_AMULET = 9102;
public static final int A_SPECIAL_TIARA = 9103;
public static final int LUNAR_RING = 9104;
public static final int SUQAH_MONSTER = 9105;
public static final int ASTRAL_TIARA = 9106;
public static final int BLURITE_BOLTS = 9139;
public static final int IRON_BOLTS = 9140;
public static final int STEEL_BOLTS = 9141;
public static final int MITHRIL_BOLTS = 9142;
public static final int ADAMANT_BOLTS = 9143;
public static final int RUNITE_BOLTS = 9144;
public static final int SILVER_BOLTS = 9145;
public static final int BRONZE_CROSSBOW = 9174;
public static final int BLURITE_CROSSBOW = 9176;
public static final int IRON_CROSSBOW = 9177;
public static final int STEEL_CROSSBOW = 9179;
public static final int MITH_CROSSBOW = 9181;
public static final int ADAMANT_CROSSBOW = 9183;
public static final int RUNE_CROSSBOW = 9185;
public static final int JADE_BOLT_TIPS = 9187;
public static final int TOPAZ_BOLT_TIPS = 9188;
public static final int SAPPHIRE_BOLT_TIPS = 9189;
public static final int EMERALD_BOLT_TIPS = 9190;
public static final int RUBY_BOLT_TIPS = 9191;
public static final int DIAMOND_BOLT_TIPS = 9192;
public static final int DRAGONSTONE_BOLT_TIPS = 9193;
public static final int ONYX_BOLT_TIPS = 9194;
public static final int OPAL_BOLTS_E = 9236;
public static final int JADE_BOLTS_E = 9237;
public static final int PEARL_BOLTS_E = 9238;
public static final int TOPAZ_BOLTS_E = 9239;
public static final int SAPPHIRE_BOLTS_E = 9240;
public static final int EMERALD_BOLTS_E = 9241;
public static final int RUBY_BOLTS_E = 9242;
public static final int DIAMOND_BOLTS_E = 9243;
public static final int DRAGONSTONE_BOLTS_E = 9244;
public static final int ONYX_BOLTS_E = 9245;
public static final int BLURITE_BOLTS_P = 9286;
public static final int IRON_BOLTS_P = 9287;
public static final int STEEL_BOLTS_P = 9288;
public static final int MITHRIL_BOLTS_P = 9289;
public static final int ADAMANT_BOLTS_P = 9290;
public static final int RUNITE_BOLTS_P = 9291;
public static final int SILVER_BOLTS_P = 9292;
public static final int BLURITE_BOLTS_P_9293 = 9293;
public static final int IRON_BOLTS_P_9294 = 9294;
public static final int STEEL_BOLTS_P_9295 = 9295;
public static final int MITHRIL_BOLTS_P_9296 = 9296;
public static final int ADAMANT_BOLTS_P_9297 = 9297;
public static final int RUNITE_BOLTS_P_9298 = 9298;
public static final int SILVER_BOLTS_P_9299 = 9299;
public static final int BLURITE_BOLTS_P_9300 = 9300;
public static final int IRON_BOLTS_P_9301 = 9301;
public static final int STEEL_BOLTS_P_9302 = 9302;
public static final int MITHRIL_BOLTS_P_9303 = 9303;
public static final int ADAMANT_BOLTS_P_9304 = 9304;
public static final int RUNITE_BOLTS_P_9305 = 9305;
public static final int SILVER_BOLTS_P_9306 = 9306;
public static final int JADE_BOLTS = 9335;
public static final int TOPAZ_BOLTS = 9336;
public static final int SAPPHIRE_BOLTS = 9337;
public static final int EMERALD_BOLTS = 9338;
public static final int RUBY_BOLTS = 9339;
public static final int DIAMOND_BOLTS = 9340;
public static final int DRAGONSTONE_BOLTS = 9341;
public static final int ONYX_BOLTS = 9342;
public static final int BRONZE_BOLTS_UNF = 9375;
public static final int BLURITE_BOLTS_UNF = 9376;
public static final int IRON_BOLTS_UNF = 9377;
public static final int STEEL_BOLTS_UNF = 9378;
public static final int MITHRIL_BOLTS_UNF = 9379;
public static final int ADAMANT_BOLTSUNF = 9380;
public static final int RUNITE_BOLTS_UNF = 9381;
public static final int SILVER_BOLTS_UNF = 9382;
public static final int GRAPPLE = 9415;
public static final int MITH_GRAPPLE_TIP = 9416;
public static final int MITH_GRAPPLE = 9418;
public static final int MITH_GRAPPLE_9419 = 9419;
public static final int BRONZE_LIMBS = 9420;
public static final int BLURITE_LIMBS = 9422;
public static final int IRON_LIMBS = 9423;
public static final int STEEL_LIMBS = 9425;
public static final int MITHRIL_LIMBS = 9427;
public static final int ADAMANTITE_LIMBS = 9429;
public static final int RUNITE_LIMBS = 9431;
public static final int BOLT_POUCH = 9433;
public static final int BOLT_MOULD = 9434;
public static final int SINEW = 9436;
public static final int CROSSBOW_STRING = 9438;
public static final int WOODEN_STOCK = 9440;
public static final int OAK_STOCK = 9442;
public static final int WILLOW_STOCK = 9444;
public static final int TEAK_STOCK = 9446;
public static final int MAPLE_STOCK = 9448;
public static final int MAHOGANY_STOCK = 9450;
public static final int YEW_STOCK = 9452;
public static final int BRONZE_CROSSBOW_U = 9454;
public static final int BLURITE_CROSSBOW_U = 9456;
public static final int IRON_CROSSBOW_U = 9457;
public static final int STEEL_CROSSBOW_U = 9459;
public static final int MITHRIL_CROSSBOW_U = 9461;
public static final int ADAMANT_CROSSBOW_U = 9463;
public static final int RUNITE_CROSSBOW_U = 9465;
public static final int BLURITE_BAR = 9467;
public static final int SAWDUST = 9468;
public static final int GRAND_SEED_POD = 9469;
public static final int GNOME_SCARF = 9470;
public static final int GNOME_GOGGLES = 9472;
public static final int REWARD_TOKEN_9474 = 9474;
public static final int MINT_CAKE = 9475;
public static final int ALUFT_ALOFT_BOX = 9477;
public static final int HALF_MADE_BATTA = 9478;
public static final int UNFINISHED_BATTA_9479 = 9479;
public static final int HALF_MADE_BATTA_9480 = 9480;
public static final int UNFINISHED_BATTA_9481 = 9481;
public static final int HALF_MADE_BATTA_9482 = 9482;
public static final int HALF_MADE_BATTA_9483 = 9483;
public static final int UNFINISHED_BATTA_9484 = 9484;
public static final int HALF_MADE_BATTA_9485 = 9485;
public static final int UNFINISHED_BATTA_9486 = 9486;
public static final int WIZARD_BLIZZARD_9487 = 9487;
public static final int WIZARD_BLIZZARD_9489 = 9489;
public static final int WIZARD_BLIZZARD_9508 = 9508;
public static final int SHORT_GREEN_GUY_9510 = 9510;
public static final int PINEAPPLE_PUNCH_9512 = 9512;
public static final int FRUIT_BLAST_9514 = 9514;
public static final int DRUNK_DRAGON_9516 = 9516;
public static final int CHOC_SATURDAY_9518 = 9518;
public static final int BLURBERRY_SPECIAL_9520 = 9520;
public static final int BATTA_TIN_9522 = 9522;
public static final int BATTA_TIN_9524 = 9524;
public static final int FRUIT_BATTA_9527 = 9527;
public static final int TOAD_BATTA_9529 = 9529;
public static final int WORM_BATTA_9531 = 9531;
public static final int VEGETABLE_BATTA_9533 = 9533;
public static final int CHEESETOM_BATTA_9535 = 9535;
public static final int TOAD_CRUNCHIES_9538 = 9538;
public static final int SPICY_CRUNCHIES_9540 = 9540;
public static final int WORM_CRUNCHIES_9542 = 9542;
public static final int CHOCCHIP_CRUNCHIES_9544 = 9544;
public static final int WORM_HOLE_9547 = 9547;
public static final int VEG_BALL_9549 = 9549;
public static final int TANGLED_TOADS_LEGS_9551 = 9551;
public static final int CHOCOLATE_BOMB_9553 = 9553;
public static final int HALF_MADE_BOWL = 9558;
public static final int HALF_MADE_BOWL_9559 = 9559;
public static final int UNFINISHED_BOWL_9560 = 9560;
public static final int HALF_MADE_BOWL_9561 = 9561;
public static final int UNFINISHED_BOWL_9562 = 9562;
public static final int HALF_MADE_BOWL_9563 = 9563;
public static final int UNFINISHED_BOWL_9564 = 9564;
public static final int MIXED_BLIZZARD = 9566;
public static final int MIXED_SGG = 9567;
public static final int MIXED_BLAST = 9568;
public static final int MIXED_PUNCH = 9569;
public static final int MIXED_SPECIAL = 9570;
public static final int MIXED_SATURDAY = 9571;
public static final int MIXED_SATURDAY_9572 = 9572;
public static final int MIXED_SATURDAY_9573 = 9573;
public static final int MIXED_DRAGON = 9574;
public static final int MIXED_DRAGON_9575 = 9575;
public static final int MIXED_DRAGON_9576 = 9576;
public static final int HALF_MADE_CRUNCHY = 9577;
public static final int UNFINISHED_CRUNCHY_9578 = 9578;
public static final int HALF_MADE_CRUNCHY_9579 = 9579;
public static final int UNFINISHED_CRUNCHY_9580 = 9580;
public static final int HALF_MADE_CRUNCHY_9581 = 9581;
public static final int UNFINISHED_CRUNCHY_9582 = 9582;
public static final int HALF_MADE_CRUNCHY_9583 = 9583;
public static final int UNFINISHED_CRUNCHY_9584 = 9584;
public static final int DOSSIER = 9589;
public static final int DOSSIER_9590 = 9590;
public static final int BROKEN_CAULDRON = 9591;
public static final int MAGIC_GLUE = 9592;
public static final int WEIRD_GLOOP = 9593;
public static final int GROUND_MUD_RUNES = 9594;
public static final int HAZELMERES_BOOK = 9595;
public static final int A_RED_CIRCLE = 9597;
public static final int A_RED_TRIANGLE = 9598;
public static final int A_RED_SQUARE = 9599;
public static final int A_RED_PENTAGON = 9600;
public static final int AN_ORANGE_CIRCLE = 9601;
public static final int AN_ORANGE_TRIANGLE = 9602;
public static final int AN_ORANGE_SQUARE = 9603;
public static final int ORANGE_PENTAGON = 9604;
public static final int A_YELLOW_CIRCLE = 9605;
public static final int A_YELLOW_TRIANGLE = 9606;
public static final int A_YELLOW_SQUARE = 9607;
public static final int A_YELLOW_PENTAGON = 9608;
public static final int A_GREEN_CIRCLE = 9609;
public static final int A_GREEN_TRIANGLE = 9610;
public static final int A_GREEN_SQUARE = 9611;
public static final int A_GREEN_PENTAGON = 9612;
public static final int A_BLUE_CIRCLE = 9613;
public static final int A_BLUE_TRIANGLE = 9614;
public static final int A_BLUE_SQUARE = 9615;
public static final int A_BLUE_PENTAGON = 9616;
public static final int AN_INDIGO_CIRCLE = 9617;
public static final int AN_INDIGO_TRIANGLE = 9618;
public static final int AN_INDIGO_SQUARE = 9619;
public static final int AN_INDIGO_PENTAGON = 9620;
public static final int A_VIOLET_CIRCLE = 9621;
public static final int A_VIOLET_TRIANGLE = 9622;
public static final int A_VIOLET_SQUARE = 9623;
public static final int A_VIOLET_PENTAGON = 9624;
public static final int CRYSTAL_SAW = 9625;
public static final int CRYSTAL_SAW_SEED = 9626;
public static final int A_HANDWRITTEN_BOOK = 9627;
public static final int TYRAS_HELM = 9629;
public static final int DAEYALT_ORE = 9632;
public static final int MESSAGE_9633 = 9633;
public static final int VYREWATCH_TOP = 9634;
public static final int VYREWATCH_LEGS = 9636;
public static final int VYREWATCH_SHOES = 9638;
public static final int CITIZEN_TOP = 9640;
public static final int CITIZEN_TROUSERS = 9642;
public static final int CITIZEN_SHOES = 9644;
public static final int CASTLE_SKETCH_1 = 9646;
public static final int CASTLE_SKETCH_2 = 9647;
public static final int CASTLE_SKETCH_3 = 9648;
public static final int MESSAGE_9649 = 9649;
public static final int BLOOD_TITHE_POUCH = 9650;
public static final int LARGE_ORNATE_KEY = 9651;
public static final int HAEMALCHEMY_VOLUME_1 = 9652;
public static final int SEALED_MESSAGE = 9653;
public static final int DOOR_KEY_9654 = 9654;
public static final int LADDER_TOP = 9655;
public static final int TOME_OF_EXPERIENCE_3 = 9656;
public static final int TOME_OF_EXPERIENCE_2 = 9657;
public static final int TOME_OF_EXPERIENCE_1 = 9658;
public static final int BUCKET_OF_WATER_9659 = 9659;
public static final int BUCKET_9660 = 9660;
public static final int USELESS_KEY = 9662;
public static final int TORCH_9665 = 9665;
public static final int PROSELYTE_HARNESS_M = 9666;
public static final int INITIATE_HARNESS_M = 9668;
public static final int PROSELYTE_HARNESS_F = 9670;
public static final int PROSELYTE_SALLET = 9672;
public static final int PROSELYTE_HAUBERK = 9674;
public static final int PROSELYTE_CUISSE = 9676;
public static final int PROSELYTE_TASSET = 9678;
public static final int SEA_SLUG_GLUE = 9680;
public static final int COMMORB_V2 = 9681;
public static final int DOOR_TRANSCRIPTION = 9682;
public static final int DEAD_SEA_SLUG = 9683;
public static final int PAGE_1 = 9684;
public static final int PAGE_2 = 9685;
public static final int PAGE_3 = 9686;
public static final int FRAGMENT_1 = 9687;
public static final int FRAGMENT_2 = 9688;
public static final int FRAGMENT_3 = 9689;
public static final int BLANK_WATER_RUNE = 9690;
public static final int WATER_RUNE_9691 = 9691;
public static final int BLANK_AIR_RUNE = 9692;
public static final int AIR_RUNE_9693 = 9693;
public static final int BLANK_EARTH_RUNE = 9694;
public static final int EARTH_RUNE_9695 = 9695;
public static final int BLANK_MIND_RUNE = 9696;
public static final int MIND_RUNE_9697 = 9697;
public static final int BLANK_FIRE_RUNE = 9698;
public static final int FIRE_RUNE_9699 = 9699;
public static final int STICK_9702 = 9702;
public static final int TRAINING_SWORD = 9703;
public static final int TRAINING_SHIELD = 9704;
public static final int TRAINING_BOW = 9705;
public static final int TRAINING_ARROWS = 9706;
public static final int SLASHED_BOOK = 9715;
public static final int ROCK_9716 = 9716;
public static final int BEATEN_BOOK = 9717;
public static final int CRANE_SCHEMATIC = 9718;
public static final int LEVER_SCHEMATIC = 9719;
public static final int CRANE_CLAW = 9720;
public static final int SCROLL_9721 = 9721;
public static final int KEY_9722 = 9722;
public static final int PIPE = 9723;
public static final int LARGE_COG = 9724;
public static final int MEDIUM_COG = 9725;
public static final int SMALL_COG = 9726;
public static final int PRIMED_BAR = 9727;
public static final int PRIMED_MIND_BAR = 9728;
public static final int ELEMENTAL_HELMET = 9729;
public static final int MIND_SHIELD = 9731;
public static final int MIND_HELMET = 9733;
public static final int DESERT_GOAT_HORN = 9735;
public static final int GOAT_HORN_DUST = 9736;
public static final int COMBAT_POTION4 = 9739;
public static final int COMBAT_POTION3 = 9741;
public static final int COMBAT_POTION2 = 9743;
public static final int COMBAT_POTION1 = 9745;
public static final int ATTACK_CAPE = 9747;
public static final int ATTACK_CAPET = 9748;
public static final int ATTACK_HOOD = 9749;
public static final int STRENGTH_CAPE = 9750;
public static final int STRENGTH_CAPET = 9751;
public static final int STRENGTH_HOOD = 9752;
public static final int DEFENCE_CAPE = 9753;
public static final int DEFENCE_CAPET = 9754;
public static final int DEFENCE_HOOD = 9755;
public static final int RANGING_CAPE = 9756;
public static final int RANGING_CAPET = 9757;
public static final int RANGING_HOOD = 9758;
public static final int PRAYER_CAPE = 9759;
public static final int PRAYER_CAPET = 9760;
public static final int PRAYER_HOOD = 9761;
public static final int MAGIC_CAPE = 9762;
public static final int MAGIC_CAPET = 9763;
public static final int MAGIC_HOOD = 9764;
public static final int RUNECRAFT_CAPE = 9765;
public static final int RUNECRAFT_CAPET = 9766;
public static final int RUNECRAFT_HOOD = 9767;
public static final int HITPOINTS_CAPE = 9768;
public static final int HITPOINTS_CAPET = 9769;
public static final int HITPOINTS_HOOD = 9770;
public static final int AGILITY_CAPE = 9771;
public static final int AGILITY_CAPET = 9772;
public static final int AGILITY_HOOD = 9773;
public static final int HERBLORE_CAPE = 9774;
public static final int HERBLORE_CAPET = 9775;
public static final int HERBLORE_HOOD = 9776;
public static final int THIEVING_CAPE = 9777;
public static final int THIEVING_CAPET = 9778;
public static final int THIEVING_HOOD = 9779;
public static final int CRAFTING_CAPE = 9780;
public static final int CRAFTING_CAPET = 9781;
public static final int CRAFTING_HOOD = 9782;
public static final int FLETCHING_CAPE = 9783;
public static final int FLETCHING_CAPET = 9784;
public static final int FLETCHING_HOOD = 9785;
public static final int SLAYER_CAPE = 9786;
public static final int SLAYER_CAPET = 9787;
public static final int SLAYER_HOOD = 9788;
public static final int CONSTRUCT_CAPE = 9789;
public static final int CONSTRUCT_CAPET = 9790;
public static final int CONSTRUCT_HOOD = 9791;
public static final int MINING_CAPE = 9792;
public static final int MINING_CAPET = 9793;
public static final int MINING_HOOD = 9794;
public static final int SMITHING_CAPE = 9795;
public static final int SMITHING_CAPET = 9796;
public static final int SMITHING_HOOD = 9797;
public static final int FISHING_CAPE = 9798;
public static final int FISHING_CAPET = 9799;
public static final int FISHING_HOOD = 9800;
public static final int COOKING_CAPE = 9801;
public static final int COOKING_CAPET = 9802;
public static final int COOKING_HOOD = 9803;
public static final int FIREMAKING_CAPE = 9804;
public static final int FIREMAKING_CAPET = 9805;
public static final int FIREMAKING_HOOD = 9806;
public static final int WOODCUTTING_CAPE = 9807;
public static final int WOODCUT_CAPET = 9808;
public static final int WOODCUTTING_HOOD = 9809;
public static final int FARMING_CAPE = 9810;
public static final int FARMING_CAPET = 9811;
public static final int FARMING_HOOD = 9812;
public static final int QUEST_POINT_CAPE = 9813;
public static final int QUEST_POINT_HOOD = 9814;
public static final int BOBBLE_HAT_9815 = 9815;
public static final int BOBBLE_SCARF_9816 = 9816;
public static final int OAK_CAPE_RACK = 9817;
public static final int TEAK_CAPE_RACK = 9818;
public static final int MAHOGANY_CAPE_RACK = 9819;
public static final int GILDED_CAPE_RACK = 9820;
public static final int MARBLE_CAPE_RACK = 9821;
public static final int MAGICAL_CAPE_RACK = 9822;
public static final int OAK_COSTUME_BOX = 9823;
public static final int TEAK_COSTUME_BOX = 9824;
public static final int MAHOGANY_COS_BOX = 9825;
public static final int OAK_ARMOUR_CASE = 9826;
public static final int TEAK_ARMOUR_CASE = 9827;
public static final int MAHOGANY_ARMOUR_CASE = 9828;
public static final int OAK_WARDROBE_9829 = 9829;
public static final int CARVED_OAK_WARDROBE = 9830;
public static final int TEAK_WARDROBE_9831 = 9831;
public static final int CARVED_TEAK_WARDROBE = 9832;
public static final int MAHOGANY_WARDROBE_9833 = 9833;
public static final int GILDED_WARDROBE_9834 = 9834;
public static final int MARBLE_WARDROBE = 9835;
public static final int OAK_TOY_BOX = 9836;
public static final int TEAK_TOY_BOX = 9837;
public static final int MAHOGANY_TOY_BOX = 9838;
public static final int OAK_TREASURE_CHEST = 9839;
public static final int TEAK_TREASURE_CHEST = 9840;
public static final int MAHOGANY_TREASURE_CHEST = 9841;
public static final int COSTUME_ROOM = 9842;
public static final int OAK_CAPE_RACK_9843 = 9843;
public static final int TEAK_CAPE_RACK_9844 = 9844;
public static final int MAHOGANY_CAPE_RACK_9845 = 9845;
public static final int GILDED_CAPE_RACK_9846 = 9846;
public static final int MARBLE_CAPE_RACK_9847 = 9847;
public static final int MAGIC_CAPE_RACK = 9848;
public static final int OAK_TOY_BOX_9849 = 9849;
public static final int TEAK_TOY_BOX_9850 = 9850;
public static final int MAHOGANY_TOY_BOX_9851 = 9851;
public static final int OAK_MAGIC_WARDROBE = 9852;
public static final int CARVED_OAK_MAGIC_WARDROBE = 9853;
public static final int TEAK_MAGIC_WARDROBE = 9854;
public static final int CARVED_TEAK_MAGIC_WARDROBE = 9855;
public static final int MAHOGANY_MAGIC_WARDROBE = 9856;
public static final int GILDED_MAGIC_WARDROBE = 9857;
public static final int MARBLE_MAGIC_WARDROBE = 9858;
public static final int OAK_ARMOUR_CASE_9859 = 9859;
public static final int TEAK_ARMOUR_CASE_9860 = 9860;
public static final int MAHOGANY_ARMOUR_CASE_9861 = 9861;
public static final int OAK_TREASURE_CHEST_9862 = 9862;
public static final int TEAK_TREASURE_CHEST_9863 = 9863;
public static final int M_TREASURE_CHEST = 9864;
public static final int OAK_FANCY_DRESS_BOX = 9865;
public static final int TEAK_FANCY_DRESS_BOX = 9866;
public static final int MAHOGANY_FANCY_DRESS_BOX = 9867;
public static final int GOUTWEEDY_LUMP = 9901;
public static final int HARDY_GOUT_TUBERS = 9902;
public static final int FARMING_MANUAL = 9903;
public static final int SAILING_BOOK = 9904;
public static final int GHOST_BUSTER_500 = 9906;
public static final int GHOST_BUSTER_500_9907 = 9907;
public static final int GHOST_BUSTER_500_9908 = 9908;
public static final int GHOST_BUSTER_500_9909 = 9909;
public static final int GHOST_BUSTER_500_9910 = 9910;
public static final int GHOST_BUSTER_500_9911 = 9911;
public static final int GHOST_BUSTER_500_9912 = 9912;
public static final int WHITE_DESTABILISER = 9913;
public static final int RED_DESTABILISER = 9914;
public static final int BLUE_DESTABILISER = 9915;
public static final int GREEN_DESTABILISER = 9916;
public static final int YELLOW_DESTABILISER = 9917;
public static final int BLACK_DESTABILISER = 9918;
public static final int EVIL_ROOT = 9919;
public static final int JACK_LANTERN_MASK = 9920;
public static final int SKELETON_BOOTS = 9921;
public static final int SKELETON_GLOVES = 9922;
public static final int SKELETON_LEGGINGS = 9923;
public static final int SKELETON_SHIRT = 9924;
public static final int SKELETON_MASK = 9925;
public static final int AUGUSTES_SAPLING = 9932;
public static final int BALLOON_STRUCTURE = 9933;
public static final int ORIGAMI_BALLOON = 9934;
public static final int YELLOW_BALLOON = 9935;
public static final int BLUE_BALLOON = 9936;
public static final int RED_BALLOON = 9937;
public static final int ORANGE_BALLOON = 9938;
public static final int GREEN_BALLOON = 9939;
public static final int PURPLE_BALLOON = 9940;
public static final int PINK_BALLOON = 9941;
public static final int BLACK_BALLOON = 9942;
public static final int SANDBAG = 9943;
public static final int BOMBER_JACKET = 9944;
public static final int BOMBER_CAP = 9945;
public static final int CAP_AND_GOGGLES = 9946;
public static final int OLD_RED_DISK = 9947;
public static final int HUNTER_CAPE = 9948;
public static final int HUNTER_CAPET = 9949;
public static final int HUNTER_HOOD = 9950;
public static final int FOOTPRINT = 9951;
public static final int IMP = 9952;
public static final int KEBBIT = 9953;
public static final int KEBBIT_9954 = 9954;
public static final int KEBBIT_9955 = 9955;
public static final int KEBBIT_9956 = 9956;
public static final int KEBBIT_9957 = 9957;
public static final int KEBBIT_9958 = 9958;
public static final int KEBBIT_9959 = 9959;
public static final int KEBBIT_9960 = 9960;
public static final int KEBBIT_9961 = 9961;
public static final int KEBBIT_9962 = 9962;
public static final int KEBBIT_9963 = 9963;
public static final int KEBBIT_9964 = 9964;
public static final int CRIMSON_SWIFT = 9965;
public static final int COPPER_LONGTAIL = 9966;
public static final int CERULEAN_TWITCH = 9967;
public static final int GOLDEN_WARBLER = 9968;
public static final int TROPICAL_WAGTAIL = 9969;
public static final int BUTTERFLY = 9970;
public static final int BUTTERFLY_9971 = 9971;
public static final int BUTTERFLY_9972 = 9972;
public static final int BUTTERFLY_9973 = 9973;
public static final int GIANT_EAGLE = 9974;
public static final int RABBIT = 9975;
public static final int CHINCHOMPA = 9976;
public static final int RED_CHINCHOMPA = 9977;
public static final int RAW_BIRD_MEAT = 9978;
public static final int ROAST_BIRD_MEAT = 9980;
public static final int BURNT_BIRD_MEAT = 9982;
public static final int SKEWERED_BIRD_MEAT = 9984;
public static final int RAW_BEAST_MEAT = 9986;
public static final int ROAST_BEAST_MEAT = 9988;
public static final int BURNT_BEAST_MEAT = 9990;
public static final int SKEWERED_BEAST = 9992;
public static final int SPICY_TOMATO = 9994;
public static final int SPICY_MINCED_MEAT = 9996;
public static final int HUNTER_POTION4 = 9998;
public static final int HUNTER_POTION3 = 10000;
public static final int HUNTER_POTION2 = 10002;
public static final int HUNTER_POTION1 = 10004;
public static final int BIRD_SNARE = 10006;
public static final int BOX_TRAP = 10008;
public static final int BUTTERFLY_NET = 10010;
public static final int BUTTERFLY_JAR = 10012;
public static final int BLACK_WARLOCK = 10014;
public static final int SNOWY_KNIGHT = 10016;
public static final int SAPPHIRE_GLACIALIS = 10018;
public static final int RUBY_HARVEST = 10020;
public static final int FALCONERS_GLOVE = 10023;
public static final int FALCONERS_GLOVE_10024 = 10024;
public static final int MAGIC_BOX = 10025;
public static final int IMPINABOX2 = 10027;
public static final int IMPINABOX1 = 10028;
public static final int TEASING_STICK = 10029;
public static final int RABBIT_SNARE = 10031;
public static final int CHINCHOMPA_10033 = 10033;
public static final int RED_CHINCHOMPA_10034 = 10034;
public static final int KYATT_LEGS = 10035;
public static final int KYATT_TOP = 10037;
public static final int KYATT_HAT = 10039;
public static final int LARUPIA_LEGS = 10041;
public static final int LARUPIA_TOP = 10043;
public static final int LARUPIA_HAT = 10045;
public static final int GRAAHK_LEGS = 10047;
public static final int GRAAHK_TOP = 10049;
public static final int GRAAHK_HEADDRESS = 10051;
public static final int WOOD_CAMO_TOP = 10053;
public static final int WOOD_CAMO_LEGS = 10055;
public static final int JUNGLE_CAMO_TOP = 10057;
public static final int JUNGLE_CAMO_LEGS = 10059;
public static final int DESERT_CAMO_TOP = 10061;
public static final int DESERT_CAMO_LEGS = 10063;
public static final int POLAR_CAMO_TOP = 10065;
public static final int POLAR_CAMO_LEGS = 10067;
public static final int SPOTTED_CAPE = 10069;
public static final int SPOTTIER_CAPE = 10071;
public static final int SPOTTED_CAPE_10073 = 10073;
public static final int SPOTTIER_CAPE_10074 = 10074;
public static final int GLOVES_OF_SILENCE = 10075;
public static final int SPIKY_VAMBRACES = 10077;
public static final int GREEN_SPIKY_VAMBRACES = 10079;
public static final int BLUE_SPIKY_VAMBRACES = 10081;
public static final int RED_SPIKY_VAMBRACES = 10083;
public static final int BLACK_SPIKY_VAMBRACES = 10085;
public static final int STRIPY_FEATHER = 10087;
public static final int RED_FEATHER = 10088;
public static final int BLUE_FEATHER = 10089;
public static final int YELLOW_FEATHER = 10090;
public static final int ORANGE_FEATHER = 10091;
public static final int FERRET = 10092;
public static final int TATTY_LARUPIA_FUR = 10093;
public static final int LARUPIA_FUR = 10095;
public static final int TATTY_GRAAHK_FUR = 10097;
public static final int GRAAHK_FUR = 10099;
public static final int TATTY_KYATT_FUR = 10101;
public static final int KYATT_FUR = 10103;
public static final int KEBBIT_SPIKE = 10105;
public static final int LONG_KEBBIT_SPIKE = 10107;
public static final int KEBBIT_TEETH = 10109;
public static final int KEBBIT_TEETH_DUST = 10111;
public static final int KEBBIT_CLAWS = 10113;
public static final int DARK_KEBBIT_FUR = 10115;
public static final int POLAR_KEBBIT_FUR = 10117;
public static final int FELDIP_WEASEL_FUR = 10119;
public static final int COMMON_KEBBIT_FUR = 10121;
public static final int DESERT_DEVIL_FUR = 10123;
public static final int SPOTTED_KEBBIT_FUR = 10125;
public static final int DASHING_KEBBIT_FUR = 10127;
public static final int BARBTAIL_HARPOON = 10129;
public static final int STRUNG_RABBIT_FOOT = 10132;
public static final int RABBIT_FOOT = 10134;
public static final int RAINBOW_FISH = 10136;
public static final int RAW_RAINBOW_FISH = 10138;
public static final int BURNT_RAINBOW_FISH = 10140;
public static final int GUAM_TAR = 10142;
public static final int MARRENTILL_TAR = 10143;
public static final int TARROMIN_TAR = 10144;
public static final int HARRALANDER_TAR = 10145;
public static final int ORANGE_SALAMANDER = 10146;
public static final int RED_SALAMANDER = 10147;
public static final int BLACK_SALAMANDER = 10148;
public static final int SWAMP_LIZARD = 10149;
public static final int NOOSE_WAND = 10150;
public static final int HUNTERS_CROSSBOW = 10156;
public static final int KEBBIT_BOLTS = 10158;
public static final int LONG_KEBBIT_BOLTS = 10159;
public static final int MORE = 10165;
public static final int BACK = 10166;
public static final int EAGLE_FEATHER = 10167;
public static final int EAGLE_CAPE = 10171;
public static final int FAKE_BEAK = 10172;
public static final int BIRD_BOOK = 10173;
public static final int METAL_FEATHER = 10174;
public static final int GOLDEN_FEATHER_10175 = 10175;
public static final int SILVER_FEATHER = 10176;
public static final int BRONZE_FEATHER = 10177;
public static final int ODD_BIRD_SEED = 10178;
public static final int FEATHERED_JOURNAL = 10179;
public static final int CLUE_SCROLL_EASY_10180 = 10180;
public static final int CASKET_EASY_10181 = 10181;
public static final int CLUE_SCROLL_EASY_10182 = 10182;
public static final int CASKET_EASY_10183 = 10183;
public static final int CLUE_SCROLL_EASY_10184 = 10184;
public static final int CASKET_EASY_10185 = 10185;
public static final int CLUE_SCROLL_EASY_10186 = 10186;
public static final int CASKET_EASY_10187 = 10187;
public static final int CLUE_SCROLL_EASY_10188 = 10188;
public static final int CASKET_EASY_10189 = 10189;
public static final int CLUE_SCROLL_EASY_10190 = 10190;
public static final int CASKET_EASY_10191 = 10191;
public static final int CLUE_SCROLL_EASY_10192 = 10192;
public static final int CASKET_EASY_10193 = 10193;
public static final int CLUE_SCROLL_EASY_10194 = 10194;
public static final int CASKET_EASY_10195 = 10195;
public static final int CLUE_SCROLL_EASY_10196 = 10196;
public static final int CASKET_EASY_10197 = 10197;
public static final int CLUE_SCROLL_EASY_10198 = 10198;
public static final int CASKET_EASY_10199 = 10199;
public static final int CLUE_SCROLL_EASY_10200 = 10200;
public static final int CASKET_EASY_10201 = 10201;
public static final int CLUE_SCROLL_EASY_10202 = 10202;
public static final int CASKET_EASY_10203 = 10203;
public static final int CLUE_SCROLL_EASY_10204 = 10204;
public static final int CASKET_EASY_10205 = 10205;
public static final int CLUE_SCROLL_EASY_10206 = 10206;
public static final int CASKET_EASY_10207 = 10207;
public static final int CLUE_SCROLL_EASY_10208 = 10208;
public static final int CASKET_EASY_10209 = 10209;
public static final int CLUE_SCROLL_EASY_10210 = 10210;
public static final int CASKET_EASY_10211 = 10211;
public static final int CLUE_SCROLL_EASY_10212 = 10212;
public static final int CASKET_EASY_10213 = 10213;
public static final int CLUE_SCROLL_EASY_10214 = 10214;
public static final int CASKET_EASY_10215 = 10215;
public static final int CLUE_SCROLL_EASY_10216 = 10216;
public static final int CASKET_EASY_10217 = 10217;
public static final int CLUE_SCROLL_EASY_10218 = 10218;
public static final int CASKET_EASY_10219 = 10219;
public static final int CLUE_SCROLL_EASY_10220 = 10220;
public static final int CASKET_EASY_10221 = 10221;
public static final int CLUE_SCROLL_EASY_10222 = 10222;
public static final int CASKET_EASY_10223 = 10223;
public static final int CLUE_SCROLL_EASY_10224 = 10224;
public static final int CASKET_EASY_10225 = 10225;
public static final int CLUE_SCROLL_EASY_10226 = 10226;
public static final int CASKET_EASY_10227 = 10227;
public static final int CLUE_SCROLL_EASY_10228 = 10228;
public static final int CASKET_EASY_10229 = 10229;
public static final int CLUE_SCROLL_EASY_10230 = 10230;
public static final int CASKET_EASY_10231 = 10231;
public static final int CLUE_SCROLL_EASY_10232 = 10232;
public static final int CASKET_EASY_10233 = 10233;
public static final int CLUE_SCROLL_HARD_10234 = 10234;
public static final int CASKET_HARD_10235 = 10235;
public static final int CLUE_SCROLL_HARD_10236 = 10236;
public static final int CASKET_HARD_10237 = 10237;
public static final int CLUE_SCROLL_HARD_10238 = 10238;
public static final int CASKET_HARD_10239 = 10239;
public static final int CLUE_SCROLL_HARD_10240 = 10240;
public static final int CASKET_HARD_10241 = 10241;
public static final int CLUE_SCROLL_HARD_10242 = 10242;
public static final int CASKET_HARD_10243 = 10243;
public static final int CLUE_SCROLL_HARD_10244 = 10244;
public static final int CASKET_HARD_10245 = 10245;
public static final int CLUE_SCROLL_HARD_10246 = 10246;
public static final int CASKET_HARD_10247 = 10247;
public static final int CLUE_SCROLL_HARD_10248 = 10248;
public static final int CASKET_HARD_10249 = 10249;
public static final int CLUE_SCROLL_HARD_10250 = 10250;
public static final int CASKET_HARD_10251 = 10251;
public static final int CLUE_SCROLL_HARD_10252 = 10252;
public static final int CASKET_HARD_10253 = 10253;
public static final int CLUE_SCROLL_MEDIUM_10254 = 10254;
public static final int CASKET_MEDIUM_10255 = 10255;
public static final int CLUE_SCROLL_MEDIUM_10256 = 10256;
public static final int CASKET_MEDIUM_10257 = 10257;
public static final int CLUE_SCROLL_MEDIUM_10258 = 10258;
public static final int CASKET_MEDIUM_10259 = 10259;
public static final int CLUE_SCROLL_MEDIUM_10260 = 10260;
public static final int CASKET_MEDIUM_10261 = 10261;
public static final int CLUE_SCROLL_MEDIUM_10262 = 10262;
public static final int CASKET_MEDIUM_10263 = 10263;
public static final int CLUE_SCROLL_MEDIUM_10264 = 10264;
public static final int CASKET_MEDIUM_10265 = 10265;
public static final int CLUE_SCROLL_MEDIUM_10266 = 10266;
public static final int CASKET_MEDIUM_10267 = 10267;
public static final int CLUE_SCROLL_MEDIUM_10268 = 10268;
public static final int CASKET_MEDIUM_10269 = 10269;
public static final int CLUE_SCROLL_MEDIUM_10270 = 10270;
public static final int CASKET_MEDIUM_10271 = 10271;
public static final int CLUE_SCROLL_MEDIUM_10272 = 10272;
public static final int CASKET_MEDIUM_10273 = 10273;
public static final int CLUE_SCROLL_MEDIUM_10274 = 10274;
public static final int CASKET_MEDIUM_10275 = 10275;
public static final int CLUE_SCROLL_MEDIUM_10276 = 10276;
public static final int CASKET_MEDIUM_10277 = 10277;
public static final int CLUE_SCROLL_MEDIUM_10278 = 10278;
public static final int CASKET_MEDIUM_10279 = 10279;
public static final int WILLOW_COMP_BOW = 10280;
public static final int YEW_COMP_BOW = 10282;
public static final int MAGIC_COMP_BOW = 10284;
public static final int RUNE_HELM_H1 = 10286;
public static final int RUNE_HELM_H2 = 10288;
public static final int RUNE_HELM_H3 = 10290;
public static final int RUNE_HELM_H4 = 10292;
public static final int RUNE_HELM_H5 = 10294;
public static final int ADAMANT_HELM_H1 = 10296;
public static final int ADAMANT_HELM_H2 = 10298;
public static final int ADAMANT_HELM_H3 = 10300;
public static final int ADAMANT_HELM_H4 = 10302;
public static final int ADAMANT_HELM_H5 = 10304;
public static final int BLACK_HELM_H1 = 10306;
public static final int BLACK_HELM_H2 = 10308;
public static final int BLACK_HELM_H3 = 10310;
public static final int BLACK_HELM_H4 = 10312;
public static final int BLACK_HELM_H5 = 10314;
public static final int BOBS_RED_SHIRT = 10316;
public static final int BOBS_BLUE_SHIRT = 10318;
public static final int BOBS_GREEN_SHIRT = 10320;
public static final int BOBS_BLACK_SHIRT = 10322;
public static final int BOBS_PURPLE_SHIRT = 10324;
public static final int PURPLE_FIRELIGHTER = 10326;
public static final int WHITE_FIRELIGHTER = 10327;
public static final int WHITE_LOGS = 10328;
public static final int PURPLE_LOGS = 10329;
public static final int _3RD_AGE_RANGE_TOP = 10330;
public static final int _3RD_AGE_RANGE_LEGS = 10332;
public static final int _3RD_AGE_RANGE_COIF = 10334;
public static final int _3RD_AGE_VAMBRACES = 10336;
public static final int _3RD_AGE_ROBE_TOP = 10338;
public static final int _3RD_AGE_ROBE = 10340;
public static final int _3RD_AGE_MAGE_HAT = 10342;
public static final int _3RD_AGE_AMULET = 10344;
public static final int _3RD_AGE_PLATELEGS = 10346;
public static final int _3RD_AGE_PLATEBODY = 10348;
public static final int _3RD_AGE_FULL_HELMET = 10350;
public static final int _3RD_AGE_KITESHIELD = 10352;
public static final int AMULET_OF_GLORY_T4 = 10354;
public static final int AMULET_OF_GLORY_T3 = 10356;
public static final int AMULET_OF_GLORY_T2 = 10358;
public static final int AMULET_OF_GLORY_T1 = 10360;
public static final int AMULET_OF_GLORY_T = 10362;
public static final int STRENGTH_AMULET_T = 10364;
public static final int AMULET_OF_MAGIC_T = 10366;
public static final int ZAMORAK_BRACERS = 10368;
public static final int ZAMORAK_DHIDE_BODY = 10370;
public static final int ZAMORAK_CHAPS = 10372;
public static final int ZAMORAK_COIF = 10374;
public static final int GUTHIX_BRACERS = 10376;
public static final int GUTHIX_DHIDE_BODY = 10378;
public static final int GUTHIX_CHAPS = 10380;
public static final int GUTHIX_COIF = 10382;
public static final int SARADOMIN_BRACERS = 10384;
public static final int SARADOMIN_DHIDE_BODY = 10386;
public static final int SARADOMIN_CHAPS = 10388;
public static final int SARADOMIN_COIF = 10390;
public static final int A_POWDERED_WIG = 10392;
public static final int FLARED_TROUSERS = 10394;
public static final int PANTALOONS = 10396;
public static final int SLEEPING_CAP = 10398;
public static final int BLACK_ELEGANT_SHIRT = 10400;
public static final int BLACK_ELEGANT_LEGS = 10402;
public static final int RED_ELEGANT_SHIRT = 10404;
public static final int RED_ELEGANT_LEGS = 10406;
public static final int BLUE_ELEGANT_SHIRT = 10408;
public static final int BLUE_ELEGANT_LEGS = 10410;
public static final int GREEN_ELEGANT_SHIRT = 10412;
public static final int GREEN_ELEGANT_LEGS = 10414;
public static final int PURPLE_ELEGANT_SHIRT = 10416;
public static final int PURPLE_ELEGANT_LEGS = 10418;
public static final int WHITE_ELEGANT_BLOUSE = 10420;
public static final int WHITE_ELEGANT_SKIRT = 10422;
public static final int RED_ELEGANT_BLOUSE = 10424;
public static final int RED_ELEGANT_SKIRT = 10426;
public static final int BLUE_ELEGANT_BLOUSE = 10428;
public static final int BLUE_ELEGANT_SKIRT = 10430;
public static final int GREEN_ELEGANT_BLOUSE = 10432;
public static final int GREEN_ELEGANT_SKIRT = 10434;
public static final int PURPLE_ELEGANT_BLOUSE = 10436;
public static final int PURPLE_ELEGANT_SKIRT = 10438;
public static final int SARADOMIN_CROZIER = 10440;
public static final int GUTHIX_CROZIER = 10442;
public static final int ZAMORAK_CROZIER = 10444;
public static final int SARADOMIN_CLOAK = 10446;
public static final int GUTHIX_CLOAK = 10448;
public static final int ZAMORAK_CLOAK = 10450;
public static final int SARADOMIN_MITRE = 10452;
public static final int GUTHIX_MITRE = 10454;
public static final int ZAMORAK_MITRE = 10456;
public static final int SARADOMIN_ROBE_TOP = 10458;
public static final int ZAMORAK_ROBE_TOP = 10460;
public static final int GUTHIX_ROBE_TOP = 10462;
public static final int SARADOMIN_ROBE_LEGS = 10464;
public static final int GUTHIX_ROBE_LEGS = 10466;
public static final int ZAMORAK_ROBE_LEGS = 10468;
public static final int SARADOMIN_STOLE = 10470;
public static final int GUTHIX_STOLE = 10472;
public static final int ZAMORAK_STOLE = 10474;
public static final int PURPLE_SWEETS_10476 = 10476;
public static final int SCROLL_10485 = 10485;
public static final int EMPTY_SACK_10486 = 10486;
public static final int UNDEAD_CHICKEN = 10487;
public static final int SELECTED_IRON = 10488;
public static final int BAR_MAGNET = 10489;
public static final int UNDEAD_TWIGS = 10490;
public static final int BLESSED_AXE = 10491;
public static final int RESEARCH_NOTES = 10492;
public static final int TRANSLATED_NOTES = 10493;
public static final int A_PATTERN = 10494;
public static final int A_CONTAINER = 10495;
public static final int POLISHED_BUTTONS = 10496;
public static final int AVAS_ATTRACTOR = 10498;
public static final int AVAS_ACCUMULATOR = 10499;
public static final int CRONEMADE_AMULET = 10500;
public static final int SNOWBALL = 10501;
public static final int GUBLINCH_SHARDS = 10506;
public static final int REINDEER_HAT = 10507;
public static final int WINTUMBER_TREE = 10508;
public static final int FREMENNIK_SEA_BOOTS = 10510;
public static final int SCROLL_10512 = 10512;
public static final int CRACKERS = 10513;
public static final int TOFU = 10514;
public static final int WORMS = 10515;
public static final int ATTACKER_HORN = 10516;
public static final int ATTACKER_HORN_10517 = 10517;
public static final int ATTACKER_HORN_10518 = 10518;
public static final int ATTACKER_HORN_10519 = 10519;
public static final int ATTACKER_HORN_10520 = 10520;
public static final int COLLECTION_BAG = 10521;
public static final int COLLECTION_BAG_10522 = 10522;
public static final int COLLECTION_BAG_10523 = 10523;
public static final int COLLECTION_BAG_10524 = 10524;
public static final int COLLECTION_BAG_10525 = 10525;
public static final int HEALER_HORN = 10526;
public static final int HEALER_HORN_10527 = 10527;
public static final int HEALER_HORN_10528 = 10528;
public static final int HEALER_HORN_10529 = 10529;
public static final int HEALER_HORN_10530 = 10530;
public static final int GREEN_EGG = 10531;
public static final int RED_EGG = 10532;
public static final int BLUE_EGG = 10533;
public static final int YELLOW_EGG = 10534;
public static final int POISONED_EGG = 10535;
public static final int SPIKEDPOIS_EGG = 10536;
public static final int OMEGA_EGG = 10537;
public static final int DEFENDER_HORN = 10538;
public static final int POISONED_TOFU = 10539;
public static final int POISONED_WORMS = 10540;
public static final int POISONED_MEAT = 10541;
public static final int HEALING_VIAL4 = 10542;
public static final int HEALING_VIAL3 = 10543;
public static final int HEALING_VIAL2 = 10544;
public static final int HEALING_VIAL1 = 10545;
public static final int HEALING_VIAL = 10546;
public static final int HEALER_HAT = 10547;
public static final int FIGHTER_HAT = 10548;
public static final int RUNNER_HAT = 10549;
public static final int RANGER_HAT = 10550;
public static final int FIGHTER_TORSO = 10551;
public static final int RUNNER_BOOTS = 10552;
public static final int PENANCE_GLOVES = 10553;
public static final int PENANCE_GLOVES_10554 = 10554;
public static final int PENANCE_SKIRT = 10555;
public static final int ATTACKER_ICON = 10556;
public static final int COLLECTOR_ICON = 10557;
public static final int DEFENDER_ICON = 10558;
public static final int HEALER_ICON = 10559;
public static final int COLLECTOR_HORN = 10560;
public static final int SPIKES_10561 = 10561;
public static final int QUEEN_HELP_BOOK = 10562;
public static final int NO_EGGS = 10563;
public static final int GRANITE_BODY = 10564;
public static final int FIRE_CAPE_10566 = 10566;
public static final int HEALER_ICON_10567 = 10567;
public static final int KERIS = 10581;
public static final int KERISP = 10582;
public static final int KERISP_10583 = 10583;
public static final int KERISP_10584 = 10584;
public static final int PARCHMENT = 10585;
public static final int COMBAT_LAMP = 10586;
public static final int TARNS_DIARY = 10587;
public static final int SALVE_AMULET_E = 10588;
public static final int GRANITE_HELM = 10589;
public static final int TERROR_DOG = 10591;
public static final int PENGUIN_BONGOS = 10592;
public static final int COWBELLS = 10593;
public static final int CLOCKWORK_BOOK = 10594;
public static final int CLOCKWORK_SUIT = 10595;
public static final int CLOCKWORK_SUIT_10596 = 10596;
public static final int MISSION_REPORT = 10597;
public static final int MISSION_REPORT_10598 = 10598;
public static final int MISSION_REPORT_10599 = 10599;
public static final int KGP_ID_CARD = 10600;
public static final int MYSTIC_HAT_10601 = 10601;
public static final int MYSTIC_HAT_DARK_10602 = 10602;
public static final int MYSTIC_HAT_LIGHT_10603 = 10603;
public static final int SKELETAL_HELM_10604 = 10604;
public static final int INFINITY_TOP_10605 = 10605;
public static final int SPLITBARK_HELM_10606 = 10606;
public static final int GHOSTLY_BOOTS_10607 = 10607;
public static final int MOONCLAN_HAT_10608 = 10608;
public static final int LUNAR_HELM_10609 = 10609;
public static final int DECORATIVE_ARMOUR_10610 = 10610;
public static final int VOID_KNIGHT_TOP_10611 = 10611;
public static final int ROGUE_MASK_10612 = 10612;
public static final int ROCKSHELL_HELM_10613 = 10613;
public static final int SPINED_HELM_10614 = 10614;
public static final int TRIBAL_MASK_10615 = 10615;
public static final int TRIBAL_MASK_10616 = 10616;
public static final int TRIBAL_MASK_10617 = 10617;
public static final int WHITE_PLATEBODY_10618 = 10618;
public static final int INITIATE_HAUBERK_10619 = 10619;
public static final int PROSELYTE_HAUBERK_10620 = 10620;
public static final int MOURNER_TOP_10621 = 10621;
public static final int KYATT_TOP_10622 = 10622;
public static final int LARUPIA_TOP_10623 = 10623;
public static final int GRAAHK_TOP_10624 = 10624;
public static final int WOOD_CAMO_TOP_10625 = 10625;
public static final int JUNGLE_CAMO_TOP_10626 = 10626;
public static final int DESERT_CAMO_TOP_10627 = 10627;
public static final int POLAR_CAMO_TOP_10628 = 10628;
public static final int MIME_MASK_10629 = 10629;
public static final int PRINCESS_BLOUSE_10630 = 10630;
public static final int ZOMBIE_SHIRT_10631 = 10631;
public static final int CAMO_TOP_10632 = 10632;
public static final int LEDERHOSEN_TOP_10633 = 10633;
public static final int SHADE_ROBE_10634 = 10634;
public static final int CAPE_OF_LEGENDS_10635 = 10635;
public static final int OBSIDIAN_CAPE_10636 = 10636;
public static final int FIRE_CAPE_10637 = 10637;
public static final int TEAM1_CAPE_10638 = 10638;
public static final int ATTACK_CAPE_10639 = 10639;
public static final int STRENGTH_CAPE_10640 = 10640;
public static final int DEFENCE_CAPE_10641 = 10641;
public static final int RANGING_CAPE_10642 = 10642;
public static final int PRAYER_CAPE_10643 = 10643;
public static final int MAGIC_CAPE_10644 = 10644;
public static final int RUNECRAFT_CAPE_10645 = 10645;
public static final int HUNTER_CAPE_10646 = 10646;
public static final int HITPOINTS_CAPE_10647 = 10647;
public static final int AGILITY_CAPE_10648 = 10648;
public static final int HERBLORE_CAPE_10649 = 10649;
public static final int THIEVING_CAPE_10650 = 10650;
public static final int CRAFTING_CAPE_10651 = 10651;
public static final int FLETCHING_CAPE_10652 = 10652;
public static final int SLAYER_CAPE_10653 = 10653;
public static final int CONSTRUCT_CAPE_10654 = 10654;
public static final int MINING_CAPE_10655 = 10655;
public static final int SMITHING_CAPE_10656 = 10656;
public static final int FISHING_CAPE_10657 = 10657;
public static final int COOKING_CAPE_10658 = 10658;
public static final int FIREMAKING_CAPE_10659 = 10659;
public static final int WOODCUTTING_CAPE_10660 = 10660;
public static final int FARMING_CAPE_10661 = 10661;
public static final int QUEST_POINT_CAPE_10662 = 10662;
public static final int SPOTTED_CAPE_10663 = 10663;
public static final int SPOTTIER_CAPE_10664 = 10664;
public static final int BLACK_SHIELD_H1_10665 = 10665;
public static final int ADAMANT_SHIELD_H1_10666 = 10666;
public static final int RUNE_SHIELD_H1_10667 = 10667;
public static final int BLACK_SHIELD_H2_10668 = 10668;
public static final int ADAMANT_SHIELD_H2_10669 = 10669;
public static final int RUNE_SHIELD_H2_10670 = 10670;
public static final int BLACK_SHIELD_H3_10671 = 10671;
public static final int ADAMANT_SHIELD_H3_10672 = 10672;
public static final int RUNE_SHIELD_H3_10673 = 10673;
public static final int BLACK_SHIELD_H4_10674 = 10674;
public static final int ADAMANT_SHIELD_H4_10675 = 10675;
public static final int RUNE_SHIELD_H4_10676 = 10676;
public static final int BLACK_SHIELD_H5_10677 = 10677;
public static final int ADAMANT_SHIELD_H5_10678 = 10678;
public static final int RUNE_SHIELD_H5_10679 = 10679;
public static final int STUDDED_BODY_G_10680 = 10680;
public static final int STUDDED_BODY_T_10681 = 10681;
public static final int DHIDE_BODY_G = 10682;
public static final int DHIDE_BODY_T = 10683;
public static final int DHIDE_BODY_G_10684 = 10684;
public static final int DHIDE_BODY_T_10685 = 10685;
public static final int WIZARD_ROBE_G = 10686;
public static final int WIZARD_ROBE_T = 10687;
public static final int ENCHANTED_TOP_10688 = 10688;
public static final int WIZARD_BOOTS_10689 = 10689;
public static final int BLACK_PLATEBODY_T_10690 = 10690;
public static final int BLACK_PLATEBODY_G_10691 = 10691;
public static final int HIGHWAYMAN_MASK_10692 = 10692;
public static final int BLUE_BERET_10693 = 10693;
public static final int BLACK_BERET_10694 = 10694;
public static final int WHITE_BERET_10695 = 10695;
public static final int RANGER_BOOTS_10696 = 10696;
public static final int ADAMANT_PLATEBODY_T_10697 = 10697;
public static final int ADAMANT_PLATEBODY_G_10698 = 10698;
public static final int BLACK_HELM_H1_10699 = 10699;
public static final int BLACK_HELM_H2_10700 = 10700;
public static final int BLACK_HELM_H3_10701 = 10701;
public static final int BLACK_HELM_H4_10702 = 10702;
public static final int BLACK_HELM_H5_10703 = 10703;
public static final int RUNE_HELM_H1_10704 = 10704;
public static final int RUNE_HELM_H2_10705 = 10705;
public static final int RUNE_HELM_H3_10706 = 10706;
public static final int RUNE_HELM_H4_10707 = 10707;
public static final int RUNE_HELM_H5_10708 = 10708;
public static final int ADAMANT_HELM_H1_10709 = 10709;
public static final int ADAMANT_HELM_H2_10710 = 10710;
public static final int ADAMANT_HELM_H3_10711 = 10711;
public static final int ADAMANT_HELM_H4_10712 = 10712;
public static final int ADAMANT_HELM_H5_10713 = 10713;
public static final int BOBS_RED_SHIRT_10714 = 10714;
public static final int BOBS_BLUE_SHIRT_10715 = 10715;
public static final int BOBS_GREEN_SHIRT_10716 = 10716;
public static final int BOBS_BLACK_SHIRT_10717 = 10717;
public static final int BOBS_PURPLE_SHIRT_10718 = 10718;
public static final int AMULET_OF_GLORY_T_10719 = 10719;
public static final int GUTHIX_CAPE_10720 = 10720;
public static final int FROG_MASK_10721 = 10721;
public static final int REINDEER_HAT_10722 = 10722;
public static final int JACK_LANTERN_MASK_10723 = 10723;
public static final int SKELETON_BOOTS_10724 = 10724;
public static final int SKELETON_GLOVES_10725 = 10725;
public static final int SKELETON_LEGGINGS_10726 = 10726;
public static final int SKELETON_SHIRT_10727 = 10727;
public static final int SKELETON_MASK_10728 = 10728;
public static final int EASTER_RING_10729 = 10729;
public static final int BLUE_MARIONETTE_10730 = 10730;
public static final int ZOMBIE_HEAD_10731 = 10731;
public static final int RUBBER_CHICKEN_10732 = 10732;
public static final int YOYO_10733 = 10733;
public static final int BUNNY_EARS_10734 = 10734;
public static final int SCYTHE_10735 = 10735;
public static final int STRENGTH_AMULET_T_10736 = 10736;
public static final int AMULET_OF_MAGIC_T_10738 = 10738;
public static final int A_POWDERED_WIG_10740 = 10740;
public static final int FLARED_TROUSERS_10742 = 10742;
public static final int PANTALOONS_10744 = 10744;
public static final int SLEEPING_CAP_10746 = 10746;
public static final int BLACK_ELEGANT_SHIRT_10748 = 10748;
public static final int RED_ELEGANT_SHIRT_10750 = 10750;
public static final int BLUE_ELEGANT_SHIRT_10752 = 10752;
public static final int GREEN_ELEGANT_SHIRT_10754 = 10754;
public static final int PURPLE_ELEGANT_SHIRT_10756 = 10756;
public static final int RED_BOATER_10758 = 10758;
public static final int ORANGE_BOATER_10760 = 10760;
public static final int GREEN_BOATER_10762 = 10762;
public static final int BLUE_BOATER_10764 = 10764;
public static final int BLACK_BOATER_10766 = 10766;
public static final int RED_HEADBAND_10768 = 10768;
public static final int BLACK_HEADBAND_10770 = 10770;
public static final int BROWN_HEADBAND_10772 = 10772;
public static final int PIRATES_HAT_10774 = 10774;
public static final int ZAMORAK_PLATEBODY_10776 = 10776;
public static final int SARADOMIN_PLATE = 10778;
public static final int GUTHIX_PLATEBODY_10780 = 10780;
public static final int GILDED_PLATEBODY_10782 = 10782;
public static final int SARADOMIN_ROBE_TOP_10784 = 10784;
public static final int ZAMORAK_ROBE_TOP_10786 = 10786;
public static final int GUTHIX_ROBE_TOP_10788 = 10788;
public static final int ZAMORAK_DHIDE_BODY_10790 = 10790;
public static final int SARADOMIN_DHIDE_BODY_10792 = 10792;
public static final int GUTHIX_DRAGONHIDE = 10794;
public static final int ROBIN_HOOD_HAT_10796 = 10796;
public static final int RUNE_PLATEBODY_G_10798 = 10798;
public static final int RUNE_PLATEBODY_T_10800 = 10800;
public static final int TAN_CAVALIER_10802 = 10802;
public static final int DARK_CAVALIER_10804 = 10804;
public static final int BLACK_CAVALIER_10806 = 10806;
public static final int ARCTIC_PYRE_LOGS = 10808;
public static final int ARCTIC_PINE_LOGS = 10810;
public static final int SPLIT_LOG = 10812;
public static final int HAIR = 10814;
public static final int RAW_YAK_MEAT = 10816;
public static final int YAKHIDE = 10818;
public static final int CURED_YAKHIDE = 10820;
public static final int YAKHIDE_ARMOUR = 10822;
public static final int YAKHIDE_ARMOUR_10824 = 10824;
public static final int NEITIZNOT_SHIELD = 10826;
public static final int HELM_OF_NEITIZNOT = 10828;
public static final int DOCUMENTS = 10829;
public static final int ROYAL_DECREE = 10830;
public static final int EMPTY_TAX_BAG = 10831;
public static final int LIGHT_TAX_BAG = 10832;
public static final int NORMAL_TAX_BAG = 10833;
public static final int HEFTY_TAX_BAG = 10834;
public static final int BULGING_TAXBAG = 10835;
public static final int SILLY_JESTER_HAT = 10836;
public static final int SILLY_JESTER_TOP = 10837;
public static final int SILLY_JESTER_TIGHTS = 10838;
public static final int SILLY_JESTER_BOOTS = 10839;
public static final int A_JESTER_STICK = 10840;
public static final int APRICOT_CREAM_PIE = 10841;
public static final int DECAPITATED_HEAD_10842 = 10842;
public static final int SPRING_SQIRK = 10844;
public static final int SUMMER_SQIRK = 10845;
public static final int AUTUMN_SQIRK = 10846;
public static final int WINTER_SQIRK = 10847;
public static final int SPRING_SQIRKJUICE = 10848;
public static final int SUMMER_SQIRKJUICE = 10849;
public static final int AUTUMN_SQIRKJUICE = 10850;
public static final int WINTER_SQIRKJUICE = 10851;
public static final int SUMMER_GARDEN = 10852;
public static final int SPRING_GARDEN = 10853;
public static final int AUTUMN_GARDEN = 10854;
public static final int WINTER_GARDEN = 10855;
public static final int SIN_SEERS_NOTE = 10856;
public static final int SEVERED_LEG = 10857;
public static final int SHADOW_SWORD = 10858;
public static final int TEA_FLASK = 10859;
public static final int HARD_HAT = 10862;
public static final int BUILDERS_SHIRT = 10863;
public static final int BUILDERS_TROUSERS = 10864;
public static final int BUILDERS_BOOTS = 10865;
public static final int RIVETS = 10866;
public static final int BINDING_FLUID = 10870;
public static final int PIPE_10871 = 10871;
public static final int PIPE_RING = 10872;
public static final int METAL_SHEET = 10873;
public static final int COLOURED_BALL = 10874;
public static final int VALVE_WHEEL = 10875;
public static final int METAL_BAR = 10876;
public static final int PLAIN_SATCHEL = 10877;
public static final int GREEN_SATCHEL = 10878;
public static final int RED_SATCHEL = 10879;
public static final int BLACK_SATCHEL = 10880;
public static final int GOLD_SATCHEL = 10881;
public static final int RUNE_SATCHEL = 10882;
public static final int HARD_HAT_10883 = 10883;
public static final int FUSE_10884 = 10884;
public static final int KEG = 10885;
public static final int PRAYER_BOOK = 10886;
public static final int BARRELCHEST_ANCHOR = 10887;
public static final int BARRELCHEST_ANCHOR_10888 = 10888;
public static final int BLESSED_LAMP = 10889;
public static final int PRAYER_BOOK_10890 = 10890;
public static final int WOODEN_CAT = 10891;
public static final int CRANIAL_CLAMP = 10893;
public static final int BRAIN_TONGS = 10894;
public static final int BELL_JAR = 10895;
public static final int WOLF_WHISTLE = 10896;
public static final int SHIPPING_ORDER = 10897;
public static final int KEG_10898 = 10898;
public static final int CRATE_PART = 10899;
public static final int SKULL_STAPLE = 10904;
public static final int MIXTURE__STEP_14 = 10909;
public static final int MIXTURE__STEP_13 = 10911;
public static final int MIXTURE__STEP_12 = 10913;
public static final int MIXTURE__STEP_11 = 10915;
public static final int MIXTURE__STEP_24 = 10917;
public static final int MIXTURE__STEP_23 = 10919;
public static final int MIXTURE__STEP_22 = 10921;
public static final int MIXTURE__STEP_21 = 10923;
public static final int SANFEW_SERUM4 = 10925;
public static final int SANFEW_SERUM3 = 10927;
public static final int SANFEW_SERUM2 = 10929;
public static final int SANFEW_SERUM1 = 10931;
public static final int LUMBERJACK_BOOTS = 10933;
public static final int REWARD_TOKEN_10934 = 10934;
public static final int REWARD_TOKEN_10935 = 10935;
public static final int REWARD_TOKEN_10936 = 10936;
public static final int NAIL_BEAST_NAILS = 10937;
public static final int LUMBERJACK_TOP = 10939;
public static final int LUMBERJACK_LEGS = 10940;
public static final int LUMBERJACK_HAT = 10941;
public static final int REWARD_TOKEN_10942 = 10942;
public static final int REWARD_TOKEN_10943 = 10943;
public static final int REWARD_TOKEN_10944 = 10944;
public static final int LUMBERJACK_TOP_10945 = 10945;
public static final int PUSHUP = 10946;
public static final int RUN = 10947;
public static final int SITUP = 10948;
public static final int STARJUMP = 10949;
public static final int SKULL_STAPLES = 10950;
public static final int SKULL_STAPLES_10951 = 10951;
public static final int SLAYER_BELL = 10952;
public static final int FROGLEATHER_BODY = 10954;
public static final int FROGLEATHER_CHAPS = 10956;
public static final int FROGLEATHER_BOOTS = 10958;
public static final int GREEN_GLOOP_SOUP = 10960;
public static final int FROGSPAWN_GUMBO = 10961;
public static final int FROGBURGER = 10962;
public static final int COATED_FROGS_LEGS = 10963;
public static final int BAT_SHISH = 10964;
public static final int FINGERS = 10965;
public static final int GRUBS__LA_MODE = 10966;
public static final int ROAST_FROG = 10967;
public static final int MUSHROOMS = 10968;
public static final int FILLETS = 10969;
public static final int LOACH = 10970;
public static final int EEL_SUSHI = 10971;
public static final int DORGESHKAAN_SPHERE = 10972;
public static final int LIGHT_ORB = 10973;
public static final int SPANNER = 10975;
public static final int LONG_BONE = 10976;
public static final int CURVED_BONE = 10977;
public static final int SWAMP_WEED = 10978;
public static final int EMPTY_LIGHT_ORB = 10980;
public static final int CAVE_GOBLIN_WIRE = 10981;
public static final int COG = 10983;
public static final int COG_10984 = 10984;
public static final int FUSE_10985 = 10985;
public static final int FUSE_10986 = 10986;
public static final int METER = 10987;
public static final int METER_10988 = 10988;
public static final int CAPACITOR = 10989;
public static final int CAPACITOR_10990 = 10990;
public static final int LEVER_10991 = 10991;
public static final int LEVER_10992 = 10992;
public static final int POWERBOX = 10993;
public static final int POWERBOX_10994 = 10994;
public static final int PERFECT_SHELL = 10995;
public static final int PERFECT_SNAIL_SHELL = 10996;
public static final int MOLANISK = 10997;
public static final int CAVE_GOBLIN = 10998;
public static final int GOBLIN_BOOK = 10999;
public static final int DAGONHAI_HISTORY = 11001;
public static final int SINKETHS_DIARY = 11002;
public static final int AN_EMPTY_FOLDER = 11003;
public static final int USED_FOLDER = 11006;
public static final int FULL_FOLDER = 11007;
public static final int RATS_PAPER = 11008;
public static final int LETTER_TO_SUROK = 11009;
public static final int SUROKS_LETTER = 11010;
public static final int ZAFFS_INSTRUCTIONS = 11011;
public static final int WAND = 11012;
public static final int INFUSED_WAND = 11013;
public static final int BEACON_RING = 11014;
public static final int CHICKEN_HEAD = 11015;
public static final int CHICKEN_FEET = 11016;
public static final int CHICKEN_WINGS = 11017;
public static final int CHICKEN_LEGS = 11018;
public static final int CHICKEN_FEET_11019 = 11019;
public static final int CHICKEN_WINGS_11020 = 11020;
public static final int CHICKEN_HEAD_11021 = 11021;
public static final int CHICKEN_LEGS_11022 = 11022;
public static final int MAGIC_EGG = 11023;
public static final int RABBIT_MOULD = 11024;
public static final int CHOCOLATE_CHUNKS = 11025;
public static final int CHOCOLATE_KEBBIT = 11026;
public static final int EASTER_EGG_11027 = 11027;
public static final int EASTER_EGG_11028 = 11028;
public static final int EASTER_EGG_11029 = 11029;
public static final int EASTER_EGG_11030 = 11030;
public static final int DAMP_PLANKS = 11031;
public static final int CRUDE_CARVING = 11032;
public static final int CRUDER_CARVING = 11033;
public static final int SVENS_LAST_MAP = 11034;
public static final int WINDSWEPT_LOGS = 11035;
public static final int PARCHMENT_11036 = 11036;
public static final int BRINE_SABRE = 11037;
public static final int KEY_11039 = 11039;
public static final int KEY_11040 = 11040;
public static final int KEY_11041 = 11041;
public static final int KEY_11042 = 11042;
public static final int KEY_11043 = 11043;
public static final int ROTTEN_BARREL = 11044;
public static final int ROTTEN_BARREL_11045 = 11045;
public static final int ROPE_11046 = 11046;
public static final int BRINE_RAT = 11047;
public static final int ARMOUR_SHARD = 11048;
public static final int ARTEFACT = 11049;
public static final int AXE_HEAD = 11050;
public static final int ARTEFACT_11051 = 11051;
public static final int HELMET_FRAGMENT = 11052;
public static final int ARTEFACT_11053 = 11053;
public static final int SHIELD_FRAGMENT = 11054;
public static final int ARTEFACT_11055 = 11055;
public static final int SWORD_FRAGMENT = 11056;
public static final int ARTEFACT_11057 = 11057;
public static final int MACE = 11058;
public static final int ARTEFACT_11059 = 11059;
public static final int GOBLIN_VILLAGE_SPHERE = 11060;
public static final int ANCIENT_MACE = 11061;
public static final int ZANIK_SLICE = 11062;
public static final int BRACELET_MOULD = 11065;
public static final int GOLD_BRACELET = 11068;
public static final int GOLD_BRACELET_11069 = 11069;
public static final int SAPPHIRE_BRACELET = 11071;
public static final int SAPPHIRE_BRACELET_11072 = 11072;
public static final int BRACELET_OF_CLAY = 11074;
public static final int EMERALD_BRACELET = 11076;
public static final int EMERALD_BRACELET_11078 = 11078;
public static final int CASTLE_WARS_BRACELET3 = 11079;
public static final int CASTLE_WARS_BRACELET2 = 11081;
public static final int CASTLE_WARS_BRACELET1 = 11083;
public static final int RUBY_BRACELET = 11085;
public static final int RUBY_BRACELET_11087 = 11087;
public static final int INOCULATION_BRACELET = 11088;
public static final int PHOENIX_NECKLACE = 11090;
public static final int DIAMOND_BRACELET = 11092;
public static final int DIAMOND_BRACELET_11094 = 11094;
public static final int ABYSSAL_BRACELET5 = 11095;
public static final int ABYSSAL_BRACELET4 = 11097;
public static final int ABYSSAL_BRACELET3 = 11099;
public static final int ABYSSAL_BRACELET2 = 11101;
public static final int ABYSSAL_BRACELET1 = 11103;
public static final int SKILLS_NECKLACE4 = 11105;
public static final int SKILLS_NECKLACE3 = 11107;
public static final int SKILLS_NECKLACE2 = 11109;
public static final int SKILLS_NECKLACE1 = 11111;
public static final int SKILLS_NECKLACE = 11113;
public static final int DRAGONSTONE_BRACELET = 11115;
public static final int DRAGON_BRACELET = 11117;
public static final int COMBAT_BRACELET4 = 11118;
public static final int COMBAT_BRACELET3 = 11120;
public static final int COMBAT_BRACELET2 = 11122;
public static final int COMBAT_BRACELET1 = 11124;
public static final int COMBAT_BRACELET = 11126;
public static final int BERSERKER_NECKLACE = 11128;
public static final int ONYX_BRACELET = 11130;
public static final int ONYX_BRACELET_11132 = 11132;
public static final int REGEN_BRACELET = 11133;
public static final int BOMBER_JACKET_11135 = 11135;
public static final int KARAMJA_GLOVES_1 = 11136;
public static final int ANTIQUE_LAMP_11137 = 11137;
public static final int KARAMJA_GLOVES_2 = 11138;
public static final int ANTIQUE_LAMP_11139 = 11139;
public static final int KARAMJA_GLOVES_3 = 11140;
public static final int ANTIQUE_LAMP_11141 = 11141;
public static final int DREAM_VIAL_EMPTY = 11151;
public static final int DREAM_VIAL_WATER = 11152;
public static final int DREAM_VIAL_HERB = 11153;
public static final int DREAM_POTION = 11154;
public static final int GROUND_ASTRAL_RUNE = 11155;
public static final int ASTRAL_RUNE_SHARDS = 11156;
public static final int DREAMY_LAMP = 11157;
public static final int CYRISUSS_CHEST = 11158;
public static final int HUNTER_KIT = 11159;
public static final int RESTORED_SHIELD = 11164;
public static final int PHOENIX_CROSSBOW_11165 = 11165;
public static final int PHOENIX_CROSSBOW_11167 = 11167;
public static final int NEWSPAPER = 11169;
public static final int NEWSPAPER_11171 = 11171;
public static final int HALF_CERTIFICATE = 11173;
public static final int HALF_CERTIFICATE_11174 = 11174;
public static final int UNCLEANED_FIND = 11175;
public static final int ARROWHEADS = 11176;
public static final int JEWELLERY = 11177;
public static final int POTTERY = 11178;
public static final int OLD_COIN = 11179;
public static final int ANCIENT_COIN = 11180;
public static final int ANCIENT_SYMBOL = 11181;
public static final int OLD_SYMBOL = 11182;
public static final int OLD_CHIPPED_VASE = 11183;
public static final int MUSEUM_MAP = 11184;
public static final int ANTIQUE_LAMP_11185 = 11185;
public static final int ANTIQUE_LAMP_11186 = 11186;
public static final int ANTIQUE_LAMP_11187 = 11187;
public static final int ANTIQUE_LAMP_11188 = 11188;
public static final int ANTIQUE_LAMP_11189 = 11189;
public static final int DIGSITE_PENDANT_1 = 11190;
public static final int DIGSITE_PENDANT_2 = 11191;
public static final int DIGSITE_PENDANT_3 = 11192;
public static final int DIGSITE_PENDANT_4 = 11193;
public static final int DIGSITE_PENDANT_5 = 11194;
public static final int CLEAN_NECKLACE = 11195;
public static final int GRIFFIN_FEATHER = 11196;
public static final int MIAZRQAS_PENDANT = 11197;
public static final int MUSIC_SHEET = 11198;
public static final int RUPERTS_HELMET = 11199;
public static final int DWARVEN_HELMET = 11200;
public static final int SHRINKING_RECIPE = 11202;
public static final int TODO_LIST = 11203;
public static final int SHRINKMEQUICK = 11204;
public static final int SHRUNK_OGLEROOT = 11205;
public static final int GOLDEN_GOBLIN = 11210;
public static final int MAGIC_BEANS = 11211;
public static final int DRAGON_ARROW = 11212;
public static final int DRAGON_FIRE_ARROW = 11217;
public static final int DRAGON_FIRE_ARROW_LIT = 11222;
public static final int DRAGON_ARROWP = 11227;
public static final int DRAGON_ARROWP_11228 = 11228;
public static final int DRAGON_ARROWP_11229 = 11229;
public static final int DRAGON_DART = 11230;
public static final int DRAGON_DARTP = 11231;
public static final int DRAGON_DART_TIP = 11232;
public static final int DRAGON_DARTP_11233 = 11233;
public static final int DRAGON_DARTP_11234 = 11234;
public static final int DARK_BOW = 11235;
public static final int DRAGON_ARROWTIPS = 11237;
public static final int BABY_IMPLING_JAR = 11238;
public static final int YOUNG_IMPLING_JAR = 11240;
public static final int GOURMET_IMPLING_JAR = 11242;
public static final int EARTH_IMPLING_JAR = 11244;
public static final int ESSENCE_IMPLING_JAR = 11246;
public static final int ECLECTIC_IMPLING_JAR = 11248;
public static final int NATURE_IMPLING_JAR = 11250;
public static final int MAGPIE_IMPLING_JAR = 11252;
public static final int NINJA_IMPLING_JAR = 11254;
public static final int DRAGON_IMPLING_JAR = 11256;
public static final int JAR_GENERATOR = 11258;
public static final int MAGIC_BUTTERFLY_NET = 11259;
public static final int IMPLING_JAR = 11260;
public static final int IMP_REPELLENT = 11262;
public static final int ANCHOVY_OIL = 11264;
public static final int ANCHOVY_PASTE = 11266;
public static final int DUMMY_11267 = 11267;
public static final int DUMMY_11268 = 11268;
public static final int DUMMY_11269 = 11269;
public static final int DUMMY_11271 = 11271;
public static final int IMPLING_SCROLL = 11273;
public static final int HAM_SHIRT_11274 = 11274;
public static final int CAVALIER_MASK = 11277;
public static final int BERET_MASK = 11278;
public static final int ELVARGS_HEAD = 11279;
public static final int CAVALIER_MASK_11280 = 11280;
public static final int BERET_MASK_11282 = 11282;
public static final int DRAGONFIRE_SHIELD = 11283;
public static final int DRAGONFIRE_SHIELD_11284 = 11284;
public static final int DRACONIC_VISAGE = 11286;
public static final int BARBARIAN_ROD = 11323;
public static final int ROE = 11324;
public static final int CAVIAR = 11326;
public static final int LEAPING_TROUT = 11328;
public static final int LEAPING_SALMON = 11330;
public static final int LEAPING_STURGEON = 11332;
public static final int FISH_OFFCUTS = 11334;
public static final int DRAGON_FULL_HELM = 11335;
public static final int MANGLED_BONES = 11337;
public static final int CHEWED_BONES = 11338;
public static final int MY_NOTES = 11339;
public static final int BARBARIAN_SKILLS = 11340;
public static final int ANCIENT_PAGE = 11341;
public static final int ANCIENT_PAGE_11342 = 11342;
public static final int ANCIENT_PAGE_11343 = 11343;
public static final int ANCIENT_PAGE_11344 = 11344;
public static final int ANCIENT_PAGE_11345 = 11345;
public static final int ANCIENT_PAGE_11346 = 11346;
public static final int ANCIENT_PAGE_11347 = 11347;
public static final int ANCIENT_PAGE_11348 = 11348;
public static final int ANCIENT_PAGE_11349 = 11349;
public static final int ANCIENT_PAGE_11350 = 11350;
public static final int ANCIENT_PAGE_11351 = 11351;
public static final int ANCIENT_PAGE_11352 = 11352;
public static final int ANCIENT_PAGE_11353 = 11353;
public static final int ANCIENT_PAGE_11354 = 11354;
public static final int ANCIENT_PAGE_11355 = 11355;
public static final int ANCIENT_PAGE_11356 = 11356;
public static final int ANCIENT_PAGE_11357 = 11357;
public static final int ANCIENT_PAGE_11358 = 11358;
public static final int ANCIENT_PAGE_11359 = 11359;
public static final int ANCIENT_PAGE_11360 = 11360;
public static final int ANCIENT_PAGE_11361 = 11361;
public static final int ANCIENT_PAGE_11362 = 11362;
public static final int ANCIENT_PAGE_11363 = 11363;
public static final int ANCIENT_PAGE_11364 = 11364;
public static final int ANCIENT_PAGE_11365 = 11365;
public static final int ANCIENT_PAGE_11366 = 11366;
public static final int BRONZE_HASTA = 11367;
public static final int IRON_HASTA = 11369;
public static final int STEEL_HASTA = 11371;
public static final int MITHRIL_HASTA = 11373;
public static final int ADAMANT_HASTA = 11375;
public static final int RUNE_HASTA = 11377;
public static final int BRONZE_HASTAP = 11379;
public static final int BRONZE_HASTAKP = 11381;
public static final int BRONZE_HASTAP_11382 = 11382;
public static final int BRONZE_HASTAP_11384 = 11384;
public static final int IRON_HASTAP = 11386;
public static final int IRON_HASTAKP = 11388;
public static final int IRON_HASTAP_11389 = 11389;
public static final int IRON_HASTAP_11391 = 11391;
public static final int STEEL_HASTAP = 11393;
public static final int STEEL_HASTAKP = 11395;
public static final int STEEL_HASTAP_11396 = 11396;
public static final int STEEL_HASTAP_11398 = 11398;
public static final int MITHRIL_HASTAP = 11400;
public static final int MITHRIL_HASTAKP = 11402;
public static final int MITHRIL_HASTAP_11403 = 11403;
public static final int MITHRIL_HASTAP_11405 = 11405;
public static final int ADAMANT_HASTAP = 11407;
public static final int ADAMANT_HASTAKP = 11409;
public static final int ADAMANT_HASTAP_11410 = 11410;
public static final int ADAMANT_HASTAP_11412 = 11412;
public static final int RUNE_HASTAP = 11414;
public static final int RUNE_HASTAKP = 11416;
public static final int RUNE_HASTAP_11417 = 11417;
public static final int RUNE_HASTAP_11419 = 11419;
public static final int FISH_VIAL = 11427;
public static final int FISH_VIAL_11428 = 11428;
public static final int ATTACK_MIX2 = 11429;
public static final int ATTACK_MIX1 = 11431;
public static final int ANTIPOISON_MIX2 = 11433;
public static final int ANTIPOISON_MIX1 = 11435;
public static final int RELICYMS_MIX2 = 11437;
public static final int RELICYMS_MIX1 = 11439;
public static final int STRENGTH_MIX1 = 11441;
public static final int STRENGTH_MIX2 = 11443;
public static final int COMBAT_MIX2 = 11445;
public static final int COMBAT_MIX1 = 11447;
public static final int RESTORE_MIX2 = 11449;
public static final int RESTORE_MIX1 = 11451;
public static final int ENERGY_MIX2 = 11453;
public static final int ENERGY_MIX1 = 11455;
public static final int DEFENCE_MIX2 = 11457;
public static final int DEFENCE_MIX1 = 11459;
public static final int AGILITY_MIX2 = 11461;
public static final int AGILITY_MIX1 = 11463;
public static final int PRAYER_MIX2 = 11465;
public static final int PRAYER_MIX1 = 11467;
public static final int SUPERATTACK_MIX2 = 11469;
public static final int SUPERATTACK_MIX1 = 11471;
public static final int ANTIPOISON_SUPERMIX2 = 11473;
public static final int ANTIPOISON_SUPERMIX1 = 11475;
public static final int FISHING_MIX2 = 11477;
public static final int FISHING_MIX1 = 11479;
public static final int SUPER_ENERGY_MIX2 = 11481;
public static final int SUPER_ENERGY_MIX1 = 11483;
public static final int SUPER_STR_MIX2 = 11485;
public static final int SUPER_STR_MIX1 = 11487;
public static final int MAGIC_ESSENCE_MIX2 = 11489;
public static final int MAGIC_ESSENCE_MIX1 = 11491;
public static final int SUPER_RESTORE_MIX2 = 11493;
public static final int SUPER_RESTORE_MIX1 = 11495;
public static final int SUPER_DEF_MIX2 = 11497;
public static final int SUPER_DEF_MIX1 = 11499;
public static final int ANTIDOTE_MIX2 = 11501;
public static final int ANTIDOTE_MIX1 = 11503;
public static final int ANTIFIRE_MIX2 = 11505;
public static final int ANTIFIRE_MIX1 = 11507;
public static final int RANGING_MIX2 = 11509;
public static final int RANGING_MIX1 = 11511;
public static final int MAGIC_MIX2 = 11513;
public static final int MAGIC_MIX1 = 11515;
public static final int HUNTING_MIX2 = 11517;
public static final int HUNTING_MIX1 = 11519;
public static final int ZAMORAK_MIX2 = 11521;
public static final int ZAMORAK_MIX1 = 11523;
public static final int WIMPY_FEATHER = 11525;
public static final int BOOK_OF_KNOWLEDGE = 11640;
public static final int GLASSBLOWING_BOOK = 11656;
public static final int VOID_MAGE_HELM = 11663;
public static final int VOID_RANGER_HELM = 11664;
public static final int VOID_MELEE_HELM = 11665;
public static final int VOID_SEAL8 = 11666;
public static final int VOID_SEAL7 = 11667;
public static final int VOID_SEAL6 = 11668;
public static final int VOID_SEAL5 = 11669;
public static final int VOID_SEAL4 = 11670;
public static final int VOID_SEAL3 = 11671;
public static final int VOID_SEAL2 = 11672;
public static final int VOID_SEAL1 = 11673;
public static final int VOID_MAGE_HELM_11674 = 11674;
public static final int VOID_RANGER_HELM_11675 = 11675;
public static final int VOID_MELEE_HELM_11676 = 11676;
public static final int EXPLORERS_NOTES = 11677;
public static final int BLACK_KNIGHT_HELM = 11678;
public static final int ANTIQUE_LAMP_11679 = 11679;
public static final int ADDRESS_FORM = 11680;
public static final int SCRAP_PAPER = 11681;
public static final int HAIR_CLIP = 11682;
public static final int FIRE_RUNE_11686 = 11686;
public static final int WATER_RUNE_11687 = 11687;
public static final int AIR_RUNE_11688 = 11688;
public static final int EARTH_RUNE_11689 = 11689;
public static final int MIND_RUNE_11690 = 11690;
public static final int BODY_RUNE_11691 = 11691;
public static final int DEATH_RUNE_11692 = 11692;
public static final int NATURE_RUNE_11693 = 11693;
public static final int CHAOS_RUNE_11694 = 11694;
public static final int LAW_RUNE_11695 = 11695;
public static final int COSMIC_RUNE_11696 = 11696;
public static final int BLOOD_RUNE_11697 = 11697;
public static final int SOUL_RUNE_11698 = 11698;
public static final int ASTRAL_RUNE_11699 = 11699;
public static final int BRONZE_ARROW_11700 = 11700;
public static final int IRON_ARROW_11701 = 11701;
public static final int STEEL_ARROW_11702 = 11702;
public static final int MITHRIL_ARROW_11703 = 11703;
public static final int RAW_PHEASANT_11704 = 11704;
public static final int BEACH_BOXING_GLOVES = 11705;
public static final int BEACH_BOXING_GLOVES_11706 = 11706;
public static final int CURSED_GOBLIN_HAMMER = 11707;
public static final int CURSED_GOBLIN_BOW = 11708;
public static final int CURSED_GOBLIN_STAFF = 11709;
public static final int ANTIDRAGON_SHIELD_NZ = 11710;
public static final int MAGIC_SECATEURS_NZ = 11711;
public static final int CHAOS_RUNE_NZ = 11712;
public static final int DEATH_RUNE_NZ = 11713;
public static final int BLOOD_RUNE_NZ = 11714;
public static final int AIR_RUNE_NZ = 11715;
public static final int WATER_RUNE_NZ = 11716;
public static final int EARTH_RUNE_NZ = 11717;
public static final int FIRE_RUNE_NZ = 11718;
public static final int RUNE_PICKAXE_NZ = 11719;
public static final int MITHRIL_PICKAXE_NZ = 11720;
public static final int IRON_PICKAXE_NZ = 11721;
public static final int SUPER_RANGING_4 = 11722;
public static final int SUPER_RANGING_3 = 11723;
public static final int SUPER_RANGING_2 = 11724;
public static final int SUPER_RANGING_1 = 11725;
public static final int SUPER_MAGIC_POTION_4 = 11726;
public static final int SUPER_MAGIC_POTION_3 = 11727;
public static final int SUPER_MAGIC_POTION_2 = 11728;
public static final int SUPER_MAGIC_POTION_1 = 11729;
public static final int OVERLOAD_4 = 11730;
public static final int OVERLOAD_3 = 11731;
public static final int OVERLOAD_2 = 11732;
public static final int OVERLOAD_1 = 11733;
public static final int ABSORPTION_4 = 11734;
public static final int ABSORPTION_3 = 11735;
public static final int ABSORPTION_2 = 11736;
public static final int ABSORPTION_1 = 11737;
public static final int HERB_BOX = 11738;
public static final int OPEN_HERB_BOX = 11739;
public static final int SCROLL_OF_REDIRECTION = 11740;
public static final int RIMMINGTON_TELEPORT = 11741;
public static final int TAVERLEY_TELEPORT = 11742;
public static final int POLLNIVNEACH_TELEPORT = 11743;
public static final int RELLEKKA_TELEPORT = 11744;
public static final int BRIMHAVEN_TELEPORT = 11745;
public static final int YANILLE_TELEPORT = 11746;
public static final int TROLLHEIM_TELEPORT = 11747;
public static final int NEW_CRYSTAL_BOW_I = 11748;
public static final int CRYSTAL_BOW_FULL_I = 11749;
public static final int CRYSTAL_BOW_910_I = 11750;
public static final int CRYSTAL_BOW_810_I = 11751;
public static final int CRYSTAL_BOW_710_I = 11752;
public static final int CRYSTAL_BOW_610_I = 11753;
public static final int CRYSTAL_BOW_510_I = 11754;
public static final int CRYSTAL_BOW_410_I = 11755;
public static final int CRYSTAL_BOW_310_I = 11756;
public static final int CRYSTAL_BOW_210_I = 11757;
public static final int CRYSTAL_BOW_110_I = 11758;
public static final int NEW_CRYSTAL_SHIELD_I = 11759;
public static final int CRYSTAL_SHIELD_FULL_I = 11760;
public static final int CRYSTAL_SHIELD_910_I = 11761;
public static final int CRYSTAL_SHIELD_810_I = 11762;
public static final int CRYSTAL_SHIELD_710_I = 11763;
public static final int CRYSTAL_SHIELD_610_I = 11764;
public static final int CRYSTAL_SHIELD_510_I = 11765;
public static final int CRYSTAL_SHIELD_410_I = 11766;
public static final int CRYSTAL_SHIELD_310_I = 11767;
public static final int CRYSTAL_SHIELD_210_I = 11768;
public static final int CRYSTAL_SHIELD_110_I = 11769;
public static final int SEERS_RING_I = 11770;
public static final int ARCHERS_RING_I = 11771;
public static final int WARRIOR_RING_I = 11772;
public static final int BERSERKER_RING_I = 11773;
public static final int BLACK_MASK_10_I = 11774;
public static final int BLACK_MASK_9_I = 11775;
public static final int BLACK_MASK_8_I = 11776;
public static final int BLACK_MASK_7_I = 11777;
public static final int BLACK_MASK_6_I = 11778;
public static final int BLACK_MASK_5_I = 11779;
public static final int BLACK_MASK_4_I = 11780;
public static final int BLACK_MASK_3_I = 11781;
public static final int BLACK_MASK_2_I = 11782;
public static final int BLACK_MASK_1_I = 11783;
public static final int BLACK_MASK_I = 11784;
public static final int ARMADYL_CROSSBOW = 11785;
public static final int STEAM_BATTLESTAFF = 11787;
public static final int MYSTIC_STEAM_STAFF = 11789;
public static final int STAFF_OF_THE_DEAD = 11791;
public static final int AGILITY_JUMP_11793 = 11793;
public static final int GODSWORD_SHARDS_1__2 = 11794;
public static final int GODSWORD_SHARDS_1__3 = 11796;
public static final int GODSWORD_BLADE = 11798;
public static final int GODSWORD_SHARDS_2__3 = 11800;
public static final int ARMADYL_GODSWORD = 11802;
public static final int BANDOS_GODSWORD = 11804;
public static final int SARADOMIN_GODSWORD = 11806;
public static final int ZAMORAK_GODSWORD = 11808;
public static final int ARMADYL_HILT = 11810;
public static final int BANDOS_HILT = 11812;
public static final int SARADOMIN_HILT = 11814;
public static final int ZAMORAK_HILT = 11816;
public static final int GODSWORD_SHARD_1 = 11818;
public static final int GODSWORD_SHARD_2 = 11820;
public static final int GODSWORD_SHARD_3 = 11822;
public static final int ZAMORAKIAN_SPEAR = 11824;
public static final int ARMADYL_HELMET = 11826;
public static final int ARMADYL_CHESTPLATE = 11828;
public static final int ARMADYL_CHAINSKIRT = 11830;
public static final int BANDOS_CHESTPLATE = 11832;
public static final int BANDOS_TASSETS = 11834;
public static final int BANDOS_BOOTS = 11836;
public static final int SARADOMIN_SWORD = 11838;
public static final int DRAGON_BOOTS = 11840;
public static final int KNIGHTS_NOTES = 11842;
public static final int KNIGHTS_NOTES_11843 = 11843;
public static final int BLACK_HWEEN_MASK = 11847;
public static final int RANCID_TURKEY = 11848;
public static final int MARK_OF_GRACE = 11849;
public static final int GRACEFUL_HOOD = 11850;
public static final int GRACEFUL_HOOD_11851 = 11851;
public static final int GRACEFUL_CAPE = 11852;
public static final int GRACEFUL_CAPE_11853 = 11853;
public static final int GRACEFUL_TOP = 11854;
public static final int GRACEFUL_TOP_11855 = 11855;
public static final int GRACEFUL_LEGS = 11856;
public static final int GRACEFUL_LEGS_11857 = 11857;
public static final int GRACEFUL_GLOVES = 11858;
public static final int GRACEFUL_GLOVES_11859 = 11859;
public static final int GRACEFUL_BOOTS = 11860;
public static final int GRACEFUL_BOOTS_11861 = 11861;
public static final int BLACK_PARTYHAT = 11862;
public static final int RAINBOW_PARTYHAT = 11863;
public static final int SLAYER_HELMET = 11864;
public static final int SLAYER_HELMET_I = 11865;
public static final int SLAYER_RING_8 = 11866;
public static final int SLAYER_RING_7 = 11867;
public static final int SLAYER_RING_6 = 11868;
public static final int SLAYER_RING_5 = 11869;
public static final int SLAYER_RING_4 = 11870;
public static final int SLAYER_RING_3 = 11871;
public static final int SLAYER_RING_2 = 11872;
public static final int SLAYER_RING_1 = 11873;
public static final int BROAD_ARROWHEADS = 11874;
public static final int BROAD_BOLTS = 11875;
public static final int UNFINISHED_BROAD_BOLTS = 11876;
public static final int EMPTY_VIAL_PACK = 11877;
public static final int WATERFILLED_VIAL_PACK = 11879;
public static final int FEATHER_PACK = 11881;
public static final int BAIT_PACK = 11883;
public static final int BROAD_ARROWHEAD_PACK = 11885;
public static final int UNFINISHED_BROAD_BOLT_PACK = 11887;
public static final int ZAMORAKIAN_HASTA = 11889;
public static final int SARADOMIN_BANNER_11891 = 11891;
public static final int ZAMORAK_BANNER_11892 = 11892;
public static final int DECORATIVE_ARMOUR_11893 = 11893;
public static final int DECORATIVE_ARMOUR_11894 = 11894;
public static final int DECORATIVE_ARMOUR_11895 = 11895;
public static final int DECORATIVE_ARMOUR_11896 = 11896;
public static final int DECORATIVE_ARMOUR_11897 = 11897;
public static final int DECORATIVE_ARMOUR_11898 = 11898;
public static final int DECORATIVE_ARMOUR_11899 = 11899;
public static final int DECORATIVE_ARMOUR_11900 = 11900;
public static final int DECORATIVE_ARMOUR_11901 = 11901;
public static final int LEAFBLADED_SWORD = 11902;
public static final int ENTOMOLOGISTS_DIARY = 11904;
public static final int TRIDENT_OF_THE_SEAS_FULL = 11905;
public static final int TRIDENT_OF_THE_SEAS = 11907;
public static final int UNCHARGED_TRIDENT = 11908;
public static final int CHOCOLATE_STRAWBERRY = 11910;
public static final int BOX_OF_CHOCOLATE_STRAWBERRIES = 11912;
public static final int BOX_OF_CHOCOLATE_STRAWBERRIES_11914 = 11914;
public static final int SLICE_OF_BIRTHDAY_CAKE = 11916;
public static final int SLICE_OF_BIRTHDAY_CAKE_11917 = 11917;
public static final int BIRTHDAY_PRESENT = 11918;
public static final int COW_MASK = 11919;
public static final int DRAGON_PICKAXE = 11920;
public static final int BONEMEAL_11922 = 11922;
public static final int BROKEN_PICKAXE_11923 = 11923;
public static final int MALEDICTION_WARD = 11924;
public static final int ODIUM_WARD = 11926;
public static final int ODIUM_SHARD_1 = 11928;
public static final int ODIUM_SHARD_2 = 11929;
public static final int ODIUM_SHARD_3 = 11930;
public static final int MALEDICTION_SHARD_1 = 11931;
public static final int MALEDICTION_SHARD_2 = 11932;
public static final int MALEDICTION_SHARD_3 = 11933;
public static final int RAW_DARK_CRAB = 11934;
public static final int DARK_CRAB = 11936;
public static final int BURNT_DARK_CRAB = 11938;
public static final int DARK_FISHING_BAIT = 11940;
public static final int LOOTING_BAG = 11941;
public static final int ECUMENICAL_KEY = 11942;
public static final int LAVA_DRAGON_BONES = 11943;
public static final int EXTENDED_ANTIFIRE4 = 11951;
public static final int EXTENDED_ANTIFIRE3 = 11953;
public static final int EXTENDED_ANTIFIRE2 = 11955;
public static final int EXTENDED_ANTIFIRE1 = 11957;
public static final int BLACK_CHINCHOMPA = 11959;
public static final int EXTENDED_ANTIFIRE_MIX2 = 11960;
public static final int EXTENDED_ANTIFIRE_MIX1 = 11962;
public static final int AMULET_OF_GLORY_T6 = 11964;
public static final int AMULET_OF_GLORY_T5 = 11966;
public static final int SKILLS_NECKLACE6 = 11968;
public static final int SKILLS_NECKLACE5 = 11970;
public static final int COMBAT_BRACELET6 = 11972;
public static final int COMBAT_BRACELET5 = 11974;
public static final int AMULET_OF_GLORY5 = 11976;
public static final int AMULET_OF_GLORY6 = 11978;
public static final int RING_OF_WEALTH_5 = 11980;
public static final int RING_OF_WEALTH_4 = 11982;
public static final int RING_OF_WEALTH_3 = 11984;
public static final int RING_OF_WEALTH_2 = 11986;
public static final int RING_OF_WEALTH_1 = 11988;
public static final int FEDORA = 11990;
public static final int LAVA_SCALE = 11992;
public static final int LAVA_SCALE_SHARD = 11994;
public static final int PET_CHAOS_ELEMENTAL = 11995;
public static final int HOLIDAY_TOOL = 11996;
public static final int EASTER = 11997;
public static final int SMOKE_BATTLESTAFF = 11998;
public static final int MYSTIC_SMOKE_STAFF = 12000;
public static final int OCCULT_NECKLACE = 12002;
public static final int KRAKEN_TENTACLE = 12004;
public static final int ABYSSAL_TENTACLE = 12006;
public static final int JAR_OF_DIRT = 12007;
public static final int SOFT_CLAY_PACK = 12009;
public static final int SOFT_CLAY_PACK_12010 = 12010;
public static final int PAYDIRT = 12011;
public static final int GOLDEN_NUGGET = 12012;
public static final int PROSPECTOR_HELMET = 12013;
public static final int PROSPECTOR_JACKET = 12014;
public static final int PROSPECTOR_LEGS = 12015;
public static final int PROSPECTOR_BOOTS = 12016;
public static final int SALVE_AMULETI = 12017;
public static final int SALVE_AMULETEI = 12018;
public static final int COAL_BAG_12019 = 12019;
public static final int GEM_BAG_12020 = 12020;
public static final int CLUE_SCROLL_MEDIUM_12021 = 12021;
public static final int CASKET_MEDIUM_12022 = 12022;
public static final int CLUE_SCROLL_MEDIUM_12023 = 12023;
public static final int CASKET_MEDIUM_12024 = 12024;
public static final int CLUE_SCROLL_MEDIUM_12025 = 12025;
public static final int CASKET_MEDIUM_12026 = 12026;
public static final int CLUE_SCROLL_MEDIUM_12027 = 12027;
public static final int CASKET_MEDIUM_12028 = 12028;
public static final int CLUE_SCROLL_MEDIUM_12029 = 12029;
public static final int CASKET_MEDIUM_12030 = 12030;
public static final int CLUE_SCROLL_MEDIUM_12031 = 12031;
public static final int CASKET_MEDIUM_12032 = 12032;
public static final int CLUE_SCROLL_MEDIUM_12033 = 12033;
public static final int CASKET_MEDIUM_12034 = 12034;
public static final int CLUE_SCROLL_MEDIUM_12035 = 12035;
public static final int CASKET_MEDIUM_12036 = 12036;
public static final int CLUE_SCROLL_MEDIUM_12037 = 12037;
public static final int CASKET_MEDIUM_12038 = 12038;
public static final int CLUE_SCROLL_MEDIUM_12039 = 12039;
public static final int CASKET_MEDIUM_12040 = 12040;
public static final int CLUE_SCROLL_MEDIUM_12041 = 12041;
public static final int CASKET_MEDIUM_12042 = 12042;
public static final int CLUE_SCROLL_MEDIUM_12043 = 12043;
public static final int CASKET_MEDIUM_12044 = 12044;
public static final int CLUE_SCROLL_MEDIUM_12045 = 12045;
public static final int CASKET_MEDIUM_12046 = 12046;
public static final int CLUE_SCROLL_MEDIUM_12047 = 12047;
public static final int CASKET_MEDIUM_12048 = 12048;
public static final int CLUE_SCROLL_MEDIUM_12049 = 12049;
public static final int CASKET_MEDIUM_12050 = 12050;
public static final int CLUE_SCROLL_MEDIUM_12051 = 12051;
public static final int CASKET_MEDIUM_12052 = 12052;
public static final int CLUE_SCROLL_MEDIUM_12053 = 12053;
public static final int CASKET_MEDIUM_12054 = 12054;
public static final int CLUE_SCROLL_MEDIUM_12055 = 12055;
public static final int CHALLENGE_SCROLL_MEDIUM_12056 = 12056;
public static final int CLUE_SCROLL_MEDIUM_12057 = 12057;
public static final int CHALLENGE_SCROLL_MEDIUM_12058 = 12058;
public static final int CLUE_SCROLL_MEDIUM_12059 = 12059;
public static final int CHALLENGE_SCROLL_MEDIUM_12060 = 12060;
public static final int CLUE_SCROLL_MEDIUM_12061 = 12061;
public static final int CHALLENGE_SCROLL_MEDIUM_12062 = 12062;
public static final int CLUE_SCROLL_MEDIUM_12063 = 12063;
public static final int CHALLENGE_SCROLL_MEDIUM_12064 = 12064;
public static final int CLUE_SCROLL_MEDIUM_12065 = 12065;
public static final int CHALLENGE_SCROLL_MEDIUM_12066 = 12066;
public static final int CLUE_SCROLL_MEDIUM_12067 = 12067;
public static final int CHALLENGE_SCROLL_MEDIUM_12068 = 12068;
public static final int CLUE_SCROLL_MEDIUM_12069 = 12069;
public static final int CHALLENGE_SCROLL_MEDIUM_12070 = 12070;
public static final int CLUE_SCROLL_MEDIUM_12071 = 12071;
public static final int CHALLENGE_SCROLL_MEDIUM_12072 = 12072;
public static final int CLUE_SCROLL_ELITE = 12073;
public static final int CLUE_SCROLL_ELITE_12074 = 12074;
public static final int CLUE_SCROLL_ELITE_12075 = 12075;
public static final int CLUE_SCROLL_ELITE_12076 = 12076;
public static final int CLUE_SCROLL_ELITE_12077 = 12077;
public static final int CLUE_SCROLL_ELITE_12078 = 12078;
public static final int CLUE_SCROLL_ELITE_12079 = 12079;
public static final int CLUE_SCROLL_ELITE_12080 = 12080;
public static final int CLUE_SCROLL_ELITE_12081 = 12081;
public static final int CLUE_SCROLL_ELITE_12082 = 12082;
public static final int CLUE_SCROLL_ELITE_12083 = 12083;
public static final int CASKET_ELITE = 12084;
public static final int CLUE_SCROLL_ELITE_12085 = 12085;
public static final int CLUE_SCROLL_ELITE_12086 = 12086;
public static final int CLUE_SCROLL_ELITE_12087 = 12087;
public static final int CLUE_SCROLL_ELITE_12088 = 12088;
public static final int CLUE_SCROLL_ELITE_12089 = 12089;
public static final int CLUE_SCROLL_ELITE_12090 = 12090;
public static final int CLUE_SCROLL_ELITE_12091 = 12091;
public static final int CLUE_SCROLL_ELITE_12092 = 12092;
public static final int CLUE_SCROLL_ELITE_12093 = 12093;
public static final int CLUE_SCROLL_ELITE_12094 = 12094;
public static final int CLUE_SCROLL_ELITE_12095 = 12095;
public static final int CLUE_SCROLL_ELITE_12096 = 12096;
public static final int CLUE_SCROLL_ELITE_12097 = 12097;
public static final int CLUE_SCROLL_ELITE_12098 = 12098;
public static final int CLUE_SCROLL_ELITE_12099 = 12099;
public static final int CLUE_SCROLL_ELITE_12100 = 12100;
public static final int CLUE_SCROLL_ELITE_12101 = 12101;
public static final int CLUE_SCROLL_ELITE_12102 = 12102;
public static final int CLUE_SCROLL_ELITE_12103 = 12103;
public static final int CLUE_SCROLL_ELITE_12104 = 12104;
public static final int CLUE_SCROLL_ELITE_12105 = 12105;
public static final int CLUE_SCROLL_ELITE_12106 = 12106;
public static final int CLUE_SCROLL_ELITE_12107 = 12107;
public static final int CLUE_SCROLL_ELITE_12108 = 12108;
public static final int CLUE_SCROLL_ELITE_12109 = 12109;
public static final int CLUE_SCROLL_ELITE_12110 = 12110;
public static final int CLUE_SCROLL_ELITE_12111 = 12111;
public static final int CASKET_ELITE_12112 = 12112;
public static final int CLUE_SCROLL_ELITE_12113 = 12113;
public static final int CLUE_SCROLL_ELITE_12114 = 12114;
public static final int CLUE_SCROLL_ELITE_12115 = 12115;
public static final int CLUE_SCROLL_ELITE_12116 = 12116;
public static final int CLUE_SCROLL_ELITE_12117 = 12117;
public static final int CLUE_SCROLL_ELITE_12118 = 12118;
public static final int CLUE_SCROLL_ELITE_12119 = 12119;
public static final int CLUE_SCROLL_ELITE_12120 = 12120;
public static final int CLUE_SCROLL_ELITE_12121 = 12121;
public static final int CLUE_SCROLL_ELITE_12122 = 12122;
public static final int CLUE_SCROLL_ELITE_12123 = 12123;
public static final int CLUE_SCROLL_ELITE_12124 = 12124;
public static final int CLUE_SCROLL_ELITE_12125 = 12125;
public static final int CLUE_SCROLL_ELITE_12126 = 12126;
public static final int CLUE_SCROLL_ELITE_12127 = 12127;
public static final int CHALLENGE_SCROLL_ELITE = 12128;
public static final int CASKET_ELITE_12129 = 12129;
public static final int CLUE_SCROLL_ELITE_12130 = 12130;
public static final int CASKET_ELITE_12131 = 12131;
public static final int CLUE_SCROLL_ELITE_12132 = 12132;
public static final int CLUE_SCROLL_ELITE_12133 = 12133;
public static final int CLUE_SCROLL_ELITE_12134 = 12134;
public static final int CLUE_SCROLL_ELITE_12135 = 12135;
public static final int CLUE_SCROLL_ELITE_12136 = 12136;
public static final int CLUE_SCROLL_ELITE_12137 = 12137;
public static final int CLUE_SCROLL_ELITE_12138 = 12138;
public static final int CHALLENGE_SCROLL_ELITE_12139 = 12139;
public static final int CLUE_SCROLL_ELITE_12140 = 12140;
public static final int CLUE_SCROLL_ELITE_12141 = 12141;
public static final int CLUE_SCROLL_ELITE_12142 = 12142;
public static final int CLUE_SCROLL_ELITE_12143 = 12143;
public static final int CLUE_SCROLL_ELITE_12144 = 12144;
public static final int CLUE_SCROLL_ELITE_12145 = 12145;
public static final int CLUE_SCROLL_ELITE_12146 = 12146;
public static final int CLUE_SCROLL_ELITE_12147 = 12147;
public static final int CLUE_SCROLL_ELITE_12148 = 12148;
public static final int CLUE_SCROLL_ELITE_12149 = 12149;
public static final int CLUE_SCROLL_ELITE_12150 = 12150;
public static final int CLUE_SCROLL_ELITE_12151 = 12151;
public static final int CLUE_SCROLL_ELITE_12152 = 12152;
public static final int CLUE_SCROLL_ELITE_12153 = 12153;
public static final int CLUE_SCROLL_ELITE_12154 = 12154;
public static final int CLUE_SCROLL_ELITE_12155 = 12155;
public static final int CLUE_SCROLL_ELITE_12156 = 12156;
public static final int CLUE_SCROLL_ELITE_12157 = 12157;
public static final int CLUE_SCROLL_ELITE_12158 = 12158;
public static final int CLUE_SCROLL_ELITE_12159 = 12159;
public static final int CASKET_ELITE_12160 = 12160;
public static final int PUZZLE_BOX_ELITE = 12161;
public static final int CLUE_SCROLL_EASY_12162 = 12162;
public static final int CASKET_EASY_12163 = 12163;
public static final int CLUE_SCROLL_EASY_12164 = 12164;
public static final int CASKET_EASY_12165 = 12165;
public static final int CLUE_SCROLL_EASY_12166 = 12166;
public static final int CLUE_SCROLL_EASY_12167 = 12167;
public static final int CLUE_SCROLL_EASY_12168 = 12168;
public static final int CLUE_SCROLL_EASY_12169 = 12169;
public static final int CLUE_SCROLL_EASY_12170 = 12170;
public static final int CASKET_EASY_12171 = 12171;
public static final int CLUE_SCROLL_EASY_12172 = 12172;
public static final int CLUE_SCROLL_EASY_12173 = 12173;
public static final int CLUE_SCROLL_EASY_12174 = 12174;
public static final int CLUE_SCROLL_EASY_12175 = 12175;
public static final int CLUE_SCROLL_EASY_12176 = 12176;
public static final int CLUE_SCROLL_EASY_12177 = 12177;
public static final int CLUE_SCROLL_EASY_12178 = 12178;
public static final int CLUE_SCROLL_EASY_12179 = 12179;
public static final int CASKET_EASY_12180 = 12180;
public static final int CLUE_SCROLL_EASY_12181 = 12181;
public static final int CLUE_SCROLL_EASY_12182 = 12182;
public static final int CLUE_SCROLL_EASY_12183 = 12183;
public static final int CLUE_SCROLL_EASY_12184 = 12184;
public static final int CLUE_SCROLL_EASY_12185 = 12185;
public static final int CLUE_SCROLL_EASY_12186 = 12186;
public static final int CLUE_SCROLL_EASY_12187 = 12187;
public static final int CLUE_SCROLL_EASY_12188 = 12188;
public static final int CLUE_SCROLL_EASY_12189 = 12189;
public static final int CLUE_SCROLL_EASY_12190 = 12190;
public static final int CLUE_SCROLL_EASY_12191 = 12191;
public static final int CLUE_SCROLL_EASY_12192 = 12192;
public static final int ANCIENT_ROBE_TOP = 12193;
public static final int ANCIENT_ROBE_LEGS = 12195;
public static final int ANCIENT_CLOAK = 12197;
public static final int ANCIENT_CROZIER = 12199;
public static final int ANCIENT_STOLE = 12201;
public static final int ANCIENT_MITRE = 12203;
public static final int BRONZE_PLATEBODY_G = 12205;
public static final int BRONZE_PLATELEGS_G = 12207;
public static final int BRONZE_PLATESKIRT_G = 12209;
public static final int BRONZE_FULL_HELM_G = 12211;
public static final int BRONZE_KITESHIELD_G = 12213;
public static final int BRONZE_PLATEBODY_T = 12215;
public static final int BRONZE_PLATELEGS_T = 12217;
public static final int BRONZE_PLATESKIRT_T = 12219;
public static final int BRONZE_FULL_HELM_T = 12221;
public static final int BRONZE_KITESHIELD_T = 12223;
public static final int IRON_PLATEBODY_T = 12225;
public static final int IRON_PLATELEGS_T = 12227;
public static final int IRON_PLATESKIRT_T = 12229;
public static final int IRON_FULL_HELM_T = 12231;
public static final int IRON_KITESHIELD_T = 12233;
public static final int IRON_PLATEBODY_G = 12235;
public static final int IRON_PLATELEGS_G = 12237;
public static final int IRON_PLATESKIRT_G = 12239;
public static final int IRON_FULL_HELM_G = 12241;
public static final int IRON_KITESHIELD_G = 12243;
public static final int BEANIE = 12245;
public static final int RED_BERET = 12247;
public static final int IMP_MASK = 12249;
public static final int GOBLIN_MASK = 12251;
public static final int ARMADYL_ROBE_TOP = 12253;
public static final int ARMADYL_ROBE_LEGS = 12255;
public static final int ARMADYL_STOLE = 12257;
public static final int ARMADYL_MITRE = 12259;
public static final int ARMADYL_CLOAK = 12261;
public static final int ARMADYL_CROZIER = 12263;
public static final int BANDOS_ROBE_TOP = 12265;
public static final int BANDOS_ROBE_LEGS = 12267;
public static final int BANDOS_STOLE = 12269;
public static final int BANDOS_MITRE = 12271;
public static final int BANDOS_CLOAK = 12273;
public static final int BANDOS_CROZIER = 12275;
public static final int MITHRIL_PLATEBODY_G = 12277;
public static final int MITHRIL_PLATELEGS_G = 12279;
public static final int MITHRIL_KITESHIELD_G = 12281;
public static final int MITHRIL_FULL_HELM_G = 12283;
public static final int MITHRIL_PLATESKIRT_G = 12285;
public static final int MITHRIL_PLATEBODY_T = 12287;
public static final int MITHRIL_PLATELEGS_T = 12289;
public static final int MITHRIL_KITESHIELD_T = 12291;
public static final int MITHRIL_FULL_HELM_T = 12293;
public static final int MITHRIL_PLATESKIRT_T = 12295;
public static final int BLACK_PICKAXE = 12297;
public static final int WHITE_HEADBAND = 12299;
public static final int BLUE_HEADBAND = 12301;
public static final int GOLD_HEADBAND = 12303;
public static final int PINK_HEADBAND = 12305;
public static final int GREEN_HEADBAND = 12307;
public static final int PINK_BOATER = 12309;
public static final int PURPLE_BOATER = 12311;
public static final int WHITE_BOATER = 12313;
public static final int PINK_ELEGANT_SHIRT = 12315;
public static final int PINK_ELEGANT_LEGS = 12317;
public static final int CRIER_HAT = 12319;
public static final int WHITE_CAVALIER = 12321;
public static final int RED_CAVALIER = 12323;
public static final int NAVY_CAVALIER = 12325;
public static final int RED_DHIDE_BODY_G = 12327;
public static final int RED_DHIDE_CHAPS_G = 12329;
public static final int RED_DHIDE_BODY_T = 12331;
public static final int RED_DHIDE_CHAPS_T = 12333;
public static final int BRIEFCASE = 12335;
public static final int SAGACIOUS_SPECTACLES = 12337;
public static final int PINK_ELEGANT_BLOUSE = 12339;
public static final int PINK_ELEGANT_SKIRT = 12341;
public static final int GOLD_ELEGANT_BLOUSE = 12343;
public static final int GOLD_ELEGANT_SKIRT = 12345;
public static final int GOLD_ELEGANT_SHIRT = 12347;
public static final int GOLD_ELEGANT_LEGS = 12349;
public static final int MUSKETEER_HAT = 12351;
public static final int MONOCLE = 12353;
public static final int BIG_PIRATE_HAT = 12355;
public static final int KATANA = 12357;
public static final int LEPRECHAUN_HAT = 12359;
public static final int CAT_MASK = 12361;
public static final int BRONZE_DRAGON_MASK = 12363;
public static final int IRON_DRAGON_MASK = 12365;
public static final int STEEL_DRAGON_MASK = 12367;
public static final int MITHRIL_DRAGON_MASK = 12369;
public static final int LAVA_DRAGON_MASK = 12371;
public static final int DRAGON_CANE = 12373;
public static final int BLACK_CANE = 12375;
public static final int ADAMANT_CANE = 12377;
public static final int RUNE_CANE = 12379;
public static final int BLACK_DHIDE_BODY_G = 12381;
public static final int BLACK_DHIDE_CHAPS_G = 12383;
public static final int BLACK_DHIDE_BODY_T = 12385;
public static final int BLACK_DHIDE_CHAPS_T = 12387;
public static final int GILDED_SCIMITAR = 12389;
public static final int GILDED_BOOTS = 12391;
public static final int ROYAL_GOWN_TOP = 12393;
public static final int ROYAL_GOWN_BOTTOM = 12395;
public static final int ROYAL_CROWN = 12397;
public static final int PARTYHAT__SPECS = 12399;
public static final int NARDAH_TELEPORT = 12402;
public static final int DIGSITE_TELEPORT = 12403;
public static final int FELDIP_HILLS_TELEPORT = 12404;
public static final int LUNAR_ISLE_TELEPORT = 12405;
public static final int MORTTON_TELEPORT = 12406;
public static final int PEST_CONTROL_TELEPORT = 12407;
public static final int PISCATORIS_TELEPORT = 12408;
public static final int TAI_BWO_WANNAI_TELEPORT = 12409;
public static final int IORWERTH_CAMP_TELEPORT = 12410;
public static final int MOS_LEHARMLESS_TELEPORT = 12411;
public static final int PIRATE_HAT__PATCH = 12412;
public static final int DRAGON_CHAINBODY_G = 12414;
public static final int DRAGON_PLATELEGS_G = 12415;
public static final int DRAGON_PLATESKIRT_G = 12416;
public static final int DRAGON_FULL_HELM_G = 12417;
public static final int DRAGON_SQ_SHIELD_G = 12418;
public static final int LIGHT_INFINITY_HAT = 12419;
public static final int LIGHT_INFINITY_TOP = 12420;
public static final int LIGHT_INFINITY_BOTTOMS = 12421;
public static final int _3RD_AGE_WAND = 12422;
public static final int _3RD_AGE_BOW = 12424;
public static final int _3RD_AGE_LONGSWORD = 12426;
public static final int PENGUIN_MASK = 12428;
public static final int AFRO = 12430;
public static final int TOP_HAT = 12432;
public static final int TOP_HAT__MONOCLE = 12434;
public static final int AMULET_OF_FURY_OR = 12436;
public static final int _3RD_AGE_CLOAK = 12437;
public static final int ROYAL_SCEPTRE = 12439;
public static final int MUSKETEER_TABARD = 12441;
public static final int MUSKETEER_PANTS = 12443;
public static final int BLACK_SKIRT_G = 12445;
public static final int BLACK_SKIRT_T = 12447;
public static final int BLACK_WIZARD_ROBE_G = 12449;
public static final int BLACK_WIZARD_ROBE_T = 12451;
public static final int BLACK_WIZARD_HAT_G = 12453;
public static final int BLACK_WIZARD_HAT_T = 12455;
public static final int DARK_INFINITY_HAT = 12457;
public static final int DARK_INFINITY_TOP = 12458;
public static final int DARK_INFINITY_BOTTOMS = 12459;
public static final int ANCIENT_PLATEBODY = 12460;
public static final int ANCIENT_PLATELEGS = 12462;
public static final int ANCIENT_PLATESKIRT = 12464;
public static final int ANCIENT_FULL_HELM = 12466;
public static final int ANCIENT_KITESHIELD = 12468;
public static final int ARMADYL_PLATEBODY = 12470;
public static final int ARMADYL_PLATELEGS = 12472;
public static final int ARMADYL_PLATESKIRT = 12474;
public static final int ARMADYL_FULL_HELM = 12476;
public static final int ARMADYL_KITESHIELD = 12478;
public static final int BANDOS_PLATEBODY = 12480;
public static final int BANDOS_PLATELEGS = 12482;
public static final int BANDOS_PLATESKIRT = 12484;
public static final int BANDOS_FULL_HELM = 12486;
public static final int BANDOS_KITESHIELD = 12488;
public static final int ANCIENT_BRACERS = 12490;
public static final int ANCIENT_DHIDE_BODY = 12492;
public static final int ANCIENT_CHAPS = 12494;
public static final int ANCIENT_COIF = 12496;
public static final int BANDOS_BRACERS = 12498;
public static final int BANDOS_DHIDE_BODY = 12500;
public static final int BANDOS_CHAPS = 12502;
public static final int BANDOS_COIF = 12504;
public static final int ARMADYL_BRACERS = 12506;
public static final int ARMADYL_DHIDE_BODY = 12508;
public static final int ARMADYL_CHAPS = 12510;
public static final int ARMADYL_COIF = 12512;
public static final int EXPLORER_BACKPACK = 12514;
public static final int PITH_HELMET = 12516;
public static final int GREEN_DRAGON_MASK = 12518;
public static final int BLUE_DRAGON_MASK = 12520;
public static final int RED_DRAGON_MASK = 12522;
public static final int BLACK_DRAGON_MASK = 12524;
public static final int FURY_ORNAMENT_KIT = 12526;
public static final int DARK_INFINITY_COLOUR_KIT = 12528;
public static final int LIGHT_INFINITY_COLOUR_KIT = 12530;
public static final int DRAGON_SQ_SHIELD_ORNAMENT_KIT = 12532;
public static final int DRAGON_CHAINBODY_ORNAMENT_KIT = 12534;
public static final int DRAGON_LEGSSKIRT_ORNAMENT_KIT = 12536;
public static final int DRAGON_FULL_HELM_ORNAMENT_KIT = 12538;
public static final int DEERSTALKER = 12540;
public static final int CLUE_SCROLL_HARD_12542 = 12542;
public static final int CASKET_HARD_12543 = 12543;
public static final int CLUE_SCROLL_HARD_12544 = 12544;
public static final int CASKET_HARD_12545 = 12545;
public static final int CLUE_SCROLL_HARD_12546 = 12546;
public static final int CASKET_HARD_12547 = 12547;
public static final int CLUE_SCROLL_HARD_12548 = 12548;
public static final int CASKET_HARD_12549 = 12549;
public static final int CLUE_SCROLL_HARD_12550 = 12550;
public static final int CASKET_HARD_12551 = 12551;
public static final int CLUE_SCROLL_HARD_12552 = 12552;
public static final int CASKET_HARD_12553 = 12553;
public static final int CLUE_SCROLL_HARD_12554 = 12554;
public static final int CASKET_HARD_12555 = 12555;
public static final int CLUE_SCROLL_HARD_12556 = 12556;
public static final int CASKET_HARD_12557 = 12557;
public static final int CLUE_SCROLL_HARD_12558 = 12558;
public static final int CASKET_HARD_12559 = 12559;
public static final int CLUE_SCROLL_HARD_12560 = 12560;
public static final int CASKET_HARD_12561 = 12561;
public static final int CLUE_SCROLL_HARD_12562 = 12562;
public static final int CASKET_HARD_12563 = 12563;
public static final int CLUE_SCROLL_HARD_12564 = 12564;
public static final int CASKET_HARD_12565 = 12565;
public static final int CLUE_SCROLL_HARD_12566 = 12566;
public static final int CHALLENGE_SCROLL_HARD_12567 = 12567;
public static final int CLUE_SCROLL_HARD_12568 = 12568;
public static final int CHALLENGE_SCROLL_HARD_12569 = 12569;
public static final int CLUE_SCROLL_HARD_12570 = 12570;
public static final int CHALLENGE_SCROLL_HARD_12571 = 12571;
public static final int CLUE_SCROLL_HARD_12572 = 12572;
public static final int CHALLENGE_SCROLL_HARD_12573 = 12573;
public static final int CLUE_SCROLL_HARD_12574 = 12574;
public static final int CHALLENGE_SCROLL_HARD_12575 = 12575;
public static final int CLUE_SCROLL_HARD_12576 = 12576;
public static final int CHALLENGE_SCROLL_HARD_12577 = 12577;
public static final int CLUE_SCROLL_HARD_12578 = 12578;
public static final int PUZZLE_BOX_HARD_12579 = 12579;
public static final int CASKET_HARD_12580 = 12580;
public static final int CLUE_SCROLL_HARD_12581 = 12581;
public static final int PUZZLE_BOX_HARD_12582 = 12582;
public static final int CASKET_HARD_12583 = 12583;
public static final int CLUE_SCROLL_HARD_12584 = 12584;
public static final int PUZZLE_BOX_HARD_12585 = 12585;
public static final int CASKET_HARD_12586 = 12586;
public static final int CLUE_SCROLL_HARD_12587 = 12587;
public static final int PUZZLE_BOX_HARD_12588 = 12588;
public static final int CASKET_HARD_12589 = 12589;
public static final int CLUE_SCROLL_HARD_12590 = 12590;
public static final int CASKET_HARD_12591 = 12591;
public static final int BLACK_PICK_HEAD = 12592;
public static final int BROKEN_PICKAXE_12594 = 12594;
public static final int RANGERS_TUNIC = 12596;
public static final int HOLY_SANDALS = 12598;
public static final int DRUIDIC_WREATH = 12600;
public static final int RING_OF_THE_GODS = 12601;
public static final int TYRANNICAL_RING = 12603;
public static final int TREASONOUS_RING = 12605;
public static final int DAMAGED_BOOK_12607 = 12607;
public static final int BOOK_OF_WAR = 12608;
public static final int DAMAGED_BOOK_12609 = 12609;
public static final int BOOK_OF_LAW = 12610;
public static final int DAMAGED_BOOK_12611 = 12611;
public static final int BOOK_OF_DARKNESS = 12612;
public static final int BANDOS_PAGE_1 = 12613;
public static final int BANDOS_PAGE_2 = 12614;
public static final int BANDOS_PAGE_3 = 12615;
public static final int BANDOS_PAGE_4 = 12616;
public static final int ARMADYL_PAGE_1 = 12617;
public static final int ARMADYL_PAGE_2 = 12618;
public static final int ARMADYL_PAGE_3 = 12619;
public static final int ARMADYL_PAGE_4 = 12620;
public static final int ANCIENT_PAGE_1 = 12621;
public static final int ANCIENT_PAGE_2 = 12622;
public static final int ANCIENT_PAGE_3 = 12623;
public static final int ANCIENT_PAGE_4 = 12624;
public static final int STAMINA_POTION4 = 12625;
public static final int STAMINA_POTION3 = 12627;
public static final int STAMINA_POTION2 = 12629;
public static final int STAMINA_POTION1 = 12631;
public static final int STAMINA_MIX2 = 12633;
public static final int STAMINA_MIX1 = 12635;
public static final int SARADOMIN_HALO = 12637;
public static final int ZAMORAK_HALO = 12638;
public static final int GUTHIX_HALO = 12639;
public static final int AMYLASE_CRYSTAL = 12640;
public static final int AMYLASE_PACK = 12641;
public static final int LUMBERYARD_TELEPORT = 12642;
public static final int PET_DAGANNOTH_SUPREME = 12643;
public static final int PET_DAGANNOTH_PRIME = 12644;
public static final int PET_DAGANNOTH_REX = 12645;
public static final int BABY_MOLE = 12646;
public static final int KALPHITE_PRINCESS = 12647;
public static final int PET_SMOKE_DEVIL = 12648;
public static final int PET_KREEARRA = 12649;
public static final int PET_GENERAL_GRAARDOR = 12650;
public static final int PET_ZILYANA = 12651;
public static final int PET_KRIL_TSUTSAROTH = 12652;
public static final int PRINCE_BLACK_DRAGON = 12653;
public static final int KALPHITE_PRINCESS_12654 = 12654;
public static final int PET_KRAKEN = 12655;
public static final int JUNK = 12656;
public static final int JUNK_12657 = 12657;
public static final int IBANS_STAFF_U = 12658;
public static final int CLAN_WARS_CAPE = 12659;
public static final int CLAN_WARS_CAPE_12660 = 12660;
public static final int CLAN_WARS_CAPE_12661 = 12661;
public static final int CLAN_WARS_CAPE_12662 = 12662;
public static final int CLAN_WARS_CAPE_12663 = 12663;
public static final int CLAN_WARS_CAPE_12664 = 12664;
public static final int CLAN_WARS_CAPE_12665 = 12665;
public static final int CLAN_WARS_CAPE_12666 = 12666;
public static final int CLAN_WARS_CAPE_12667 = 12667;
public static final int CLAN_WARS_CAPE_12668 = 12668;
public static final int CLAN_WARS_CAPE_12669 = 12669;
public static final int CLAN_WARS_CAPE_12670 = 12670;
public static final int CLAN_WARS_CAPE_12671 = 12671;
public static final int CLAN_WARS_CAPE_12672 = 12672;
public static final int CLAN_WARS_CAPE_12673 = 12673;
public static final int CLAN_WARS_CAPE_12674 = 12674;
public static final int CLAN_WARS_CAPE_12675 = 12675;
public static final int CLAN_WARS_CAPE_12676 = 12676;
public static final int CLAN_WARS_CAPE_12677 = 12677;
public static final int CLAN_WARS_CAPE_12678 = 12678;
public static final int CLAN_WARS_CAPE_12679 = 12679;
public static final int CLAN_WARS_CAPE_12680 = 12680;
public static final int CLAN_WARS_CAPE_12681 = 12681;
public static final int CLAN_WARS_CAPE_12682 = 12682;
public static final int CLAN_WARS_CAPE_12683 = 12683;
public static final int CLAN_WARS_CAPE_12684 = 12684;
public static final int CLAN_WARS_CAPE_12685 = 12685;
public static final int CLAN_WARS_CAPE_12686 = 12686;
public static final int CLAN_WARS_CAPE_12687 = 12687;
public static final int CLAN_WARS_CAPE_12688 = 12688;
public static final int CLAN_WARS_CAPE_12689 = 12689;
public static final int CLAN_WARS_CAPE_12690 = 12690;
public static final int TYRANNICAL_RING_I = 12691;
public static final int TREASONOUS_RING_I = 12692;
public static final int KREEARRA = 12693;
public static final int CHAOS_ELEMENTAL = 12694;
public static final int SUPER_COMBAT_POTION4 = 12695;
public static final int SUPER_COMBAT_POTION3 = 12697;
public static final int SUPER_COMBAT_POTION2 = 12699;
public static final int SUPER_COMBAT_POTION1 = 12701;
public static final int PET_PENANCE_QUEEN = 12703;
public static final int OAK_HOUSE = 12704;
public static final int TEAK_HOUSE = 12705;
public static final int MAHOGANY_HOUSE = 12706;
public static final int CONSECRATED_HOUSE = 12707;
public static final int DESECRATED_HOUSE = 12708;
public static final int NATURE_HOUSE = 12709;
public static final int GRASSLAND_HABITAT = 12710;
public static final int FOREST_HABITAT = 12711;
public static final int DESERT_HABITAT = 12712;
public static final int POLAR_HABITAT = 12713;
public static final int VOLCANIC_HABITAT = 12714;
public static final int OAK_SCRATCHING_POST = 12715;
public static final int TEAK_SCRATCHING_POST = 12716;
public static final int MAHOGANY_SCRATCHING_POST = 12717;
public static final int SIMPLE_ARENA = 12718;
public static final int ADVANCED_ARENA = 12719;
public static final int GLORIOUS_ARENA = 12720;
public static final int PET_LIST = 12721;
public static final int OAK_FEEDER = 12722;
public static final int TEAK_FEEDER = 12723;
public static final int MAHOGANY_FEEDER = 12724;
public static final int MENAGERIE = 12725;
public static final int MENAGERIE_12726 = 12726;
public static final int EVENT_RPG = 12727;
public static final int AIR_RUNE_PACK = 12728;
public static final int WATER_RUNE_PACK = 12730;
public static final int EARTH_RUNE_PACK = 12732;
public static final int FIRE_RUNE_PACK = 12734;
public static final int MIND_RUNE_PACK = 12736;
public static final int CHAOS_RUNE_PACK = 12738;
public static final int BIRD_SNARE_PACK = 12740;
public static final int BOX_TRAP_PACK = 12742;
public static final int MAGIC_IMP_BOX_PACK = 12744;
public static final int ARCHAIC_EMBLEM_TIER_1 = 12746;
public static final int ARCHAIC_EMBLEM_TIER_1_12747 = 12747;
public static final int ARCHAIC_EMBLEM_TIER_2 = 12748;
public static final int ARCHAIC_EMBLEM_TIER_3 = 12749;
public static final int ARCHAIC_EMBLEM_TIER_4 = 12750;
public static final int ARCHAIC_EMBLEM_TIER_5 = 12751;
public static final int ARCHAIC_EMBLEM_TIER_6 = 12752;
public static final int ARCHAIC_EMBLEM_TIER_7 = 12753;
public static final int ARCHAIC_EMBLEM_TIER_8 = 12754;
public static final int ARCHAIC_EMBLEM_TIER_9 = 12755;
public static final int ARCHAIC_EMBLEM_TIER_10 = 12756;
public static final int BLUE_DARK_BOW_PAINT = 12757;
public static final int GREEN_DARK_BOW_PAINT = 12759;
public static final int YELLOW_DARK_BOW_PAINT = 12761;
public static final int WHITE_DARK_BOW_PAINT = 12763;
public static final int DARK_BOW_12765 = 12765;
public static final int DARK_BOW_12766 = 12766;
public static final int DARK_BOW_12767 = 12767;
public static final int DARK_BOW_12768 = 12768;
public static final int FROZEN_WHIP_MIX = 12769;
public static final int VOLCANIC_WHIP_MIX = 12771;
public static final int VOLCANIC_ABYSSAL_WHIP = 12773;
public static final int FROZEN_ABYSSAL_WHIP = 12774;
public static final int ANNAKARL_TELEPORT = 12775;
public static final int CARRALLANGAR_TELEPORT = 12776;
public static final int DAREEYAK_TELEPORT = 12777;
public static final int GHORROCK_TELEPORT = 12778;
public static final int KHARYRLL_TELEPORT = 12779;
public static final int LASSAR_TELEPORT = 12780;
public static final int PADDEWWA_TELEPORT = 12781;
public static final int SENNTISTEN_TELEPORT = 12782;
public static final int RING_OF_WEALTH_SCROLL = 12783;
public static final int RING_OF_WEALTH_I = 12785;
public static final int MAGIC_SHORTBOW_SCROLL = 12786;
public static final int MAGIC_SHORTBOW_I = 12788;
public static final int CLUE_BOX = 12789;
public static final int RUNE_POUCH = 12791;
public static final int NEST_BOX_EMPTY = 12792;
public static final int NEST_BOX_SEEDS = 12793;
public static final int NEST_BOX_RING = 12794;
public static final int STEAM_BATTLESTAFF_12795 = 12795;
public static final int MYSTIC_STEAM_STAFF_12796 = 12796;
public static final int DRAGON_PICKAXE_12797 = 12797;
public static final int STEAM_STAFF_UPGRADE_KIT = 12798;
public static final int DRAGON_PICKAXE_UPGRADE_KIT = 12800;
public static final int WARD_UPGRADE_KIT = 12802;
public static final int SARADOMINS_TEAR = 12804;
public static final int MALEDICTION_WARD_12806 = 12806;
public static final int ODIUM_WARD_12807 = 12807;
public static final int SARAS_BLESSED_SWORD_FULL = 12808;
public static final int SARADOMINS_BLESSED_SWORD = 12809;
public static final int IRONMAN_HELM = 12810;
public static final int IRONMAN_PLATEBODY = 12811;
public static final int IRONMAN_PLATELEGS = 12812;
public static final int ULTIMATE_IRONMAN_HELM = 12813;
public static final int ULTIMATE_IRONMAN_PLATEBODY = 12814;
public static final int ULTIMATE_IRONMAN_PLATELEGS = 12815;
public static final int PET_DARK_CORE = 12816;
public static final int ELYSIAN_SPIRIT_SHIELD = 12817;
public static final int ELYSIAN_SIGIL = 12819;
public static final int SPECTRAL_SPIRIT_SHIELD = 12821;
public static final int SPECTRAL_SIGIL = 12823;
public static final int ARCANE_SPIRIT_SHIELD = 12825;
public static final int ARCANE_SIGIL = 12827;
public static final int SPIRIT_SHIELD = 12829;
public static final int BLESSED_SPIRIT_SHIELD = 12831;
public static final int HOLY_ELIXIR = 12833;
public static final int COMMUNITY_PUMPKIN = 12835;
public static final int GRIM_REAPERS_DIARY = 12836;
public static final int GRIM_ROBE = 12837;
public static final int WILL_AND_TESTAMENT = 12838;
public static final int HUMAN_BONES = 12839;
public static final int SERVANTS_SKULL = 12840;
public static final int HOURGLASS_12841 = 12841;
public static final int SCYTHE_SHARPENER = 12842;
public static final int HUMAN_EYE = 12843;
public static final int VOICE_POTION = 12844;
public static final int GRIM_REAPER_HOOD = 12845;
public static final int TARGET_TELEPORT_SCROLL = 12846;
public static final int GRANITE_MAUL_12848 = 12848;
public static final int GRANITE_CLAMP = 12849;
public static final int AMULET_OF_THE_DAMNED_FULL = 12851;
public static final int AMULET_OF_THE_DAMNED = 12853;
public static final int FLAMTAER_BAG = 12854;
public static final int HUNTERS_HONOUR = 12855;
public static final int ROGUES_REVENGE = 12856;
public static final int OLIVE_OIL_PACK = 12857;
public static final int EYE_OF_NEWT_PACK = 12859;
public static final int THANKSGIVING_DINNER = 12861;
public static final int THANKSGIVING_DINNER_12862 = 12862;
public static final int DWARF_CANNON_SET = 12863;
public static final int GREEN_DRAGONHIDE_SET = 12865;
public static final int BLUE_DRAGONHIDE_SET = 12867;
public static final int RED_DRAGONHIDE_SET = 12869;
public static final int BLACK_DRAGONHIDE_SET = 12871;
public static final int GUTHANS_ARMOUR_SET = 12873;
public static final int VERACS_ARMOUR_SET = 12875;
public static final int DHAROKS_ARMOUR_SET = 12877;
public static final int TORAGS_ARMOUR_SET = 12879;
public static final int AHRIMS_ARMOUR_SET = 12881;
public static final int KARILS_ARMOUR_SET = 12883;
public static final int JAR_OF_SAND = 12885;
public static final int SANTA_MASK = 12887;
public static final int SANTA_JACKET = 12888;
public static final int SANTA_PANTALOONS = 12889;
public static final int SANTA_GLOVES = 12890;
public static final int SANTA_BOOTS = 12891;
public static final int ANTISANTA_MASK = 12892;
public static final int ANTISANTA_JACKET = 12893;
public static final int ANTISANTA_PANTALOONS = 12894;
public static final int ANTISANTA_GLOVES = 12895;
public static final int ANTISANTA_BOOTS = 12896;
public static final int ANTISANTAS_COAL_BOX = 12897;
public static final int ANTISANTAS_COAL_BOX_FULL = 12898;
public static final int TRIDENT_OF_THE_SWAMP = 12899;
public static final int UNCHARGED_TOXIC_TRIDENT = 12900;
public static final int TOXIC_STAFF_UNCHARGED = 12902;
public static final int TOXIC_STAFF_OF_THE_DEAD = 12904;
public static final int ANTIVENOM4 = 12905;
public static final int ANTIVENOM3 = 12907;
public static final int ANTIVENOM2 = 12909;
public static final int ANTIVENOM1 = 12911;
public static final int ANTIVENOM4_12913 = 12913;
public static final int ANTIVENOM3_12915 = 12915;
public static final int ANTIVENOM2_12917 = 12917;
public static final int ANTIVENOM1_12919 = 12919;
public static final int PET_SNAKELING = 12921;
public static final int TANZANITE_FANG = 12922;
public static final int TOXIC_BLOWPIPE_EMPTY = 12924;
public static final int TOXIC_BLOWPIPE = 12926;
public static final int SERPENTINE_VISAGE = 12927;
public static final int SERPENTINE_HELM_UNCHARGED = 12929;
public static final int SERPENTINE_HELM = 12931;
public static final int MAGIC_FANG = 12932;
public static final int ZULRAHS_SCALES = 12934;
public static final int OHNS_DIARY = 12935;
public static final int JAR_OF_SWAMP = 12936;
public static final int ZULANDRA_TELEPORT = 12938;
public static final int PET_SNAKELING_12939 = 12939;
public static final int PET_SNAKELING_12940 = 12940;
public static final int DRAGON_DEFENDER = 12954;
public static final int FREE_TO_PLAY_STARTER_PACK = 12955;
public static final int COW_TOP = 12956;
public static final int COW_TROUSERS = 12957;
public static final int COW_GLOVES = 12958;
public static final int COW_SHOES = 12959;
public static final int BRONZE_SET_LG = 12960;
public static final int BRONZE_SET_SK = 12962;
public static final int BRONZE_TRIMMED_SET_LG = 12964;
public static final int BRONZE_TRIMMED_SET_SK = 12966;
public static final int BRONZE_GOLDTRIMMED_SET_LG = 12968;
public static final int BRONZE_GOLDTRIMMED_SET_SK = 12970;
public static final int IRON_SET_LG = 12972;
public static final int IRON_SET_SK = 12974;
public static final int IRON_TRIMMED_SET_LG = 12976;
public static final int IRON_TRIMMED_SET_SK = 12978;
public static final int IRON_GOLDTRIMMED_SET_LG = 12980;
public static final int IRON_GOLDTRIMMED_SET_SK = 12982;
public static final int STEEL_SET_LG = 12984;
public static final int STEEL_SET_SK = 12986;
public static final int BLACK_SET_LG = 12988;
public static final int BLACK_SET_SK = 12990;
public static final int BLACK_TRIMMED_SET_LG = 12992;
public static final int BLACK_TRIMMED_SET_SK = 12994;
public static final int BLACK_GOLDTRIMMED_SET_LG = 12996;
public static final int BLACK_GOLDTRIMMED_SET_SK = 12998;
public static final int MITHRIL_SET_LG = 13000;
public static final int MITHRIL_SET_SK = 13002;
public static final int MITHRIL_TRIMMED_SET_LG = 13004;
public static final int MITHRIL_TRIMMED_SET_SK = 13006;
public static final int MITHRIL_GOLDTRIMMED_SET_LG = 13008;
public static final int MITHRIL_GOLDTRIMMED_SET_SK = 13010;
public static final int ADAMANT_SET_LG = 13012;
public static final int ADAMANT_SET_SK = 13014;
public static final int ADAMANT_TRIMMED_SET_LG = 13016;
public static final int ADAMANT_TRIMMED_SET_SK = 13018;
public static final int ADAMANT_GOLDTRIMMED_SET_LG = 13020;
public static final int ADAMANT_GOLDTRIMMED_SET_SK = 13022;
public static final int RUNE_ARMOUR_SET_LG = 13024;
public static final int RUNE_ARMOUR_SET_SK = 13026;
public static final int RUNE_TRIMMED_SET_LG = 13028;
public static final int RUNE_TRIMMED_SET_SK = 13030;
public static final int RUNE_GOLDTRIMMED_SET_LG = 13032;
public static final int RUNE_GOLDTRIMMED_SET_SK = 13034;
public static final int GILDED_ARMOUR_SET_LG = 13036;
public static final int GILDED_ARMOUR_SET_SK = 13038;
public static final int SARADOMIN_ARMOUR_SET_LG = 13040;
public static final int SARADOMIN_ARMOUR_SET_SK = 13042;
public static final int ZAMORAK_ARMOUR_SET_LG = 13044;
public static final int ZAMORAK_ARMOUR_SET_SK = 13046;
public static final int GUTHIX_ARMOUR_SET_LG = 13048;
public static final int GUTHIX_ARMOUR_SET_SK = 13050;
public static final int ARMADYL_RUNE_ARMOUR_SET_LG = 13052;
public static final int ARMADYL_RUNE_ARMOUR_SET_SK = 13054;
public static final int BANDOS_RUNE_ARMOUR_SET_LG = 13056;
public static final int BANDOS_RUNE_ARMOUR_SET_SK = 13058;
public static final int ANCIENT_RUNE_ARMOUR_SET_LG = 13060;
public static final int ANCIENT_RUNE_ARMOUR_SET_SK = 13062;
public static final int COMBAT_POTION_SET = 13064;
public static final int SUPER_POTION_SET = 13066;
public static final int QUEST_POINT_CAPE_T = 13068;
public static final int ACHIEVEMENT_DIARY_CAPE_T = 13069;
public static final int ACHIEVEMENT_DIARY_HOOD = 13070;
public static final int CHOMPY_CHICK = 13071;
public static final int ELITE_VOID_TOP = 13072;
public static final int ELITE_VOID_ROBE = 13073;
public static final int PHARAOHS_SCEPTRE_8 = 13074;
public static final int PHARAOHS_SCEPTRE_7 = 13075;
public static final int PHARAOHS_SCEPTRE_6 = 13076;
public static final int PHARAOHS_SCEPTRE_5 = 13077;
public static final int PHARAOHS_SCEPTRE_4 = 13078;
public static final int ENCHANTED_LYRE5 = 13079;
public static final int NEW_CRYSTAL_HALBERD_FULL_I = 13080;
public static final int CRYSTAL_HALBERD_FULL_I = 13081;
public static final int CRYSTAL_HALBERD_910_I = 13082;
public static final int CRYSTAL_HALBERD_810_I = 13083;
public static final int CRYSTAL_HALBERD_710_I = 13084;
public static final int CRYSTAL_HALBERD_610_I = 13085;
public static final int CRYSTAL_HALBERD_510_I = 13086;
public static final int CRYSTAL_HALBERD_410_I = 13087;
public static final int CRYSTAL_HALBERD_310_I = 13088;
public static final int CRYSTAL_HALBERD_210_I = 13089;
public static final int CRYSTAL_HALBERD_110_I = 13090;
public static final int NEW_CRYSTAL_HALBERD_FULL = 13091;
public static final int CRYSTAL_HALBERD_FULL = 13092;
public static final int CRYSTAL_HALBERD_910 = 13093;
public static final int CRYSTAL_HALBERD_810 = 13094;
public static final int CRYSTAL_HALBERD_710 = 13095;
public static final int CRYSTAL_HALBERD_610 = 13096;
public static final int CRYSTAL_HALBERD_510 = 13097;
public static final int CRYSTAL_HALBERD_410 = 13098;
public static final int CRYSTAL_HALBERD_310 = 13099;
public static final int CRYSTAL_HALBERD_210 = 13100;
public static final int CRYSTAL_HALBERD_110 = 13101;
public static final int TELEPORT_CRYSTAL_5 = 13102;
public static final int KARAMJA_GLOVES_4 = 13103;
public static final int VARROCK_ARMOUR_1 = 13104;
public static final int VARROCK_ARMOUR_2 = 13105;
public static final int VARROCK_ARMOUR_3 = 13106;
public static final int VARROCK_ARMOUR_4 = 13107;
public static final int WILDERNESS_SWORD_1 = 13108;
public static final int WILDERNESS_SWORD_2 = 13109;
public static final int WILDERNESS_SWORD_3 = 13110;
public static final int WILDERNESS_SWORD_4 = 13111;
public static final int MORYTANIA_LEGS_1 = 13112;
public static final int MORYTANIA_LEGS_2 = 13113;
public static final int MORYTANIA_LEGS_3 = 13114;
public static final int MORYTANIA_LEGS_4 = 13115;
public static final int BONECRUSHER = 13116;
public static final int FALADOR_SHIELD_1 = 13117;
public static final int FALADOR_SHIELD_2 = 13118;
public static final int FALADOR_SHIELD_3 = 13119;
public static final int FALADOR_SHIELD_4 = 13120;
public static final int ARDOUGNE_CLOAK_1 = 13121;
public static final int ARDOUGNE_CLOAK_2 = 13122;
public static final int ARDOUGNE_CLOAK_3 = 13123;
public static final int ARDOUGNE_CLOAK_4 = 13124;
public static final int EXPLORERS_RING_1 = 13125;
public static final int EXPLORERS_RING_2 = 13126;
public static final int EXPLORERS_RING_3 = 13127;
public static final int EXPLORERS_RING_4 = 13128;
public static final int FREMENNIK_SEA_BOOTS_1 = 13129;
public static final int FREMENNIK_SEA_BOOTS_2 = 13130;
public static final int FREMENNIK_SEA_BOOTS_3 = 13131;
public static final int FREMENNIK_SEA_BOOTS_4 = 13132;
public static final int DESERT_AMULET_1 = 13133;
public static final int DESERT_AMULET_2 = 13134;
public static final int DESERT_AMULET_3 = 13135;
public static final int DESERT_AMULET_4 = 13136;
public static final int KANDARIN_HEADGEAR_1 = 13137;
public static final int KANDARIN_HEADGEAR_2 = 13138;
public static final int KANDARIN_HEADGEAR_3 = 13139;
public static final int KANDARIN_HEADGEAR_4 = 13140;
public static final int WESTERN_BANNER_1 = 13141;
public static final int WESTERN_BANNER_2 = 13142;
public static final int WESTERN_BANNER_3 = 13143;
public static final int WESTERN_BANNER_4 = 13144;
public static final int ANTIQUE_LAMP_13145 = 13145;
public static final int ANTIQUE_LAMP_13146 = 13146;
public static final int ANTIQUE_LAMP_13147 = 13147;
public static final int ANTIQUE_LAMP_13148 = 13148;
public static final int HOLY_BOOK_PAGE_SET = 13149;
public static final int UNHOLY_BOOK_PAGE_SET = 13151;
public static final int BOOK_OF_BALANCE_PAGE_SET = 13153;
public static final int BOOK_OF_WAR_PAGE_SET = 13155;
public static final int BOOK_OF_LAW_PAGE_SET = 13157;
public static final int BOOK_OF_DARKNESS_PAGE_SET = 13159;
public static final int ZAMORAK_DRAGONHIDE_SET = 13161;
public static final int SARADOMIN_DRAGONHIDE_SET = 13163;
public static final int GUTHIX_DRAGONHIDE_SET = 13165;
public static final int BANDOS_DRAGONHIDE_SET = 13167;
public static final int ARMADYL_DRAGONHIDE_SET = 13169;
public static final int ANCIENT_DRAGONHIDE_SET = 13171;
public static final int PARTYHAT_SET = 13173;
public static final int HALLOWEEN_MASK_SET = 13175;
public static final int VENENATIS_SPIDERLING = 13177;
public static final int CALLISTO_CUB = 13178;
public static final int VETION_JR = 13179;
public static final int VETION_JR_13180 = 13180;
public static final int SCORPIAS_OFFSPRING = 13181;
public static final int BUNNY_FEET = 13182;
public static final int EMPTY_BLASTER = 13183;
public static final int INCOMPLETE_BLASTER = 13184;
public static final int EASTER_BLASTER = 13185;
public static final int VOLATILE_MINERAL = 13186;
public static final int PACKAGE = 13187;
public static final int DIANGOS_CLAWS = 13188;
public static final int OLD_SCHOOL_BOND = 13190;
public static final int OLD_SCHOOL_BOND_UNTRADEABLE = 13192;
public static final int BONE_BOLT_PACK = 13193;
public static final int ODDSKULL = 13195;
public static final int TANZANITE_HELM_UNCHARGED = 13196;
public static final int TANZANITE_HELM = 13197;
public static final int MAGMA_HELM_UNCHARGED = 13198;
public static final int MAGMA_HELM = 13199;
public static final int TANZANITE_MUTAGEN = 13200;
public static final int MAGMA_MUTAGEN = 13201;
public static final int RING_OF_THE_GODS_I = 13202;
public static final int MASK_OF_BALANCE = 13203;
public static final int PLATINUM_TOKEN = 13204;
public static final int ROTTEN_EGG = 13205;
public static final int TIGER_TOY = 13215;
public static final int LION_TOY = 13216;
public static final int SNOW_LEOPARD_TOY = 13217;
public static final int AMUR_LEOPARD_TOY = 13218;
public static final int MUSIC_CAPE = 13221;
public static final int MUSIC_CAPET = 13222;
public static final int MUSIC_HOOD = 13223;
public static final int MUSIC_CAPE_13224 = 13224;
public static final int TZREKJAD = 13225;
public static final int HERB_SACK = 13226;
public static final int ETERNAL_CRYSTAL = 13227;
public static final int PEGASIAN_CRYSTAL = 13229;
public static final int PRIMORDIAL_CRYSTAL = 13231;
public static final int SMOULDERING_STONE = 13233;
public static final int ETERNAL_BOOTS = 13235;
public static final int PEGASIAN_BOOTS = 13237;
public static final int PRIMORDIAL_BOOTS = 13239;
public static final int INFERNAL_AXE = 13241;
public static final int INFERNAL_AXE_UNCHARGED = 13242;
public static final int INFERNAL_PICKAXE = 13243;
public static final int INFERNAL_PICKAXE_UNCHARGED = 13244;
public static final int JAR_OF_SOULS = 13245;
public static final int HELLPUPPY = 13247;
public static final int KEY_MASTERS_KEY = 13248;
public static final int KEY_MASTER_TELEPORT = 13249;
public static final int PLANT_POT_PACK = 13250;
public static final int SACK_PACK = 13252;
public static final int BASKET_PACK = 13254;
public static final int SARADOMINS_LIGHT = 13256;
public static final int ANGLER_HAT = 13258;
public static final int ANGLER_TOP = 13259;
public static final int ANGLER_WADERS = 13260;
public static final int ANGLER_BOOTS = 13261;
public static final int ABYSSAL_ORPHAN = 13262;
public static final int ABYSSAL_BLUDGEON = 13263;
public static final int ABYSSAL_DAGGER = 13265;
public static final int ABYSSAL_DAGGER_P = 13267;
public static final int ABYSSAL_DAGGER_P_13269 = 13269;
public static final int ABYSSAL_DAGGER_P_13271 = 13271;
public static final int UNSIRED = 13273;
public static final int BLUDGEON_SPINE = 13274;
public static final int BLUDGEON_CLAW = 13275;
public static final int BLUDGEON_AXON = 13276;
public static final int JAR_OF_MIASMA = 13277;
public static final int OVERSEERS_BOOK = 13279;
public static final int MAX_CAPE = 13280;
public static final int MAX_HOOD = 13281;
public static final int MAX_CAPE_13282 = 13282;
public static final int GRAVEDIGGER_MASK = 13283;
public static final int GRAVEDIGGER_TOP = 13284;
public static final int GRAVEDIGGER_LEGGINGS = 13285;
public static final int GRAVEDIGGER_BOOTS = 13286;
public static final int GRAVEDIGGER_GLOVES = 13287;
public static final int ANTIPANTIES = 13288;
public static final int BANK_KEY = 13302;
public static final int BANK_KEY_13303 = 13303;
public static final int BANK_KEY_13304 = 13304;
public static final int BANK_KEY_13305 = 13305;
public static final int BANK_KEY_13306 = 13306;
public static final int BLOOD_MONEY = 13307;
public static final int DEADMANS_CHEST = 13317;
public static final int DEADMANS_LEGS = 13318;
public static final int DEADMANS_CAPE = 13319;
public static final int HERON = 13320;
public static final int ROCK_GOLEM = 13321;
public static final int BEAVER = 13322;
public static final int BABY_CHINCHOMPA = 13323;
public static final int BABY_CHINCHOMPA_13324 = 13324;
public static final int BABY_CHINCHOMPA_13325 = 13325;
public static final int BABY_CHINCHOMPA_13326 = 13326;
public static final int ROTTEN_ONION = 13327;
public static final int GREEN_BANNER = 13328;
public static final int FIRE_MAX_CAPE = 13329;
public static final int FIRE_MAX_HOOD = 13330;
public static final int SARADOMIN_MAX_CAPE = 13331;
public static final int SARADOMIN_MAX_HOOD = 13332;
public static final int ZAMORAK_MAX_CAPE = 13333;
public static final int ZAMORAK_MAX_HOOD = 13334;
public static final int GUTHIX_MAX_CAPE = 13335;
public static final int GUTHIX_MAX_HOOD = 13336;
public static final int ACCUMULATOR_MAX_CAPE = 13337;
public static final int ACCUMULATOR_MAX_HOOD = 13338;
public static final int SACRED_EEL = 13339;
public static final int AGILITY_CAPE_13340 = 13340;
public static final int AGILITY_CAPET_13341 = 13341;
public static final int MAX_CAPE_13342 = 13342;
public static final int BLACK_SANTA_HAT = 13343;
public static final int INVERTED_SANTA_HAT = 13344;
public static final int ANTIPRESENT = 13345;
public static final int PRESENT_13346 = 13346;
public static final int VIAL_OF_TEARS_EMPTY = 13347;
public static final int VIAL_OF_TEARS_1 = 13348;
public static final int VIAL_OF_TEARS_2 = 13349;
public static final int VIAL_OF_TEARS_3 = 13350;
public static final int VIAL_OF_TEARS_FULL = 13351;
public static final int VIAL_OF_SORROW = 13352;
public static final int GRICOLLERS_CAN = 13353;
public static final int LOVAKITE_BAR = 13354;
public static final int JUNIPER_LOGS = 13355;
public static final int LOVAKITE_ORE = 13356;
public static final int SHAYZIEN_GLOVES_1 = 13357;
public static final int SHAYZIEN_BOOTS_1 = 13358;
public static final int SHAYZIEN_HELM_1 = 13359;
public static final int SHAYZIEN_GREAVES_1 = 13360;
public static final int SHAYZIEN_PLATEBODY_1 = 13361;
public static final int SHAYZIEN_GLOVES_2 = 13362;
public static final int SHAYZIEN_BOOTS_2 = 13363;
public static final int SHAYZIEN_HELM_2 = 13364;
public static final int SHAYZIEN_GREAVES_2 = 13365;
public static final int SHAYZIEN_PLATEBODY_2 = 13366;
public static final int SHAYZIEN_GLOVES_3 = 13367;
public static final int SHAYZIEN_BOOTS_3 = 13368;
public static final int SHAYZIEN_HELM_3 = 13369;
public static final int SHAYZIEN_GREAVES_3 = 13370;
public static final int SHAYZIEN_PLATEBODY_3 = 13371;
public static final int SHAYZIEN_GLOVES_4 = 13372;
public static final int SHAYZIEN_BOOTS_4 = 13373;
public static final int SHAYZIEN_HELM_4 = 13374;
public static final int SHAYZIEN_GREAVES_4 = 13375;
public static final int SHAYZIEN_PLATEBODY_4 = 13376;
public static final int SHAYZIEN_GLOVES_5 = 13377;
public static final int SHAYZIEN_BOOTS_5 = 13378;
public static final int SHAYZIEN_HELM_5 = 13379;
public static final int SHAYZIEN_GREAVES_5 = 13380;
public static final int SHAYZIEN_PLATEBODY_5 = 13381;
public static final int SHAYZIEN_MEDPACK = 13382;
public static final int XERICIAN_FABRIC = 13383;
public static final int XERICIAN_HAT = 13385;
public static final int XERICIAN_TOP = 13387;
public static final int XERICIAN_ROBE = 13389;
public static final int LIZARDMAN_FANG = 13391;
public static final int XERICS_TALISMAN_INERT = 13392;
public static final int XERICS_TALISMAN = 13393;
public static final int GANG_MEETING_INFO = 13394;
public static final int INTELLIGENCE = 13395;
public static final int TRAINING_MANUAL = 13396;
public static final int SERVERY_FLOUR = 13397;
public static final int SERVERY_PASTRY_DOUGH = 13398;
public static final int SERVERY_RAW_MEAT = 13399;
public static final int SERVERY_DISH = 13400;
public static final int SERVERY_PIE_SHELL = 13401;
public static final int SERVERY_UNCOOKED_PIE = 13402;
public static final int SERVERY_MEAT_PIE = 13403;
public static final int SERVERY_PIZZA_BASE = 13404;
public static final int SERVERY_TOMATO = 13405;
public static final int SERVERY_INCOMPLETE_PIZZA = 13406;
public static final int SERVERY_CHEESE = 13407;
public static final int SERVERY_UNCOOKED_PIZZA = 13408;
public static final int SERVERY_PLAIN_PIZZA = 13409;
public static final int SERVERY_PINEAPPLE = 13410;
public static final int SERVERY_PINEAPPLE_CHUNKS = 13411;
public static final int SERVERY_PINEAPPLE_PIZZA = 13412;
public static final int SERVERY_COOKED_MEAT = 13413;
public static final int SERVERY_POTATO = 13414;
public static final int SERVERY_INCOMPLETE_STEW = 13415;
public static final int SERVERY_INCOMPLETE_STEW_13416 = 13416;
public static final int SERVERY_UNCOOKED_STEW = 13417;
public static final int SERVERY_STEW = 13418;
public static final int SULPHUROUS_FERTILISER = 13419;
public static final int GRICOLLERS_FERTILISER = 13420;
public static final int SALTPETRE = 13421;
public static final int GOLOVANOVA_SEED = 13423;
public static final int BOLOGANO_SEED = 13424;
public static final int LOGAVANO_SEED = 13425;
public static final int GOLOVANOVA_FRUIT = 13426;
public static final int BOLOGANO_FRUIT = 13427;
public static final int LOGAVANO_FRUIT = 13428;
public static final int FRESH_FISH = 13429;
public static final int BUCKET_OF_SANDWORMS = 13430;
public static final int SANDWORMS = 13431;
public static final int SANDWORMS_PACK = 13432;
public static final int STOLEN_PENDANT = 13434;
public static final int STOLEN_GARNET_RING = 13435;
public static final int STOLEN_CIRCLET = 13436;
public static final int STOLEN_FAMILY_HEIRLOOM = 13437;
public static final int STOLEN_JEWELRY_BOX = 13438;
public static final int RAW_ANGLERFISH = 13439;
public static final int ANGLERFISH = 13441;
public static final int BURNT_ANGLERFISH = 13443;
public static final int DENSE_ESSENCE_BLOCK = 13445;
public static final int DARK_ESSENCE_BLOCK = 13446;
public static final int ENSOULED_GOBLIN_HEAD = 13447;
public static final int ENSOULED_GOBLIN_HEAD_13448 = 13448;
public static final int ENSOULED_MONKEY_HEAD = 13450;
public static final int ENSOULED_MONKEY_HEAD_13451 = 13451;
public static final int ENSOULED_IMP_HEAD = 13453;
public static final int ENSOULED_IMP_HEAD_13454 = 13454;
public static final int ENSOULED_MINOTAUR_HEAD = 13456;
public static final int ENSOULED_MINOTAUR_HEAD_13457 = 13457;
public static final int ENSOULED_SCORPION_HEAD = 13459;
public static final int ENSOULED_SCORPION_HEAD_13460 = 13460;
public static final int ENSOULED_BEAR_HEAD = 13462;
public static final int ENSOULED_BEAR_HEAD_13463 = 13463;
public static final int ENSOULED_UNICORN_HEAD = 13465;
public static final int ENSOULED_UNICORN_HEAD_13466 = 13466;
public static final int ENSOULED_DOG_HEAD = 13468;
public static final int ENSOULED_DOG_HEAD_13469 = 13469;
public static final int ENSOULED_CHAOS_DRUID_HEAD = 13471;
public static final int ENSOULED_CHAOS_DRUID_HEAD_13472 = 13472;
public static final int ENSOULED_GIANT_HEAD = 13474;
public static final int ENSOULED_GIANT_HEAD_13475 = 13475;
public static final int ENSOULED_OGRE_HEAD = 13477;
public static final int ENSOULED_OGRE_HEAD_13478 = 13478;
public static final int ENSOULED_ELF_HEAD = 13480;
public static final int ENSOULED_ELF_HEAD_13481 = 13481;
public static final int ENSOULED_TROLL_HEAD = 13483;
public static final int ENSOULED_TROLL_HEAD_13484 = 13484;
public static final int ENSOULED_HORROR_HEAD = 13486;
public static final int ENSOULED_HORROR_HEAD_13487 = 13487;
public static final int ENSOULED_KALPHITE_HEAD = 13489;
public static final int ENSOULED_KALPHITE_HEAD_13490 = 13490;
public static final int ENSOULED_DAGANNOTH_HEAD = 13492;
public static final int ENSOULED_DAGANNOTH_HEAD_13493 = 13493;
public static final int ENSOULED_BLOODVELD_HEAD = 13495;
public static final int ENSOULED_BLOODVELD_HEAD_13496 = 13496;
public static final int ENSOULED_TZHAAR_HEAD = 13498;
public static final int ENSOULED_TZHAAR_HEAD_13499 = 13499;
public static final int ENSOULED_DEMON_HEAD = 13501;
public static final int ENSOULED_DEMON_HEAD_13502 = 13502;
public static final int ENSOULED_AVIANSIE_HEAD = 13504;
public static final int ENSOULED_AVIANSIE_HEAD_13505 = 13505;
public static final int ENSOULED_ABYSSAL_HEAD = 13507;
public static final int ENSOULED_ABYSSAL_HEAD_13508 = 13508;
public static final int ENSOULED_DRAGON_HEAD = 13510;
public static final int ENSOULED_DRAGON_HEAD_13511 = 13511;
public static final int BOOK_OF_ARCANE_KNOWLEDGE = 13513;
public static final int DARK_MANUSCRIPT = 13514;
public static final int DARK_MANUSCRIPT_13515 = 13515;
public static final int DARK_MANUSCRIPT_13516 = 13516;
public static final int DARK_MANUSCRIPT_13517 = 13517;
public static final int DARK_MANUSCRIPT_13518 = 13518;
public static final int DARK_MANUSCRIPT_13519 = 13519;
public static final int DARK_MANUSCRIPT_13520 = 13520;
public static final int DARK_MANUSCRIPT_13521 = 13521;
public static final int DARK_MANUSCRIPT_13522 = 13522;
public static final int DARK_MANUSCRIPT_13523 = 13523;
public static final int RADAS_CENSUS = 13524;
public static final int RICKTORS_DIARY_7 = 13525;
public static final int EATHRAM__RADA_EXTRACT = 13526;
public static final int KILLING_OF_A_KING = 13527;
public static final int HOSIDIUS_LETTER = 13528;
public static final int WINTERTODT_PARABLE = 13529;
public static final int TWILL_ACCORD = 13530;
public static final int BYRNES_CORONATION_SPEECH = 13531;
public static final int IDEOLOGY_OF_DARKNESS = 13532;
public static final int RADAS_JOURNEY = 13533;
public static final int TRANSVERGENCE_THEORY = 13534;
public static final int TRISTESSAS_TRAGEDY = 13535;
public static final int TREACHERY_OF_ROYALTY = 13536;
public static final int TRANSPORTATION_INCANTATIONS = 13537;
public static final int SHAYZIEN_SUPPLY_GLOVES_1 = 13538;
public static final int SHAYZIEN_SUPPLY_BOOTS_1 = 13539;
public static final int SHAYZIEN_SUPPLY_HELM_1 = 13540;
public static final int SHAYZIEN_SUPPLY_GREAVES_1 = 13541;
public static final int SHAYZIEN_SUPPLY_PLATEBODY_1 = 13542;
public static final int SHAYZIEN_SUPPLY_GLOVES_2 = 13543;
public static final int SHAYZIEN_SUPPLY_BOOTS_2 = 13544;
public static final int SHAYZIEN_SUPPLY_HELM_2 = 13545;
public static final int SHAYZIEN_SUPPLY_GREAVES_2 = 13546;
public static final int SHAYZIEN_SUPPLY_PLATEBODY_2 = 13547;
public static final int SHAYZIEN_SUPPLY_GLOVES_3 = 13548;
public static final int SHAYZIEN_SUPPLY_BOOTS_3 = 13549;
public static final int SHAYZIEN_SUPPLY_HELM_3 = 13550;
public static final int SHAYZIEN_SUPPLY_GREAVES_3 = 13551;
public static final int SHAYZIEN_SUPPLY_PLATEBODY_3 = 13552;
public static final int SHAYZIEN_SUPPLY_GLOVES_4 = 13553;
public static final int SHAYZIEN_SUPPLY_BOOTS_4 = 13554;
public static final int SHAYZIEN_SUPPLY_HELM_4 = 13555;
public static final int SHAYZIEN_SUPPLY_GREAVES_4 = 13556;
public static final int SHAYZIEN_SUPPLY_PLATEBODY_4 = 13557;
public static final int SHAYZIEN_SUPPLY_GLOVES_5 = 13558;
public static final int SHAYZIEN_SUPPLY_BOOTS_5 = 13559;
public static final int SHAYZIEN_SUPPLY_HELM_5 = 13560;
public static final int SHAYZIEN_SUPPLY_GREAVES_5 = 13561;
public static final int SHAYZIEN_SUPPLY_PLATEBODY_5 = 13562;
public static final int SHAYZIEN_SUPPLY_CRATE = 13563;
public static final int SHAYZIEN_SUPPLY_SET_1 = 13565;
public static final int SHAYZIEN_SUPPLY_SET_2 = 13566;
public static final int SHAYZIEN_SUPPLY_SET_3 = 13567;
public static final int SHAYZIEN_SUPPLY_SET_4 = 13568;
public static final int SHAYZIEN_SUPPLY_SET_5 = 13569;
public static final int JUNIPER_CHARCOAL = 13570;
public static final int VOLCANIC_SULPHUR = 13571;
public static final int DYNAMITE_POT = 13572;
public static final int DYNAMITE = 13573;
public static final int BLASTED_ORE = 13575;
public static final int DRAGON_WARHAMMER = 13576;
public static final int GRACEFUL_HOOD_13579 = 13579;
public static final int GRACEFUL_HOOD_13580 = 13580;
public static final int GRACEFUL_CAPE_13581 = 13581;
public static final int GRACEFUL_CAPE_13582 = 13582;
public static final int GRACEFUL_TOP_13583 = 13583;
public static final int GRACEFUL_TOP_13584 = 13584;
public static final int GRACEFUL_LEGS_13585 = 13585;
public static final int GRACEFUL_LEGS_13586 = 13586;
public static final int GRACEFUL_GLOVES_13587 = 13587;
public static final int GRACEFUL_GLOVES_13588 = 13588;
public static final int GRACEFUL_BOOTS_13589 = 13589;
public static final int GRACEFUL_BOOTS_13590 = 13590;
public static final int GRACEFUL_HOOD_13591 = 13591;
public static final int GRACEFUL_HOOD_13592 = 13592;
public static final int GRACEFUL_CAPE_13593 = 13593;
public static final int GRACEFUL_CAPE_13594 = 13594;
public static final int GRACEFUL_TOP_13595 = 13595;
public static final int GRACEFUL_TOP_13596 = 13596;
public static final int GRACEFUL_LEGS_13597 = 13597;
public static final int GRACEFUL_LEGS_13598 = 13598;
public static final int GRACEFUL_GLOVES_13599 = 13599;
public static final int GRACEFUL_GLOVES_13600 = 13600;
public static final int GRACEFUL_BOOTS_13601 = 13601;
public static final int GRACEFUL_BOOTS_13602 = 13602;
public static final int GRACEFUL_HOOD_13603 = 13603;
public static final int GRACEFUL_HOOD_13604 = 13604;
public static final int GRACEFUL_CAPE_13605 = 13605;
public static final int GRACEFUL_CAPE_13606 = 13606;
public static final int GRACEFUL_TOP_13607 = 13607;
public static final int GRACEFUL_TOP_13608 = 13608;
public static final int GRACEFUL_LEGS_13609 = 13609;
public static final int GRACEFUL_LEGS_13610 = 13610;
public static final int GRACEFUL_GLOVES_13611 = 13611;
public static final int GRACEFUL_GLOVES_13612 = 13612;
public static final int GRACEFUL_BOOTS_13613 = 13613;
public static final int GRACEFUL_BOOTS_13614 = 13614;
public static final int GRACEFUL_HOOD_13615 = 13615;
public static final int GRACEFUL_HOOD_13616 = 13616;
public static final int GRACEFUL_CAPE_13617 = 13617;
public static final int GRACEFUL_CAPE_13618 = 13618;
public static final int GRACEFUL_TOP_13619 = 13619;
public static final int GRACEFUL_TOP_13620 = 13620;
public static final int GRACEFUL_LEGS_13621 = 13621;
public static final int GRACEFUL_LEGS_13622 = 13622;
public static final int GRACEFUL_GLOVES_13623 = 13623;
public static final int GRACEFUL_GLOVES_13624 = 13624;
public static final int GRACEFUL_BOOTS_13625 = 13625;
public static final int GRACEFUL_BOOTS_13626 = 13626;
public static final int GRACEFUL_HOOD_13627 = 13627;
public static final int GRACEFUL_HOOD_13628 = 13628;
public static final int GRACEFUL_CAPE_13629 = 13629;
public static final int GRACEFUL_CAPE_13630 = 13630;
public static final int GRACEFUL_TOP_13631 = 13631;
public static final int GRACEFUL_TOP_13632 = 13632;
public static final int GRACEFUL_LEGS_13633 = 13633;
public static final int GRACEFUL_LEGS_13634 = 13634;
public static final int GRACEFUL_GLOVES_13635 = 13635;
public static final int GRACEFUL_GLOVES_13636 = 13636;
public static final int GRACEFUL_BOOTS_13637 = 13637;
public static final int GRACEFUL_BOOTS_13638 = 13638;
public static final int SEED_BOX = 13639;
public static final int FARMERS_BORO_TROUSERS = 13640;
public static final int FARMERS_BORO_TROUSERS_13641 = 13641;
public static final int FARMERS_JACKET = 13642;
public static final int FARMERS_SHIRT = 13643;
public static final int FARMERS_BOOTS = 13644;
public static final int FARMERS_BOOTS_13645 = 13645;
public static final int FARMERS_STRAWHAT = 13646;
public static final int FARMERS_STRAWHAT_13647 = 13647;
public static final int CLUE_BOTTLE_EASY = 13648;
public static final int CLUE_BOTTLE_MEDIUM = 13649;
public static final int CLUE_BOTTLE_HARD = 13650;
public static final int CLUE_BOTTLE_ELITE = 13651;
public static final int DRAGON_CLAWS = 13652;
public static final int BIRD_NEST_13653 = 13653;
public static final int NEST_BOX_SEEDS_13654 = 13654;
public static final int GNOME_CHILD_HAT = 13655;
public static final int PRESENT_13656 = 13656;
public static final int GRAPE_SEED = 13657;
public static final int TELEPORT_CARD = 13658;
public static final int CHRONICLE = 13660;
public static final int BUNNY_TOP = 13663;
public static final int BUNNY_LEGS = 13664;
public static final int BUNNY_PAWS = 13665;
public static final int DEADMAN_TELEPORT_TABLET = 13666;
public static final int GRACEFUL_HOOD_13667 = 13667;
public static final int GRACEFUL_HOOD_13668 = 13668;
public static final int GRACEFUL_CAPE_13669 = 13669;
public static final int GRACEFUL_CAPE_13670 = 13670;
public static final int GRACEFUL_TOP_13671 = 13671;
public static final int GRACEFUL_TOP_13672 = 13672;
public static final int GRACEFUL_LEGS_13673 = 13673;
public static final int GRACEFUL_LEGS_13674 = 13674;
public static final int GRACEFUL_GLOVES_13675 = 13675;
public static final int GRACEFUL_GLOVES_13676 = 13676;
public static final int GRACEFUL_BOOTS_13677 = 13677;
public static final int GRACEFUL_BOOTS_13678 = 13678;
public static final int CABBAGE_CAPE = 13679;
public static final int CABBAGE_RUNE = 13680;
public static final int CRUCIFEROUS_CODEX = 13681;
public static final int USELESS_KEY_16684 = 16684;
public static final int NEW_CRYSTAL_BOW_16888 = 16888;
public static final int NEW_CRYSTAL_BOW_I_16889 = 16889;
public static final int NEW_CRYSTAL_SHIELD_16890 = 16890;
public static final int NEW_CRYSTAL_SHIELD_I_16891 = 16891;
public static final int NEW_CRYSTAL_HALBERD_FULL_I_16892 = 16892;
public static final int NEW_CRYSTAL_HALBERD_FULL_16893 = 16893;
public static final int DEAD_ORB_17152 = 17152;
public static final int BAG_FULL_OF_GEMS = 19473;
public static final int ACHIEVEMENT_DIARY_CAPE = 19476;
public static final int LIGHT_BALLISTA = 19478;
public static final int HEAVY_BALLISTA = 19481;
public static final int DRAGON_JAVELIN = 19484;
public static final int DRAGON_JAVELINP = 19486;
public static final int DRAGON_JAVELINP_19488 = 19488;
public static final int DRAGON_JAVELINP_19490 = 19490;
public static final int ZENYTE_BRACELET = 19492;
public static final int ZENYTE = 19493;
public static final int UNCUT_ZENYTE = 19496;
public static final int ZENYTE_AMULET_U = 19501;
public static final int MYSTERIOUS_NOTE = 19505;
public static final int MYSTERIOUS_NOTE_19507 = 19507;
public static final int MYSTERIOUS_NOTE_19509 = 19509;
public static final int SCRAWLED_NOTE_19511 = 19511;
public static final int TRANSLATED_NOTE = 19513;
public static final int BOOK_OF_SPYOLOGY = 19515;
public static final int BRUSH = 19517;
public static final int JUICECOATED_BRUSH = 19519;
public static final int HANDKERCHIEF = 19521;
public static final int KRUKS_PAW = 19523;
public static final int KRUK_MONKEY_GREEGREE = 19525;
public static final int SATCHEL = 19527;
public static final int SATCHEL_19528 = 19528;
public static final int ZENYTE_SHARD = 19529;
public static final int ZENYTE_BRACELET_19532 = 19532;
public static final int ZENYTE_NECKLACE = 19535;
public static final int ZENYTE_RING = 19538;
public static final int ZENYTE_AMULET = 19541;
public static final int TORMENTED_BRACELET = 19544;
public static final int NECKLACE_OF_ANGUISH = 19547;
public static final int RING_OF_SUFFERING = 19550;
public static final int AMULET_OF_TORTURE = 19553;
public static final int MONKEY_19556 = 19556;
public static final int NIEVE = 19558;
public static final int ELYSIAN_SPIRIT_SHIELD_19559 = 19559;
public static final int CHARGED_ONYX = 19560;
public static final int DECONSTRUCTED_ONYX = 19562;
public static final int ROYAL_SEED_POD = 19564;
public static final int BRONZE_KEY_19566 = 19566;
public static final int COMBAT_SCARRED_KEY = 19567;
public static final int COMBAT_SCRATCHED_KEY = 19568;
public static final int COMBAT_DAMAGED_KEY = 19569;
public static final int BRONZE_JAVELIN_HEADS = 19570;
public static final int IRON_JAVELIN_HEADS = 19572;
public static final int STEEL_JAVELIN_HEADS = 19574;
public static final int MITHRIL_JAVELIN_HEADS = 19576;
public static final int ADAMANT_JAVELIN_HEADS = 19578;
public static final int RUNE_JAVELIN_HEADS = 19580;
public static final int DRAGON_JAVELIN_HEADS = 19582;
public static final int JAVELIN_SHAFT = 19584;
public static final int LIGHT_FRAME = 19586;
public static final int HEAVY_FRAME = 19589;
public static final int BALLISTA_LIMBS = 19592;
public static final int INCOMPLETE_LIGHT_BALLISTA = 19595;
public static final int INCOMPLETE_HEAVY_BALLISTA = 19598;
public static final int BALLISTA_SPRING = 19601;
public static final int UNSTRUNG_LIGHT_BALLISTA = 19604;
public static final int UNSTRUNG_HEAVY_BALLISTA = 19607;
public static final int MONKEY_TAIL = 19610;
public static final int LUMBRIDGE_GRAVEYARD_TELEPORT = 19613;
public static final int DRAYNOR_MANOR_TELEPORT = 19615;
public static final int MIND_ALTAR_TELEPORT = 19617;
public static final int SALVE_GRAVEYARD_TELEPORT = 19619;
public static final int FENKENSTRAINS_CASTLE_TELEPORT = 19621;
public static final int WEST_ARDOUGNE_TELEPORT = 19623;
public static final int HARMONY_ISLAND_TELEPORT = 19625;
public static final int CEMETERY_TELEPORT = 19627;
public static final int BARROWS_TELEPORT = 19629;
public static final int APE_ATOLL_TELEPORT = 19631;
public static final int SOUL_BEARER = 19634;
public static final int DAMAGED_SOUL_BEARER = 19636;
public static final int SOUL_JOURNEY = 19637;
public static final int BLACK_SLAYER_HELMET = 19639;
public static final int BLACK_SLAYER_HELMET_I = 19641;
public static final int GREEN_SLAYER_HELMET = 19643;
public static final int GREEN_SLAYER_HELMET_I = 19645;
public static final int RED_SLAYER_HELMET = 19647;
public static final int RED_SLAYER_HELMET_I = 19649;
public static final int HOSIDIUS_TELEPORT = 19651;
public static final int GOLOVANOVA_FRUIT_TOP = 19653;
public static final int UNCOOKED_BOTANICAL_PIE = 19656;
public static final int HALF_A_BOTANICAL_PIE = 19659;
public static final int BOTANICAL_PIE = 19662;
public static final int DAMAGED_MONKEY_TAIL = 19665;
public static final int MINECART_CONTROL_SCROLL = 19668;
public static final int REDWOOD_LOGS = 19669;
public static final int REDWOOD_PYRE_LOGS = 19672;
public static final int ARCLIGHT = 19675;
public static final int ANCIENT_SHARD = 19677;
public static final int DARK_TOTEM_BASE = 19679;
public static final int DARK_TOTEM_MIDDLE = 19681;
public static final int DARK_TOTEM_TOP = 19683;
public static final int DARK_TOTEM = 19685;
public static final int HELM_OF_RAEDWALD = 19687;
public static final int CLUE_HUNTER_GARB = 19689;
public static final int CLUE_HUNTER_GLOVES = 19691;
public static final int CLUE_HUNTER_TROUSERS = 19693;
public static final int CLUE_HUNTER_BOOTS = 19695;
public static final int CLUE_HUNTER_CLOAK = 19697;
public static final int HORNWOOD_HELM = 19699;
public static final int JAR_OF_DARKNESS = 19701;
public static final int COMPOST_PACK = 19704;
public static final int AMULET_OF_ETERNAL_GLORY = 19707;
public static final int RING_OF_SUFFERING_I = 19710;
public static final int CLUE_NEST_EASY = 19712;
public static final int CLUE_NEST_MEDIUM = 19714;
public static final int CLUE_NEST_HARD = 19716;
public static final int CLUE_NEST_ELITE = 19718;
public static final int OCCULT_NECKLACE_OR = 19720;
public static final int DRAGON_DEFENDER_T = 19722;
public static final int LEFT_EYE_PATCH = 19724;
public static final int DOUBLE_EYE_PATCH = 19727;
public static final int BLOODHOUND = 19730;
public static final int LUCKY_IMPLING_JAR = 19732;
public static final int CLUE_SCROLL_MEDIUM_19734 = 19734;
public static final int CHALLENGE_SCROLL_MEDIUM_19735 = 19735;
public static final int CLUE_SCROLL_MEDIUM_19736 = 19736;
public static final int CHALLENGE_SCROLL_MEDIUM_19737 = 19737;
public static final int CLUE_SCROLL_MEDIUM_19738 = 19738;
public static final int CHALLENGE_SCROLL_MEDIUM_19739 = 19739;
public static final int CLUE_SCROLL_MEDIUM_19740 = 19740;
public static final int CHALLENGE_SCROLL_MEDIUM_19741 = 19741;
public static final int CLUE_SCROLL_MEDIUM_19742 = 19742;
public static final int CHALLENGE_SCROLL_MEDIUM_19743 = 19743;
public static final int CLUE_SCROLL_MEDIUM_19744 = 19744;
public static final int CHALLENGE_SCROLL_MEDIUM_19745 = 19745;
public static final int CLUE_SCROLL_MEDIUM_19746 = 19746;
public static final int CHALLENGE_SCROLL_MEDIUM_19747 = 19747;
public static final int CLUE_SCROLL_MEDIUM_19748 = 19748;
public static final int CHALLENGE_SCROLL_MEDIUM_19749 = 19749;
public static final int CLUE_SCROLL_MEDIUM_19750 = 19750;
public static final int CHALLENGE_SCROLL_MEDIUM_19751 = 19751;
public static final int CLUE_SCROLL_MEDIUM_19752 = 19752;
public static final int CHALLENGE_SCROLL_MEDIUM_19753 = 19753;
public static final int CLUE_SCROLL_MEDIUM_19754 = 19754;
public static final int CHALLENGE_SCROLL_MEDIUM_19755 = 19755;
public static final int CLUE_SCROLL_MEDIUM_19756 = 19756;
public static final int CHALLENGE_SCROLL_MEDIUM_19757 = 19757;
public static final int CLUE_SCROLL_MEDIUM_19758 = 19758;
public static final int CHALLENGE_SCROLL_MEDIUM_19759 = 19759;
public static final int CLUE_SCROLL_MEDIUM_19760 = 19760;
public static final int KEY_MEDIUM_19761 = 19761;
public static final int CLUE_SCROLL_MEDIUM_19762 = 19762;
public static final int CHALLENGE_SCROLL_MEDIUM_19763 = 19763;
public static final int CLUE_SCROLL_MEDIUM_19764 = 19764;
public static final int CHALLENGE_SCROLL_MEDIUM_19765 = 19765;
public static final int CLUE_SCROLL_MEDIUM_19766 = 19766;
public static final int CHALLENGE_SCROLL_MEDIUM_19767 = 19767;
public static final int CLUE_SCROLL_MEDIUM_19768 = 19768;
public static final int CHALLENGE_SCROLL_MEDIUM_19769 = 19769;
public static final int CLUE_SCROLL_MEDIUM_19770 = 19770;
public static final int CHALLENGE_SCROLL_MEDIUM_19771 = 19771;
public static final int CLUE_SCROLL_MEDIUM_19772 = 19772;
public static final int CHALLENGE_SCROLL_MEDIUM_19773 = 19773;
public static final int CLUE_SCROLL_MEDIUM_19774 = 19774;
public static final int CASKET_MEDIUM_19775 = 19775;
public static final int CLUE_SCROLL_MEDIUM_19776 = 19776;
public static final int CASKET_MEDIUM_19777 = 19777;
public static final int CLUE_SCROLL_MEDIUM_19778 = 19778;
public static final int CASKET_MEDIUM_19779 = 19779;
public static final int CLUE_SCROLL_MEDIUM_19780 = 19780;
public static final int CASKET_MEDIUM_19781 = 19781;
public static final int CLUE_SCROLL_ELITE_19782 = 19782;
public static final int CLUE_SCROLL_ELITE_19783 = 19783;
public static final int CLUE_SCROLL_ELITE_19784 = 19784;
public static final int CLUE_SCROLL_ELITE_19785 = 19785;
public static final int CLUE_SCROLL_ELITE_19786 = 19786;
public static final int CLUE_SCROLL_ELITE_19787 = 19787;
public static final int CLUE_SCROLL_ELITE_19788 = 19788;
public static final int CLUE_SCROLL_ELITE_19789 = 19789;
public static final int CLUE_SCROLL_ELITE_19790 = 19790;
public static final int CLUE_SCROLL_ELITE_19791 = 19791;
public static final int CLUE_SCROLL_ELITE_19792 = 19792;
public static final int CLUE_SCROLL_ELITE_19793 = 19793;
public static final int CLUE_SCROLL_ELITE_19794 = 19794;
public static final int CLUE_SCROLL_ELITE_19795 = 19795;
public static final int CLUE_SCROLL_ELITE_19796 = 19796;
public static final int CLUE_SCROLL_ELITE_19797 = 19797;
public static final int CLUE_SCROLL_ELITE_19798 = 19798;
public static final int CLUE_SCROLL_ELITE_19799 = 19799;
public static final int CLUE_SCROLL_ELITE_19800 = 19800;
public static final int CLUE_SCROLL_ELITE_19801 = 19801;
public static final int CLUE_SCROLL_ELITE_19802 = 19802;
public static final int CLUE_SCROLL_ELITE_19803 = 19803;
public static final int CLUE_SCROLL_ELITE_19804 = 19804;
public static final int CLUE_SCROLL_ELITE_19805 = 19805;
public static final int CLUE_SCROLL_ELITE_19806 = 19806;
public static final int CLUE_SCROLL_ELITE_19807 = 19807;
public static final int CLUE_SCROLL_ELITE_19808 = 19808;
public static final int CLUE_SCROLL_ELITE_19809 = 19809;
public static final int CLUE_SCROLL_ELITE_19810 = 19810;
public static final int CLUE_SCROLL_ELITE_19811 = 19811;
public static final int KEY_ELITE = 19812;
public static final int CLUE_SCROLL_ELITE_19813 = 19813;
public static final int CLUE_SCROLL_EASY_19814 = 19814;
public static final int CASKET_EASY_19815 = 19815;
public static final int CLUE_SCROLL_EASY_19816 = 19816;
public static final int CLUE_SCROLL_EASY_19817 = 19817;
public static final int CLUE_SCROLL_EASY_19818 = 19818;
public static final int CLUE_SCROLL_EASY_19819 = 19819;
public static final int CLUE_SCROLL_EASY_19820 = 19820;
public static final int CLUE_SCROLL_EASY_19821 = 19821;
public static final int CLUE_SCROLL_EASY_19822 = 19822;
public static final int CLUE_SCROLL_EASY_19823 = 19823;
public static final int CLUE_SCROLL_EASY_19824 = 19824;
public static final int CLUE_SCROLL_EASY_19825 = 19825;
public static final int CLUE_SCROLL_EASY_19826 = 19826;
public static final int CASKET_EASY_19827 = 19827;
public static final int CLUE_SCROLL_EASY_19828 = 19828;
public static final int CLUE_SCROLL_EASY_19829 = 19829;
public static final int CLUE_SCROLL_EASY_19830 = 19830;
public static final int CLUE_SCROLL_EASY_19831 = 19831;
public static final int CASKET_EASY_19832 = 19832;
public static final int CLUE_SCROLL_EASY_19833 = 19833;
public static final int CASKET_EASY_19834 = 19834;
public static final int CLUE_SCROLL_MASTER = 19835;
public static final int REWARD_CASKET_MASTER = 19836;
public static final int TORN_CLUE_SCROLL_PART_1 = 19837;
public static final int TORN_CLUE_SCROLL_PART_2 = 19838;
public static final int TORN_CLUE_SCROLL_PART_3 = 19839;
public static final int CLUE_SCROLL_HARD_19840 = 19840;
public static final int CASKET_HARD_19841 = 19841;
public static final int CLUE_SCROLL_HARD_19842 = 19842;
public static final int CASKET_HARD_19843 = 19843;
public static final int CLUE_SCROLL_HARD_19844 = 19844;
public static final int CASKET_HARD_19845 = 19845;
public static final int CLUE_SCROLL_HARD_19846 = 19846;
public static final int CHALLENGE_SCROLL_HARD_19847 = 19847;
public static final int CLUE_SCROLL_HARD_19848 = 19848;
public static final int CASKET_HARD_19849 = 19849;
public static final int CLUE_SCROLL_HARD_19850 = 19850;
public static final int CASKET_HARD_19851 = 19851;
public static final int CLUE_SCROLL_HARD_19852 = 19852;
public static final int CLUE_SCROLL_HARD_19853 = 19853;
public static final int CLUE_SCROLL_HARD_19854 = 19854;
public static final int CHALLENGE_SCROLL_HARD_19855 = 19855;
public static final int CLUE_SCROLL_HARD_19856 = 19856;
public static final int CLUE_SCROLL_HARD_19857 = 19857;
public static final int CLUE_SCROLL_HARD_19858 = 19858;
public static final int CHALLENGE_SCROLL_HARD_19859 = 19859;
public static final int CLUE_SCROLL_HARD_19860 = 19860;
public static final int CASKET_HARD_19861 = 19861;
public static final int CLUE_SCROLL_HARD_19862 = 19862;
public static final int CASKET_HARD_19863 = 19863;
public static final int CLUE_SCROLL_HARD_19864 = 19864;
public static final int CASKET_HARD_19865 = 19865;
public static final int CLUE_SCROLL_HARD_19866 = 19866;
public static final int CASKET_HARD_19867 = 19867;
public static final int CLUE_SCROLL_HARD_19868 = 19868;
public static final int CASKET_HARD_19869 = 19869;
public static final int CLUE_SCROLL_HARD_19870 = 19870;
public static final int CASKET_HARD_19871 = 19871;
public static final int CLUE_SCROLL_HARD_19872 = 19872;
public static final int CASKET_HARD_19873 = 19873;
public static final int CLUE_SCROLL_HARD_19874 = 19874;
public static final int CASKET_HARD_19875 = 19875;
public static final int CLUE_SCROLL_HARD_19876 = 19876;
public static final int CASKET_HARD_19877 = 19877;
public static final int CLUE_SCROLL_HARD_19878 = 19878;
public static final int CASKET_HARD_19879 = 19879;
public static final int CLUE_SCROLL_HARD_19880 = 19880;
public static final int CASKET_HARD_19881 = 19881;
public static final int CLUE_SCROLL_HARD_19882 = 19882;
public static final int CHALLENGE_SCROLL_HARD_19883 = 19883;
public static final int CLUE_SCROLL_HARD_19884 = 19884;
public static final int CHALLENGE_SCROLL_HARD_19885 = 19885;
public static final int CLUE_SCROLL_HARD_19886 = 19886;
public static final int PUZZLE_BOX_HARD_19887 = 19887;
public static final int CLUE_SCROLL_HARD_19888 = 19888;
public static final int CHALLENGE_SCROLL_HARD_19889 = 19889;
public static final int CLUE_SCROLL_HARD_19890 = 19890;
public static final int PUZZLE_BOX_HARD_19891 = 19891;
public static final int CLUE_SCROLL_HARD_19892 = 19892;
public static final int CHALLENGE_SCROLL_HARD_19893 = 19893;
public static final int CLUE_SCROLL_HARD_19894 = 19894;
public static final int PUZZLE_BOX_HARD_19895 = 19895;
public static final int CLUE_SCROLL_HARD_19896 = 19896;
public static final int PUZZLE_BOX_HARD_19897 = 19897;
public static final int CLUE_SCROLL_HARD_19898 = 19898;
public static final int CHALLENGE_SCROLL_HARD_19899 = 19899;
public static final int CLUE_SCROLL_HARD_19900 = 19900;
public static final int CHALLENGE_SCROLL_HARD_19901 = 19901;
public static final int CLUE_SCROLL_HARD_19902 = 19902;
public static final int PUZZLE_BOX_HARD_19903 = 19903;
public static final int CLUE_SCROLL_HARD_19904 = 19904;
public static final int CHALLENGE_SCROLL_HARD_19905 = 19905;
public static final int CLUE_SCROLL_HARD_19906 = 19906;
public static final int CHALLENGE_SCROLL_HARD_19907 = 19907;
public static final int CLUE_SCROLL_HARD_19908 = 19908;
public static final int CHALLENGE_SCROLL_HARD_19909 = 19909;
public static final int CLUE_SCROLL_HARD_19910 = 19910;
public static final int PUZZLE_BOX_HARD_19911 = 19911;
public static final int ZOMBIE_HEAD_19912 = 19912;
public static final int CYCLOPS_HEAD = 19915;
public static final int NUNCHAKU = 19918;
public static final int ANCIENT_DHIDE_BOOTS = 19921;
public static final int BANDOS_DHIDE_BOOTS = 19924;
public static final int GUTHIX_DHIDE_BOOTS = 19927;
public static final int ARMADYL_DHIDE_BOOTS = 19930;
public static final int SARADOMIN_DHIDE_BOOTS = 19933;
public static final int ZAMORAK_DHIDE_BOOTS = 19936;
public static final int STRANGE_DEVICE = 19939;
public static final int HEAVY_CASKET = 19941;
public static final int ARCEUUS_SCARF = 19943;
public static final int HOSIDIUS_SCARF = 19946;
public static final int LOVAKENGJ_SCARF = 19949;
public static final int PISCARILIUS_SCARF = 19952;
public static final int SHAYZIEN_SCARF = 19955;
public static final int DARK_TUXEDO_JACKET = 19958;
public static final int DARK_TUXEDO_CUFFS = 19961;
public static final int DARK_TROUSERS = 19964;
public static final int DARK_TUXEDO_SHOES = 19967;
public static final int DARK_BOW_TIE = 19970;
public static final int LIGHT_TUXEDO_JACKET = 19973;
public static final int LIGHT_TUXEDO_CUFFS = 19976;
public static final int LIGHT_TROUSERS = 19979;
public static final int LIGHT_TUXEDO_SHOES = 19982;
public static final int LIGHT_BOW_TIE = 19985;
public static final int BLACKSMITHS_HELM = 19988;
public static final int BUCKET_HELM = 19991;
public static final int RANGER_GLOVES = 19994;
public static final int HOLY_WRAPS = 19997;
public static final int DRAGON_SCIMITAR_OR = 20000;
public static final int DRAGON_SCIMITAR_ORNAMENT_KIT = 20002;
public static final int RING_OF_NATURE = 20005;
public static final int FANCY_TIARA = 20008;
public static final int _3RD_AGE_AXE = 20011;
public static final int _3RD_AGE_PICKAXE = 20014;
public static final int RING_OF_COINS = 20017;
public static final int LESSER_DEMON_MASK = 20020;
public static final int GREATER_DEMON_MASK = 20023;
public static final int BLACK_DEMON_MASK = 20026;
public static final int OLD_DEMON_MASK = 20029;
public static final int JUNGLE_DEMON_MASK = 20032;
public static final int SAMURAI_KASA = 20035;
public static final int SAMURAI_SHIRT = 20038;
public static final int SAMURAI_GLOVES = 20041;
public static final int SAMURAI_GREAVES = 20044;
public static final int SAMURAI_BOOTS = 20047;
public static final int OBSIDIAN_CAPE_R = 20050;
public static final int HALF_MOON_SPECTACLES = 20053;
public static final int ALE_OF_THE_GODS = 20056;
public static final int BUCKET_HELM_G = 20059;
public static final int TORTURE_ORNAMENT_KIT = 20062;
public static final int OCCULT_ORNAMENT_KIT = 20065;
public static final int ARMADYL_GODSWORD_ORNAMENT_KIT = 20068;
public static final int BANDOS_GODSWORD_ORNAMENT_KIT = 20071;
public static final int SARADOMIN_GODSWORD_ORNAMENT_KIT = 20074;
public static final int ZAMORAK_GODSWORD_ORNAMENT_KIT = 20077;
public static final int MUMMYS_HEAD = 20080;
public static final int MUMMYS_BODY = 20083;
public static final int MUMMYS_HANDS = 20086;
public static final int MUMMYS_LEGS = 20089;
public static final int MUMMYS_FEET = 20092;
public static final int ANKOU_MASK = 20095;
public static final int ANKOU_TOP = 20098;
public static final int ANKOU_GLOVES = 20101;
public static final int ANKOUS_LEGGINGS = 20104;
public static final int ANKOU_SOCKS = 20107;
public static final int BOWL_WIG = 20110;
public static final int ARCEUUS_HOOD = 20113;
public static final int HOSIDIUS_HOOD = 20116;
public static final int LOVAKENGJ_HOOD = 20119;
public static final int PISCARILIUS_HOOD = 20122;
public static final int SHAYZIEN_HOOD = 20125;
public static final int HOOD_OF_DARKNESS = 20128;
public static final int ROBE_TOP_OF_DARKNESS = 20131;
public static final int GLOVES_OF_DARKNESS = 20134;
public static final int ROBE_BOTTOM_OF_DARKNESS = 20137;
public static final int BOOTS_OF_DARKNESS = 20140;
public static final int DRAGON_DEFENDER_ORNAMENT_KIT = 20143;
public static final int GILDED_MED_HELM = 20146;
public static final int GILDED_CHAINBODY = 20149;
public static final int GILDED_SQ_SHIELD = 20152;
public static final int GILDED_2H_SWORD = 20155;
public static final int GILDED_SPEAR = 20158;
public static final int GILDED_HASTA = 20161;
public static final int LARGE_SPADE = 20164;
public static final int WOODEN_SHIELD_G = 20166;
public static final int STEEL_PLATEBODY_G = 20169;
public static final int STEEL_PLATELEGS_G = 20172;
public static final int STEEL_PLATESKIRT_G = 20175;
public static final int STEEL_FULL_HELM_G = 20178;
public static final int STEEL_KITESHIELD_G = 20181;
public static final int STEEL_PLATEBODY_T = 20184;
public static final int STEEL_PLATELEGS_T = 20187;
public static final int STEEL_PLATESKIRT_T = 20190;
public static final int STEEL_FULL_HELM_T = 20193;
public static final int STEEL_KITESHIELD_T = 20196;
public static final int MONKS_ROBE_TOP_G = 20199;
public static final int MONKS_ROBE_G = 20202;
public static final int GOLDEN_CHEFS_HAT = 20205;
public static final int GOLDEN_APRON = 20208;
public static final int TEAM_CAPE_ZERO = 20211;
public static final int TEAM_CAPE_X = 20214;
public static final int TEAM_CAPE_I = 20217;
public static final int HOLY_BLESSING = 20220;
public static final int UNHOLY_BLESSING = 20223;
public static final int PEACEFUL_BLESSING = 20226;
public static final int HONOURABLE_BLESSING = 20229;
public static final int WAR_BLESSING = 20232;
public static final int ANCIENT_BLESSING = 20235;
public static final int CHARGE_DRAGONSTONE_JEWELLERY_SCROLL = 20238;
public static final int CRIER_COAT = 20240;
public static final int CRIER_BELL = 20243;
public static final int BLACK_LEPRECHAUN_HAT = 20246;
public static final int CLUELESS_SCROLL = 20249;
public static final int ARCEUUS_BANNER = 20251;
public static final int HOSIDIUS_BANNER = 20254;
public static final int LOVAKENGJ_BANNER = 20257;
public static final int PISCARILIUS_BANNER = 20260;
public static final int SHAYZIEN_BANNER = 20263;
public static final int BLACK_UNICORN_MASK = 20266;
public static final int WHITE_UNICORN_MASK = 20269;
public static final int CABBAGE_ROUND_SHIELD = 20272;
public static final int GNOMISH_FIRELIGHTER = 20275;
public static final int GNOMISH_FIRELIGHTER_20278 = 20278;
public static final int PUZZLE_BOX_MASTER = 20280;
public static final int PUZZLE_BOX_MASTER_20281 = 20281;
public static final int PUZZLE_BOX_MASTER_20282 = 20282;
public static final int LIGHT_BOX = 20355;
public static final int CLUE_GEODE_EASY = 20358;
public static final int CLUE_GEODE_MEDIUM = 20360;
public static final int CLUE_GEODE_HARD = 20362;
public static final int CLUE_GEODE_ELITE = 20364;
public static final int AMULET_OF_TORTURE_OR = 20366;
public static final int ARMADYL_GODSWORD_OR = 20368;
public static final int BANDOS_GODSWORD_OR = 20370;
public static final int SARADOMIN_GODSWORD_OR = 20372;
public static final int ZAMORAK_GODSWORD_OR = 20374;
public static final int STEEL_TRIMMED_SET_LG = 20376;
public static final int STEEL_TRIMMED_SET_SK = 20379;
public static final int STEEL_GOLDTRIMMED_SET_LG = 20382;
public static final int STEEL_GOLDTRIMMED_SET_SK = 20385;
public static final int ADAMANT_ARROW_20388 = 20388;
public static final int DRAGON_ARROW_20389 = 20389;
public static final int SHARK_20390 = 20390;
public static final int PRAYER_POTION4_20393 = 20393;
public static final int PRAYER_POTION3_20394 = 20394;
public static final int PRAYER_POTION2_20395 = 20395;
public static final int PRAYER_POTION1_20396 = 20396;
public static final int SPEAR = 20397;
public static final int YEW_SHORTBOW_20401 = 20401;
public static final int RUNE_SCIMITAR_20402 = 20402;
public static final int MAPLE_SHORTBOW_20403 = 20403;
public static final int ABYSSAL_WHIP_20405 = 20405;
public static final int DRAGON_SCIMITAR_20406 = 20406;
public static final int DRAGON_DAGGER_20407 = 20407;
public static final int DARK_BOW_20408 = 20408;
public static final int ADAMANT_PLATEBODY_20415 = 20415;
public static final int ADAMANT_PLATELEGS_20416 = 20416;
public static final int BLUE_DHIDE_BODY_20417 = 20417;
public static final int BLUE_DHIDE_CHAPS_20418 = 20418;
public static final int RUNE_PLATEBODY_20421 = 20421;
public static final int RUNE_PLATELEGS_20422 = 20422;
public static final int BLACK_DHIDE_BODY_20423 = 20423;
public static final int BLACK_DHIDE_CHAPS_20424 = 20424;
public static final int MYSTIC_ROBE_TOP_20425 = 20425;
public static final int MYSTIC_ROBE_BOTTOM_20426 = 20426;
public static final int DRAGON_CHAINBODY_20428 = 20428;
public static final int DRAGON_PLATELEGS_20429 = 20429;
public static final int ANCIENT_MAGICKS_TABLET = 20430;
public static final int ANCIENT_STAFF_20431 = 20431;
public static final int EVIL_CHICKEN_FEET = 20433;
public static final int EVIL_CHICKEN_WINGS = 20436;
public static final int EVIL_CHICKEN_HEAD = 20439;
public static final int EVIL_CHICKEN_LEGS = 20442;
public static final int FIRE_CAPE_BROKEN = 20445;
public static final int FIRE_MAX_CAPE_BROKEN = 20447;
public static final int BRONZE_DEFENDER_BROKEN = 20449;
public static final int IRON_DEFENDER_BROKEN = 20451;
public static final int STEEL_DEFENDER_BROKEN = 20453;
public static final int BLACK_DEFENDER_BROKEN = 20455;
public static final int MITHRIL_DEFENDER_BROKEN = 20457;
public static final int ADAMANT_DEFENDER_BROKEN = 20459;
public static final int RUNE_DEFENDER_BROKEN = 20461;
public static final int DRAGON_DEFENDER_BROKEN = 20463;
public static final int VOID_KNIGHT_TOP_BROKEN = 20465;
public static final int ELITE_VOID_TOP_BROKEN = 20467;
public static final int VOID_KNIGHT_ROBE_BROKEN = 20469;
public static final int ELITE_VOID_ROBE_BROKEN = 20471;
public static final int VOID_KNIGHT_MACE_BROKEN = 20473;
public static final int VOID_KNIGHT_GLOVES_BROKEN = 20475;
public static final int VOID_MAGE_HELM_BROKEN = 20477;
public static final int VOID_RANGER_HELM_BROKEN = 20479;
public static final int VOID_MELEE_HELM_BROKEN = 20481;
public static final int DECORATIVE_SWORD_BROKEN = 20483;
public static final int DECORATIVE_ARMOUR_BROKEN = 20485;
public static final int DECORATIVE_ARMOUR_BROKEN_20487 = 20487;
public static final int DECORATIVE_HELM_BROKEN = 20489;
public static final int DECORATIVE_SHIELD_BROKEN = 20491;
public static final int DECORATIVE_ARMOUR_BROKEN_20493 = 20493;
public static final int DECORATIVE_ARMOUR_BROKEN_20495 = 20495;
public static final int DECORATIVE_ARMOUR_BROKEN_20497 = 20497;
public static final int DECORATIVE_ARMOUR_BROKEN_20499 = 20499;
public static final int DECORATIVE_ARMOUR_BROKEN_20501 = 20501;
public static final int DECORATIVE_ARMOUR_BROKEN_20503 = 20503;
public static final int DECORATIVE_ARMOUR_BROKEN_20505 = 20505;
public static final int FIGHTER_HAT_BROKEN = 20507;
public static final int RANGER_HAT_BROKEN = 20509;
public static final int HEALER_HAT_BROKEN = 20511;
public static final int FIGHTER_TORSO_BROKEN = 20513;
public static final int PENANCE_SKIRT_BROKEN = 20515;
public static final int ELDER_CHAOS_TOP = 20517;
public static final int ELDER_CHAOS_ROBE = 20520;
public static final int CATALYTIC_RUNE_PACK = 20523;
public static final int ELEMENTAL_RUNE_PACK = 20524;
public static final int ADAMANT_ARROW_PACK = 20525;
public static final int BLOODY_KEY = 20526;
public static final int SURVIVAL_TOKEN = 20527;
public static final int STASH_UNITS_EASY = 20532;
public static final int STASH_UNITS_MEDIUM = 20533;
public static final int STASH_UNITS_HARD = 20534;
public static final int STASH_UNITS_ELITE = 20535;
public static final int STASH_UNITS_MASTER = 20536;
public static final int SARADOMIN_HALO_BROKEN = 20537;
public static final int ZAMORAK_HALO_BROKEN = 20539;
public static final int GUTHIX_HALO_BROKEN = 20541;
public static final int REWARD_CASKET_ELITE = 20543;
public static final int REWARD_CASKET_HARD = 20544;
public static final int REWARD_CASKET_MEDIUM = 20545;
public static final int REWARD_CASKET_EASY = 20546;
public static final int MONKFISH_20547 = 20547;
public static final int SUPER_ENERGY4_20548 = 20548;
public static final int SUPER_ENERGY3_20549 = 20549;
public static final int SUPER_ENERGY2_20550 = 20550;
public static final int SUPER_ENERGY1_20551 = 20551;
public static final int RUNE_BATTLEAXE_20552 = 20552;
public static final int BEGINNER_WAND_20553 = 20553;
public static final int TOKTZXILAK_20554 = 20554;
public static final int RUNE_2H_SWORD_20555 = 20555;
public static final int APPRENTICE_WAND_20556 = 20556;
public static final int GRANITE_MAUL_20557 = 20557;
public static final int MAGIC_SHORTBOW_20558 = 20558;
public static final int DRAGON_2H_SWORD_20559 = 20559;
public static final int MASTER_WAND_20560 = 20560;
public static final int ADAMANT_FULL_HELM_20561 = 20561;
public static final int MYSTIC_HAT_20562 = 20562;
public static final int PROSELYTE_SALLET_20563 = 20563;
public static final int PROSELYTE_HAUBERK_20564 = 20564;
public static final int PROSELYTE_CUISSE_20565 = 20565;
public static final int RED_DHIDE_BODY_20566 = 20566;
public static final int RED_DHIDE_CHAPS_20567 = 20567;
public static final int SPLITBARK_HELM_20568 = 20568;
public static final int WARRIOR_HELM_20571 = 20571;
public static final int ARCHER_HELM_20572 = 20572;
public static final int FARSEER_HELM_20573 = 20573;
public static final int INFINITY_TOP_20574 = 20574;
public static final int INFINITY_BOTTOMS_20575 = 20575;
public static final int _3RD_AGE_ROBE_TOP_20576 = 20576;
public static final int _3RD_AGE_ROBE_20577 = 20577;
public static final int CLIMBING_BOOTS_20578 = 20578;
public static final int MYSTIC_BOOTS_20579 = 20579;
public static final int SNAKESKIN_BOOTS_20580 = 20580;
public static final int MITHRIL_GLOVES_20581 = 20581;
public static final int ADAMANT_GLOVES_20582 = 20582;
public static final int RUNE_GLOVES_20583 = 20583;
public static final int AMULET_OF_ACCURACY_20584 = 20584;
public static final int AMULET_OF_POWER_20585 = 20585;
public static final int AMULET_OF_GLORY_20586 = 20586;
public static final int ROPE_20587 = 20587;
public static final int STALE_BAGUETTE = 20590;
public static final int ARMADYL_GODSWORD_20593 = 20593;
public static final int BANK_FILLER = 20594;
public static final int ELDER_CHAOS_HOOD = 20595;
public static final int AHRIMS_ROBETOP_20598 = 20598;
public static final int AHRIMS_ROBESKIRT_20599 = 20599;
public static final int RUNE_ARROW_20600 = 20600;
public static final int RUNE_ARROW_PACK = 20607;
public static final int BLOODIER_KEY = 20608;
public static final int FAIRY_ENCHANTMENT = 20609;
public static final int ANCIENT_SIGNET = 20611;
public static final int LUNAR_SIGNET = 20613;
public static final int ARCEUUS_SIGNET = 20615;
public static final int ANCIENT_ALTAR = 20617;
public static final int LUNAR_ALTAR = 20618;
public static final int DARK_ALTAR = 20619;
public static final int OCCULT_ALTAR = 20620;
public static final int OCCULT_ALTAR_20621 = 20621;
public static final int OCCULT_ALTAR_20622 = 20622;
public static final int MAHOGANY_ADVENTURE_LOG = 20623;
public static final int GILDED_ADVENTURE_LOG = 20624;
public static final int MARBLE_ADVENTURE_LOG = 20625;
public static final int BASIC_JEWELLERY_BOX = 20626;
public static final int FANCY_JEWELLERY_BOX = 20627;
public static final int ORNATE_JEWELLERY_BOX = 20628;
public static final int BOSS_LAIR_DISPLAY = 20629;
public static final int MOUNTED_EMBLEM = 20630;
public static final int MOUNTED_COINS = 20631;
public static final int CAPE_HANGER = 20632;
public static final int QUEST_LIST = 20633;
public static final int TIP_JAR = 20634;
public static final int SPIRIT_TREE_20635 = 20635;
public static final int FAIRY_RING = 20636;
public static final int SPIRIT_TREE__FAIRY_RING = 20637;
public static final int TOPIARY_BUSH = 20638;
public static final int RESTORATION_POOL = 20639;
public static final int REVITALISATION_POOL = 20640;
public static final int REJUVENATION_POOL = 20641;
public static final int FANCY_REJUVENATION_POOL = 20642;
public static final int ORNATE_REJUVENATION_POOL = 20643;
public static final int ZEN_THEME = 20644;
public static final int OTHERWORLDLY_THEME = 20645;
public static final int VOLCANIC_THEME = 20646;
public static final int REDWOOD_FENCE = 20647;
public static final int OBSIDIAN_FENCE = 20648;
public static final int TEAK_GARDEN_BENCH = 20649;
public static final int GNOME_BENCH = 20650;
public static final int MARBLE_DECORATIVE_BENCH = 20651;
public static final int OBSIDIAN_DECORATIVE_BENCH = 20652;
public static final int SUPERIOR_GARDEN = 20653;
public static final int ACHIEVEMENT_GALLERY = 20654;
public static final int RING_OF_SUFFERING_R = 20655;
public static final int RING_OF_SUFFERING_RI = 20657;
public static final int GIANT_SQUIRREL = 20659;
public static final int TANGLEROOT = 20661;
public static final int ROCKY = 20663;
public static final int RIFT_GUARDIAN = 20665;
public static final int RIFT_GUARDIAN_20667 = 20667;
public static final int RIFT_GUARDIAN_20669 = 20669;
public static final int RIFT_GUARDIAN_20671 = 20671;
public static final int RIFT_GUARDIAN_20673 = 20673;
public static final int RIFT_GUARDIAN_20675 = 20675;
public static final int RIFT_GUARDIAN_20677 = 20677;
public static final int RIFT_GUARDIAN_20679 = 20679;
public static final int RIFT_GUARDIAN_20681 = 20681;
public static final int RIFT_GUARDIAN_20683 = 20683;
public static final int RIFT_GUARDIAN_20685 = 20685;
public static final int RIFT_GUARDIAN_20687 = 20687;
public static final int RIFT_GUARDIAN_20689 = 20689;
public static final int RIFT_GUARDIAN_20691 = 20691;
public static final int PHOENIX = 20693;
public static final int BRUMA_ROOT = 20695;
public static final int BRUMA_KINDLING = 20696;
public static final int REJUVENATION_POTION_UNF = 20697;
public static final int BRUMA_HERB = 20698;
public static final int REJUVENATION_POTION_4 = 20699;
public static final int REJUVENATION_POTION_3 = 20700;
public static final int REJUVENATION_POTION_2 = 20701;
public static final int REJUVENATION_POTION_1 = 20702;
public static final int SUPPLY_CRATE = 20703;
public static final int PYROMANCER_GARB = 20704;
public static final int PYROMANCER_ROBE = 20706;
public static final int PYROMANCER_HOOD = 20708;
public static final int PYROMANCER_BOOTS = 20710;
public static final int WARM_GLOVES = 20712;
public static final int TOME_OF_FIRE = 20714;
public static final int TOME_OF_FIRE_EMPTY = 20716;
public static final int BURNT_PAGE = 20718;
public static final int BRUMA_TORCH = 20720;
public static final int EMERALD_LANTERN_20722 = 20722;
public static final int IMBUED_HEART = 20724;
public static final int LEAFBLADED_BATTLEAXE = 20727;
public static final int MIST_BATTLESTAFF = 20730;
public static final int MYSTIC_MIST_STAFF = 20733;
public static final int DUST_BATTLESTAFF = 20736;
public static final int MYSTIC_DUST_STAFF = 20739;
public static final int EMPTY_JUG_PACK = 20742;
public static final int COMBAT_DUMMY = 20745;
public static final int UNDEAD_COMBAT_DUMMY = 20746;
public static final int BOLOGAS_BLESSING = 20747;
public static final int ZAMORAKS_GRAPES = 20749;
public static final int ZAMORAKS_UNFERMENTED_WINE = 20752;
public static final int GIANT_KEY = 20754;
public static final int HILL_GIANT_CLUB = 20756;
public static final int ARDOUGNE_MAX_CAPE = 20760;
public static final int ARDOUGNE_MAX_HOOD = 20764;
public static final int MANOR_KEY = 20766;
public static final int RUBY_KEY = 20767;
public static final int EMERALD_KEY = 20768;
public static final int SAPPHIRE_KEY = 20769;
public static final int NOTES_20770 = 20770;
public static final int NOTES_20771 = 20771;
public static final int NOTES_20772 = 20772;
public static final int BANSHEE_MASK = 20773;
public static final int BANSHEE_TOP = 20775;
public static final int BANSHEE_ROBE = 20777;
public static final int HUNTING_KNIFE = 20779;
public static final int KILLERS_KNIFE = 20781;
public static final int BANDOS_GODSWORD_20782 = 20782;
public static final int DRAGON_CLAWS_20784 = 20784;
public static final int DRAGON_WARHAMMER_20785 = 20785;
public static final int RING_OF_WEALTH_I5 = 20786;
public static final int RING_OF_WEALTH_I4 = 20787;
public static final int RING_OF_WEALTH_I3 = 20788;
public static final int RING_OF_WEALTH_I2 = 20789;
public static final int RING_OF_WEALTH_I1 = 20790;
public static final int EXTRA_SUPPLY_CRATE = 20791;
public static final int HARDCORE_IRONMAN_HELM = 20792;
public static final int HARDCORE_IRONMAN_PLATEBODY = 20794;
public static final int HARDCORE_IRONMAN_PLATELEGS = 20796;
public static final int SMELLY_JOURNAL = 20798;
public static final int KINDLING_20799 = 20799;
public static final int EMPTY_GOURD_VIAL = 20800;
public static final int WATERFILLED_GOURD_VIAL = 20801;
public static final int HEALER_ICON_20802 = 20802;
public static final int SNOW_GLOBE = 20832;
public static final int SACK_OF_PRESENTS = 20834;
public static final int GIANT_PRESENT = 20836;
public static final int CORRUPTED_HELM = 20838;
public static final int CORRUPTED_PLATEBODY = 20840;
public static final int CORRUPTED_PLATELEGS = 20842;
public static final int CORRUPTED_PLATESKIRT = 20844;
public static final int CORRUPTED_KITESHIELD = 20846;
public static final int DRAGON_THROWNAXE = 20849;
public static final int OLMLET = 20851;
public static final int CAVE_WORMS = 20853;
public static final int BURNT_FISH_20854 = 20854;
public static final int RAW_PYSK_FISH_0 = 20855;
public static final int PYSK_FISH_0 = 20856;
public static final int RAW_SUPHI_FISH_1 = 20857;
public static final int SUPHI_FISH_1 = 20858;
public static final int RAW_LECKISH_FISH_2 = 20859;
public static final int LECKISH_FISH_2 = 20860;
public static final int RAW_BRAWK_FISH_3 = 20861;
public static final int BRAWK_FISH_3 = 20862;
public static final int RAW_MYCIL_FISH_4 = 20863;
public static final int MYCIL_FISH_4 = 20864;
public static final int RAW_ROQED_FISH_5 = 20865;
public static final int ROQED_FISH_5 = 20866;
public static final int RAW_KYREN_FISH_6 = 20867;
public static final int KYREN_FISH_6 = 20868;
public static final int BURNT_BAT = 20869;
public static final int RAW_GUANIC_BAT_0 = 20870;
public static final int GUANIC_BAT_0 = 20871;
public static final int RAW_PRAEL_BAT_1 = 20872;
public static final int PRAEL_BAT_1 = 20873;
public static final int RAW_GIRAL_BAT_2 = 20874;
public static final int GIRAL_BAT_2 = 20875;
public static final int RAW_PHLUXIA_BAT_3 = 20876;
public static final int PHLUXIA_BAT_3 = 20877;
public static final int RAW_KRYKET_BAT_4 = 20878;
public static final int KRYKET_BAT_4 = 20879;
public static final int RAW_MURNG_BAT_5 = 20880;
public static final int MURNG_BAT_5 = 20881;
public static final int RAW_PSYKK_BAT_6 = 20882;
public static final int PSYKK_BAT_6 = 20883;
public static final int KEYSTONE_CRYSTAL = 20884;
public static final int CAVERN_GRUBS = 20885;
public static final int CREATURE_KEEPERS_JOURNAL = 20886;
public static final int NISTIRIOS_MANIFESTO = 20888;
public static final int TEKTONS_JOURNAL = 20890;
public static final int MEDIVAEMIA_BLOSSOM = 20892;
public static final int TRANSDIMENSIONAL_NOTES = 20893;
public static final int VANGUARD_JUDGEMENT = 20895;
public static final int HOUNDMASTERS_DIARY = 20897;
public static final int DARK_JOURNAL = 20899;
public static final int GRIMY_NOXIFER = 20901;
public static final int NOXIFER = 20902;
public static final int NOXIFER_SEED = 20903;
public static final int GRIMY_GOLPAR = 20904;
public static final int GOLPAR = 20905;
public static final int GOLPAR_SEED = 20906;
public static final int GRIMY_BUCHU_LEAF = 20907;
public static final int BUCHU_LEAF = 20908;
public static final int BUCHU_SEED = 20909;
public static final int STINKHORN_MUSHROOM = 20910;
public static final int ENDARKENED_JUICE = 20911;
public static final int CICELY = 20912;
public static final int ELDER_1 = 20913;
public static final int ELDER_2 = 20914;
public static final int ELDER_3 = 20915;
public static final int ELDER_4 = 20916;
public static final int ELDER_POTION_1 = 20917;
public static final int ELDER_POTION_2 = 20918;
public static final int ELDER_POTION_3 = 20919;
public static final int ELDER_POTION_4 = 20920;
public static final int ELDER_1_20921 = 20921;
public static final int ELDER_2_20922 = 20922;
public static final int ELDER_3_20923 = 20923;
public static final int ELDER_4_20924 = 20924;
public static final int TWISTED_1 = 20925;
public static final int TWISTED_2 = 20926;
public static final int TWISTED_3 = 20927;
public static final int TWISTED_4 = 20928;
public static final int TWISTED_POTION_1 = 20929;
public static final int TWISTED_POTION_2 = 20930;
public static final int TWISTED_POTION_3 = 20931;
public static final int TWISTED_POTION_4 = 20932;
public static final int TWISTED_1_20933 = 20933;
public static final int TWISTED_2_20934 = 20934;
public static final int TWISTED_3_20935 = 20935;
public static final int TWISTED_4_20936 = 20936;
public static final int KODAI_1 = 20937;
public static final int KODAI_2 = 20938;
public static final int KODAI_3 = 20939;
public static final int KODAI_4 = 20940;
public static final int KODAI_POTION_1 = 20941;
public static final int KODAI_POTION_2 = 20942;
public static final int KODAI_POTION_3 = 20943;
public static final int KODAI_POTION_4 = 20944;
public static final int KODAI_1_20945 = 20945;
public static final int KODAI_2_20946 = 20946;
public static final int KODAI_3_20947 = 20947;
public static final int KODAI_4_20948 = 20948;
public static final int REVITALISATION_1 = 20949;
public static final int REVITALISATION_2 = 20950;
public static final int REVITALISATION_3 = 20951;
public static final int REVITALISATION_4 = 20952;
public static final int REVITALISATION_POTION_1 = 20953;
public static final int REVITALISATION_POTION_2 = 20954;
public static final int REVITALISATION_POTION_3 = 20955;
public static final int REVITALISATION_POTION_4 = 20956;
public static final int REVITALISATION_1_20957 = 20957;
public static final int REVITALISATION_2_20958 = 20958;
public static final int REVITALISATION_3_20959 = 20959;
public static final int REVITALISATION_4_20960 = 20960;
public static final int PRAYER_ENHANCE_1 = 20961;
public static final int PRAYER_ENHANCE_2 = 20962;
public static final int PRAYER_ENHANCE_3 = 20963;
public static final int PRAYER_ENHANCE_4 = 20964;
public static final int PRAYER_ENHANCE_1_20965 = 20965;
public static final int PRAYER_ENHANCE_2_20966 = 20966;
public static final int PRAYER_ENHANCE_3_20967 = 20967;
public static final int PRAYER_ENHANCE_4_20968 = 20968;
public static final int PRAYER_ENHANCE_1_20969 = 20969;
public static final int PRAYER_ENHANCE_2_20970 = 20970;
public static final int PRAYER_ENHANCE_3_20971 = 20971;
public static final int PRAYER_ENHANCE_4_20972 = 20972;
public static final int XERICS_AID_1 = 20973;
public static final int XERICS_AID_2 = 20974;
public static final int XERICS_AID_3 = 20975;
public static final int XERICS_AID_4 = 20976;
public static final int XERICS_AID_1_20977 = 20977;
public static final int XERICS_AID_2_20978 = 20978;
public static final int XERICS_AID_3_20979 = 20979;
public static final int XERICS_AID_4_20980 = 20980;
public static final int XERICS_AID_1_20981 = 20981;
public static final int XERICS_AID_2_20982 = 20982;
public static final int XERICS_AID_3_20983 = 20983;
public static final int XERICS_AID_4_20984 = 20984;
public static final int OVERLOAD_1_20985 = 20985;
public static final int OVERLOAD_2_20986 = 20986;
public static final int OVERLOAD_3_20987 = 20987;
public static final int OVERLOAD_4_20988 = 20988;
public static final int OVERLOAD_1_20989 = 20989;
public static final int OVERLOAD_2_20990 = 20990;
public static final int OVERLOAD_3_20991 = 20991;
public static final int OVERLOAD_4_20992 = 20992;
public static final int OVERLOAD_1_20993 = 20993;
public static final int OVERLOAD_2_20994 = 20994;
public static final int OVERLOAD_3_20995 = 20995;
public static final int OVERLOAD_4_20996 = 20996;
public static final int TWISTED_BOW = 20997;
public static final int TWISTED_BUCKLER = 21000;
public static final int ELDER_MAUL = 21003;
public static final int KODAI_WAND = 21006;
public static final int DRAGON_SWORD = 21009;
public static final int DRAGON_HUNTER_CROSSBOW = 21012;
public static final int DINHS_BULWARK = 21015;
public static final int ANCESTRAL_HAT = 21018;
public static final int ANCESTRAL_ROBE_TOP = 21021;
public static final int ANCESTRAL_ROBE_BOTTOM = 21024;
public static final int DARK_RELIC = 21027;
public static final int DRAGON_HARPOON = 21028;
public static final int INFERNAL_HARPOON = 21031;
public static final int INFERNAL_HARPOON_UNCHARGED = 21033;
public static final int DEXTEROUS_PRAYER_SCROLL = 21034;
public static final int MALLIGNUM_ROOT_PLANK = 21036;
public static final int SMALL_STORAGE_UNIT = 21037;
public static final int MEDIUM_STORAGE_UNIT = 21038;
public static final int LARGE_STORAGE_UNIT = 21039;
public static final int MEDIUM_STORAGE_UNIT_21040 = 21040;
public static final int LARGE_STORAGE_UNIT_21041 = 21041;
public static final int LARGE_STORAGE_UNIT_21042 = 21042;
public static final int KODAI_INSIGNIA = 21043;
public static final int ANCIENT_TABLET = 21046;
public static final int TORN_PRAYER_SCROLL = 21047;
public static final int ANCESTRAL_ROBES_SET = 21049;
public static final int MANOR_KEY_21052 = 21052;
public static final int RUBY_KEY_21053 = 21053;
public static final int EMERALD_KEY_21054 = 21054;
public static final int SAPPHIRE_KEY_21055 = 21055;
public static final int NOTES_21056 = 21056;
public static final int NOTES_21057 = 21057;
public static final int NOTES_21058 = 21058;
public static final int KILLERS_KNIFE_21059 = 21059;
public static final int BANDOS_GODSWORD_21060 = 21060;
public static final int GRACEFUL_HOOD_21061 = 21061;
public static final int GRACEFUL_HOOD_21063 = 21063;
public static final int GRACEFUL_CAPE_21064 = 21064;
public static final int GRACEFUL_CAPE_21066 = 21066;
public static final int GRACEFUL_TOP_21067 = 21067;
public static final int GRACEFUL_TOP_21069 = 21069;
public static final int GRACEFUL_LEGS_21070 = 21070;
public static final int GRACEFUL_LEGS_21072 = 21072;
public static final int GRACEFUL_GLOVES_21073 = 21073;
public static final int GRACEFUL_GLOVES_21075 = 21075;
public static final int GRACEFUL_BOOTS_21076 = 21076;
public static final int GRACEFUL_BOOTS_21078 = 21078;
public static final int ARCANE_PRAYER_SCROLL = 21079;
public static final int OPAL_RING = 21081;
public static final int JADE_RING = 21084;
public static final int TOPAZ_RING = 21087;
public static final int OPAL_NECKLACE = 21090;
public static final int JADE_NECKLACE = 21093;
public static final int TOPAZ_NECKLACE = 21096;
public static final int OPAL_AMULET_U = 21099;
public static final int JADE_AMULET_U = 21102;
public static final int TOPAZ_AMULET_U = 21105;
public static final int OPAL_AMULET = 21108;
public static final int JADE_AMULET = 21111;
public static final int TOPAZ_AMULET = 21114;
public static final int OPAL_BRACELET = 21117;
public static final int JADE_BRACELET = 21120;
public static final int TOPAZ_BRACELET = 21123;
public static final int RING_OF_PURSUIT = 21126;
public static final int RING_OF_RETURNING5 = 21129;
public static final int RING_OF_RETURNING4 = 21132;
public static final int RING_OF_RETURNING3 = 21134;
public static final int RING_OF_RETURNING2 = 21136;
public static final int RING_OF_RETURNING1 = 21138;
public static final int EFARITAYS_AID = 21140;
public static final int DODGY_NECKLACE = 21143;
public static final int NECKLACE_OF_PASSAGE5 = 21146;
public static final int NECKLACE_OF_PASSAGE4 = 21149;
public static final int NECKLACE_OF_PASSAGE3 = 21151;
public static final int NECKLACE_OF_PASSAGE2 = 21153;
public static final int NECKLACE_OF_PASSAGE1 = 21155;
public static final int NECKLACE_OF_FAITH = 21157;
public static final int AMULET_OF_BOUNTY = 21160;
public static final int AMULET_OF_CHEMISTRY = 21163;
public static final int BURNING_AMULET5 = 21166;
public static final int BURNING_AMULET4 = 21169;
public static final int BURNING_AMULET3 = 21171;
public static final int BURNING_AMULET2 = 21173;
public static final int BURNING_AMULET1 = 21175;
public static final int EXPEDITIOUS_BRACELET = 21177;
public static final int FLAMTAER_BRACELET = 21180;
public static final int BRACELET_OF_SLAUGHTER = 21183;
public static final int FIRE_MAX_CAPE_21186 = 21186;
public static final int ROCK_GOLEM_21187 = 21187;
public static final int ROCK_GOLEM_21188 = 21188;
public static final int ROCK_GOLEM_21189 = 21189;
public static final int ROCK_GOLEM_21190 = 21190;
public static final int ROCK_GOLEM_21191 = 21191;
public static final int ROCK_GOLEM_21192 = 21192;
public static final int ROCK_GOLEM_21193 = 21193;
public static final int ROCK_GOLEM_21194 = 21194;
public static final int ROCK_GOLEM_21195 = 21195;
public static final int ROCK_GOLEM_21196 = 21196;
public static final int ROCK_GOLEM_21197 = 21197;
public static final int LAVA_BATTLESTAFF_21198 = 21198;
public static final int MYSTIC_LAVA_STAFF_21200 = 21200;
public static final int LAVA_STAFF_UPGRADE_KIT = 21202;
public static final int ELDER_MAUL_21205 = 21205;
public static final int DRAGON_SWORD_21206 = 21206;
public static final int DRAGON_THROWNAXE_21207 = 21207;
public static final int INVITATION_LIST = 21208;
public static final int BIRTHDAY_BALLOONS = 21209;
public static final int _4TH_BIRTHDAY_HAT = 21211;
public static final int SERVANTS_MONEYBAG = 21213;
public static final int EASTER_EGG_HELM = 21214;
public static final int FRUITY_EASTER_EGG = 21216;
public static final int FRESH_EASTER_EGG = 21217;
public static final int BITTER_EASTER_EGG = 21218;
public static final int EARTHY_EASTER_EGG = 21219;
public static final int SPICY_EASTER_EGG = 21220;
public static final int MEATY_EASTER_EGG = 21221;
public static final int SALTED_EASTER_EGG = 21222;
public static final int RICH_EASTER_EGG = 21223;
public static final int FLUFFY_EASTER_EGG = 21224;
public static final int SMOKED_EASTER_EGG = 21225;
public static final int FISHY_EASTER_EGG = 21226;
public static final int CRUNCHY_EASTER_EGG = 21227;
public static final int FRUITY_CHOCOLATE_MIX = 21228;
public static final int FRESH_CHOCOLATE_MIX = 21229;
public static final int BITTER_CHOCOLATE_MIX = 21230;
public static final int EARTHY_CHOCOLATE_MIX = 21231;
public static final int SPICY_CHOCOLATE_MIX = 21232;
public static final int MEATY_CHOCOLATE_MIX = 21233;
public static final int SALTED_CHOCOLATE_MIX = 21234;
public static final int RICH_CHOCOLATE_MIX = 21235;
public static final int FLUFFY_CHOCOLATE_MIX = 21236;
public static final int SMOKED_CHOCOLATE_MIX = 21237;
public static final int FISHY_CHOCOLATE_MIX = 21238;
public static final int CRUNCHY_CHOCOLATE_MIX = 21239;
public static final int WESTER_BANANA = 21240;
public static final int WESTER_PAPAYA = 21241;
public static final int WESTER_LEMON = 21242;
public static final int BUCKET_OF_WESTER_SAND = 21243;
public static final int WESTER_SPICES = 21244;
public static final int BEEF_FILLET = 21245;
public static final int SEA_SALT = 21246;
public static final int GOLD_FRAGMENT = 21247;
public static final int FLUFFY_FEATHERS = 21248;
public static final int WESTER_FISH = 21249;
public static final int ROCK_21250 = 21250;
public static final int WESTER_CHOCOLATE = 21251;
public static final int EGG_MOULD = 21252;
public static final int FARMERS_STRAWHAT_21253 = 21253;
public static final int FARMERS_STRAWHAT_21254 = 21254;
public static final int SLAYERS_STAFF_E = 21255;
public static final int SLAYERS_ENCHANTMENT = 21257;
public static final int ENCHANTED_SCROLL = 21259;
public static final int ENCHANTED_QUILL = 21260;
public static final int MYSTERIOUS_ORB = 21261;
public static final int ANTIQUE_LAMP_21262 = 21262;
public static final int COPPERS_CRIMSON_COLLAR = 21263;
public static final int PURPLE_SLAYER_HELMET = 21264;
public static final int PURPLE_SLAYER_HELMET_I = 21266;
public static final int SLAYER_RING_ETERNAL = 21268;
public static final int ETERNAL_GEM = 21270;
public static final int SKOTOS = 21273;
public static final int DARK_CLAW = 21275;
public static final int SKULL_SCEPTRE_I = 21276;
public static final int TZHAARHUR = 21278;
public static final int OBSIDIAN_ARMOUR_SET = 21279;
public static final int INFERNAL_MAX_HOOD = 21282;
public static final int INFERNAL_MAX_CAPE = 21284;
public static final int INFERNAL_MAX_CAPE_21285 = 21285;
public static final int INFERNAL_CAPE_BROKEN = 21287;
public static final int INFERNAL_MAX_CAPE_BROKEN = 21289;
public static final int JALNIBREK = 21291;
public static final int INFERNAL_EEL = 21293;
public static final int INFERNAL_CAPE = 21295;
public static final int INFERNAL_CAPE_21297 = 21297;
public static final int OBSIDIAN_HELMET = 21298;
public static final int OBSIDIAN_PLATEBODY = 21301;
public static final int OBSIDIAN_PLATELEGS = 21304;
public static final int ROGUES_EQUIPMENT_CRATE = 21307;
public static final int RED_RAINBOW_STRAND = 21308;
public static final int ORANGE_RAINBOW_STRAND = 21309;
public static final int YELLOW_RAINBOW_STRAND = 21310;
public static final int GREEN_RAINBOW_STRAND = 21311;
public static final int BLUE_RAINBOW_STRAND = 21312;
public static final int PURPLE_RAINBOW_STRAND = 21313;
public static final int RAINBOW_SCARF = 21314;
public static final int AMETHYST_BROAD_BOLTS = 21316;
public static final int AMETHYST_JAVELIN = 21318;
public static final int AMETHYST_JAVELINP = 21320;
public static final int AMETHYST_JAVELINP_21322 = 21322;
public static final int AMETHYST_JAVELINP_21324 = 21324;
public static final int AMETHYST_ARROW = 21326;
public static final int AMETHYST_FIRE_ARROW = 21328;
public static final int AMETHYST_FIRE_ARROW_LIT = 21330;
public static final int AMETHYST_ARROWP = 21332;
public static final int AMETHYST_ARROWP_21334 = 21334;
public static final int AMETHYST_ARROWP_21336 = 21336;
public static final int AMETHYST_BOLT_TIPS = 21338;
public static final int ROCK_GOLEM_21340 = 21340;
public static final int UNIDENTIFIED_MINERALS = 21341;
public static final int MINING_GLOVES = 21343;
public static final int SUPERIOR_MINING_GLOVES = 21345;
public static final int AMETHYST = 21347;
public static final int AMETHYST_ARROWTIPS = 21350;
public static final int AMETHYST_JAVELIN_HEADS = 21352;
public static final int HAND_FAN = 21354;
public static final int MINNOW = 21356;
public static final int ROCK_GOLEM_21358 = 21358;
public static final int ROCK_GOLEM_21359 = 21359;
public static final int ROCK_GOLEM_21360 = 21360;
public static final int MASTER_SCROLL_BOOK_EMPTY = 21387;
public static final int MASTER_SCROLL_BOOK = 21389;
public static final int BRUTAL_BLACK_DRAGON = 21391;
public static final int EXPERT_MINING_GLOVES = 21392;
public static final int KARAMBWANJI = 21394;
public static final int CLAN_WARS_CAPE_21396 = 21396;
public static final int CLAN_WARS_CAPE_21397 = 21397;
public static final int CLAN_WARS_CAPE_21398 = 21398;
public static final int CLAN_WARS_CAPE_21399 = 21399;
public static final int CLAN_WARS_CAPE_21400 = 21400;
public static final int CLAN_WARS_CAPE_21401 = 21401;
public static final int CLAN_WARS_CAPE_21402 = 21402;
public static final int CLAN_WARS_CAPE_21403 = 21403;
public static final int CLAN_WARS_CAPE_21404 = 21404;
public static final int CLAN_WARS_CAPE_21405 = 21405;
public static final int CLAN_WARS_CAPE_21406 = 21406;
public static final int CLAN_WARS_CAPE_21407 = 21407;
public static final int CLAN_WARS_CAPE_21408 = 21408;
public static final int CLAN_WARS_CAPE_21409 = 21409;
public static final int CLAN_WARS_CAPE_21410 = 21410;
public static final int CLAN_WARS_CAPE_21411 = 21411;
public static final int CLAN_WARS_CAPE_21412 = 21412;
public static final int CLAN_WARS_CAPE_21413 = 21413;
public static final int CLAN_WARS_CAPE_21414 = 21414;
public static final int CLAN_WARS_CAPE_21415 = 21415;
public static final int CLAN_WARS_CAPE_21416 = 21416;
public static final int CLAN_WARS_CAPE_21417 = 21417;
public static final int CLAN_WARS_CAPE_21418 = 21418;
public static final int CLAN_WARS_CAPE_21419 = 21419;
public static final int CLAN_WARS_CAPE_21420 = 21420;
public static final int CLAN_WARS_CAPE_21421 = 21421;
public static final int CLAN_WARS_CAPE_21422 = 21422;
public static final int CLAN_WARS_CAPE_21423 = 21423;
public static final int CLAN_WARS_CAPE_21424 = 21424;
public static final int CLAN_WARS_CAPE_21425 = 21425;
public static final int CLAN_WARS_CAPE_21426 = 21426;
public static final int CLAN_WARS_CAPE_21427 = 21427;
public static final int WILDERNESS_CAPE = 21428;
public static final int WILDERNESS_CAPE_21429 = 21429;
public static final int WILDERNESS_CAPE_21430 = 21430;
public static final int WILDERNESS_CAPE_21431 = 21431;
public static final int WILDERNESS_CAPE_21432 = 21432;
public static final int WILDERNESS_CHAMPION_AMULET = 21433;
public static final int WILDERNESS_CAPE_21434 = 21434;
public static final int WILDERNESS_CAPE_21435 = 21435;
public static final int WILDERNESS_CAPE_21436 = 21436;
public static final int WILDERNESS_CAPE_21437 = 21437;
public static final int WILDERNESS_CAPE_21438 = 21438;
public static final int CHAMPIONS_CAPE = 21439;
public static final int TEAK_SEEDLING = 21469;
public static final int MAHOGANY_SEEDLING = 21471;
public static final int TEAK_SEEDLING_W = 21473;
public static final int MAHOGANY_SEEDLING_W = 21475;
public static final int TEAK_SAPLING = 21477;
public static final int MAHOGANY_SAPLING = 21480;
public static final int ULTRACOMPOST = 21483;
public static final int TEAK_SEED = 21486;
public static final int MAHOGANY_SEED = 21488;
public static final int SEAWEED_SPORE = 21490;
public static final int GIANT_SEAWEED = 21504;
public static final int FOSSIL_ISLAND_WYVERN = 21507;
public static final int FOSSIL_ISLAND_WYVERN_21508 = 21508;
public static final int HERBI = 21509;
public static final int HERBIBOAR = 21511;
public static final int BIRD_HOUSE = 21512;
public static final int OAK_BIRD_HOUSE = 21515;
public static final int WILLOW_BIRD_HOUSE = 21518;
public static final int TEAK_BIRD_HOUSE = 21521;
public static final int CLUE_SCROLL_ELITE_21524 = 21524;
public static final int CLUE_SCROLL_ELITE_21525 = 21525;
public static final int CLUE_SCROLL_HARD_21526 = 21526;
public static final int CLUE_SCROLL_HARD_21527 = 21527;
public static final int SAWMILL_PROPOSAL = 21528;
public static final int SAWMILL_AGREEMENT = 21529;
public static final int BONE_CHARM = 21530;
public static final int POTION_OF_SEALEGS = 21531;
public static final int IRON_ORE_FRAGMENT = 21532;
public static final int SILVER_ORE_FRAGMENT = 21533;
public static final int COAL_FRAGMENT = 21534;
public static final int GOLD_ORE_FRAGMENT = 21535;
public static final int MITHRIL_ORE_FRAGMENT = 21536;
public static final int ADAMANTITE_ORE_FRAGMENT = 21537;
public static final int RUNITE_ORE_FRAGMENT = 21538;
public static final int HEATPROOF_VESSEL = 21539;
public static final int LARGE_ROCK = 21540;
public static final int VOLCANIC_MINE_TELEPORT = 21541;
public static final int CALCITE = 21543;
public static final int PYROPHOSPHITE = 21545;
public static final int SMALL_ENRICHED_BONE = 21547;
public static final int MEDIUM_ENRICHED_BONE = 21549;
public static final int LARGE_ENRICHED_BONE = 21551;
public static final int RARE_ENRICHED_BONE = 21553;
public static final int NUMULITE = 21555;
public static final int UNIDENTIFIED_SMALL_FOSSIL = 21562;
public static final int UNIDENTIFIED_MEDIUM_FOSSIL = 21564;
public static final int UNIDENTIFIED_LARGE_FOSSIL = 21566;
public static final int UNIDENTIFIED_RARE_FOSSIL = 21568;
public static final int SMALL_FOSSILISED_LIMBS = 21570;
public static final int SMALL_FOSSILISED_SPINE = 21572;
public static final int SMALL_FOSSILISED_RIBS = 21574;
public static final int SMALL_FOSSILISED_PELVIS = 21576;
public static final int SMALL_FOSSILISED_SKULL = 21578;
public static final int MEDIUM_FOSSILISED_LIMBS = 21580;
public static final int MEDIUM_FOSSILISED_SPINE = 21582;
public static final int MEDIUM_FOSSILISED_RIBS = 21584;
public static final int MEDIUM_FOSSILISED_PELVIS = 21586;
public static final int MEDIUM_FOSSILISED_SKULL = 21588;
public static final int FOSSILISED_ROOTS = 21590;
public static final int FOSSILISED_STUMP = 21592;
public static final int FOSSILISED_BRANCH = 21594;
public static final int FOSSILISED_LEAF = 21596;
public static final int FOSSILISED_MUSHROOM = 21598;
public static final int LARGE_FOSSILISED_LIMBS = 21600;
public static final int LARGE_FOSSILISED_SPINE = 21602;
public static final int LARGE_FOSSILISED_RIBS = 21604;
public static final int LARGE_FOSSILISED_PELVIS = 21606;
public static final int LARGE_FOSSILISED_SKULL = 21608;
public static final int RARE_FOSSILISED_LIMBS = 21610;
public static final int RARE_FOSSILISED_SPINE = 21612;
public static final int RARE_FOSSILISED_RIBS = 21614;
public static final int RARE_FOSSILISED_PELVIS = 21616;
public static final int RARE_FOSSILISED_SKULL = 21618;
public static final int RARE_FOSSILISED_TUSK = 21620;
public static final int VOLCANIC_ASH = 21622;
public static final int HOOP_SNAKE = 21624;
public static final int SULLIUSCEP_CAP = 21626;
public static final int ARCHAEOLOGISTS_DIARY = 21629;
public static final int ANCIENT_DIARY = 21631;
public static final int ANCIENT_WYVERN_SHIELD = 21633;
public static final int ANCIENT_WYVERN_SHIELD_21634 = 21634;
public static final int WYVERN_VISAGE = 21637;
public static final int ANTIQUE_LAMP_21640 = 21640;
public static final int ANTIQUE_LAMP_21641 = 21641;
public static final int ANTIQUE_LAMP_21642 = 21642;
public static final int GRANITE_BOOTS = 21643;
public static final int GRANITE_LONGSWORD = 21646;
public static final int MERFOLK_TRIDENT = 21649;
public static final int DRIFT_NET = 21652;
public static final int PUFFERFISH = 21655;
public static final int MERMAIDS_TEAR = 21656;
public static final int FOSSIL_ISLAND_NOTE_BOOK = 21662;
public static final int SCRIBBLED_NOTE = 21664;
public static final int PARTIAL_NOTE = 21666;
public static final int ANCIENT_NOTE = 21668;
public static final int ANCIENT_WRITINGS = 21670;
public static final int EXPERIMENTAL_NOTE = 21672;
public static final int PARAGRAPH_OF_TEXT = 21674;
public static final int MUSTY_SMELLING_NOTE = 21676;
public static final int HASTILY_SCRAWLED_NOTE = 21678;
public static final int OLD_WRITING = 21680;
public static final int SHORT_NOTE = 21682;
public static final int UNCOOKED_MUSHROOM_PIE = 21684;
public static final int HALF_A_MUSHROOM_PIE = 21687;
public static final int MUSHROOM_PIE = 21690;
public static final int BOWL_OF_FISH = 21693;
public static final int RUNEFEST_SHIELD = 21695;
public static final int ASH_COVERED_TOME = 21697;
public static final int TZHAAR_AIR_RUNE_PACK = 21698;
public static final int TZHAAR_WATER_RUNE_PACK = 21701;
public static final int TZHAAR_EARTH_RUNE_PACK = 21704;
public static final int TZHAAR_FIRE_RUNE_PACK = 21707;
public static final int DEATH_NOTE = 21710;
public static final int MURKY_POTION = 21711;
public static final int SPECTRAL_POTION = 21712;
public static final int TOMBERRIES = 21713;
public static final int TATTERED_BOOK = 21714;
public static final int NOTE_21715 = 21715;
public static final int CARVED_GEM = 21716;
public static final int TIME_BUBBLE = 21717;
public static final int TRAIBORN_NOTE = 21718;
public static final int JONAS_MASK = 21719;
public static final int JONAS_MASK_21720 = 21720;
public static final int DIVING_HELMET = 21722;
public static final int DIVING_APPARATUS_21723 = 21723;
public static final int BRITTLE_KEY = 21724;
public static final int GRANITE_DUST = 21726;
public static final int GRANITE_CANNONBALL = 21728;
public static final int BLACK_TOURMALINE_CORE = 21730;
public static final int GUARDIAN_BOOTS = 21733;
public static final int GRANITE_GLOVES = 21736;
public static final int GRANITE_RING = 21739;
public static final int GRANITE_HAMMER = 21742;
public static final int JAR_OF_STONE = 21745;
public static final int NOON = 21748;
public static final int MIDNIGHT = 21750;
public static final int GRANITE_RING_I = 21752;
public static final int ROCK_THROWNHAMMER = 21754;
public static final int VARLAMORE_ENVOY = 21756;
public static final int ROYAL_ACCORD_OF_TWILL = 21758;
public static final int HOSIDIUS_FAVOUR_CERTIFICATE = 21759;
public static final int KHAREDSTS_MEMOIRS = 21760;
public static final int LUNCH_BY_THE_LANCALLIUMS = 21762;
public static final int THE_FISHERS_FLUTE = 21764;
public static final int HISTORY_AND_HEARSAY = 21766;
public static final int JEWELLERY_OF_JUBILATION = 21768;
public static final int A_DARK_DISPOSITION = 21770;
public static final int SECRET_PAGE = 21772;
public static final int LETTER_21774 = 21774;
public static final int PISCARILIUS_FAVOUR_CERTIFICATE = 21775;
public static final int IMBUED_SARADOMIN_MAX_CAPE = 21776;
public static final int IMBUED_SARADOMIN_MAX_HOOD = 21778;
public static final int IMBUED_ZAMORAK_MAX_CAPE = 21780;
public static final int IMBUED_ZAMORAK_MAX_HOOD = 21782;
public static final int IMBUED_GUTHIX_MAX_CAPE = 21784;
public static final int IMBUED_GUTHIX_MAX_HOOD = 21786;
public static final int OBELISK = 21788;
public static final int IMBUED_SARADOMIN_CAPE = 21791;
public static final int IMBUED_GUTHIX_CAPE = 21793;
public static final int IMBUED_ZAMORAK_CAPE = 21795;
public static final int JUSTICIARS_HAND = 21797;
public static final int ENTS_ROOTS = 21798;
public static final int DEMONS_HEART = 21799;
public static final int ENCHANTED_SYMBOL = 21800;
public static final int REVENANT_CAVE_TELEPORT = 21802;
public static final int ANCIENT_CRYSTAL = 21804;
public static final int ANCIENT_EMBLEM = 21807;
public static final int ANCIENT_TOTEM = 21810;
public static final int ANCIENT_STATUETTE = 21813;
public static final int BRACELET_OF_ETHEREUM = 21816;
public static final int BRACELET_OF_ETHEREUM_UNCHARGED = 21817;
public static final int REVENANT_ETHER = 21820;
public static final int REDUNDANT_HAT = 21826;
public static final int REDUNDANT_TOP = 21829;
public static final int REDUNDANT_LEGGINGS = 21832;
public static final int OGRE_ARTEFACT_21837 = 21837;
public static final int SHAMAN_MASK = 21838;
public static final int SNOW_IMP_COSTUME_HEAD = 21841;
public static final int SNOW_IMP_COSTUME_BODY = 21842;
public static final int SNOW_IMP_COSTUME_LEGS = 21843;
public static final int SNOW_IMP_COSTUME_TAIL = 21844;
public static final int SNOW_IMP_COSTUME_GLOVES = 21845;
public static final int SNOW_IMP_COSTUME_FEET = 21846;
public static final int SNOW_IMP_COSTUME_HEAD_21847 = 21847;
public static final int SNOW_IMP_COSTUME_BODY_21849 = 21849;
public static final int SNOW_IMP_COSTUME_LEGS_21851 = 21851;
public static final int SNOW_IMP_COSTUME_TAIL_21853 = 21853;
public static final int SNOW_IMP_COSTUME_GLOVES_21855 = 21855;
public static final int SNOW_IMP_COSTUME_FEET_21857 = 21857;
public static final int WISE_OLD_MANS_SANTA_HAT = 21859;
public static final int ENCHANTED_CURTAINS = 21861;
public static final int ENCHANTED_SNOWY_CURTAINS = 21862;
public static final int WISE_OLD_MANS_TELEPORT_TABLET = 21863;
public static final int SNOW_SPRITE = 21864;
public static final int FINE_MESH_NET = 21865;
public static final int SANTA_SUIT = 21866;
public static final int SANTA_SUIT_WET = 21867;
public static final int SANTA_SUIT_DRY = 21868;
public static final int LOGS_AND_KINDLING = 21869;
public static final int PROMISSORY_NOTE_21870 = 21870;
public static final int SANTAS_SEAL = 21871;
public static final int VAULT_KEY = 21872;
public static final int EMPTY_SACK_21873 = 21873;
public static final int BULGING_SACK = 21874;
public static final int KRISTMAS_KEBAB = 21875;
public static final int WRATH_RUNE = 21880;
public static final int DRAGON_ARMOUR_SET_LG = 21882;
public static final int DRAGON_ARMOUR_SET_SK = 21885;
public static final int TURQUOISE_SLAYER_HELMET = 21888;
public static final int TURQUOISE_SLAYER_HELMET_I = 21890;
public static final int DRAGON_PLATEBODY = 21892;
public static final int DRAGON_KITESHIELD = 21895;
public static final int ASSEMBLER_MAX_CAPE = 21898;
public static final int ASSEMBLER_MAX_HOOD = 21900;
public static final int DRAGON_CROSSBOW = 21902;
public static final int DRAGON_BOLTS = 21905;
public static final int VORKATHS_HEAD_21907 = 21907;
public static final int VORKATHS_STUFFED_HEAD = 21909;
public static final int RUNE_DRAGON = 21911;
public static final int VORKATHS_HEAD_21912 = 21912;
public static final int MYTHICAL_CAPE = 21913;
public static final int AVAS_ASSEMBLER_BROKEN = 21914;
public static final int ASSEMBLER_MAX_CAPE_BROKEN = 21916;
public static final int DRAGON_LIMBS = 21918;
public static final int DRAGON_CROSSBOW_U = 21921;
public static final int DRAGON_BOLTS_P = 21924;
public static final int DRAGON_BOLTS_P_21926 = 21926;
public static final int DRAGON_BOLTS_P_21928 = 21928;
public static final int DRAGON_BOLTS_UNF = 21930;
public static final int OPAL_DRAGON_BOLTS_E = 21932;
public static final int JADE_DRAGON_BOLTS_E = 21934;
public static final int PEARL_DRAGON_BOLTS_E = 21936;
public static final int TOPAZ_DRAGON_BOLTS_E = 21938;
public static final int SAPPHIRE_DRAGON_BOLTS_E = 21940;
public static final int EMERALD_DRAGON_BOLTS_E = 21942;
public static final int RUBY_DRAGON_BOLTS_E = 21944;
public static final int DIAMOND_DRAGON_BOLTS_E = 21946;
public static final int DRAGONSTONE_DRAGON_BOLTS_E = 21948;
public static final int ONYX_DRAGON_BOLTS_E = 21950;
public static final int MAGIC_STOCK = 21952;
public static final int OPAL_DRAGON_BOLTS = 21955;
public static final int JADE_DRAGON_BOLTS = 21957;
public static final int PEARL_DRAGON_BOLTS = 21959;
public static final int TOPAZ_DRAGON_BOLTS = 21961;
public static final int SAPPHIRE_DRAGON_BOLTS = 21963;
public static final int EMERALD_DRAGON_BOLTS = 21965;
public static final int RUBY_DRAGON_BOLTS = 21967;
public static final int DIAMOND_DRAGON_BOLTS = 21969;
public static final int DRAGONSTONE_DRAGON_BOLTS = 21971;
public static final int ONYX_DRAGON_BOLTS = 21973;
public static final int CRUSHED_SUPERIOR_DRAGON_BONES = 21975;
public static final int SUPER_ANTIFIRE_POTION4 = 21978;
public static final int SUPER_ANTIFIRE_POTION3 = 21981;
public static final int SUPER_ANTIFIRE_POTION2 = 21984;
public static final int SUPER_ANTIFIRE_POTION1 = 21987;
public static final int RIFT_GUARDIAN_21990 = 21990;
public static final int VORKI = 21992;
public static final int SUPER_ANTIFIRE_MIX2 = 21994;
public static final int SUPER_ANTIFIRE_MIX1 = 21997;
public static final int CLUE_SCROLL_ELITE_22000 = 22000;
public static final int CLUE_SCROLL_EASY_22001 = 22001;
public static final int DRAGONFIRE_WARD = 22002;
public static final int DRAGONFIRE_WARD_22003 = 22003;
public static final int SKELETAL_VISAGE = 22006;
public static final int MAP_PIECE = 22009;
public static final int MAP_PIECE_22010 = 22010;
public static final int MAP_PIECE_22011 = 22011;
public static final int MAP_PIECE_22012 = 22012;
public static final int MAP_PIECE_22013 = 22013;
public static final int MAP_PIECE_22014 = 22014;
public static final int MAP_PIECE_22015 = 22015;
public static final int MAP_PIECE_22016 = 22016;
public static final int MAP_PIECE_22017 = 22017;
public static final int MAP_PIECE_22018 = 22018;
public static final int MAP_PIECE_22019 = 22019;
public static final int MAP_PIECE_22020 = 22020;
public static final int MAP_PIECE_22021 = 22021;
public static final int MAP_PIECE_22022 = 22022;
public static final int MAP_PIECE_22023 = 22023;
public static final int MAP_PIECE_22024 = 22024;
public static final int MAP_PIECE_22025 = 22025;
public static final int MAP_PIECE_22026 = 22026;
public static final int MAP_PIECE_22027 = 22027;
public static final int MAP_PIECE_22028 = 22028;
public static final int MAP_PIECE_22029 = 22029;
public static final int MAP_PIECE_22030 = 22030;
public static final int MAP_PIECE_22031 = 22031;
public static final int MAP_PIECE_22032 = 22032;
public static final int AIVAS_DIARY = 22033;
public static final int VARROCK_CENSUS_RECORDS = 22035;
public static final int MALUMACS_JOURNAL = 22037;
public static final int ABLENKIANS_ESCAPE = 22039;
public static final int IMCANDORIAS_FALL = 22041;
public static final int IMAFORES_BETRAYAL = 22043;
public static final int LUTWIDGE_AND_THE_MOONFLY = 22045;
public static final int SERAFINA = 22047;
public static final int THE_WEEPING = 22049;
public static final int OLD_NOTES = 22051;
public static final int OLD_NOTES_22053 = 22053;
public static final int OLD_NOTES_22055 = 22055;
public static final int OLD_NOTES_22057 = 22057;
public static final int OLD_NOTES_22059 = 22059;
public static final int OLD_NOTES_22061 = 22061;
public static final int OLD_NOTES_22063 = 22063;
public static final int OLD_NOTES_22065 = 22065;
public static final int OLD_NOTES_22067 = 22067;
public static final int OLD_NOTES_22069 = 22069;
public static final int OLD_NOTES_22071 = 22071;
public static final int OLD_NOTES_22073 = 22073;
public static final int OLD_NOTES_22075 = 22075;
public static final int OLD_NOTES_22077 = 22077;
public static final int INERT_LOCATOR_ORB = 22079;
public static final int LOCATOR_ORB = 22081;
public static final int ROBERT_BUST = 22083;
public static final int CAMORRA_BUST = 22084;
public static final int TRISTAN_BUST = 22085;
public static final int AIVAS_BUST = 22086;
public static final int DRAGON_KEY = 22087;
public static final int DRAGON_KEY_PIECE = 22088;
public static final int DRAGON_KEY_PIECE_22089 = 22089;
public static final int DRAGON_KEY_PIECE_22090 = 22090;
public static final int DRAGON_KEY_PIECE_22091 = 22091;
public static final int DRAGON_KEY_22092 = 22092;
public static final int ANCIENT_KEY = 22093;
public static final int WATER_CONTAINER = 22094;
public static final int SWAMP_PASTE_22095 = 22095;
public static final int REVITALISATION_POTION = 22096;
public static final int DRAGON_METAL_SHARD = 22097;
public static final int DRAGON_METAL_SLICE = 22100;
public static final int DRAGON_METAL_LUMP = 22103;
public static final int JAR_OF_DECAY = 22106;
public static final int AVAS_ASSEMBLER = 22109;
public static final int DRAGONBONE_NECKLACE = 22111;
public static final int MYTHICAL_CAPE_22114 = 22114;
public static final int BONEMEAL_22116 = 22116;
public static final int WRATH_TALISMAN = 22118;
public static final int WRATH_TIARA = 22121;
public static final int SUPERIOR_DRAGON_BONES = 22124;
public static final int ADAMANT_KITESHIELD_22127 = 22127;
public static final int ADAMANT_KITESHIELD_22129 = 22129;
public static final int ADAMANT_KITESHIELD_22131 = 22131;
public static final int ADAMANT_KITESHIELD_22133 = 22133;
public static final int ADAMANT_KITESHIELD_22135 = 22135;
public static final int ADAMANT_KITESHIELD_22137 = 22137;
public static final int ADAMANT_KITESHIELD_22139 = 22139;
public static final int ADAMANT_KITESHIELD_22141 = 22141;
public static final int ADAMANT_KITESHIELD_22143 = 22143;
public static final int ADAMANT_KITESHIELD_22145 = 22145;
public static final int ADAMANT_KITESHIELD_22147 = 22147;
public static final int ADAMANT_KITESHIELD_22149 = 22149;
public static final int ADAMANT_KITESHIELD_22151 = 22151;
public static final int ADAMANT_KITESHIELD_22153 = 22153;
public static final int ADAMANT_KITESHIELD_22155 = 22155;
public static final int ADAMANT_KITESHIELD_22157 = 22157;
public static final int ADAMANT_HERALDIC_HELM = 22159;
public static final int ADAMANT_HERALDIC_HELM_22161 = 22161;
public static final int ADAMANT_HERALDIC_HELM_22163 = 22163;
public static final int ADAMANT_HERALDIC_HELM_22165 = 22165;
public static final int ADAMANT_HERALDIC_HELM_22167 = 22167;
public static final int ADAMANT_HERALDIC_HELM_22169 = 22169;
public static final int ADAMANT_HERALDIC_HELM_22171 = 22171;
public static final int ADAMANT_HERALDIC_HELM_22173 = 22173;
public static final int ADAMANT_HERALDIC_HELM_22175 = 22175;
public static final int ADAMANT_HERALDIC_HELM_22177 = 22177;
public static final int ADAMANT_HERALDIC_HELM_22179 = 22179;
public static final int ADAMANT_HERALDIC_HELM_22181 = 22181;
public static final int ADAMANT_HERALDIC_HELM_22183 = 22183;
public static final int ADAMANT_HERALDIC_HELM_22185 = 22185;
public static final int ADAMANT_HERALDIC_HELM_22187 = 22187;
public static final int ADAMANT_HERALDIC_HELM_22189 = 22189;
public static final int USEFUL_ROCK = 22191;
public static final int MAPLE_BIRD_HOUSE = 22192;
public static final int MAHOGANY_BIRD_HOUSE = 22195;
public static final int YEW_BIRD_HOUSE = 22198;
public static final int MAGIC_BIRD_HOUSE = 22201;
public static final int REDWOOD_BIRD_HOUSE = 22204;
public static final int GLISTENING_TEAR = 22207;
public static final int WRATH_RUNE_22208 = 22208;
public static final int EXTENDED_SUPER_ANTIFIRE4 = 22209;
public static final int EXTENDED_SUPER_ANTIFIRE3 = 22212;
public static final int EXTENDED_SUPER_ANTIFIRE2 = 22215;
public static final int EXTENDED_SUPER_ANTIFIRE1 = 22218;
public static final int EXTENDED_SUPER_ANTIFIRE_MIX2 = 22221;
public static final int EXTENDED_SUPER_ANTIFIRE_MIX1 = 22224;
public static final int BULLET_ARROW = 22227;
public static final int FIELD_ARROW = 22228;
public static final int BLUNT_ARROW = 22229;
public static final int BARBED_ARROW = 22230;
public static final int DRAGON_BOOTS_ORNAMENT_KIT = 22231;
public static final int DRAGON_BOOTS_G = 22234;
public static final int DRAGON_PLATEBODY_ORNAMENT_KIT = 22236;
public static final int DRAGON_KITESHIELD_ORNAMENT_KIT = 22239;
public static final int DRAGON_PLATEBODY_G = 22242;
public static final int DRAGON_KITESHIELD_G = 22244;
public static final int ANGUISH_ORNAMENT_KIT = 22246;
public static final int NECKLACE_OF_ANGUISH_OR = 22249;
public static final int OAK_SHIELD = 22251;
public static final int WILLOW_SHIELD = 22254;
public static final int MAPLE_SHIELD = 22257;
public static final int YEW_SHIELD = 22260;
public static final int MAGIC_SHIELD = 22263;
public static final int REDWOOD_SHIELD = 22266;
public static final int HARD_LEATHER_SHIELD = 22269;
public static final int SNAKESKIN_SHIELD = 22272;
public static final int GREEN_DHIDE_SHIELD = 22275;
public static final int BLUE_DHIDE_SHIELD = 22278;
public static final int RED_DHIDE_SHIELD = 22281;
public static final int BLACK_DHIDE_SHIELD = 22284;
public static final int LEATHER_SHIELDS_FLYER = 22287;
public static final int TRIDENT_OF_THE_SEAS_E = 22288;
public static final int UNCHARGED_TRIDENT_E = 22290;
public static final int TRIDENT_OF_THE_SWAMP_E = 22292;
public static final int UNCHARGED_TOXIC_TRIDENT_E = 22294;
public static final int STAFF_OF_LIGHT = 22296;
public static final int ANCIENT_MEDALLION = 22299;
public static final int ANCIENT_EFFIGY = 22302;
public static final int ANCIENT_RELIC = 22305;
public static final int HEALER_ICON_22308 = 22308;
public static final int HEALER_ICON_22309 = 22309;
public static final int HEALER_ICON_22310 = 22310;
public static final int HEALER_ICON_22311 = 22311;
public static final int COLLECTOR_ICON_22312 = 22312;
public static final int COLLECTOR_ICON_22313 = 22313;
public static final int COLLECTOR_ICON_22314 = 22314;
public static final int COLLECTOR_ICON_22315 = 22315;
public static final int PROP_SWORD = 22316;
public static final int PET_CORPOREAL_CRITTER = 22318;
public static final int TZREKZUK = 22319;
public static final int CHAMPIONS_LAMP = 22320;
public static final int ROTTEN_CABBAGE = 22321;
public static final int AVERNIC_DEFENDER = 22322;
public static final int SANGUINESTI_STAFF = 22323;
public static final int GHRAZI_RAPIER = 22324;
public static final int SCYTHE_OF_VITUR = 22325;
public static final int JUSTICIAR_FACEGUARD = 22326;
public static final int JUSTICIAR_CHESTGUARD = 22327;
public static final int JUSTICIAR_LEGGUARDS = 22328;
public static final int DEADMAN_STARTER_PACK = 22330;
public static final int STARTER_SWORD = 22331;
public static final int STARTER_BOW = 22333;
public static final int STARTER_STAFF = 22335;
public static final int COLLECTOR_ICON_22337 = 22337;
public static final int COLLECTOR_ICON_22338 = 22338;
public static final int COLLECTOR_ICON_22339 = 22339;
public static final int DEFENDER_ICON_22340 = 22340;
public static final int DEFENDER_ICON_22341 = 22341;
public static final int DEFENDER_ICON_22342 = 22342;
public static final int DEFENDER_ICON_22343 = 22343;
public static final int DEFENDER_ICON_22344 = 22344;
public static final int DEFENDER_ICON_22345 = 22345;
public static final int ATTACKER_ICON_22346 = 22346;
public static final int ATTACKER_ICON_22347 = 22347;
public static final int ATTACKER_ICON_22348 = 22348;
public static final int ATTACKER_ICON_22349 = 22349;
public static final int EGGSHELL_PLATEBODY = 22351;
public static final int EGGSHELL_PLATELEGS = 22353;
public static final int HOLY_HANDEGG = 22355;
public static final int PEACEFUL_HANDEGG = 22358;
public static final int CHAOTIC_HANDEGG = 22361;
public static final int OCULUS_ORB = 22364;
public static final int SHAYZIEN_FAVOUR_CERTIFICATE = 22365;
public static final int CYAN_CRYSTAL_22366 = 22366;
public static final int KOUREND_FAVOUR_CERTIFICATE = 22367;
public static final int BRYOPHYTAS_STAFF_UNCHARGED = 22368;
public static final int BRYOPHYTAS_STAFF = 22370;
public static final int BRYOPHYTAS_ESSENCE = 22372;
public static final int MOSSY_KEY = 22374;
public static final int PUPPADILE = 22376;
public static final int TEKTINY = 22378;
public static final int VANGUARD = 22380;
public static final int VASA_MINIRIO = 22382;
public static final int VESPINA = 22384;
public static final int METAMORPHIC_DUST = 22386;
public static final int XERICS_GUARD = 22388;
public static final int XERICS_WARRIOR = 22390;
public static final int XERICS_SENTINEL = 22392;
public static final int XERICS_GENERAL = 22394;
public static final int XERICS_CHAMPION = 22396;
public static final int IVANDIS_FLAIL = 22398;
public static final int DRAKANS_MEDALLION = 22400;
public static final int MYSTERIOUS_HERB = 22402;
public static final int MYSTERIOUS_MEAT = 22403;
public static final int MYSTERIOUS_CRUSHED_MEAT = 22404;
public static final int VIAL_OF_BLOOD = 22405;
public static final int UNFINISHED_BLOOD_POTION = 22406;
public static final int BLOOD_POTION = 22407;
public static final int UNFINISHED_POTION_22408 = 22408;
public static final int POTION_22409 = 22409;
public static final int OLD_NOTES_22410 = 22410;
public static final int OLD_DIARY = 22411;
public static final int FLAYGIANS_NOTES = 22413;
public static final int CHAIN = 22414;
public static final int TOME_OF_EXPERIENCE = 22415;
public static final int THE_TURNCLOAK = 22416;
public static final int EXPLOSIVE_DISCOVERY = 22418;
public static final int BLOODY_GRIMOIRE = 22420;
public static final int ELIXIR_OF_EVERLASTING = 22422;
public static final int BURIED_ALIVE = 22424;
public static final int DEED = 22426;
public static final int OLD_KEY = 22428;
public static final int BLOODY_BRACER = 22430;
public static final int EMERALD_SICKLE_B = 22433;
public static final int ENCHANTED_EMERALD_SICKLE_B = 22435;
public static final int ROTTEN_CARROT = 22437;
public static final int JUSTICIAR_ARMOUR_SET = 22438;
public static final int AVERNIC_DEFENDER_BROKEN = 22441;
public static final int CADANTINE_BLOOD_POTION_UNF = 22443;
public static final int VIAL_OF_BLOOD_22446 = 22446;
public static final int BATTLEMAGE_POTION4 = 22449;
public static final int BATTLEMAGE_POTION3 = 22452;
public static final int BATTLEMAGE_POTION2 = 22455;
public static final int BATTLEMAGE_POTION1 = 22458;
public static final int BASTION_POTION4 = 22461;
public static final int BASTION_POTION3 = 22464;
public static final int BASTION_POTION2 = 22467;
public static final int BASTION_POTION1 = 22470;
public static final int LIL_ZIK = 22473;
public static final int MESSAGE_22475 = 22475;
public static final int AVERNIC_DEFENDER_HILT = 22477;
public static final int SANGUINESTI_STAFF_UNCHARGED = 22481;
public static final int SCYTHE_OF_VITUR_UNCHARGED = 22486;
public static final int SINHAZA_SHROUD_TIER_1 = 22494;
public static final int SINHAZA_SHROUD_TIER_2 = 22496;
public static final int SINHAZA_SHROUD_TIER_3 = 22498;
public static final int SINHAZA_SHROUD_TIER_4 = 22500;
public static final int SINHAZA_SHROUD_TIER_5 = 22502;
public static final int SERAFINAS_DIARY = 22504;
public static final int THE_BUTCHER = 22506;
public static final int ARACHNIDS_OF_VAMPYRIUM = 22508;
public static final int THE_SHADOW_REALM = 22510;
public static final int THE_WILD_HUNT = 22512;
public static final int VERZIK_VITUR__PATIENT_RECORD = 22514;
public static final int DAWNBRINGER = 22516;
public static final int VERZIKS_CRYSTAL_SHARD = 22517;
public static final int CABBAGE_22519 = 22519;
public static final int CABBAGE_22520 = 22520;
public static final int COIN_POUCH = 22521;
public static final int COIN_POUCH_22522 = 22522;
public static final int COIN_POUCH_22523 = 22523;
public static final int COIN_POUCH_22524 = 22524;
public static final int COIN_POUCH_22525 = 22525;
public static final int COIN_POUCH_22526 = 22526;
public static final int COIN_POUCH_22527 = 22527;
public static final int COIN_POUCH_22528 = 22528;
public static final int COIN_POUCH_22529 = 22529;
public static final int COIN_POUCH_22530 = 22530;
public static final int COIN_POUCH_22531 = 22531;
public static final int COIN_POUCH_22532 = 22532;
public static final int COIN_POUCH_22533 = 22533;
public static final int COIN_POUCH_22534 = 22534;
public static final int COIN_POUCH_22535 = 22535;
public static final int COIN_POUCH_22536 = 22536;
public static final int COIN_POUCH_22537 = 22537;
public static final int COIN_POUCH_22538 = 22538;
public static final int ROTTEN_STRAWBERRY = 22541;
public static final int VIGGORAS_CHAINMACE_U = 22542;
public static final int VIGGORAS_CHAINMACE = 22545;
public static final int CRAWS_BOW_U = 22547;
public static final int CRAWS_BOW = 22550;
public static final int THAMMARONS_SCEPTRE_U = 22552;
public static final int THAMMARONS_SCEPTRE = 22555;
public static final int AMULET_OF_AVARICE = 22557;
public static final int LOOTING_BAG_22586 = 22586;
public static final int OLD_MANS_COFFIN = 22588;
public static final int REDUCED_CADAVA_POTION = 22589;
public static final int GOAT_DUNG = 22590;
public static final int WEISS_FIRE_NOTES = 22591;
public static final int TE_SALT = 22593;
public static final int EFH_SALT = 22595;
public static final int URT_SALT = 22597;
public static final int ICY_BASALT = 22599;
public static final int STONY_BASALT = 22601;
public static final int BASALT = 22603;
public static final int FIRE_OF_ETERNAL_LIGHT = 22606;
public static final int FIRE_OF_DEHUMIDIFICATION = 22607;
public static final int FIRE_OF_NOURISHMENT = 22608;
public static final int FIRE_OF_UNSEASONAL_WARMTH = 22609;
public static final int VESTAS_SPEAR = 22610;
public static final int VESTAS_LONGSWORD = 22613;
public static final int VESTAS_CHAINBODY = 22616;
public static final int VESTAS_PLATESKIRT = 22619;
public static final int STATIUSS_WARHAMMER = 22622;
public static final int STATIUSS_FULL_HELM = 22625;
public static final int STATIUSS_PLATEBODY = 22628;
public static final int STATIUSS_PLATELEGS = 22631;
public static final int MORRIGANS_THROWING_AXE = 22634;
public static final int MORRIGANS_JAVELIN = 22636;
public static final int MORRIGANS_COIF = 22638;
public static final int MORRIGANS_LEATHER_BODY = 22641;
public static final int MORRIGANS_LEATHER_CHAPS = 22644;
public static final int ZURIELS_STAFF = 22647;
public static final int ZURIELS_HOOD = 22650;
public static final int ZURIELS_ROBE_TOP = 22653;
public static final int ZURIELS_ROBE_BOTTOM = 22656;
public static final int EMPTY_BUCKET_PACK = 22660;
public static final int PET_SMOKE_DEVIL_22663 = 22663;
public static final int SCYTHE_OF_VITUR_22664 = 22664;
public static final int ARMADYL_GODSWORD_22665 = 22665;
public static final int RUBBER_CHICKEN_22666 = 22666;
public static final int KQ_HEAD_TATTERED = 22671;
public static final int STUFFED_KQ_HEAD_TATTERED = 22673;
public static final int SCROLL_SACK = 22675;
public static final int EEK = 22684;
public static final int CLOWN_MASK = 22689;
public static final int CLOWN_BOW_TIE = 22692;
public static final int CLOWN_GOWN = 22695;
public static final int CLOWN_TROUSERS = 22698;
public static final int CLOWN_SHOES = 22701;
public static final int PORTAL_NEXUS = 22704;
public static final int MARBLE_PORTAL_NEXUS = 22705;
public static final int GILDED_PORTAL_NEXUS = 22706;
public static final int CRYSTALLINE_PORTAL_NEXUS = 22707;
public static final int MOUNTED_XERICS_TALISMAN = 22708;
public static final int MOUNTED_DIGSITE_PENDANT = 22709;
public static final int CURATORS_MEDALLION = 22710;
public static final int COLLECTION_LOG = 22711;
public static final int STARFACE = 22713;
public static final int TREE_TOP = 22715;
public static final int TREE_SKIRT = 22717;
public static final int CANDY_CANE = 22719;
public static final int ATTACKER_ICON_22721 = 22721;
public static final int ATTACKER_ICON_22722 = 22722;
public static final int ATTACKER_ICON_22723 = 22723;
public static final int COLLECTOR_ICON_22724 = 22724;
public static final int DEFENDER_ICON_22725 = 22725;
public static final int DEFENDER_ICON_22726 = 22726;
public static final int DEFENDER_ICON_22727 = 22727;
public static final int DEFENDER_ICON_22728 = 22728;
public static final int ATTACKER_ICON_22729 = 22729;
public static final int ATTACKER_ICON_22730 = 22730;
public static final int DRAGON_HASTA = 22731;
public static final int DRAGON_HASTAP = 22734;
public static final int DRAGON_HASTAP_22737 = 22737;
public static final int DRAGON_HASTAP_22740 = 22740;
public static final int DRAGON_HASTAKP = 22743;
public static final int FAKE_DRAGON_HASTAKP = 22744;
public static final int IKKLE_HYDRA = 22746;
public static final int IKKLE_HYDRA_22748 = 22748;
public static final int IKKLE_HYDRA_22750 = 22750;
public static final int IKKLE_HYDRA_22752 = 22752;
public static final int BONEMEAL_22754 = 22754;
public static final int BONEMEAL_22756 = 22756;
public static final int BONEMEAL_22758 = 22758;
public static final int LOVAKENGJ_FAVOUR_CERTIFICATE = 22760;
public static final int DINHS_HAMMER = 22761;
public static final int GENERATOR_CRANK = 22762;
public static final int _8GALLON_JUG = 22763;
public static final int _5GALLON_JUG = 22764;
public static final int ENERGY_DISK_LEVEL_4 = 22765;
public static final int ENERGY_DISK_LEVEL_3 = 22766;
public static final int ENERGY_DISK_LEVEL_2 = 22767;
public static final int ENERGY_DISK_LEVEL_1 = 22768;
public static final int UNKNOWN_FLUID_1 = 22769;
public static final int UNKNOWN_FLUID_2 = 22770;
public static final int UNKNOWN_FLUID_3 = 22771;
public static final int UNKNOWN_FLUID_4 = 22772;
public static final int UNKNOWN_FLUID_5 = 22773;
public static final int OLD_NOTES_22774 = 22774;
public static final int ANCIENT_LETTER = 22775;
public static final int ARCEUUS_FAVOUR_CERTIFICATE = 22777;
public static final int DARK_ALTAR_22778 = 22778;
public static final int WYRM_BONES = 22780;
public static final int DRAKE_BONES = 22783;
public static final int HYDRA_BONES = 22786;
public static final int UNCOOKED_DRAGONFRUIT_PIE = 22789;
public static final int HALF_A_DRAGONFRUIT_PIE = 22792;
public static final int DRAGONFRUIT_PIE = 22795;
public static final int BIRD_NEST_22798 = 22798;
public static final int BIRD_NEST_22800 = 22800;
public static final int RADAS_BLESSING = 22803;
public static final int DRAGON_KNIFE = 22804;
public static final int DRAGON_KNIFEP = 22806;
public static final int DRAGON_KNIFEP_22808 = 22808;
public static final int DRAGON_KNIFEP_22810 = 22810;
public static final int DRAGON_KNIFE_22812 = 22812;
public static final int DRAGON_KNIFE_22814 = 22814;
public static final int CORMORANTS_GLOVE = 22816;
public static final int CORMORANTS_GLOVE_22817 = 22817;
public static final int FISH_CHUNKS = 22818;
public static final int MOLCH_PEARL = 22820;
public static final int BLUEGILL = 22826;
public static final int COMMON_TENCH = 22829;
public static final int MOTTLED_EEL = 22832;
public static final int GREATER_SIREN = 22835;
public static final int FISH_SACK = 22838;
public static final int GOLDEN_TENCH = 22840;
public static final int PEARL_BARBARIAN_ROD = 22842;
public static final int PEARL_FLY_FISHING_ROD = 22844;
public static final int PEARL_FISHING_ROD = 22846;
public static final int CELASTRUS_SEEDLING = 22848;
public static final int REDWOOD_SEEDLING = 22850;
public static final int CELASTRUS_SEEDLING_W = 22852;
public static final int REDWOOD_SEEDLING_W = 22854;
public static final int CELASTRUS_SAPLING = 22856;
public static final int REDWOOD_SAPLING = 22859;
public static final int DRAGONFRUIT_SEEDLING = 22862;
public static final int DRAGONFRUIT_SEEDLING_W = 22864;
public static final int DRAGONFRUIT_SAPLING = 22866;
public static final int CELASTRUS_SEED = 22869;
public static final int REDWOOD_TREE_SEED = 22871;
public static final int POTATO_CACTUS_SEED = 22873;
public static final int HESPORI_SEED = 22875;
public static final int DRAGONFRUIT_TREE_SEED = 22877;
public static final int SNAPE_GRASS_SEED = 22879;
public static final int ATTAS_SEED = 22881;
public static final int IASOR_SEED = 22883;
public static final int KRONOS_SEED = 22885;
public static final int WHITE_LILY_SEED = 22887;
public static final int DRAGONFRUIT = 22929;
public static final int WHITE_LILY = 22932;
public static final int CELASTRUS_BARK = 22935;
public static final int RADAS_BLESSING_1 = 22941;
public static final int RADAS_BLESSING_2 = 22943;
public static final int RADAS_BLESSING_3 = 22945;
public static final int RADAS_BLESSING_4 = 22947;
public static final int BATTLEFRONT_TELEPORT = 22949;
public static final int BOOTS_OF_BRIMSTONE = 22951;
public static final int DEVOUT_BOOTS = 22954;
public static final int DRAKES_CLAW = 22957;
public static final int DRAKES_TOOTH = 22960;
public static final int BROKEN_DRAGON_HASTA = 22963;
public static final int HYDRAS_CLAW = 22966;
public static final int HYDRAS_HEART = 22969;
public static final int HYDRAS_FANG = 22971;
public static final int HYDRAS_EYE = 22973;
public static final int BRIMSTONE_RING = 22975;
public static final int DRAGON_HUNTER_LANCE = 22978;
public static final int FEROCIOUS_GLOVES = 22981;
public static final int HYDRA_LEATHER = 22983;
public static final int BONECRUSHER_NECKLACE = 22986;
public static final int HYDRA_TAIL = 22988;
public static final int STONE_TABLET_22991 = 22991;
public static final int SEED_PACK = 22993;
public static final int BOTTOMLESS_COMPOST_BUCKET = 22994;
public static final int BOTTOMLESS_COMPOST_BUCKET_22997 = 22997;
public static final int BOTTLED_DRAGONBREATH_UNPOWERED = 22999;
public static final int BOTTLED_DRAGONBREATH = 23002;
public static final int TATTY_NOTE = 23007;
public static final int GIELINORS_FLORA__FLOWERS = 23009;
public static final int GIELINORS_FLORA__BUSHES = 23011;
public static final int GIELINORS_FLORA__HOPS = 23013;
public static final int GIELINORS_FLORA__ALLOTMENTS = 23015;
public static final int GIELINORS_FLORA__HERBS = 23017;
public static final int GIELINORS_FLORA__TREES = 23019;
public static final int GIELINORS_FLORA__FRUIT = 23021;
public static final int OLD_NOTES_23023 = 23023;
public static final int OLD_NOTES_23025 = 23025;
public static final int OLD_NOTES_23027 = 23027;
public static final int OLD_NOTES_23029 = 23029;
public static final int OLD_NOTES_23031 = 23031;
public static final int OLD_NOTES_23033 = 23033;
public static final int OLD_NOTES_23035 = 23035;
public static final int BOOTS_OF_STONE = 23037;
public static final int WYRM = 23040;
public static final int DRAKE = 23041;
public static final int HYDRA = 23042;
public static final int SULPHUR_LIZARD = 23043;
public static final int CLUE_SCROLL_HARD_23045 = 23045;
public static final int CLUE_SCROLL_MEDIUM_23046 = 23046;
public static final int MYSTIC_HAT_DUSK = 23047;
public static final int MYSTIC_ROBE_TOP_DUSK = 23050;
public static final int MYSTIC_ROBE_BOTTOM_DUSK = 23053;
public static final int MYSTIC_GLOVES_DUSK = 23056;
public static final int MYSTIC_BOOTS_DUSK = 23059;
public static final int NEST_BOX_SEEDS_23062 = 23062;
public static final int JAR_OF_CHEMICALS = 23064;
public static final int TREASURE_SCROLL = 23067;
public static final int TREASURE_SCROLL_23068 = 23068;
public static final int MYSTERIOUS_ORB_23069 = 23069;
public static final int TREASURE_SCROLL_23070 = 23070;
public static final int ANCIENT_CASKET = 23071;
public static final int ANTIQUE_LAMP_23072 = 23072;
public static final int HYDRA_SLAYER_HELMET = 23073;
public static final int HYDRA_SLAYER_HELMET_I = 23075;
public static final int ALCHEMICAL_HYDRA_HEADS = 23077;
public static final int STUFFED_HYDRA_HEADS = 23079;
public static final int ALCHEMICAL_HYDRA_HEAD = 23081;
public static final int ANTIQUE_LAMP_23082 = 23082;
public static final int BRIMSTONE_KEY = 23083;
public static final int ORNATE_GLOVES = 23091;
public static final int ORNATE_BOOTS = 23093;
public static final int ORNATE_LEGS = 23095;
public static final int ORNATE_TOP = 23097;
public static final int ORNATE_CAPE = 23099;
public static final int ORNATE_HELM = 23101;
public static final int BIRTHDAY_CAKE = 23108;
public static final int MYSTIC_SET_LIGHT = 23110;
public static final int MYSTIC_SET_BLUE = 23113;
public static final int MYSTIC_SET_DARK = 23116;
public static final int MYSTIC_SET_DUSK = 23119;
public static final int OILY_PEARL_FISHING_ROD = 23122;
public static final int GILDED_DRAGONHIDE_SET = 23124;
public static final int CLUE_NEST_BEGINNER = 23127;
public static final int CLUE_BOTTLE_BEGINNER = 23129;
public static final int CLUE_SCROLL_MEDIUM_23131 = 23131;
public static final int CHALLENGE_SCROLL_MEDIUM_23132 = 23132;
public static final int CLUE_SCROLL_MEDIUM_23133 = 23133;
public static final int CHALLENGE_SCROLL_MEDIUM_23134 = 23134;
public static final int CLUE_SCROLL_MEDIUM_23135 = 23135;
public static final int CLUE_SCROLL_MEDIUM_23136 = 23136;
public static final int CLUE_SCROLL_MEDIUM_23137 = 23137;
public static final int CLUE_SCROLL_MEDIUM_23138 = 23138;
public static final int CLUE_SCROLL_MEDIUM_23139 = 23139;
public static final int CLUE_SCROLL_MEDIUM_23140 = 23140;
public static final int CLUE_SCROLL_MEDIUM_23141 = 23141;
public static final int CLUE_SCROLL_MEDIUM_23142 = 23142;
public static final int CLUE_SCROLL_MEDIUM_23143 = 23143;
public static final int CLUE_SCROLL_ELITE_23144 = 23144;
public static final int CLUE_SCROLL_ELITE_23145 = 23145;
public static final int CLUE_SCROLL_ELITE_23146 = 23146;
public static final int CLUE_SCROLL_ELITE_23147 = 23147;
public static final int CLUE_SCROLL_ELITE_23148 = 23148;
public static final int CLUE_SCROLL_EASY_23149 = 23149;
public static final int CLUE_SCROLL_EASY_23150 = 23150;
public static final int CLUE_SCROLL_EASY_23151 = 23151;
public static final int CLUE_SCROLL_EASY_23152 = 23152;
public static final int CLUE_SCROLL_EASY_23153 = 23153;
public static final int CLUE_SCROLL_EASY_23154 = 23154;
public static final int CLUE_SCROLL_EASY_23155 = 23155;
public static final int CLUE_SCROLL_EASY_23156 = 23156;
public static final int CLUE_SCROLL_EASY_23157 = 23157;
public static final int CLUE_SCROLL_EASY_23158 = 23158;
public static final int CLUE_SCROLL_EASY_23159 = 23159;
public static final int CLUE_SCROLL_EASY_23160 = 23160;
public static final int CLUE_SCROLL_EASY_23161 = 23161;
public static final int CLUE_SCROLL_EASY_23162 = 23162;
public static final int CLUE_SCROLL_EASY_23163 = 23163;
public static final int CLUE_SCROLL_EASY_23164 = 23164;
public static final int CLUE_SCROLL_EASY_23165 = 23165;
public static final int CLUE_SCROLL_EASY_23166 = 23166;
public static final int CLUE_SCROLL_HARD_23167 = 23167;
public static final int CLUE_SCROLL_HARD_23168 = 23168;
public static final int CLUE_SCROLL_HARD_23169 = 23169;
public static final int CLUE_SCROLL_HARD_23170 = 23170;
public static final int PUZZLE_BOX_HARD_23171 = 23171;
public static final int CLUE_SCROLL_HARD_23172 = 23172;
public static final int PUZZLE_BOX_HARD_23173 = 23173;
public static final int CLUE_SCROLL_HARD_23174 = 23174;
public static final int CLUE_SCROLL_HARD_23175 = 23175;
public static final int CLUE_SCROLL_HARD_23176 = 23176;
public static final int CLUE_SCROLL_HARD_23177 = 23177;
public static final int CLUE_SCROLL_HARD_23178 = 23178;
public static final int CLUE_SCROLL_HARD_23179 = 23179;
public static final int CLUE_SCROLL_HARD_23180 = 23180;
public static final int CLUE_SCROLL_HARD_23181 = 23181;
public static final int CLUE_SCROLL_BEGINNER = 23182;
public static final int STRANGE_DEVICE_23183 = 23183;
public static final int MIMIC = 23184;
public static final int RING_OF_3RD_AGE = 23185;
public static final int GUTHIX_DHIDE_SHIELD = 23188;
public static final int SARADOMIN_DHIDE_SHIELD = 23191;
public static final int ZAMORAK_DHIDE_SHIELD = 23194;
public static final int ANCIENT_DHIDE_SHIELD = 23197;
public static final int ARMADYL_DHIDE_SHIELD = 23200;
public static final int BANDOS_DHIDE_SHIELD = 23203;
public static final int DUAL_SAI = 23206;
public static final int RUNE_PLATEBODY_H1 = 23209;
public static final int RUNE_PLATEBODY_H2 = 23212;
public static final int RUNE_PLATEBODY_H3 = 23215;
public static final int RUNE_PLATEBODY_H4 = 23218;
public static final int RUNE_PLATEBODY_H5 = 23221;
public static final int THIEVING_BAG = 23224;
public static final int RUNE_DEFENDER_ORNAMENT_KIT = 23227;
public static final int RUNE_DEFENDER_T = 23230;
public static final int TZHAARKETOM_ORNAMENT_KIT = 23232;
public static final int TZHAARKETOM_T = 23235;
public static final int BERSERKER_NECKLACE_ORNAMENT_KIT = 23237;
public static final int BERSERKER_NECKLACE_OR = 23240;
public static final int _3RD_AGE_PLATESKIRT = 23242;
public static final int REWARD_CASKET_BEGINNER = 23245;
public static final int FREMENNIK_KILT = 23246;
public static final int RANGERS_TIGHTS = 23249;
public static final int GIANT_BOOT = 23252;
public static final int URIS_HAT = 23255;
public static final int GILDED_COIF = 23258;
public static final int GILDED_DHIDE_VAMBRACES = 23261;
public static final int GILDED_DHIDE_BODY = 23264;
public static final int GILDED_DHIDE_CHAPS = 23267;
public static final int ADAMANT_DRAGON_MASK = 23270;
public static final int RUNE_DRAGON_MASK = 23273;
public static final int GILDED_PICKAXE = 23276;
public static final int GILDED_AXE = 23279;
public static final int GILDED_SPADE = 23282;
public static final int MOLE_SLIPPERS = 23285;
public static final int FROG_SLIPPERS = 23288;
public static final int BEAR_FEET = 23291;
public static final int DEMON_FEET = 23294;
public static final int JESTER_CAPE = 23297;
public static final int SHOULDER_PARROT = 23300;
public static final int MONKS_ROBE_TOP_T = 23303;
public static final int MONKS_ROBE_T = 23306;
public static final int AMULET_OF_DEFENCE_T = 23309;
public static final int SANDWICH_LADY_HAT = 23312;
public static final int SANDWICH_LADY_TOP = 23315;
public static final int SANDWICH_LADY_BOTTOM = 23318;
public static final int RUNE_SCIMITAR_ORNAMENT_KIT_GUTHIX = 23321;
public static final int RUNE_SCIMITAR_ORNAMENT_KIT_SARADOMIN = 23324;
public static final int RUNE_SCIMITAR_ORNAMENT_KIT_ZAMORAK = 23327;
public static final int RUNE_SCIMITAR_23330 = 23330;
public static final int RUNE_SCIMITAR_23332 = 23332;
public static final int RUNE_SCIMITAR_23334 = 23334;
public static final int _3RD_AGE_DRUIDIC_ROBE_TOP = 23336;
public static final int _3RD_AGE_DRUIDIC_ROBE_BOTTOMS = 23339;
public static final int _3RD_AGE_DRUIDIC_STAFF = 23342;
public static final int _3RD_AGE_DRUIDIC_CLOAK = 23345;
public static final int TORMENTED_ORNAMENT_KIT = 23348;
public static final int CAPE_OF_SKULLS = 23351;
public static final int AMULET_OF_POWER_T = 23354;
public static final int RAIN_BOW = 23357;
public static final int HAM_JOINT = 23360;
public static final int STAFF_OF_BOB_THE_CAT = 23363;
public static final int BLACK_PLATEBODY_H1 = 23366;
public static final int BLACK_PLATEBODY_H2 = 23369;
public static final int BLACK_PLATEBODY_H3 = 23372;
public static final int BLACK_PLATEBODY_H4 = 23375;
public static final int BLACK_PLATEBODY_H5 = 23378;
public static final int LEATHER_BODY_G = 23381;
public static final int LEATHER_CHAPS_G = 23384;
public static final int WATSON_TELEPORT = 23387;
public static final int SPIKED_MANACLES = 23389;
public static final int ADAMANT_PLATEBODY_H1 = 23392;
public static final int ADAMANT_PLATEBODY_H2 = 23395;
public static final int ADAMANT_PLATEBODY_H3 = 23398;
public static final int ADAMANT_PLATEBODY_H4 = 23401;
public static final int ADAMANT_PLATEBODY_H5 = 23404;
public static final int WOLF_MASK = 23407;
public static final int WOLF_CLOAK = 23410;
public static final int CLIMBING_BOOTS_G = 23413;
public static final int STASH_UNITS_BEGINNER = 23416;
public static final int PUZZLE_BOX_MASTER_23417 = 23417;
public static final int CLUE_GEODE_BEGINNER = 23442;
public static final int TORMENTED_BRACELET_OR = 23444;
public static final int GIANT_EASTER_EGG = 23446;
public static final int BUNNYMAN_MASK = 23448;
public static final int ENCHANTED_LYREI = 23458;
public static final int ATTACKER_ICON_23460 = 23460;
public static final int ATTACKER_ICON_23461 = 23461;
public static final int ATTACKER_ICON_23462 = 23462;
public static final int ATTACKER_ICON_23463 = 23463;
public static final int ATTACKER_ICON_23464 = 23464;
public static final int ATTACKER_ICON_23465 = 23465;
public static final int DEFENDER_ICON_23466 = 23466;
public static final int DEFENDER_ICON_23467 = 23467;
public static final int DEFENDER_ICON_23468 = 23468;
public static final int DEFENDER_ICON_23469 = 23469;
public static final int DEFENDER_ICON_23470 = 23470;
public static final int COLLECTOR_ICON_23471 = 23471;
public static final int COLLECTOR_ICON_23472 = 23472;
public static final int COLLECTOR_ICON_23473 = 23473;
public static final int COLLECTOR_ICON_23474 = 23474;
public static final int COLLECTOR_ICON_23475 = 23475;
public static final int COLLECTOR_ICON_23476 = 23476;
public static final int COLLECTOR_ICON_23477 = 23477;
public static final int HEALER_ICON_23478 = 23478;
public static final int HEALER_ICON_23479 = 23479;
public static final int HEALER_ICON_23480 = 23480;
public static final int HEALER_ICON_23481 = 23481;
public static final int HEALER_ICON_23482 = 23482;
public static final int HEALER_ICON_23483 = 23483;
public static final int HEALER_ICON_23484 = 23484;
public static final int HEALER_ICON_23485 = 23485;
public static final int HEALER_ICON_23486 = 23486;
public static final int ARCHAIC_EMBLEM_TIER_10_23487 = 23487;
public static final int WINE_OF_ZAMORAK_23489 = 23489;
public static final int LARRANS_KEY = 23490;
public static final int SRARACHA = 23495;
public static final int TEMPLE_COIN = 23497;
public static final int GRUBBY_KEY = 23499;
public static final int TEMPLE_KEY = 23502;
public static final int TOME_OF_THE_MOON = 23504;
public static final int TOME_OF_THE_SUN = 23506;
public static final int TOME_OF_THE_TEMPLE = 23508;
public static final int TATTERED_MOON_PAGE = 23510;
public static final int TATTERED_SUN_PAGE = 23512;
public static final int TATTERED_TEMPLE_PAGE = 23514;
public static final int LAMP_OF_KNOWLEDGE = 23516;
public static final int GIANT_EGG_SACFULL = 23517;
public static final int GIANT_EGG_SAC = 23520;
public static final int MASK_OF_RANUL = 23522;
public static final int JAR_OF_EYES = 23525;
public static final int SARACHNIS_CUDGEL = 23528;
public static final int COOKED_KARAMBWAN_23533 = 23533;
public static final int SUPER_COMBAT_POTION4_23543 = 23543;
public static final int SUPER_COMBAT_POTION3_23545 = 23545;
public static final int SUPER_COMBAT_POTION2_23547 = 23547;
public static final int SUPER_COMBAT_POTION1_23549 = 23549;
public static final int RANGING_POTION4_23551 = 23551;
public static final int RANGING_POTION3_23553 = 23553;
public static final int RANGING_POTION2_23555 = 23555;
public static final int RANGING_POTION1_23557 = 23557;
public static final int SANFEW_SERUM4_23559 = 23559;
public static final int SANFEW_SERUM3_23561 = 23561;
public static final int SANFEW_SERUM2_23563 = 23563;
public static final int SANFEW_SERUM1_23565 = 23565;
public static final int SUPER_RESTORE4_23567 = 23567;
public static final int SUPER_RESTORE3_23569 = 23569;
public static final int SUPER_RESTORE2_23571 = 23571;
public static final int SUPER_RESTORE1_23573 = 23573;
public static final int SARADOMIN_BREW4_23575 = 23575;
public static final int SARADOMIN_BREW3_23577 = 23577;
public static final int SARADOMIN_BREW2_23579 = 23579;
public static final int SARADOMIN_BREW1_23581 = 23581;
public static final int STAMINA_POTION4_23583 = 23583;
public static final int STAMINA_POTION3_23585 = 23585;
public static final int STAMINA_POTION2_23587 = 23587;
public static final int STAMINA_POTION1_23589 = 23589;
public static final int HELM_OF_NEITIZNOT_23591 = 23591;
public static final int BARROWS_GLOVES_23593 = 23593;
public static final int BERSERKER_RING_23595 = 23595;
public static final int DRAGON_DEFENDER_23597 = 23597;
public static final int SPIRIT_SHIELD_23599 = 23599;
public static final int RUNE_CROSSBOW_23601 = 23601;
public static final int IMBUED_GUTHIX_CAPE_23603 = 23603;
public static final int IMBUED_ZAMORAK_CAPE_23605 = 23605;
public static final int IMBUED_SARADOMIN_CAPE_23607 = 23607;
public static final int AVAS_ACCUMULATOR_23609 = 23609;
public static final int ARMADYL_CROSSBOW_23611 = 23611;
public static final int STAFF_OF_THE_DEAD_23613 = 23613;
public static final int VESTAS_LONGSWORD_23615 = 23615;
public static final int ZURIELS_STAFF_23617 = 23617;
public static final int MORRIGANS_JAVELIN_23619 = 23619;
public static final int STATIUSS_WARHAMMER_23620 = 23620;
public static final int INFERNAL_CAPE_23622 = 23622;
public static final int SEERS_RING_I_23624 = 23624;
public static final int KODAI_WAND_23626 = 23626;
public static final int GHRAZI_RAPIER_23628 = 23628;
public static final int HEAVY_BALLISTA_23630 = 23630;
public static final int KARILS_LEATHERTOP_23632 = 23632;
public static final int DHAROKS_PLATELEGS_23633 = 23633;
public static final int TORAGS_PLATELEGS_23634 = 23634;
public static final int VERACS_PLATESKIRT_23635 = 23635;
public static final int VERACS_HELM_23636 = 23636;
public static final int TORAGS_HELM_23637 = 23637;
public static final int GUTHANS_HELM_23638 = 23638;
public static final int DHAROKS_HELM_23639 = 23639;
public static final int AMULET_OF_FURY_23640 = 23640;
public static final int BLESSED_SPIRIT_SHIELD_23642 = 23642;
public static final int ETERNAL_BOOTS_23644 = 23644;
public static final int BANDOS_TASSETS_23646 = 23646;
public static final int DRAGON_JAVELIN_23648 = 23648;
public static final int DIAMOND_BOLTS_E_23649 = 23649;
public static final int RUNE_POUCH_23650 = 23650;
public static final int MAGES_BOOK_23652 = 23652;
public static final int AHRIMS_STAFF_23653 = 23653;
public static final int OCCULT_NECKLACE_23654 = 23654;
public static final int CRYSTAL_SEEDLING = 23655;
public static final int CRYSTAL_SEEDLING_W = 23657;
public static final int CRYSTAL_SAPLING = 23659;
public static final int CRYSTAL_ACORN = 23661;
public static final int DRAGONSTONE_ARMOUR_SET = 23667;
public static final int FLIER_23670 = 23670;
public static final int CRYSTAL_AXE = 23673;
public static final int CRYSTAL_AXE_INACTIVE = 23675;
public static final int DRAGON_PICKAXEOR = 23677;
public static final int CRYSTAL_PICKAXE = 23680;
public static final int CRYSTAL_PICKAXE_INACTIVE = 23682;
public static final int DIVINE_SUPER_COMBAT_POTION4 = 23685;
public static final int DIVINE_SUPER_COMBAT_POTION3 = 23688;
public static final int DIVINE_SUPER_COMBAT_POTION2 = 23691;
public static final int DIVINE_SUPER_COMBAT_POTION1 = 23694;
public static final int DIVINE_SUPER_ATTACK_POTION4 = 23697;
public static final int DIVINE_SUPER_ATTACK_POTION3 = 23700;
public static final int DIVINE_SUPER_ATTACK_POTION2 = 23703;
public static final int DIVINE_SUPER_ATTACK_POTION1 = 23706;
public static final int DIVINE_SUPER_STRENGTH_POTION4 = 23709;
public static final int DIVINE_SUPER_STRENGTH_POTION3 = 23712;
public static final int DIVINE_SUPER_STRENGTH_POTION2 = 23715;
public static final int DIVINE_SUPER_STRENGTH_POTION1 = 23718;
public static final int DIVINE_SUPER_DEFENCE_POTION4 = 23721;
public static final int DIVINE_SUPER_DEFENCE_POTION3 = 23724;
public static final int DIVINE_SUPER_DEFENCE_POTION2 = 23727;
public static final int DIVINE_SUPER_DEFENCE_POTION1 = 23730;
public static final int DIVINE_RANGING_POTION4 = 23733;
public static final int DIVINE_RANGING_POTION3 = 23736;
public static final int DIVINE_RANGING_POTION2 = 23739;
public static final int DIVINE_RANGING_POTION1 = 23742;
public static final int DIVINE_MAGIC_POTION4 = 23745;
public static final int DIVINE_MAGIC_POTION3 = 23748;
public static final int DIVINE_MAGIC_POTION2 = 23751;
public static final int DIVINE_MAGIC_POTION1 = 23754;
public static final int YOUNGLLEF = 23757;
public static final int CORRUPTED_YOUNGLLEF = 23759;
public static final int SMOLCANO = 23760;
public static final int CRYSTAL_HARPOON = 23762;
public static final int CRYSTAL_HARPOON_INACTIVE = 23764;
public static final int CRYSTAL_IMPLING_JAR = 23768;
public static final int CLUE_SCROLL_ELITE_23770 = 23770;
public static final int PRIFDDINAS_TELEPORT = 23771;
public static final int SCRAWLED_NOTES = 23773;
public static final int HAND_MIRROR_23775 = 23775;
public static final int RED_CRYSTAL_23776 = 23776;
public static final int YELLOW_CRYSTAL_23777 = 23777;
public static final int GREEN_CRYSTAL_23778 = 23778;
public static final int CYAN_CRYSTAL_23779 = 23779;
public static final int BLUE_CRYSTAL_23780 = 23780;
public static final int MAGENTA_CRYSTAL_23781 = 23781;
public static final int BLACK_CRYSTAL = 23782;
public static final int GREEN_CRYSTAL_23783 = 23783;
public static final int FRACTURED_CRYSTAL_23784 = 23784;
public static final int ARDOUGNE_KNIGHT_HELM = 23785;
public static final int ARDOUGNE_KNIGHT_PLATEBODY = 23787;
public static final int ARDOUGNE_KNIGHT_PLATELEGS = 23789;
public static final int ARDOUGNE_KNIGHT_TABARD = 23791;
public static final int BLUE_LIQUID = 23792;
public static final int GREEN_POWDER = 23793;
public static final int CLEAR_LIQUID = 23794;
public static final int RED_POWDER = 23795;
public static final int ODE_TO_ETERNITY = 23796;
public static final int ELDER_CADANTINE = 23798;
public static final int ELDER_CADANTINE_POTION_UNF = 23800;
public static final int CRYSTAL_23802 = 23802;
public static final int CRYSTAL_DUST = 23804;
public static final int INVERSION_POTION = 23806;
public static final int CRYSTAL_SEED = 23808;
public static final int CRYSTAL_SEED_23810 = 23810;
public static final int ORB_OF_LIGHT_23812 = 23812;
public static final int CLUE_SCROLL_23814 = 23814;
public static final int CLUE_SCROLL_23815 = 23815;
public static final int CLUE_SCROLL_23816 = 23816;
public static final int CLUE_SCROLL_23817 = 23817;
public static final int EXPLOSIVE_POTION_23818 = 23818;
public static final int CORRUPTED_SCEPTRE = 23820;
public static final int CORRUPTED_AXE = 23821;
public static final int CORRUPTED_PICKAXE = 23822;
public static final int CORRUPTED_HARPOON = 23823;
public static final int CORRUPTED_SHARDS = 23824;
public static final int CORRUPTED_DUST = 23830;
public static final int CORRUPTED_SPIKE = 23831;
public static final int CORRUPTED_BOWSTRING = 23832;
public static final int CORRUPTED_ORB = 23833;
public static final int WEAPON_FRAME = 23834;
public static final int GRYM_LEAF = 23835;
public static final int LINUM_TIRINUM = 23836;
public static final int CORRUPTED_ORE = 23837;
public static final int PHREN_BARK = 23838;
public static final int VIAL_23839 = 23839;
public static final int CORRUPTED_HELM_BASIC = 23840;
public static final int CORRUPTED_HELM_ATTUNED = 23841;
public static final int CORRUPTED_HELM_PERFECTED = 23842;
public static final int CORRUPTED_BODY_BASIC = 23843;
public static final int CORRUPTED_BODY_ATTUNED = 23844;
public static final int CORRUPTED_BODY_PERFECTED = 23845;
public static final int CORRUPTED_LEGS_BASIC = 23846;
public static final int CORRUPTED_LEGS_ATTUNED = 23847;
public static final int CORRUPTED_LEGS_PERFECTED = 23848;
public static final int CORRUPTED_HALBERD_BASIC = 23849;
public static final int CORRUPTED_HALBERD_ATTUNED = 23850;
public static final int CORRUPTED_HALBERD_PERFECTED = 23851;
public static final int CORRUPTED_STAFF_BASIC = 23852;
public static final int CORRUPTED_STAFF_ATTUNED = 23853;
public static final int CORRUPTED_STAFF_PERFECTED = 23854;
public static final int CORRUPTED_BOW_BASIC = 23855;
public static final int CORRUPTED_BOW_ATTUNED = 23856;
public static final int CORRUPTED_BOW_PERFECTED = 23857;
public static final int CORRUPTED_TELEPORT_CRYSTAL = 23858;
public static final int GAUNTLET_CAPE = 23859;
public static final int CRYSTAL_SCEPTRE = 23861;
public static final int CRYSTAL_AXE_23862 = 23862;
public static final int CRYSTAL_PICKAXE_23863 = 23863;
public static final int CRYSTAL_HARPOON_23864 = 23864;
public static final int PESTLE_AND_MORTAR_23865 = 23865;
public static final int CRYSTAL_SHARDS = 23866;
public static final int CRYSTAL_DUST_23867 = 23867;
public static final int CRYSTAL_SPIKE = 23868;
public static final int CRYSTALLINE_BOWSTRING = 23869;
public static final int CRYSTAL_ORB = 23870;
public static final int WEAPON_FRAME_23871 = 23871;
public static final int RAW_PADDLEFISH = 23872;
public static final int BURNT_FISH_23873 = 23873;
public static final int PADDLEFISH = 23874;
public static final int GRYM_LEAF_23875 = 23875;
public static final int LINUM_TIRINUM_23876 = 23876;
public static final int CRYSTAL_ORE = 23877;
public static final int PHREN_BARK_23878 = 23878;
public static final int VIAL_23879 = 23879;
public static final int WATERFILLED_VIAL = 23880;
public static final int GRYM_POTION_UNF = 23881;
public static final int EGNIOL_POTION_1 = 23882;
public static final int EGNIOL_POTION_2 = 23883;
public static final int EGNIOL_POTION_3 = 23884;
public static final int EGNIOL_POTION_4 = 23885;
public static final int CRYSTAL_HELM_BASIC = 23886;
public static final int CRYSTAL_HELM_ATTUNED = 23887;
public static final int CRYSTAL_HELM_PERFECTED = 23888;
public static final int CRYSTAL_BODY_BASIC = 23889;
public static final int CRYSTAL_BODY_ATTUNED = 23890;
public static final int CRYSTAL_BODY_PERFECTED = 23891;
public static final int CRYSTAL_LEGS_BASIC = 23892;
public static final int CRYSTAL_LEGS_ATTUNED = 23893;
public static final int CRYSTAL_LEGS_PERFECTED = 23894;
public static final int CRYSTAL_HALBERD_BASIC = 23895;
public static final int CRYSTAL_HALBERD_ATTUNED = 23896;
public static final int CRYSTAL_HALBERD_PERFECTED = 23897;
public static final int CRYSTAL_STAFF_BASIC = 23898;
public static final int CRYSTAL_STAFF_ATTUNED = 23899;
public static final int CRYSTAL_STAFF_PERFECTED = 23900;
public static final int CRYSTAL_BOW_BASIC = 23901;
public static final int CRYSTAL_BOW_ATTUNED = 23902;
public static final int CRYSTAL_BOW_PERFECTED = 23903;
public static final int TELEPORT_CRYSTAL = 23904;
public static final int TEPHRA = 23905;
public static final int REFINED_TEPHRA = 23906;
public static final int IMBUED_TEPHRA = 23907;
public static final int ZALCANO_SHARD = 23908;
public static final int CRYSTAL_CROWN = 23911;
public static final int CRYSTAL_CROWN_23913 = 23913;
public static final int CRYSTAL_CROWN_23915 = 23915;
public static final int CRYSTAL_CROWN_23917 = 23917;
public static final int CRYSTAL_CROWN_23919 = 23919;
public static final int CRYSTAL_CROWN_23921 = 23921;
public static final int CRYSTAL_CROWN_23923 = 23923;
public static final int CRYSTAL_CROWN_23925 = 23925;
public static final int CRYSTAL_OF_ITHELL = 23927;
public static final int CRYSTAL_OF_IORWERTH = 23929;
public static final int CRYSTAL_OF_TRAHAEARN = 23931;
public static final int CRYSTAL_OF_CADARN = 23933;
public static final int CRYSTAL_OF_CRWYS = 23935;
public static final int CRYSTAL_OF_MEILYR = 23937;
public static final int CRYSTAL_OF_HEFIN = 23939;
public static final int CRYSTAL_OF_AMLODD = 23941;
public static final int ELVEN_SIGNET = 23943;
public static final int ETERNAL_TELEPORT_CRYSTAL = 23946;
public static final int ELVEN_DAWN = 23948;
public static final int ENHANCED_CRYSTAL_KEY = 23951;
public static final int CRYSTAL_TOOL_SEED = 23953;
public static final int CRYSTAL_ARMOUR_SEED = 23956;
public static final int ENHANCED_CRYSTAL_TELEPORT_SEED = 23959;
public static final int CRYSTAL_SHARD = 23962;
public static final int CRYSTAL_DUST_23964 = 23964;
public static final int CRYSTAL_HELM = 23971;
public static final int CRYSTAL_HELM_INACTIVE = 23973;
public static final int CRYSTAL_BODY = 23975;
public static final int CRYSTAL_BODY_INACTIVE = 23977;
public static final int CRYSTAL_LEGS = 23979;
public static final int CRYSTAL_LEGS_INACTIVE = 23981;
public static final int CRYSTAL_BOW = 23983;
public static final int CRYSTAL_BOW_INACTIVE = 23985;
public static final int CRYSTAL_HALBERD = 23987;
public static final int CRYSTAL_HALBERD_INACTIVE = 23989;
public static final int CRYSTAL_SHIELD = 23991;
public static final int CRYSTAL_SHIELD_INACTIVE = 23993;
public static final int BLADE_OF_SAELDOR = 23995;
public static final int BLADE_OF_SAELDOR_INACTIVE = 23997;
public static final int CRYSTAL_GRAIL = 24000;
public static final int ELVEN_BOOTS = 24003;
public static final int ELVEN_GLOVES = 24006;
public static final int ELVEN_TOP = 24009;
public static final int ELVEN_SKIRT = 24012;
public static final int ELVEN_TOP_24015 = 24015;
public static final int ELVEN_SKIRT_24018 = 24018;
public static final int ELVEN_TOP_24021 = 24021;
public static final int ELVEN_LEGWEAR = 24024;
public static final int ELVEN_TOP_24027 = 24027;
public static final int MEMORIAM_CRYSTAL_1 = 24030;
public static final int MEMORIAM_CRYSTAL_2 = 24031;
public static final int MEMORIAM_CRYSTAL_3 = 24032;
public static final int MEMORIAM_CRYSTAL_4 = 24033;
public static final int DRAGONSTONE_FULL_HELM = 24034;
public static final int DRAGONSTONE_PLATEBODY = 24037;
public static final int DRAGONSTONE_PLATELEGS = 24040;
public static final int DRAGONSTONE_BOOTS = 24043;
public static final int DRAGONSTONE_GAUNTLETS = 24046;
public static final int CRAZED_SCRIBBLES = 24049;
public static final int A_DEAR_FRIEND = 24051;
public static final int ON_LEPRECHAUNS = 24053;
public static final int BLOODY_DIARY = 24055;
public static final int THE_EIGHT_CLANS = 24057;
public static final int GOLLWYNS_FINAL_STATEMENT = 24059;
public static final int NIFF__HARRY = 24061;
public static final int SOGGY_JOURNAL = 24063;
public static final int EBRILLS_JOURNAL = 24065;
public static final int STAINED_JOURNAL = 24067;
public static final int THE_TRUTH_BEHIND_THE_MYTH_EXCERPT = 24069;
public static final int THE_LIVING_STATUES = 24071;
public static final int THE_SPURNED_DEMON = 24073;
public static final int LEGENDS_OF_THE_MOUNTAIN = 24075;
public static final int CRYSTAL_BOW_24123 = 24123;
public static final int CRYSTAL_HALBERD_24125 = 24125;
public static final int CRYSTAL_SHIELD_24127 = 24127;
public static final int COMBAT_PATH_STARTER_KIT = 24130;
public static final int COMBAT_PATH_VOUCHER = 24131;
public static final int MARBLE_LECTERN = 24132;
public static final int INFERNAL_MAX_CAPE_L = 24133;
public static final int FIRE_MAX_CAPE_L = 24134;
public static final int ASSEMBLER_MAX_CAPE_L = 24135;
public static final int BRONZE_DEFENDER_L = 24136;
public static final int IRON_DEFENDER_L = 24137;
public static final int STEEL_DEFENDER_L = 24138;
public static final int BLACK_DEFENDER_L = 24139;
public static final int MITHRIL_DEFENDER_L = 24140;
public static final int ADAMANT_DEFENDER_L = 24141;
public static final int RUNE_DEFENDER_L = 24142;
public static final int DRAGON_DEFENDER_L = 24143;
public static final int STAFF_OF_BALANCE = 24144;
public static final int ARMADYL_HALO_BROKEN = 24147;
public static final int BANDOS_HALO_BROKEN = 24149;
public static final int SEREN_HALO_BROKEN = 24151;
public static final int ANCIENT_HALO_BROKEN = 24153;
public static final int BRASSICA_HALO_BROKEN = 24155;
public static final int DECORATIVE_SWORD_L = 24157;
public static final int DECORATIVE_ARMOUR_L = 24158;
public static final int DECORATIVE_ARMOUR_L_24159 = 24159;
public static final int DECORATIVE_HELM_L = 24160;
public static final int DECORATIVE_SHIELD_L = 24161;
public static final int DECORATIVE_ARMOUR_L_24162 = 24162;
public static final int DECORATIVE_ARMOUR_L_24163 = 24163;
public static final int DECORATIVE_ARMOUR_L_24164 = 24164;
public static final int DECORATIVE_ARMOUR_L_24165 = 24165;
public static final int DECORATIVE_ARMOUR_L_24166 = 24166;
public static final int DECORATIVE_ARMOUR_L_24167 = 24167;
public static final int DECORATIVE_ARMOUR_L_24168 = 24168;
public static final int SARADOMIN_HALO_L = 24169;
public static final int ZAMORAK_HALO_L = 24170;
public static final int GUTHIX_HALO_L = 24171;
public static final int HEALER_HAT_L = 24172;
public static final int FIGHTER_HAT_L = 24173;
public static final int RANGER_HAT_L = 24174;
public static final int FIGHTER_TORSO_L = 24175;
public static final int PENANCE_SKIRT_L = 24176;
public static final int VOID_KNIGHT_TOP_L = 24177;
public static final int ELITE_VOID_TOP_L = 24178;
public static final int VOID_KNIGHT_ROBE_L = 24179;
public static final int ELITE_VOID_ROBE_L = 24180;
public static final int VOID_KNIGHT_MACE_L = 24181;
public static final int VOID_KNIGHT_GLOVES_L = 24182;
public static final int VOID_MAGE_HELM_L = 24183;
public static final int VOID_RANGER_HELM_L = 24184;
public static final int VOID_MELEE_HELM_L = 24185;
public static final int AVERNIC_DEFENDER_L = 24186;
public static final int TROUVER_PARCHMENT = 24187;
public static final int DEADMANS_CHEST_24189 = 24189;
public static final int DEADMANS_LEGS_24190 = 24190;
public static final int DEADMANS_CAPE_24191 = 24191;
public static final int ARMADYL_HALO = 24192;
public static final int ARMADYL_HALO_L = 24194;
public static final int BANDOS_HALO = 24195;
public static final int BANDOS_HALO_L = 24197;
public static final int SEREN_HALO = 24198;
public static final int SEREN_HALO_L = 24200;
public static final int ANCIENT_HALO = 24201;
public static final int ANCIENT_HALO_L = 24203;
public static final int BRASSICA_HALO = 24204;
public static final int BRASSICA_HALO_L = 24206;
public static final int VICTORS_CAPE_1 = 24207;
public static final int VICTORS_CAPE_10 = 24209;
public static final int VICTORS_CAPE_50 = 24211;
public static final int VICTORS_CAPE_100 = 24213;
public static final int VICTORS_CAPE_500 = 24215;
public static final int GUTHIXIAN_ICON = 24217;
public static final int SWIFT_BLADE = 24219;
public static final int AVAS_ASSEMBLER_L = 24222;
public static final int FIRE_CAPE_L = 24223;
public static final int INFERNAL_CAPE_L = 24224;
public static final int GRANITE_MAUL_24225 = 24225;
public static final int GRANITE_MAUL_24227 = 24227;
public static final int ORNATE_MAUL_HANDLE = 24229;
public static final int IMBUED_SARADOMIN_MAX_CAPE_L = 24232;
public static final int IMBUED_ZAMORAK_MAX_CAPE_L = 24233;
public static final int IMBUED_GUTHIX_MAX_CAPE_L = 24234;
public static final int HOUSE_ADVERTISEMENT = 24235;
public static final int IMBUED_SARADOMIN_CAPE_BROKEN = 24236;
public static final int IMBUED_SARADOMIN_MAX_CAPE_BROKEN = 24238;
public static final int IMBUED_GUTHIX_CAPE_BROKEN = 24240;
public static final int IMBUED_GUTHIX_MAX_CAPE_BROKEN = 24242;
public static final int IMBUED_ZAMORAK_CAPE_BROKEN = 24244;
public static final int IMBUED_ZAMORAK_MAX_CAPE_BROKEN = 24246;
public static final int IMBUED_SARADOMIN_CAPE_L = 24248;
public static final int IMBUED_GUTHIX_CAPE_L = 24249;
public static final int IMBUED_ZAMORAK_CAPE_L = 24250;
public static final int WILDERNESS_CRABS_TELEPORT = 24251;
public static final int CLUE_SCROLL_ELITE_24253 = 24253;
public static final int FANG = 24254;
public static final int VENOM_GLAND = 24255;
public static final int UNSEALED_LETTER = 24256;
public static final int UNSEALED_LETTER_24257 = 24257;
public static final int V_SIGIL = 24258;
public static final int V_SIGIL_E = 24259;
public static final int MOLTEN_GLASS_I = 24260;
public static final int LUNAR_GLASS = 24261;
public static final int POLISHING_ROCK = 24262;
public static final int BALLAD_OF_THE_BASILISK = 24263;
public static final int VS_SHIELD = 24265;
public static final int VS_SHIELD_24266 = 24266;
public static final int BASILISK_JAW = 24268;
public static final int NEITIZNOT_FACEGUARD = 24271;
public static final int BASILISK_KNIGHT = 24276;
public static final int MYSTERIOUS_EMBLEM_TIER_1 = 24277;
public static final int MYSTERIOUS_EMBLEM_TIER_2 = 24279;
public static final int MYSTERIOUS_EMBLEM_TIER_3 = 24281;
public static final int MYSTERIOUS_EMBLEM_TIER_4 = 24283;
public static final int MYSTERIOUS_EMBLEM_TIER_5 = 24285;
public static final int DECORATIVE_EMBLEM = 24287;
public static final int DAGONHAI_HAT = 24288;
public static final int DAGONHAI_ROBE_TOP = 24291;
public static final int DAGONHAI_ROBE_BOTTOM = 24294;
public static final int WHITE_BED_SHEETS = 24297;
public static final int SMOKE_POWDER = 24298;
public static final int SHINY_GLASS = 24299;
public static final int SPOOKY_HOOD = 24300;
public static final int SPOOKY_ROBE = 24301;
public static final int SPOOKY_SKIRT = 24302;
public static final int SPOOKY_GLOVES = 24303;
public static final int SPOOKY_BOOTS = 24304;
public static final int SPOOKY_HOOD_24305 = 24305;
public static final int SPOOKY_ROBE_24307 = 24307;
public static final int SPOOKY_SKIRT_24309 = 24309;
public static final int SPOOKY_GLOVES_24311 = 24311;
public static final int SPOOKY_BOOTS_24313 = 24313;
public static final int SPOOKIER_HOOD = 24315;
public static final int SPOOKIER_ROBE = 24317;
public static final int SPOOKIER_SKIRT = 24319;
public static final int SPOOKIER_GLOVES = 24321;
public static final int SPOOKIER_BOOTS = 24323;
public static final int PUMPKIN_LANTERN = 24325;
public static final int SKELETON_LANTERN = 24327;
public static final int BOUNTY_CRATE = 24329;
public static final int BIRTHDAY_CAKE_24331 = 24331;
public static final int BIRTHDAY_CAKE_24332 = 24332;
public static final int DAGONHAI_ROBES_SET = 24333;
public static final int TARGET_TELEPORT = 24336;
public static final int BOUNTY_HUNTER_HAT_TIER_1 = 24338;
public static final int BOUNTY_HUNTER_HAT_TIER_2 = 24340;
public static final int BOUNTY_HUNTER_HAT_TIER_3 = 24342;
public static final int BOUNTY_HUNTER_HAT_TIER_4 = 24344;
public static final int BOUNTY_HUNTER_HAT_TIER_5 = 24346;
public static final int BOUNTY_HUNTER_HAT_TIER_6 = 24348;
public static final int SCROLL_BOX_BEGINNER = 24361;
public static final int SCROLL_BOX_EASY = 24362;
public static final int SCROLL_BOX_MEDIUM = 24363;
public static final int SCROLL_BOX_HARD = 24364;
public static final int SCROLL_BOX_ELITE = 24365;
public static final int SCROLL_BOX_MASTER = 24366;
public static final int CABBAGE_24367 = 24367;
public static final int TWISTED_SLAYER_HELMET = 24370;
public static final int TWISTED_DRAGON_TROPHY = 24372;
public static final int TWISTED_RUNE_TROPHY = 24374;
public static final int TWISTED_ADAMANT_TROPHY = 24376;
public static final int TWISTED_MITHRIL_TROPHY = 24378;
public static final int TWISTED_STEEL_TROPHY = 24380;
public static final int TWISTED_IRON_TROPHY = 24382;
public static final int TWISTED_BRONZE_TROPHY = 24384;
public static final int TWISTED_HAT_T3 = 24387;
public static final int TWISTED_COAT_T3 = 24389;
public static final int TWISTED_TROUSERS_T3 = 24391;
public static final int TWISTED_BOOTS_T3 = 24393;
public static final int TWISTED_CANE = 24395;
public static final int TWISTED_HAT_T2 = 24397;
public static final int TWISTED_COAT_T2 = 24399;
public static final int TWISTED_TROUSERS_T2 = 24401;
public static final int TWISTED_BOOTS_T2 = 24403;
public static final int TWISTED_HAT_T1 = 24405;
public static final int TWISTED_COAT_T1 = 24407;
public static final int TWISTED_TROUSERS_T1 = 24409;
public static final int TWISTED_BOOTS_T1 = 24411;
public static final int TWISTED_BANNER = 24413;
public static final int RUNE_POUCH_L = 24416;
public static final int INQUISITORS_MACE = 24417;
public static final int GRAVESTONE = 24418;
public static final int INQUISITORS_GREAT_HELM = 24419;
public static final int INQUISITORS_HAUBERK = 24420;
public static final int INQUISITORS_PLATESKIRT = 24421;
public static final int NIGHTMARE_STAFF = 24422;
public static final int HARMONISED_NIGHTMARE_STAFF = 24423;
public static final int VOLATILE_NIGHTMARE_STAFF = 24424;
public static final int ELDRITCH_NIGHTMARE_STAFF = 24425;
public static final int CABBAGE_24426 = 24426;
public static final int GREEN_GINGERBREAD_SHIELD = 24428;
public static final int RED_GINGERBREAD_SHIELD = 24430;
public static final int BLUE_GINGERBREAD_SHIELD = 24431;
public static final int FESTIVE_CINNAMON_STICK = 24432;
public static final int FESTIVE_GINGER_POWDER = 24433;
public static final int FESTIVE_EGG = 24434;
public static final int FESTIVE_POT = 24435;
public static final int FESTIVE_FLOUR = 24436;
public static final int GINGERBREAD_SHIELD = 24437;
public static final int ICED_GINGERBREAD_SHIELD = 24438;
public static final int ICED_GINGERBREAD_SHIELD_24439 = 24439;
public static final int ICED_GINGERBREAD_SHIELD_24440 = 24440;
public static final int SCAPERUNE_TELEPORT = 24441;
public static final int BAKERY_STORAGE_KEY = 24442;
public static final int GINGERBREAD_GNOME = 24443;
public static final int TWISTED_SLAYER_HELMET_I = 24444;
public static final int TWISTED_TELEPORT_SCROLL = 24460;
public static final int TWISTED_BLUEPRINTS = 24463;
public static final int TWISTED_HORNS = 24466;
public static final int TWISTED_RELICHUNTER_T1_ARMOUR_SET = 24469;
public static final int TWISTED_RELICHUNTER_T2_ARMOUR_SET = 24472;
public static final int TWISTED_RELICHUNTER_T3_ARMOUR_SET = 24475;
public static final int OPEN_HERB_SACK = 24478;
public static final int SPICE_RACK = 24479;
public static final int OPEN_COAL_BAG = 24480;
public static final int OPEN_GEM_BAG = 24481;
public static final int OPEN_SEED_BOX = 24482;
public static final int PHOENIX_24483 = 24483;
public static final int PHOENIX_24484 = 24484;
public static final int PHOENIX_24485 = 24485;
public static final int PHOENIX_24486 = 24486;
public static final int INQUISITORS_ARMOUR_SET = 24488;
public static final int LITTLE_NIGHTMARE = 24491;
public static final int CLUE_SCROLL_HARD_24493 = 24493;
public static final int PUZZLE_BOX_HARD_24494 = 24494;
public static final int JAR_OF_DREAMS = 24495;
public static final int HARMONISED_ORB = 24511;
public static final int VOLATILE_ORB = 24514;
public static final int ELDRITCH_ORB = 24517;
public static final int VICTORS_CAPE_1000 = 24520;
public static final int DEATHS_COFFER = 24523;
public static final int GRAVESTONE_24524 = 24524;
public static final int CAT_EARS = 24525;
public static final int HELL_CAT_EARS = 24527;
public static final int LAMP_OF_THE_GATHERER = 24528;
public static final int HARMONY = 24529;
public static final int RUNNER_HAT_BROKEN = 24531;
public static final int RUNNER_HAT_L = 24533;
public static final int MITHRIL_SEEDS_24534 = 24534;
public static final int MAGIC_EGG_BALL = 24535;
public static final int CARROT_SWORD = 24537;
public static final int _24CARAT_SWORD = 24539;
public static final int PAINTED_FAKE_MAGIC_EGG = 24541;
public static final int UNPAINTED_FAKE_MAGIC_EGG = 24542;
public static final int CONCH_SHELL = 24543;
public static final int BROKEN_EGG = 24544;
public static final int DUMMY_PORTAL = 24545;
public static final int CARROT = 24546;
public static final int BROKEN_GOAT_HORN = 24547;
public static final int CAKE_24549 = 24549;
public static final int BLADE_OF_SAELDOR_C = 24551;
public static final int BLADE_OF_SAELDOR_C_24553 = 24553;
public static final int PYROMANCER_SET = 24554;
public static final int TANGLEROOT_24555 = 24555;
public static final int TANGLEROOT_24557 = 24557;
public static final int TANGLEROOT_24559 = 24559;
public static final int TANGLEROOT_24561 = 24561;
public static final int TANGLEROOT_24563 = 24563;
public static final int ANTIQUE_EMBLEM_TIER_1 = 24565;
public static final int ANTIQUE_EMBLEM_TIER_2 = 24567;
public static final int ANTIQUE_EMBLEM_TIER_3 = 24569;
public static final int ANTIQUE_EMBLEM_TIER_4 = 24571;
public static final int ANTIQUE_EMBLEM_TIER_5 = 24573;
public static final int ANTIQUE_EMBLEM_TIER_6 = 24575;
public static final int ANTIQUE_EMBLEM_TIER_7 = 24577;
public static final int ANTIQUE_EMBLEM_TIER_8 = 24579;
public static final int ANTIQUE_EMBLEM_TIER_9 = 24581;
public static final int ANTIQUE_EMBLEM_TIER_10 = 24583;
public static final int LOOTING_BAG_NOTE = 24585;
public static final int RUNE_POUCH_NOTE = 24587;
public static final int BLIGHTED_MANTA_RAY = 24589;
public static final int BLIGHTED_ANGLERFISH = 24592;
public static final int BLIGHTED_KARAMBWAN = 24595;
public static final int BLIGHTED_SUPER_RESTORE4 = 24598;
public static final int BLIGHTED_SUPER_RESTORE3 = 24601;
public static final int BLIGHTED_SUPER_RESTORE2 = 24603;
public static final int BLIGHTED_SUPER_RESTORE1 = 24605;
public static final int BLIGHTED_ANCIENT_ICE_SACK = 24607;
public static final int BLIGHTED_BIND_SACK = 24609;
public static final int BLIGHTED_SNARE_SACK = 24611;
public static final int BLIGHTED_ENTANGLE_SACK = 24613;
public static final int BLIGHTED_TELEPORT_SPELL_SACK = 24615;
public static final int VESTAS_BLIGHTED_LONGSWORD = 24617;
public static final int VESTAS_LONGSWORD_INACTIVE = 24619;
public static final int BLIGHTED_VENGEANCE_SACK = 24621;
public static final int DIVINE_BATTLEMAGE_POTION4 = 24623;
public static final int DIVINE_BATTLEMAGE_POTION3 = 24626;
public static final int DIVINE_BATTLEMAGE_POTION2 = 24629;
public static final int DIVINE_BATTLEMAGE_POTION1 = 24632;
public static final int DIVINE_BASTION_POTION4 = 24635;
public static final int DIVINE_BASTION_POTION3 = 24638;
public static final int DIVINE_BASTION_POTION2 = 24641;
public static final int DIVINE_BASTION_POTION1 = 24644;
public static final int LOGS_24650 = 24650;
public static final int RAW_SHRIMPS_24652 = 24652;
public static final int BONES_24655 = 24655;
public static final int ENRAGED_TEKTINY = 24656;
public static final int FLYING_VESPINA = 24658;
public static final int MASSIVE_STORAGE_UNIT = 24660;
public static final int MASSIVE_STORAGE_UNIT_24661 = 24661;
public static final int MASSIVE_STORAGE_UNIT_24662 = 24662;
public static final int MASSIVE_STORAGE_UNIT_24663 = 24663;
public static final int TWISTED_ANCESTRAL_HAT = 24664;
public static final int TWISTED_ANCESTRAL_ROBE_TOP = 24666;
public static final int TWISTED_ANCESTRAL_ROBE_BOTTOM = 24668;
public static final int TWISTED_ANCESTRAL_COLOUR_KIT = 24670;
public static final int HAEMALCHEMY_VOLUME_2 = 24672;
public static final int VYRE_NOBLE_TOP_UNSCENTED = 24673;
public static final int VYRE_NOBLE_LEGS_UNSCENTED = 24674;
public static final int VYRE_NOBLE_SHOES_UNSCENTED = 24675;
public static final int VYRE_NOBLE_TOP = 24676;
public static final int VYRE_NOBLE_LEGS = 24678;
public static final int VYRE_NOBLE_SHOES = 24680;
public static final int OLD_NOTE = 24682;
public static final int TATTY_NOTE_24684 = 24684;
public static final int JOURNAL_PAGE = 24686;
public static final int ANCIENT_ARMOUR = 24688;
public static final int TOME_OF_EXPERIENCE_24690 = 24690;
public static final int BLISTERWOOD_LOGS = 24691;
public static final int RUBY_SICKLE_B = 24693;
public static final int ENCHANTED_RUBY_SICKLE_B = 24695;
public static final int BLISTERWOOD_SICKLE = 24697;
public static final int BLISTERWOOD_FLAIL = 24699;
public static final int DARK_SQUIRREL = 24701;
public static final int VYRE = 24702;
public static final int COIN_POUCH_24703 = 24703;
public static final int DAEYALT_ESSENCE = 24704;
public static final int DAEYALT_SHARD = 24706;
public static final int VAMPYRE = 24708;
public static final int HALLOWED_CRYSTAL_SHARD = 24709;
public static final int HALLOWED_MARK = 24711;
public static final int HALLOWED_TOKEN = 24719;
public static final int HALLOWED_GRAPPLE = 24721;
public static final int HALLOWED_FOCUS = 24723;
public static final int HALLOWED_SYMBOL = 24725;
public static final int HALLOWED_HAMMER = 24727;
public static final int DARK_DYE = 24729;
public static final int HALLOWED_RING = 24731;
public static final int DARK_ACORN = 24733;
public static final int RING_OF_ENDURANCE_UNCHARGED = 24735;
public static final int RING_OF_ENDURANCE = 24736;
public static final int STRANGE_OLD_LOCKPICK = 24738;
public static final int STRANGE_OLD_LOCKPICK_FULL = 24740;
public static final int GRACEFUL_HOOD_24743 = 24743;
public static final int GRACEFUL_HOOD_24745 = 24745;
public static final int GRACEFUL_CAPE_24746 = 24746;
public static final int GRACEFUL_CAPE_24748 = 24748;
public static final int GRACEFUL_TOP_24749 = 24749;
public static final int GRACEFUL_TOP_24751 = 24751;
public static final int GRACEFUL_LEGS_24752 = 24752;
public static final int GRACEFUL_LEGS_24754 = 24754;
public static final int GRACEFUL_GLOVES_24755 = 24755;
public static final int GRACEFUL_GLOVES_24757 = 24757;
public static final int GRACEFUL_BOOTS_24758 = 24758;
public static final int GRACEFUL_BOOTS_24760 = 24760;
public static final int STRANGE_HALLOWED_TOME = 24761;
public static final int MYSTERIOUS_PAGE = 24763;
public static final int MYSTERIOUS_PAGE_24765 = 24765;
public static final int MYSTERIOUS_PAGE_24767 = 24767;
public static final int MYSTERIOUS_PAGE_24769 = 24769;
public static final int MYSTERIOUS_PAGE_24771 = 24771;
public static final int CLUE_SCROLL_ELITE_24773 = 24773;
public static final int BLOOD_PINT = 24774;
public static final int BLOOD_SHARD = 24777;
public static final int AMULET_OF_BLOOD_FURY = 24780;
public static final int RAW_MYSTERY_MEAT = 24782;
public static final int COOKED_MYSTERY_MEAT = 24785;
public static final int PAT_OF_NOT_GARLIC_BUTTER = 24788;
public static final int LONG_ROPE = 24790;
public static final int SEVERED_LEG_24792 = 24792;
public static final int VYRE_NOBLE_BLAZER = 24794;
public static final int VYRE_NOBLE_COAT_TAILS = 24796;
public static final int VYRE_NOBLE_VEST = 24798;
public static final int VYRE_NOBLE_PANTS = 24800;
public static final int VYRE_NOBLE_CORSET = 24802;
public static final int VYRE_NOBLE_SKIRT = 24804;
public static final int VYRE_NOBLE_DRESS_TOP = 24806;
public static final int VYRE_NOBLE_DRESS_BOTTOM = 24808;
public static final int VYRE_NOBLE_BLAZER_24810 = 24810;
public static final int VYRE_NOBLE_COAT_TAILS_24812 = 24812;
public static final int VYRE_NOBLE_VEST_24814 = 24814;
public static final int VYRE_NOBLE_PANTS_24816 = 24816;
public static final int VYRE_NOBLE_CORSET_24818 = 24818;
public static final int VYRE_NOBLE_SKIRT_24820 = 24820;
public static final int VYRE_NOBLE_DRESS_TOP_24822 = 24822;
public static final int VYRE_NOBLE_DRESS_BOTTOM_24824 = 24824;
public static final int VYRE_NOBLE_BLAZER_24826 = 24826;
public static final int VYRE_NOBLE_COAT_TAILS_24828 = 24828;
public static final int VYRE_NOBLE_VEST_24830 = 24830;
public static final int VYRE_NOBLE_PANTS_24832 = 24832;
public static final int VYRE_NOBLE_CORSET_24834 = 24834;
public static final int VYRE_NOBLE_SKIRT_24836 = 24836;
public static final int VYRE_NOBLE_DRESS_TOP_24838 = 24838;
public static final int VYRE_NOBLE_DRESS_BOTTOM_24840 = 24840;
public static final int A_TASTE_OF_HOPE = 24842;
public static final int RING_OF_ENDURANCE_UNCHARGED_24844 = 24844;
public static final int RED = 24847;
public static final int ZIGGY = 24849;
public static final int SOFT_CLAY_PACK_24851 = 24851;
public static final int BAG_FULL_OF_GEMS_24853 = 24853;
public static final int MYTHICAL_MAX_CAPE = 24855;
public static final int MYTHICAL_MAX_HOOD = 24857;
public static final int WARRIOR_PATH_STARTER_KIT = 24859;
public static final int WIZARD_PATH_STARTER_KIT = 24860;
public static final int RANGER_PATH_STARTER_KIT = 24861;
public static final int KARAMJAN_MONKEY = 24862;
public static final int ZOMBIE_MONKEY = 24863;
public static final int MANIACAL_MONKEY = 24864;
public static final int SKELETON_MONKEY = 24865;
public static final int KRUK_JR = 24866;
public static final int PRINCELY_MONKEY = 24867;
public static final int GOLDEN_ARMADYL_SPECIAL_ATTACK = 24868;
public static final int GOLDEN_BANDOS_SPECIAL_ATTACK = 24869;
public static final int GOLDEN_SARADOMIN_SPECIAL_ATTACK = 24870;
public static final int GOLDEN_ZAMORAK_SPECIAL_ATTACK = 24871;
/* This file is automatically generated. Do not edit. */
}
|
package org.jgroups.tests;
import org.jgroups.*;
import org.jgroups.protocols.DUPL;
import org.jgroups.protocols.pbcast.NAKACK;
import org.jgroups.protocols.pbcast.STABLE;
import org.jgroups.stack.ProtocolStack;
import org.jgroups.util.Tuple;
import org.jgroups.util.Util;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
/**
* Tests whether UNICAST or NAKACK prevent delivery of duplicate messages. JGroups guarantees that a message is
* delivered once and only once. The test inserts DUPL below both UNICAST and NAKACK and makes it duplicate (1)
* unicast, (2) multicast, (3) regular and (4) OOB messages. The receiver(s) then check for the presence of duplicate
* messages.
* @author Bela Ban
* @version $Id: DuplicateTest.java,v 1.17 2010/01/19 17:05:34 belaban Exp $
*/
@Test(groups=Global.STACK_DEPENDENT,sequential=true)
public class DuplicateTest extends ChannelTestBase {
private JChannel c1, c2, c3;
protected Address a1, a2, a3;
private MyReceiver r1, r2, r3;
@BeforeMethod
void init() throws Exception {
createChannels(true, true, (short)5, (short)5);
c1.setName("C1"); c2.setName("C2"); c3.setName("C3");
a1=c1.getAddress();
a2=c2.getAddress();
a3=c3.getAddress();
r1=new MyReceiver("C1");
r2=new MyReceiver("C2");
r3=new MyReceiver("C3");
c1.setReceiver(r1);
c2.setReceiver(r2);
c3.setReceiver(r3);
}
@AfterClass
void tearDown() throws Exception {
Util.close(c3, c2, c1);
}
public void testRegularUnicastsToSelf() throws Exception {
send(c1, c1.getAddress(), false, 10);
sendStableMessages(c1,c2, c3);
check(r1, 1, false, new Tuple<Address,Integer>(a1, 10));
}
public void testOOBUnicastsToSelf() throws Exception {
send(c1, c1.getAddress(), true, 10);
sendStableMessages(c1,c2,c3);
check(r1, 1, true, new Tuple<Address,Integer>(a1, 10));
}
public void testRegularUnicastsToOthers() throws Exception {
send(c1, c2.getAddress(), false, 10);
send(c1, c3.getAddress(), false, 10);
sendStableMessages(c1,c2,c3);
check(r2, 1, false, new Tuple<Address,Integer>(a1, 10));
check(r3, 1, false, new Tuple<Address,Integer>(a1, 10));
}
@Test(invocationCount=10)
public void testOOBUnicastsToOthers() throws Exception {
send(c1, c2.getAddress(), true, 10);
send(c1, c3.getAddress(), true, 10);
sendStableMessages(c1,c2,c3);
check(r2, 1, true, new Tuple<Address,Integer>(a1, 10));
check(r3, 1, true, new Tuple<Address,Integer>(a1, 10));
}
public void testRegularMulticastToAll() throws Exception {
send(c1, null /** multicast */, false, 10);
sendStableMessages(c1,c2,c3);
check(r1, 1, false, new Tuple<Address,Integer>(a1, 10));
check(r2, 1, false, new Tuple<Address,Integer>(a1, 10));
check(r3, 1, false, new Tuple<Address,Integer>(a1, 10));
}
public void testOOBMulticastToAll() throws Exception {
send(c1, null /** multicast */, true, 10);
sendStableMessages(c1,c2,c3);
check(r1, 1, true, new Tuple<Address,Integer>(a1, 10));
check(r2, 1, true, new Tuple<Address,Integer>(a1, 10));
check(r3, 1, true, new Tuple<Address,Integer>(a1, 10));
}
public void testRegularMulticastToAll3Senders() throws Exception {
send(c1, null /** multicast */, false, 10);
send(c2, null /** multicast */, false, 10);
send(c3, null /** multicast */, false, 10);
sendStableMessages(c1,c2,c3);
check(r1, 3, false, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
check(r2, 3, false, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
check(r3, 3, false, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
}
@Test(invocationCount=5)
public void testOOBMulticastToAll3Senders() throws Exception {
send(c1, null /** multicast */, true, 10);
send(c2, null /** multicast */, true, 10);
send(c3, null /** multicast */, true, 10);
sendStableMessages(c1,c2,c3);
check(r1, 3, true, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
check(r2, 3, true, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
check(r3, 3, true, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
}
public void testMixedMulticastsToAll3Members() throws Exception {
send(c1, null /** multicast */, false, true, 10);
send(c2, null /** multicast */, false, true, 10);
send(c3, null /** multicast */, false, true, 10);
sendStableMessages(c1,c2,c3);
check(r1, 3, true, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
check(r2, 3, true, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
check(r3, 3, true, new Tuple<Address,Integer>(a1, 10), new Tuple<Address,Integer>(a2, 10), new Tuple<Address,Integer>(a3, 10));
}
private static void send(Channel sender_channel, Address dest, boolean oob, int num_msgs) throws Exception {
send(sender_channel, dest, oob, false, num_msgs);
}
private static void send(Channel sender_channel, Address dest, boolean oob, boolean mixed, int num_msgs) throws Exception {
long seqno=1;
for(int i=0; i < num_msgs; i++) {
Message msg=new Message(dest, null, seqno++);
if(mixed) {
if(i % 2 == 0)
msg.setFlag(Message.OOB);
}
else if(oob) {
msg.setFlag(Message.OOB);
}
sender_channel.send(msg);
}
}
private static void sendStableMessages(JChannel ... channels) {
for(JChannel ch: channels) {
STABLE stable=(STABLE)ch.getProtocolStack().findProtocol(STABLE.class);
if(stable != null)
stable.runMessageGarbageCollection();
}
}
private void createChannels(boolean copy_multicasts, boolean copy_unicasts, int num_outgoing_copies, int num_incoming_copies) throws Exception {
c1=createChannel(true, 3);
DUPL dupl=new DUPL(copy_multicasts, copy_unicasts, num_incoming_copies, num_outgoing_copies);
ProtocolStack stack=c1.getProtocolStack();
stack.insertProtocol(dupl, ProtocolStack.BELOW, NAKACK.class);
c2=createChannel(c1);
c3=createChannel(c1);
c1.connect("DuplicateTest");
c2.connect("DuplicateTest");
c3.connect("DuplicateTest");
assert c3.getView().size() == 3 : "view was " + c1.getView() + " but should have been 3";
}
private void check(MyReceiver receiver, int expected_size, boolean oob, Tuple<Address,Integer>... vals) {
Map<Address, Collection<Long>> msgs=receiver.getMsgs();
for(int i=0; i < 10; i++) {
if(msgs.size() == expected_size)
break;
Util.sleep(1000);
System.out.println("expected size=" + expected_size + ", actual size=" + msgs.size());
}
assert msgs.size() == expected_size : "expected size=" + expected_size + ", msgs: " + msgs.keySet();
for(Tuple<Address,Integer> tuple: vals) {
Address addr=tuple.getVal1();
Collection<Long> list=msgs.get(addr);
assert list != null : "no list available for " + addr;
int expected_values=tuple.getVal2();
for(int i=0; i < 20; i++) {
if(list.size() == expected_values)
break;
Util.sleep(1000);
sendStableMessages(c1,c2,c3);
System.out.println("expected values=" + expected_values +", actual size=" + list.size());
}
System.out.println("[" + receiver.getName() + "]: " + addr + ": " + list);
assert list.size() == expected_values : addr + "'s list's size is not " + tuple.getVal2() +
", list: " + list + " (size=" + list.size() + ")";
if(!oob) // if OOB messages, ordering is not guaranteed
check(addr, list);
else
checkPresence(list);
}
}
private static void check(Address addr, Collection<Long> list) {
long id=list.iterator().next();
for(long val: list) {
assert val == id : "[" + addr + "]: val=" + val + " (expected " + id + "): list is " + list;
id++;
}
}
private static void checkPresence(Collection<Long> list) {
for(long l=1; l <= 10; l++) {
assert list.contains(l) : l + " is not in the list " + list;
}
}
private static class MyReceiver extends ReceiverAdapter {
final String name;
private final ConcurrentMap<Address, Collection<Long>> msgs=new ConcurrentHashMap<Address,Collection<Long>>();
public MyReceiver(String name) {
this.name=name;
}
public String getName() {
return name;
}
public Map<Address, Collection<Long>> getMsgs() {
return msgs;
}
public void receive(Message msg) {
Address addr=msg.getSrc();
Long val=(Long)msg.getObject();
Collection<Long> list=msgs.get(addr);
if(list == null) {
list=new ConcurrentLinkedQueue<Long>();
Collection<Long> tmp=msgs.putIfAbsent(addr, list);
if(tmp != null)
list=tmp;
}
list.add(val);
}
public void clear() {
msgs.clear();
}
public String toString() {
StringBuilder sb=new StringBuilder();
sb.append("receiver " + name).append(":\n");
for(Map.Entry<Address,Collection<Long>> entry: msgs.entrySet()) {
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
return sb.toString();
}
}
}
|
package com.magenta.guice.jpa;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.inject.AbstractModule;
import com.google.inject.BindingAnnotation;
import com.google.inject.ConfigurationException;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Stage;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import com.google.inject.spi.Message;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@SuppressWarnings("EntityManagerInspection")
@RunWith(MockitoJUnitRunner.class)
public class DBInterceptorTest {
@Mock
private EntityManagerFactory defaultEMF;
@Mock
private EntityManagerFactory fooEMF;
@Mock
private EntityManagerFactory adjusterEMF;
@Mock
private EntityManager defaultEM;
@Mock
private EntityManager fooEM;
@Mock
private EntityManager adjusterEM;
@Mock
private EntityTransaction transaction;
@Mock
private EntityTransaction fooTransaction;
@Mock
private EntityTransaction adjusterTransaction;
private Foo foo;
private Injector injector;
@Before
public void setUp() throws Exception {
when(defaultEMF.createEntityManager()).thenReturn(defaultEM);
when(fooEMF.createEntityManager()).thenReturn(fooEM);
when(adjusterEMF.createEntityManager()).thenReturn(adjusterEM);
when(defaultEM.getTransaction()).thenReturn(transaction);
when(fooEM.getTransaction()).thenReturn(fooTransaction);
when(adjusterEM.getTransaction()).thenReturn(adjusterTransaction);
Module module = new AbstractModule() {
@Override
protected void configure() {
bind(EntityManagerFactory.class).toInstance(defaultEMF);
bind(EntityManagerFactory.class).annotatedWith(Names.named("foo")).toInstance(fooEMF);
bind(EntityManagerFactory.class).annotatedWith(AdJuster.class).toInstance(adjusterEMF);
}
};
injector = Guice.createInjector(Stage.PRODUCTION, module, new JPAModule());
foo = injector.getInstance(Foo.class);
}
@Test
public void testDefaultCall() throws Exception {
foo.defaultDB();
//verify
verify(defaultEMF).createEntityManager();
verify(adjusterEMF, never()).createEntityManager();
verify(fooEMF, never()).createEntityManager();
verify(transaction, never()).begin();
verify(transaction, never()).commit();
verify(transaction, never()).rollback();
verify(defaultEM).flush();
verify(defaultEM).close();
}
@Test
public void testDefaultTransactionalCall() throws Exception {
foo.defaultTransactionalDB();
//verify
verify(defaultEMF).createEntityManager();
verify(adjusterEMF, never()).createEntityManager();
verify(fooEMF, never()).createEntityManager();
verify(transaction).begin();
verify(transaction).commit();
verify(transaction, never()).rollback();
verify(defaultEM).flush();
verify(defaultEM).close();
}
@Test
public void testDefaultTransactionalRollbackCall() throws Exception {
try {
foo.defaultTransactionalRollbackDB();
fail("Error should not be caught");
} catch (FooException ignore) {
}
//verify
verify(defaultEMF).createEntityManager();
verify(adjusterEMF, never()).createEntityManager();
verify(fooEMF, never()).createEntityManager();
verify(transaction).begin();
verify(transaction, never()).commit();
verify(transaction).rollback();
verify(defaultEM).close();
}
@Test
public void testAnnotatedByAnnotationCall() throws Exception {
foo.fooDB();
//verify
verify(fooEMF).createEntityManager();
verify(defaultEMF, never()).createEntityManager();
verify(adjusterEMF, never()).createEntityManager();
verify(fooEM).flush();
verify(fooEM).close();
}
@Test
public void testAnnotatedByAnnotationClassCall() throws Exception {
foo.adjusterDB();
//verify
verify(adjusterEMF).createEntityManager();
verify(fooEMF, never()).createEntityManager();
verify(defaultEMF, never()).createEntityManager();
verify(adjusterEM).flush();
verify(adjusterEM).close();
}
@Test
public void testAnnotatedByAnnotationDoubleCall() throws Exception {
foo.fooDoubleDB();
//verify
verify(fooEMF, times(1)).createEntityManager();
verify(fooEM, times(1)).close();
}
@Test
public void testAnnotatedByAnnotationClassDoubleCall() throws Exception {
foo.adjusterDoubleDB();
//verify
verify(adjusterEMF, times(1)).createEntityManager();
verify(adjusterEM, times(1)).close();
}
@Test
public void testMatreshka() throws Exception {
foo.matreshka();
verify(defaultEMF, times(1)).createEntityManager();
verify(defaultEM, times(1)).flush();
verify(defaultEM, times(1)).close();
verify(fooEMF, times(1)).createEntityManager();
verify(fooEM, times(1)).flush();
verify(fooEM, times(1)).close();
verify(adjusterEMF, times(1)).createEntityManager();
verify(adjusterEM, times(1)).flush();
verify(adjusterEM, times(1)).close();
verify(adjusterTransaction).begin();
verify(adjusterTransaction).commit();
}
@Test
public void testErrorMatreshka() throws Exception {
try {
foo.errorMatreshka();
fail();
} catch (FooException ignore) {
}
verify(defaultEMF, times(1)).createEntityManager();
verify(defaultEM, times(1)).close();
verify(fooEMF, times(1)).createEntityManager();
verify(fooEM, times(1)).close();
verify(adjusterEMF, times(1)).createEntityManager();
verify(adjusterEM, times(1)).close();
verify(transaction).begin();
verify(transaction).rollback();
verify(fooTransaction).begin();
verify(fooTransaction).rollback();
verify(adjusterTransaction).begin();
verify(adjusterTransaction).rollback();
}
@Test
public void testMultiMatreshka() throws Exception {
int threadsCount = 3;
final CountDownLatch countDown = new CountDownLatch(threadsCount);
Executor executor = Executors.newFixedThreadPool(threadsCount);
for (int i = 0; i < threadsCount; i++) {
executor.execute(new Runnable() {
@Override
public void run() {
foo.matreshka();
countDown.countDown();
}
});
}
countDown.await(2, TimeUnit.SECONDS);
verify(defaultEMF, times(threadsCount)).createEntityManager();
verify(defaultEM, times(threadsCount)).flush();
verify(defaultEM, times(threadsCount)).close();
verify(fooEMF, times(threadsCount)).createEntityManager();
verify(fooEM, times(threadsCount)).flush();
verify(fooEM, times(threadsCount)).close();
verify(adjusterEMF, times(threadsCount)).createEntityManager();
verify(adjusterEM, times(threadsCount)).flush();
verify(adjusterEM, times(threadsCount)).close();
verify(adjusterTransaction, times(threadsCount)).begin();
verify(adjusterTransaction, times(threadsCount)).commit();
}
@Test
public void testWithoutDB() throws Exception {
try {
foo.withoutDB();
fail("IllegalStateException should bew here");
} catch (IllegalStateException e) {
}
}
@Test
public void testInheritance() throws Exception {
Inherited instance = injector.getInstance(Inherited.class);
instance.db();
verify(defaultEMF).createEntityManager();
verify(defaultEM).flush();
verify(defaultEM).close();
}
@Test
public void testWithInnerCall() throws Exception {
EntityTransaction entityTransaction = new EntityTransaction() {
boolean active = false;
boolean committed = false;
boolean rollbacked = false;
@Override
public void begin() {
if (active) {
throw new RuntimeException("Already began");
}
active = true;
}
@Override
public void commit() {
if (committed || !active) {
throw new RuntimeException("Already committed or wasn't active");
}
active = false;
committed = true;
}
@Override
public void rollback() {
if (rollbacked || !active) {
throw new RuntimeException("Already rollbacked or wasn't active");
}
rollbacked = true;
active = false;
}
@Override
public void setRollbackOnly() {
rollbacked = true;
}
@Override
public boolean getRollbackOnly() {
return rollbacked;
}
@Override
public boolean isActive() {
return active;
}
};
when(defaultEM.getTransaction()).thenReturn(entityTransaction);
foo.withInnerCall();
verify(defaultEMF, times(1)).createEntityManager();
verify(defaultEM, times(2)).flush();
verify(defaultEM, times(1)).close();
}
@Test
public void testWithErrorInnerCall() throws Exception {
when(transaction.isActive()).thenReturn(false, true);
foo.withErrorInnerCall();
verify(defaultEMF, times(1)).createEntityManager();
verify(defaultEM, times(1)).flush();
verify(defaultEM, times(1)).getDelegate();
verify(defaultEM, times(1)).close();
verify(transaction).setRollbackOnly();
}
@Test
public void ConstructorCall() throws Exception {
injector.getInstance(ConstructorCall.class);
verify(defaultEMF).createEntityManager();
verify(defaultEM).flush();
verify(defaultEM).close();
}
@Test
public void testNotPreparedDBInterceptor() throws Exception {
DBInterceptor interceptor = new DBInterceptor();
try {
interceptor.invoke(null);
fail("Should be unable to use unprepared interceptor.");
} catch (IllegalStateException throwable) {
} catch (Throwable throwable) {
throw new Exception(throwable);
}
}
@Test
public void testDoubleAnnotated() throws Exception {
DBInterceptor dbInterceptor = new DBInterceptor();
Method method = Bad.class.getDeclaredMethod("doubleAnnotated");
try {
dbInterceptor.getAnnotations(method);
fail("Should be IllegalStateException because this method is double annotated");
} catch (IllegalStateException e) {
}
}
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Test
public void testNotRegisteredAnnotationDiscover() throws Exception {
try {
injector.getInstance(Bad.class);
fail("Should not be create due to 2 errors!");
} catch (ConfigurationException e) {
Collection<Message> errorMessages = e.getErrorMessages();
for (Message errorMessage : errorMessages) {
assertTrue(errorMessage.getCause() instanceof IllegalStateException);
assertTrue(errorMessage.getMessage().contains("At least two binding annotations used")
|| errorMessage.getMessage().contains("Container contains @DB"));
}
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testJustInTimeWrongAnnotations() throws Exception {
Module module = new AbstractModule() {
@Override
protected void configure() {
bind(EntityManagerFactory.class).annotatedWith(Names.named("foo")).toInstance(fooEMF);
bind(EntityManagerFactory.class).annotatedWith(AdJuster.class).toInstance(adjusterEMF);
}
};
injector = Guice.createInjector(Stage.DEVELOPMENT, module, new JPAModule());
Bad instance = injector.getInstance(Bad.class);
try {
instance.doubleAnnotated();
fail("Double annotated method should not be called");
} catch (IllegalStateException ignored) {
}
try {
instance.notRegisteredAnnotation();
fail("Not registered annotation should not be served.");
} catch (IllegalStateException ignored) {
}
try {
instance.withUnexistedDefault();
fail("Not registered annotation should not be served.");
} catch (IllegalStateException ignored) {
}
}
@Test
public void testCloseIsNotClosing() throws Exception {
foo.close();
verify(defaultEM, times(1)).close();
}
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
@interface AdJuster {
}
static class Foo {
private final EntityManager em;
@Inject
Foo(EntityManager em) {
this.em = em;
}
@DB
void defaultDB() {
em.flush();
}
@DB(transaction = DB.Transaction.REQUIRED)
void defaultTransactionalDB() {
em.flush();
}
@DB(transaction = DB.Transaction.REQUIRED)
void defaultTransactionalRollbackDB() {
throw new FooException();
}
@DB
@Named("foo")
void fooDB() {
em.flush();
}
@DB(transaction = DB.Transaction.REQUIRED)
@Named("foo")
void fooDBWithError() {
throw new FooException();
}
@DB
@Named("foo")
void fooDoubleDB() {
fooDB();
}
@DB
@AdJuster
void adjusterDB() {
em.flush();
}
@DB
@AdJuster
void adjusterDoubleDB() {
adjusterDB();
}
@DB(transaction = DB.Transaction.REQUIRED)
@AdJuster
void adjusterThroughFooDB() {
em.flush();
fooDB();
}
@DB(transaction = DB.Transaction.REQUIRED)
@AdJuster
void adjusterThroughFooDBWithError() {
em.flush();
fooDBWithError();
}
@DB
void matreshka() {
em.flush();
adjusterThroughFooDB();
}
@DB(transaction = DB.Transaction.REQUIRED)
void errorMatreshka() {
adjusterThroughFooDBWithError();
}
void withoutDB() {
em.flush();
}
@DB(transaction = DB.Transaction.REQUIRED)
void withInnerCall() {
em.flush();
innerCall();
}
@DB(transaction = DB.Transaction.REQUIRED)
void withErrorInnerCall() {
em.flush();
try {
innerErrorCall();
} catch (FooException ignore) {
}
em.getDelegate();
}
@DB(transaction = DB.Transaction.REQUIRED)
void innerCall() {
em.flush();
}
@DB
void innerErrorCall() {
throw new FooException();
}
@DB
public void close() {
em.close();
}
}
static class ConstructorCall {
private final EntityManager em;
@Inject
ConstructorCall(EntityManager em) {
this.em = em;
db();
}
@DB
void db() {
em.flush();
}
}
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
@interface Wrong {
}
static class Bad {
@DB
@Named("foo")
@AdJuster
void doubleAnnotated() {
}
@DB
@Wrong
void notRegisteredAnnotation() {
}
@DB
void withUnexistedDefault() {
}
}
static class Ancestor {
private EntityManager em;
Ancestor(EntityManager em) {
this.em = em;
}
@DB
void db() {
em.flush();
}
}
static class Inherited extends Ancestor {
@Inject
Inherited(EntityManager em) {
super(em);
}
}
static class FooException extends RuntimeException {
}
}
|
package ai.h2o.automl.collectors;
import hex.tree.DHistogram;
import hex.tree.SharedTreeModel;
import jsr166y.CountedCompleter;
import water.H2O;
import water.MRTask;
import water.MemoryManager;
import water.fvec.Chunk;
import water.util.ArrayUtils;
import water.util.AtomicUtils;
import water.util.Log;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Collect metadata over a single column.
*/
public class MetaCollector {
enum COLLECT {
skew() {
@Override void op( double[] d0s, double d1 ) { d0s[0]++; }
@Override void atomic_op( double[] d0s, double[] d1s ) { d0s[0] += d1s[0]; }
@Override double postPass( double ds[], long n ) { return ds[0]; }
},
kurtosis() {
@Override void op( double[] d0s, double d1 ) { d0s[0]+=d1; }
@Override void atomic_op( double[] d0s, double[] d1s ) { d0s[0] += d1s[0]; }
@Override double postPass( double ds[], long n ) { return ds[0]/n; }
},
uniqPerChk() {
@Override void op( double[] d0s, double d1 ) { d0s[0]+=d1; }
@Override void atomic_op( double[] d0s, double[] d1s ) { d0s[0] += d1s[0]; }
@Override double postPass( double ds[], long n ) { return ds[0]; }
},
timePerChunk() {
@Override void op( double[] d0s, double d1 ) { d0s[0]+=d1*d1; }
@Override void atomic_op( double[] d0s, double[] d1s ) { d0s[0] += d1s[0]; }
@Override double postPass( double ds[], long n) { return ds[0]; }
},
mode() {
@Override void op( double[] d0s, double d1 ) { d0s[(int)d1]++; }
@Override void atomic_op( double[] d0s, double[] d1s ) { ArrayUtils.add(d0s,d1s); }
@Override double postPass( double ds[], long n ) { return ArrayUtils.maxIndex(ds); }
@Override double[] initVal(int maxx) { return new double[maxx]; }
},
;
abstract void op( double[] d0, double d1 );
abstract void atomic_op( double[] d0, double[] d1 );
abstract double postPass( double ds[], long n );
double[] initVal(int maxx) { return new double[]{0}; }
}
public static class ParallelTasks<T extends H2O.H2OCountedCompleter<T>> extends H2O.H2OCountedCompleter {
private final AtomicInteger _ctr; // Concurrency control
private static int MAXP = 100; // Max number of concurrent columns
private final T[] _tasks; // task holder (will be 1 per column)
public ParallelTasks(T[] tasks) {
_ctr = new AtomicInteger(MAXP-1);
_tasks = tasks;
}
@Override public void compute2() {
final int nTasks = _tasks.length;
addToPendingCount(nTasks-1);
for (int i=0; i < Math.min(MAXP, nTasks); ++i) asyncVecTask(i);
}
private void asyncVecTask(final int task) {
_tasks[task].setCompleter(new Callback());
_tasks[task].fork();
}
private class Callback extends H2O.H2OCallback{
public Callback(){super(ParallelTasks.this);}
@Override public void callback(H2O.H2OCountedCompleter cc) {
int i = _ctr.incrementAndGet();
if (i < _tasks.length)
asyncVecTask(i);
}
@Override
public boolean onExceptionalCompletion(Throwable ex, CountedCompleter caller) {
ex.printStackTrace();
return super.onExceptionalCompletion(ex, caller);
}
}
}
/**
* A wrapper class around DHistogram.
*
* NB: _sums and _ssqs are not the same as those found in DHistogram instances.
* The difference being that these are compounded over the column data, rather than
* over the target column.
*/
public final static class DynamicHisto extends MRTask<DynamicHisto> {
public DHistogram _h;
public double[] _sums; // different from _h._sums
public double[] _ssqs; // different from _h._ssqs
public DynamicHisto(DHistogram h) { _h=h; }
DynamicHisto(String name, final int nbins, int nbins_cats, byte isInt,
double min, double max) {
if(!(Double.isNaN(min)) && !(Double.isNaN(max))) { //If both are NaN then we don't need a histogram
_h = makeDHistogram(name, nbins, nbins_cats, isInt, min, max);
}else{
Log.info("Ignoring all NaN column -> "+ name);
}
}
private static class SharedTreeParameters extends SharedTreeModel.SharedTreeParameters {
public String algoName() { return "DUM"; }
public String fullName() { return "dummy"; }
public String javaName() { return "this.is.unused"; }
}
public static DHistogram makeDHistogram(String name, int nbins, int nbins_cats, byte isInt,
double min, double max) {
final double minIn = Math.max(min,-Double.MAX_VALUE); // inclusive vector min
final double maxIn = Math.min(max, Double.MAX_VALUE); // inclusive vector max
final double maxEx = DHistogram.find_maxEx(maxIn,isInt==1?1:0); // smallest exclusive max
SharedTreeModel.SharedTreeParameters parms = new SharedTreeParameters();
// make(String name, final int nbins, byte isInt, double min, double maxEx, long seed, SharedTreeModel.SharedTreeParameters parms, Key globalQuantilesKey) {
parms._nbins = nbins;
parms._nbins_cats = nbins_cats;
return DHistogram.make(name, nbins, isInt, minIn, maxEx, 0, parms, null);
}
public double binAt(int b) { return _h.binAt(b); }
// TODO: move into DHistogram
public double mean(int b ) {
double n = _h.w(b);
return n>0 ? _sums[b]/n : _h.binAt(b);
}
// TODO: move into DHistogram
public double var (int b) { // sample variance
double n = _h.w(b);
if( n<=1 ) return 0;
return Math.max(0, (_ssqs[b] - _sums[b]*_sums[b]/n)/(n-1));
}
protected void init() {
_h.init();
_sums = MemoryManager.malloc8d(_h._nbin);
_ssqs = MemoryManager.malloc8d(_h._nbin);
}
@Override public void setupLocal() { init(); }
@Override public void map(Chunk c) { accum(c); }
@Override public void reduce(DynamicHisto ht) {
merge(ht._h);
if( _sums!=ht._sums ) ArrayUtils.add(_sums, ht._sums);
if( _ssqs!=ht._ssqs ) ArrayUtils.add(_ssqs, ht._ssqs);
}
void accum(Chunk C) {
double min = _h.find_min();
double max = _h.find_maxIn();
double[] bins = new double[_h._nbin];
double[] sums = new double[_h._nbin];
double[] ssqs = new double[_h._nbin];
for(int r=0; r<C._len; ++r) {
double colData = C.atd(r);
if( colData < min ) min = colData;
if( colData > max ) max = colData;
int b = _h.bin(colData);
bins[b] += 1;
sums[b] += colData;
ssqs[b] += colData*colData;
}
_h.setMin(min); _h.setMaxIn(max);
for(int b=0; b<bins.length; ++b)
if( bins[b]!=0 ) {
_h.addWAtomic(b, bins[b]);
AtomicUtils.DoubleArray.add(_sums, b, sums[b]);
AtomicUtils.DoubleArray.add(_ssqs, b, ssqs[b]);
}
}
public void merge(DHistogram h) {
if( _h==h ) return;
if( _h==null ) _h=h;
else if( h!=null )
_h.add(h);
}
}
}
|
package water;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlets.ProxyServlet;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.security.Credential;
import water.network.SecurityUtils;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
public class JettyProxy extends AbstractHTTPD {
private final String _proxyTo;
private final Credentials _credentials;
public JettyProxy(H2O.BaseArgs args, Credentials credentials, String proxyTo) {
super(args);
_proxyTo = proxyTo;
_credentials = credentials;
}
@Override
protected void registerHandlers(HandlerWrapper handlerWrapper, ServletContextHandler context) {
ServletHolder proxyServlet = new ServletHolder(Transparent.class);
proxyServlet.setInitParameter("ProxyTo", _proxyTo);
proxyServlet.setInitParameter("Prefix", "/");
proxyServlet.setInitParameter("BasicAuth", _credentials.toBasicAuth());
/**
* Transparent proxy that automatically adds authentication to each request
*/
public static class Transparent extends ProxyServlet.Transparent {
private String _basicAuth;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
_basicAuth = config.getInitParameter("BasicAuth");
}
@Override
protected void customizeExchange(HttpExchange exchange, HttpServletRequest request) {
exchange.setRequestHeader("Authorization", _basicAuth);
}
}
/**
* Representation of the User-Password pair
*/
public static class Credentials {
private static final int GEN_PASSWORD_LENGTH = 16;
private final String _user;
private final String _password;
private Credentials(String _user, String _password) {
this._user = _user;
this._password = _password;
}
public String toBasicAuth() {
return "Basic " + B64Code.encode(_user + ":" + _password);
}
public String toHashFileEntry() {
return _user + ": " + Credential.MD5.digest(_password) + "\n";
}
public String toDebugString() {
return "Credentials[_user='" + _user + "', _password='" + _password + "']";
}
public static Credentials make(String user, String password) {
return new Credentials(user, password);
}
public static Credentials make(String user) {
return make(user, SecurityUtils.passwordGenerator(GEN_PASSWORD_LENGTH));
}
}
}
|
package io.github.ihongs.serv.centra;
import io.github.ihongs.combat.CombatHelper;
import io.github.ihongs.combat.anno.Combat;
import java.io.IOException;
import java.io.InputStream;
import java.io.File;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
*
* @author Hongs
*/
@Combat("resources")
public class Resources {
@Combat("list")
public static void list(String[] args)
throws IOException {
if (args.length <= 0) {
CombatHelper.println(
"Usage: resources.list " +
.currentThread ( )
/**
* jar file:/xxxx/xxxx.jar!/zzzz/zzzz
* dir /xxxx/xxxx/zzzz/zzzz
* [1]
* [2] jar file: !/
*/
switch (prot) {
case "jar" :
root = root.substring(5, root.length() - path.length() - 2);
saveResourcesInJar(dist, root, path, recu);
break;
case "file":
root = root.substring(0, root.length() - path.length() - 0);
saveResourcesInDir(dist, root, path, recu);
break;
default:
throw new IOException("Can not get resrouces in "+ link.toString());
}
}
}
private static void saveResourcesInJar(String dist, String root, String path, boolean recu)
throws IOException {
try(JarFile jfile = new JarFile(root)) {
Enumeration<JarEntry> items = jfile.entries();
path = path + "/" ;
int leng = path.length();
while ( items.hasMoreElements( )) {
JarEntry item = items.nextElement();
String name = item . getName( );
if ( name.endsWith( "/" )
|| name.endsWith(".class")) {
continue;
}
if (!name.startsWith( path )) {
continue;
}
if (!recu && name.indexOf("/", leng) > 0) {
continue;
}
if (dist != null) {
InputStream fils = jfile.getInputStream(item);
File disf = new File(dist +"/"+ name);
File dirf = disf.getParentFile();
Path disp = disf.toPath();
if (!dirf.exists()) {
dirf.mkdirs();
}
Files.copy(fils, disp, StandardCopyOption.REPLACE_EXISTING);
}
CombatHelper.paintln(name);
}
}
}
private static void saveResourcesInDir(String dist, String root, String path, boolean recu)
throws IOException {
File[] files = new File (root + path).listFiles( );
for (File file : files) {
if (! file.isDirectory()) {
String name = path + "/" + file.getName( );
if (name.endsWith(".class")) {
continue;
}
if (dist != null) {
File disf = new File(dist +"/"+ name);
File dirf = disf.getParentFile();
Path disp = disf.toPath();
Path filp = file.toPath();
if (!dirf.exists()) {
dirf.mkdirs();
}
Files.copy(filp, disp, StandardCopyOption.REPLACE_EXISTING);
}
CombatHelper.paintln(name);
} else if (recu) {
String name = path + "/" + file.getName( );
saveResourcesInDir(dist, root, name, recu);
}
}
}
}
|
package org.zstack.identity;
import org.springframework.beans.factory.annotation.Autowired;
import org.zstack.core.Platform;
import org.zstack.core.db.EntityMetadata;
import org.zstack.header.identity.AccountConstant;
import org.zstack.header.identity.SessionInventory;
import org.zstack.header.zql.ASTNode;
import org.zstack.header.zql.MarshalZQLASTTreeExtensionPoint;
import org.zstack.header.zql.RestrictByExprExtensionPoint;
import org.zstack.header.zql.ZQLExtensionContext;
import org.zstack.zql.ZQLContext;
import org.zstack.zql.ast.ZQLMetadata;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class IdentityZQLExtension implements MarshalZQLASTTreeExtensionPoint, RestrictByExprExtensionPoint {
private static final String ENTITY_NAME = "__ACCOUNT_FILTER__";
private static final String ENTITY_FIELD = "__ACCOUNT_FILTER_FIELD__";
public static final String SKIP_IDENTITY_FILTER = "__SKIP_IDENTITY_FILTER __";
@Autowired
private AccountManager acntMgr;
@Override
public void marshalZQLASTTree(ASTNode.Query node) {
SessionInventory session = ZQLContext.getAPISession();
if (session == null) {
return;
}
ASTNode.RestrictExpr expr = new ASTNode.RestrictExpr();
expr.setEntity(ENTITY_NAME);
expr.setField(ENTITY_FIELD);
node.addRestrictExpr(expr);
}
protected List<String> getRestrictAccountUuids(SessionInventory session) {
return null;
}
@Override
public String restrictByExpr(ZQLExtensionContext context, ASTNode.RestrictExpr expr) {
if (!ENTITY_NAME.equals(expr.getEntity()) || !ENTITY_FIELD.equals(expr.getField())) {
// not for us
return null;
}
Boolean skip = (Boolean) ZQLContext.getCustomizedContext(SKIP_IDENTITY_FILTER);
if (skip != null && skip) {
throw new SkipThisRestrictExprException();
}
List<String> restrictAccountUuids = getRestrictAccountUuids(context.getAPISession());
String accountUuid = context.getAPISession().getAccountUuid();
if (AccountConstant.INITIAL_SYSTEM_ADMIN_UUID.equals(accountUuid) && restrictAccountUuids == null) {
throw new SkipThisRestrictExprException();
}
if (restrictAccountUuids == null) {
restrictAccountUuids = new ArrayList<>();
}
restrictAccountUuids.add(context.getAPISession().getAccountUuid());
ZQLMetadata.InventoryMetadata src = ZQLMetadata.getInventoryMetadataByName(context.getQueryTargetInventoryName());
if (!acntMgr.isResourceHavingAccountReference(src.inventoryAnnotation.mappingVOClass())) {
throw new SkipThisRestrictExprException();
}
String primaryKey = EntityMetadata.getPrimaryKeyField(src.inventoryAnnotation.mappingVOClass()).getName();
String accountStr = restrictAccountUuids.stream()
.map(uuid -> String.format("'%s'", uuid))
.collect(Collectors.joining(","));
return String.format("(%s.%s IN (SELECT accountresourcerefvo.resourceUuid FROM AccountResourceRefVO accountresourcerefvo WHERE" +
" accountresourcerefvo.ownerAccountUuid in (%s) OR (accountresourcerefvo.resourceUuid" +
" IN (SELECT sharedresourcevo.resourceUuid FROM SharedResourceVO sharedresourcevo WHERE" +
" sharedresourcevo.receiverAccountUuid in (%s) OR sharedresourcevo.toPublic = 1))))",
src.simpleInventoryName(), primaryKey, accountStr, accountStr);
}
}
|
package de.fhg.aisec.ids.api.conm;
/**
* Bean representing an "IDSCP Connection" .
*
* @author Gerd Brost (gerd.brost@aisec.fraunhofer.de)
*
*/
public class IDSCPConnection {
private String endpointIdentifier;
private String lastProtocolState;
public IDSCPConnection() {
}
// TODO JS: Never used. Remove?
public IDSCPConnection(String endpointIdentifier, String lastProtocolState) {
this.endpointIdentifier = endpointIdentifier;
this.lastProtocolState = lastProtocolState;
}
public String getEndpointIdentifier() {
return endpointIdentifier;
}
public void setEndpointIdentifier(String endpointIdentifier) {
this.endpointIdentifier = endpointIdentifier;
}
public String getAttestationResult() {
return lastProtocolState;
}
public void setAttestationResult(String lastProtocolState) {
this.lastProtocolState = lastProtocolState;
}
@Override
public String toString() {
return "IDSCPConnection [endpoint_identifier=" + endpointIdentifier + ", lastProtocolState=" + lastProtocolState + "]";
}
}
|
package mondrian.test;
import mondrian.olap.*;
import mondrian.resource.MondrianResource;
import mondrian.rolap.*;
import mondrian.spi.Dialect;
import java.sql.*;
import javax.sql.DataSource;
/**
* Test generation of SQL to access the fact table data underlying an MDX
* result set.
*
* @author jhyde
* @since May 10, 2006
*/
public class DrillThroughTest extends FoodMartTestCase {
public DrillThroughTest() {
super();
}
public DrillThroughTest(String name) {
super(name);
}
public void testTrivialCalcMemberDrillThrough() {
Result result = executeQuery(
"WITH MEMBER [Measures].[Formatted Unit Sales]"
+ " AS '[Measures].[Unit Sales]', FORMAT_STRING='$
+ "MEMBER [Measures].[Twice Unit Sales]"
+ " AS '[Measures].[Unit Sales] * 2'\n"
+ "MEMBER [Measures].[Twice Unit Sales Plus Store Sales] "
+ " AS '[Measures].[Twice Unit Sales] + [Measures].[Store Sales]',"
+ " FOMRAT_STRING='
+ "MEMBER [Measures].[Foo] "
+ " AS '[Measures].[Unit Sales] + ([Measures].[Unit Sales], [Time].[Time].PrevMember)'\n"
+ "MEMBER [Measures].[Unit Sales Percentage] "
+ " AS '[Measures].[Unit Sales] / [Measures].[Twice Unit Sales]'\n"
+ "SELECT {[Measures].[Unit Sales],\n"
+ " [Measures].[Formatted Unit Sales],\n"
+ " [Measures].[Twice Unit Sales],\n"
+ " [Measures].[Twice Unit Sales Plus Store Sales],\n"
+ " [Measures].[Foo],\n"
+ " [Measures].[Unit Sales Percentage]} on columns,\n"
+ " {[Product].Children} on rows\n"
+ "from Sales");
// can drill through [Formatted Unit Sales]
final Cell cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
// can drill through [Unit Sales]
assertTrue(result.getCell(new int[]{1, 0}).canDrillThrough());
// can drill through [Twice Unit Sales]
assertTrue(result.getCell(new int[]{2, 0}).canDrillThrough());
// can drill through [Twice Unit Sales Plus Store Sales]
assertTrue(result.getCell(new int[]{3, 0}).canDrillThrough());
// can not drill through [Foo]
assertFalse(result.getCell(new int[]{4, 0}).canDrillThrough());
// can drill through [Unit Sales Percentage]
assertTrue(result.getCell(new int[]{5, 0}).canDrillThrough());
assertNotNull(
result.getCell(
new int[]{
5, 0
}).getDrillThroughSQL(false));
String sql = cell.getDrillThroughSQL(false);
String expectedSql =
"select `time_by_day`.`the_year` as `Year`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `time_by_day` =as= `time_by_day`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product` "
+ "where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`product_id` = `product`.`product_id`"
+ " and `product`.`product_class_id` = `product_class`.`product_class_id`"
+ " and `product_class`.`product_family` = 'Drink' "
+ "order by `time_by_day`.`the_year` ASC,"
+ " `product_class`.`product_family` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 7978);
// Can drill through a trivial calc member.
final Cell calcCell = result.getCell(new int[]{1, 0});
assertTrue(calcCell.canDrillThrough());
sql = calcCell.getDrillThroughSQL(false);
assertNotNull(sql);
expectedSql =
"select `time_by_day`.`the_year` as `Year`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `time_by_day` =as= `time_by_day`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product` "
+ "where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`product_id` = `product`.`product_id`"
+ " and `product`.`product_class_id` = `product_class`.`product_class_id`"
+ " and `product_class`.`product_family` = 'Drink' "
+ "order by `time_by_day`.`the_year` ASC,"
+ " `product_class`.`product_family` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 7978);
assertEquals(calcCell.getDrillThroughCount(), 7978);
}
public void testTrivialCalcMemberNotMeasure() {
// [Product].[My Food] is trivial because it maps to a single member.
// First, on ROWS axis.
Result result = executeQuery(
"with member [Product].[My Food]\n"
+ " AS [Product].[Food], FORMAT_STRING = '
+ "SELECT [Measures].[Unit Sales] * [Gender].[M] on 0,\n"
+ " [Marital Status].[S] * [Product].[My Food] on 1\n"
+ "from [Sales]");
Cell cell = result.getCell(new int[] {0, 0});
assertTrue(cell.canDrillThrough());
assertEquals(16129, cell.getDrillThroughCount());
// Next, on filter axis.
result = executeQuery(
"with member [Product].[My Food]\n"
+ " AS [Product].[Food], FORMAT_STRING = '
+ "SELECT [Measures].[Unit Sales] * [Gender].[M] on 0,\n"
+ " [Marital Status].[S] on 1\n"
+ "from [Sales]\n"
+ "where [Product].[My Food]");
cell = result.getCell(new int[] {0, 0});
assertTrue(cell.canDrillThrough());
assertEquals(16129, cell.getDrillThroughCount());
// Trivial member with Aggregate.
result = executeQuery(
"with member [Product].[My Food]\n"
+ " AS Aggregate({[Product].[Food]}), FORMAT_STRING = '
+ "SELECT [Measures].[Unit Sales] * [Gender].[M] on 0,\n"
+ " [Marital Status].[S] * [Product].[My Food] on 1\n"
+ "from [Sales]");
cell = result.getCell(new int[] {0, 0});
assertTrue(cell.canDrillThrough());
assertEquals(16129, cell.getDrillThroughCount());
// Non-trivial member on rows.
result = executeQuery(
"with member [Product].[My Food Drink]\n"
+ " AS Aggregate({[Product].[Food], [Product].[Drink]}),\n"
+ " FORMAT_STRING = '
+ "SELECT [Measures].[Unit Sales] * [Gender].[M] on 0,\n"
+ " [Marital Status].[S] * [Product].[My Food Drink] on 1\n"
+ "from [Sales]");
cell = result.getCell(new int[] {0, 0});
assertFalse(cell.canDrillThrough());
// drop the constraint when we drill through
assertEquals(22479, cell.getDrillThroughCount());
// Non-trivial member on filter axis.
result = executeQuery(
"with member [Product].[My Food Drink]\n"
+ " AS Aggregate({[Product].[Food], [Product].[Drink]}),\n"
+ " FORMAT_STRING = '
+ "SELECT [Measures].[Unit Sales] * [Gender].[M] on 0,\n"
+ " [Marital Status].[S] on 1\n"
+ "from [Sales]\n"
+ "where [Product].[My Food Drink]");
cell = result.getCell(new int[] {0, 0});
assertFalse(cell.canDrillThrough());
}
public void testDrillThrough() {
Result result = executeQuery(
"WITH MEMBER [Measures].[Price] AS '[Measures].[Store Sales] / ([Measures].[Store Sales], [Time].[Time].PrevMember)'\n"
+ "SELECT {[Measures].[Unit Sales], [Measures].[Price]} on columns,\n"
+ " {[Product].Children} on rows\n"
+ "from Sales");
final Cell cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
String sql = cell.getDrillThroughSQL(false);
String expectedSql =
"select `time_by_day`.`the_year` as `Year`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `time_by_day` =as= `time_by_day`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product` "
+ "where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`product_id` = `product`.`product_id`"
+ " and `product`.`product_class_id` = `product_class`.`product_class_id`"
+ " and `product_class`.`product_family` = 'Drink' "
+ "order by `time_by_day`.`the_year` ASC,"
+ " `product_class`.`product_family` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 7978);
// Cannot drill through a calc member.
final Cell calcCell = result.getCell(new int[]{1, 1});
assertFalse(calcCell.canDrillThrough());
sql = calcCell.getDrillThroughSQL(false);
assertNull(sql);
}
private String getNameExp(
Result result,
String hierName,
String levelName)
{
final Cube cube = result.getQuery().getCube();
RolapStar star = ((RolapCube) cube).getStar();
Hierarchy h =
cube.lookupHierarchy(
new Id.NameSegment(hierName, Id.Quoting.UNQUOTED), false);
if (h == null) {
return null;
}
for (Level l : h.getLevels()) {
if (l.getName().equals(levelName)) {
MondrianDef.Expression exp = ((RolapLevel) l).getNameExp();
String nameExpStr = exp.getExpression(star.getSqlQuery());
nameExpStr = nameExpStr.replace('"', '`') ;
return nameExpStr;
}
}
return null;
}
public void testDrillThrough2() {
Result result = executeQuery(
"WITH MEMBER [Measures].[Price] AS '[Measures].[Store Sales] / ([Measures].[Unit Sales], [Time].[Time].PrevMember)'\n"
+ "SELECT {[Measures].[Unit Sales], [Measures].[Price]} on columns,\n"
+ " {[Product].Children} on rows\n"
+ "from Sales");
String sql = result.getCell(new int[]{0, 0}).getDrillThroughSQL(true);
String nameExpStr = getNameExp(result, "Customers", "Name");
String expectedSql =
"select `store`.`store_country` as `Store Country`,"
+ " `store`.`store_state` as `Store State`,"
+ " `store`.`store_city` as `Store City`,"
+ " `store`.`store_name` as `Store Name`,"
+ " `store`.`store_sqft` as `Store Sqft`,"
+ " `store`.`store_type` as `Store Type`,"
+ " `time_by_day`.`the_year` as `Year`,"
+ " `time_by_day`.`quarter` as `Quarter`,"
+ " `time_by_day`.`month_of_year` as `Month`,"
+ " `time_by_day`.`week_of_year` as `Week`,"
+ " `time_by_day`.`day_of_month` as `Day`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `product_class`.`product_department` as `Product Department`,"
+ " `product_class`.`product_category` as `Product Category`,"
+ " `product_class`.`product_subcategory` as `Product Subcategory`,"
+ " `product`.`brand_name` as `Brand Name`,"
+ " `product`.`product_name` as `Product Name`,"
+ " `promotion`.`media_type` as `Media Type`,"
+ " `promotion`.`promotion_name` as `Promotion Name`,"
+ " `customer`.`country` as `Country`,"
+ " `customer`.`state_province` as `State Province`,"
+ " `customer`.`city` as `City`, "
+ nameExpStr
+ " as `Name`,"
+ " `customer`.`customer_id` as `Name (Key)`,"
+ " `customer`.`education` as `Education Level`,"
+ " `customer`.`gender` as `Gender`,"
+ " `customer`.`marital_status` as `Marital Status`,"
+ " `customer`.`yearly_income` as `Yearly Income`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `store` =as= `store`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `time_by_day` =as= `time_by_day`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product`,"
+ " `promotion` =as= `promotion`,"
+ " `customer` =as= `customer` "
+ "where `sales_fact_1997`.`store_id` = `store`.`store_id`"
+ " and `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`product_id` = `product`.`product_id`"
+ " and `product`.`product_class_id` = `product_class`.`product_class_id`"
+ " and `product_class`.`product_family` = 'Drink'"
+ " and `sales_fact_1997`.`promotion_id` = `promotion`.`promotion_id`"
+ " and `sales_fact_1997`.`customer_id` = `customer`.`customer_id` "
+ "order by `store`.`store_country` ASC,"
+ " `store`.`store_state` ASC,"
+ " `store`.`store_city` ASC,"
+ " `store`.`store_name` ASC,"
+ " `store`.`store_sqft` ASC,"
+ " `store`.`store_type` ASC,"
+ " `time_by_day`.`the_year` ASC,"
+ " `time_by_day`.`quarter` ASC,"
+ " `time_by_day`.`month_of_year` ASC,"
+ " `time_by_day`.`week_of_year` ASC,"
+ " `time_by_day`.`day_of_month` ASC,"
+ " `product_class`.`product_family` ASC,"
+ " `product_class`.`product_department` ASC,"
+ " `product_class`.`product_category` ASC,"
+ " `product_class`.`product_subcategory` ASC,"
+ " `product`.`brand_name` ASC,"
+ " `product`.`product_name` ASC,"
+ " `promotion`.`media_type` ASC,"
+ " `promotion`.`promotion_name` ASC,"
+ " `customer`.`country` ASC,"
+ " `customer`.`state_province` ASC,"
+ " `customer`.`city` ASC, "
+ nameExpStr
+ " ASC,"
+ " `customer`.`customer_id` ASC,"
+ " `customer`.`education` ASC,"
+ " `customer`.`gender` ASC,"
+ " `customer`.`marital_status` ASC,"
+ " `customer`.`yearly_income` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 7978);
// Drillthrough SQL is null for cell based on calc member
sql = result.getCell(new int[]{1, 1}).getDrillThroughSQL(true);
assertNull(sql);
}
public void testDrillThrough3() {
Result result = executeQuery(
"select {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} ON COLUMNS, \n"
+ "Hierarchize(Union(Union(Crossjoin({[Promotion Media].[All Media]}, {[Product].[All Products]}), \n"
+ "Crossjoin({[Promotion Media].[All Media]}, [Product].[All Products].Children)), Crossjoin({[Promotion Media].[All Media]}, [Product].[All Products].[Drink].Children))) ON ROWS \n"
+ "from [Sales] where [Time].[1997].[Q4].[12]");
// [Promotion Media].[All Media], [Product].[All
// Products].[Drink].[Dairy], [Measures].[Store Cost]
Cell cell = result.getCell(new int[]{0, 4});
String sql = cell.getDrillThroughSQL(true);
String nameExpStr = getNameExp(result, "Customers", "Name");
String expectedSql =
"select"
+ " `store`.`store_country` as `Store Country`,"
+ " `store`.`store_state` as `Store State`,"
+ " `store`.`store_city` as `Store City`,"
+ " `store`.`store_name` as `Store Name`,"
+ " `store`.`store_sqft` as `Store Sqft`,"
+ " `store`.`store_type` as `Store Type`,"
+ " `time_by_day`.`the_year` as `Year`,"
+ " `time_by_day`.`quarter` as `Quarter`,"
+ " `time_by_day`.`month_of_year` as `Month`,"
+ " `time_by_day`.`week_of_year` as `Week`,"
+ " `time_by_day`.`day_of_month` as `Day`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `product_class`.`product_department` as `Product Department`,"
+ " `product_class`.`product_category` as `Product Category`,"
+ " `product_class`.`product_subcategory` as `Product Subcategory`,"
+ " `product`.`brand_name` as `Brand Name`,"
+ " `product`.`product_name` as `Product Name`,"
+ " `promotion`.`media_type` as `Media Type`,"
+ " `promotion`.`promotion_name` as `Promotion Name`,"
+ " `customer`.`country` as `Country`,"
+ " `customer`.`state_province` as `State Province`,"
+ " `customer`.`city` as `City`,"
+ " " + nameExpStr + " as `Name`,"
+ " `customer`.`customer_id` as `Name (Key)`,"
+ " `customer`.`education` as `Education Level`,"
+ " `customer`.`gender` as `Gender`,"
+ " `customer`.`marital_status` as `Marital Status`,"
+ " `customer`.`yearly_income` as `Yearly Income`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `store =as= `store`, "
+ "`sales_fact_1997` =as= `sales_fact_1997`, "
+ "`time_by_day` =as= `time_by_day`, "
+ "`product_class` =as= `product_class`, "
+ "`product` =as= `product`, "
+ "`promotion` =as= `promotion`, "
+ "`customer` =as= `customer` "
+ "where `sales_fact_1997`.`store_id` = `store`.`store_id` and "
+ "`sales_fact_1997`.`time_id` = `time_by_day`.`time_id` and "
+ "`time_by_day`.`the_year` = 1997 and "
+ "`time_by_day`.`quarter` = 'Q4' and "
+ "`time_by_day`.`month_of_year` = 12 and "
+ "`sales_fact_1997`.`product_id` = `product`.`product_id` and "
+ "`product`.`product_class_id` = `product_class`.`product_class_id` and "
+ "`product_class`.`product_family` = 'Drink' and "
+ "`product_class`.`product_department` = 'Dairy' and "
+ "`sales_fact_1997`.`promotion_id` = `promotion`.`promotion_id` and "
+ "`sales_fact_1997`.`customer_id` = `customer`.`customer_id` "
+ "order by `store`.`store_country` ASC,"
+ " `store`.`store_state` ASC,"
+ " `store`.`store_city` ASC,"
+ " `store`.`store_name` ASC,"
+ " `store`.`store_sqft` ASC,"
+ " `store`.`store_type` ASC,"
+ " `time_by_day`.`the_year` ASC,"
+ " `time_by_day`.`quarter` ASC,"
+ " `time_by_day`.`month_of_year` ASC,"
+ " `time_by_day`.`week_of_year` ASC,"
+ " `time_by_day`.`day_of_month` ASC,"
+ " `product_class`.`product_family` ASC,"
+ " `product_class`.`product_department` ASC,"
+ " `product_class`.`product_category` ASC,"
+ " `product_class`.`product_subcategory` ASC,"
+ " `product`.`brand_name` ASC,"
+ " `product`.`product_name` ASC,"
+ " `promotion.media_type` ASC,"
+ " `promotion`.`promotion_name` ASC,"
+ " `customer`.`country` ASC,"
+ " `customer`.`state_province` ASC,"
+ " `customer`.`city` ASC,"
+ " " + nameExpStr + " ASC,"
+ " `customer`.`customer_id` ASC,"
+ " `customer`.`education` ASC,"
+ " `customer`.gender` ASC,"
+ " `customer`.`marital_status` ASC,"
+ " `customer`.`yearly_income` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 141);
}
public void testDrillThroughBugMondrian180() {
Result result = executeQuery(
"with set [Date Range] as '{[Time].[1997].[Q1], [Time].[1997].[Q2]}'\n"
+ "member [Time].[Time].[Date Range] as 'Aggregate([Date Range])'\n"
+ "select {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ "Hierarchize(Union(Union(Union({[Store].[All Stores]}, [Store].[All Stores].Children), [Store].[All Stores].[USA].Children), [Store].[All Stores].[USA].[CA].Children)) ON ROWS\n"
+ "from [Sales]\n"
+ "where [Time].[Date Range]");
final Cell cell = result.getCell(new int[]{0, 6});
// It is not valid to drill through this cell, because it contains a
// non-trivial calculated member.
assertFalse(cell.canDrillThrough());
// For backwards compatibility, generate drill-through SQL (ignoring
// calculated members) even though we said we could not drill through.
String sql = cell.getDrillThroughSQL(true);
String nameExpStr = getNameExp(result, "Customers", "Name");
final String expectedSql =
"select"
+ " `store`.`store_state` as `Store State`,"
+ " `store`.`store_city` as `Store City`,"
+ " `store`.`store_name` as `Store Name`,"
+ " `store`.`store_sqft` as `Store Sqft`,"
+ " `store`.`store_type` as `Store Type`,"
+ " `time_by_day`.`the_year` as `Year`,"
+ " `time_by_day`.`quarter` as `Quarter`,"
+ " `time_by_day`.`month_of_year` as `Month`,"
+ " `time_by_day`.`week_of_year` as `Week`,"
+ " `time_by_day`.`day_of_month` as `Day`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `product_class`.`product_department` as `Product Department`,"
+ " `product_class`.`product_category` as `Product Category`,"
+ " `product_class`.`product_subcategory` as `Product Subcategory`,"
+ " `product`.`brand_name` as `Brand Name`,"
+ " `product`.`product_name` as `Product Name`,"
+ " `promotion`.`media_type` as `Media Type`,"
+ " `promotion`.`promotion_name` as `Promotion Name`,"
+ " `customer`.`country` as `Country`,"
+ " `customer`.`state_province` as `State Province`,"
+ " `customer`.`city` as `City`, "
+ nameExpStr
+ " as `Name`,"
+ " `customer`.`customer_id` as `Name (Key)`,"
+ " `customer`.`education` as `Education Level`,"
+ " `customer`.`gender` as `Gender`,"
+ " `customer`.`marital_status` as `Marital Status`,"
+ " `customer`.`yearly_income` as `Yearly Income`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `store` =as= `store`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `time_by_day` =as= `time_by_day`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product`,"
+ " `promotion` =as= `promotion`,"
+ " `customer` =as= `customer` "
+ "where `sales_fact_1997`.`store_id` = `store`.`store_id` and"
+ " `store`.`store_state` = 'CA' and"
+ " `store`.`store_city` = 'Beverly Hills' and"
+ " `sales_fact_1997`.time_id` = `time_by_day`.`time_id` and"
+ " `sales_fact_1997`.`product_id` = `product`.`product_id` and"
+ " `product`.`product_class_id` = `product_class`.`product_class_id` and"
+ " `sales_fact_1997`.`promotion_id` = `promotion`.`promotion_id` and"
+ " `sales_fact_1997`.`customer_id` = `customer`.`customer_id`"
+ " order by"
+ " `store`.`store_state` ASC,"
+ " `store`.`store_city` ASC,"
+ " `store`.`store_name` ASC,"
+ " `store`.`store_sqft` ASC,"
+ " `store`.`store_type` ASC,"
+ " `time_by_day`.`the_year` ASC,"
+ " `time_by_day`.`quarter` ASC,"
+ " `time_by_day`.`month_of_year` ASC,"
+ " `time_by_day`.`week_of_year` ASC,"
+ " `time_by_day`.`day_of_month` ASC,"
+ " `product_class`.`product_family` ASC,"
+ " `product_class`.`product_department` ASC,"
+ " `product_class`.`product_category` ASC,"
+ " `product_class`.`product_subcategory` ASC,"
+ " `product`.`brand_name` ASC,"
+ " `product`.`product_name` ASC,"
+ " `promotion`.`media_type` ASC,"
+ " `promotion`.`promotion_name` ASC,"
+ " `customer`.`country` ASC,"
+ " `customer`.`state_province` ASC,"
+ " `customer`.`city` ASC, "
+ nameExpStr
+ " ASC,"
+ " `customer`.`customer_id` ASC,"
+ " `customer`.`education` ASC,"
+ " `customer`.`gender` ASC,"
+ " `customer`.`marital_status` ASC,"
+ " `customer`.`yearly_income` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 6815);
}
/**
* Tests that proper SQL is being generated for a Measure specified
* as an expression.
*/
public void testDrillThroughMeasureExp() {
Result result = executeQuery(
"SELECT {[Measures].[Promotion Sales]} on columns,\n"
+ " {[Product].Children} on rows\n"
+ "from Sales");
String sql = result.getCell(new int[] {0, 0}).getDrillThroughSQL(false);
String expectedSql =
"select"
+ " `time_by_day`.`the_year` as `Year`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " (case when `sales_fact_1997`.`promotion_id` = 0 then 0"
+ " else `sales_fact_1997`.`store_sales` end)"
+ " as `Promotion Sales` "
+ "from `time_by_day` =as= `time_by_day`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product` "
+ "where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`product_id` = `product`.`product_id`"
+ " and `product`.`product_class_id` = `product_class`.`product_class_id`"
+ " and `product_class`.`product_family` = 'Drink' "
+ "order by `time_by_day`.`the_year` ASC, `product_class`.`product_family` ASC";
final Cube cube = result.getQuery().getCube();
RolapStar star = ((RolapCube) cube).getStar();
// Adjust expected SQL for dialect differences in FoodMart.xml.
Dialect dialect = star.getSqlQueryDialect();
final String caseStmt =
" \\(case when `sales_fact_1997`.`promotion_id` = 0 then 0"
+ " else `sales_fact_1997`.`store_sales` end\\)";
switch (dialect.getDatabaseProduct()) {
case ACCESS:
expectedSql = expectedSql.replaceAll(
caseStmt,
" Iif(`sales_fact_1997`.`promotion_id` = 0, 0,"
+ " `sales_fact_1997`.`store_sales`)");
break;
case INFOBRIGHT:
expectedSql = expectedSql.replaceAll(
caseStmt, " `sales_fact_1997`.`store_sales`");
break;
}
getTestContext().assertSqlEquals(expectedSql, sql, 7978);
}
/**
* Tests that drill-through works if two dimension tables have primary key
* columns with the same name. Related to bug 1592556, "XMLA Drill through
* bug".
*/
public void testDrillThroughDupKeys() {
// Note here that the type on the Store Id level is Integer or
// Numeric. The default, of course, would be String.
// For DB2 and Derby, we need the Integer type, otherwise the
// generated SQL will be something like:
// `store_ragged`.`store_id` = '19'
// and DB2 and Derby don't like converting from CHAR to INTEGER
TestContext testContext = TestContext.instance().createSubstitutingCube(
"Sales",
" <Dimension name=\"Store2\" foreignKey=\"store_id\">\n"
+ " <Hierarchy hasAll=\"true\" primaryKey=\"store_id\">\n"
+ " <Table name=\"store_ragged\"/>\n"
+ " <Level name=\"Store Country\" column=\"store_country\" uniqueMembers=\"true\"/>\n"
+ " <Level name=\"Store Id\" column=\"store_id\" captionColumn=\"store_name\" uniqueMembers=\"true\" type=\"Integer\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n"
+ " <Dimension name=\"Store3\" foreignKey=\"store_id\">\n"
+ " <Hierarchy hasAll=\"true\" primaryKey=\"store_id\">\n"
+ " <Table name=\"store\"/>\n"
+ " <Level name=\"Store Country\" column=\"store_country\" uniqueMembers=\"true\"/>\n"
+ " <Level name=\"Store Id\" column=\"store_id\" captionColumn=\"store_name\" uniqueMembers=\"true\" type=\"Numeric\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n");
Result result = testContext.executeQuery(
"SELECT {[Store2].[Store Id].Members} on columns,\n"
+ " NON EMPTY([Store3].[Store Id].Members) on rows\n"
+ "from Sales");
String sql = result.getCell(new int[] {0, 0}).getDrillThroughSQL(false);
String expectedSql =
"select `time_by_day`.`the_year` as `Year`,"
+ " `store_ragged`.`store_id` as `Store Id`,"
+ " `store`.`store_id` as `Store Id_0`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales` "
+ "from `time_by_day` =as= `time_by_day`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `store_ragged` =as= `store_ragged`,"
+ " `store` =as= `store` "
+ "where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`store_id` = `store_ragged`.`store_id`"
+ " and `store_ragged`.`store_id` = 19"
+ " and `sales_fact_1997`.`store_id` = `store`.`store_id`"
+ " and `store`.`store_id` = 2 "
+ "order by `time_by_day`.`the_year` ASC, `store_ragged`.`store_id` ASC, `store`.`store_id` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 0);
}
/**
* Tests that cells in a virtual cube say they can be drilled through.
*/
public void testDrillThroughVirtualCube() {
Result result = executeQuery(
"select Crossjoin([Customers].[All Customers].[USA].[OR].Children, {[Measures].[Unit Sales]}) ON COLUMNS, "
+ " [Gender].[All Gender].Children ON ROWS"
+ " from [Warehouse and Sales]"
+ " where [Time].[1997].[Q4].[12]");
String sql = result.getCell(new int[]{0, 0}).getDrillThroughSQL(false);
String expectedSql =
"select `time_by_day`.`the_year` as `Year`,"
+ " `time_by_day`.`quarter` as `Quarter`,"
+ " `time_by_day`.month_of_year` as `Month`,"
+ " `customer`.`state_province` as `State Province`,"
+ " `customer`.`city` as `City`,"
+ " `customer`.`gender` as `Gender`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales`"
+ " from `time_by_day` =as= `time_by_day`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `customer` =as= `customer`"
+ " where `sales_fact_1997`.`time_id` = `time_by_day`.`time_id` and"
+ " `time_by_day`.`the_year` = 1997 and"
+ " `time_by_day`.`quarter` = 'Q4' and"
+ " `time_by_day`.`month_of_year` = 12 and"
+ " `sales_fact_1997`.`customer_id` = `customer`.customer_id` and"
+ " `customer`.`state_province` = 'OR' and"
+ " `customer`.`city` = 'Albany' and"
+ " `customer`.`gender` = 'F'"
+ " order by `time_by_day`.`the_year` ASC,"
+ " `time_by_day`.`quarter` ASC,"
+ " `time_by_day`.`month_of_year` ASC,"
+ " `customer`.`state_province` ASC,"
+ " `customer`.`city` ASC,"
+ " `customer`.`gender` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 73);
}
/**
* This tests for bug 1438285, "nameColumn cannot be column in level
* definition".
*/
public void testBug1438285() {
final Dialect dialect = getTestContext().getDialect();
if (dialect.getDatabaseProduct() == Dialect.DatabaseProduct.TERADATA) {
// On default Teradata express instance there isn't enough spool
// space to run this query.
return;
}
// Specify the column and nameColumn to be the same
// in order to reproduce the problem
final TestContext testContext =
TestContext.instance().createSubstitutingCube(
"Sales",
" <Dimension name=\"Store2\" foreignKey=\"store_id\">\n"
+ " <Hierarchy hasAll=\"true\" allMemberName=\"All Stores\" >\n"
+ " <Table name=\"store_ragged\"/>\n"
+ " <Level name=\"Store Id\" column=\"store_id\" nameColumn=\"store_id\" ordinalColumn=\"region_id\" uniqueMembers=\"true\">\n"
+ " </Level>"
+ " </Hierarchy>\n"
+ " </Dimension>\n");
Result result = testContext.executeQuery(
"SELECT {[Measures].[Unit Sales]} on columns, "
+ "{[Store2].members} on rows FROM [Sales]");
// Prior to fix the request for the drill through SQL would result in
// an assertion error
String sql = result.getCell(new int[] {0, 0}).getDrillThroughSQL(true);
String nameExpStr = getNameExp(result, "Customers", "Name");
String expectedSql =
"select "
+ "`store`.`store_country` as `Store Country`,"
+ " `store`.`store_state` as `Store State`,"
+ " `store`.`store_city` as `Store City`,"
+ " `store`.`store_name` as `Store Name`,"
+ " `store`.`store_sqft` as `Store Sqft`,"
+ " `store`.`store_type` as `Store Type`,"
+ " `time_by_day`.`the_year` as `Year`,"
+ " `time_by_day`.`quarter` as `Quarter`,"
+ " `time_by_day`.`month_of_year` as `Month`,"
+ " `time_by_day`.`week_of_year` as `Week`,"
+ " `time_by_day`.`day_of_month` as `Day`,"
+ " `product_class`.`product_family` as `Product Family`,"
+ " `product_class`.`product_department` as `Product Department`,"
+ " `product_class`.`product_category` as `Product Category`,"
+ " `product_class`.`product_subcategory` as `Product Subcategory`,"
+ " `product`.`brand_name` as `Brand Name`,"
+ " `product`.`product_name` as `Product Name`,"
+ " `store_ragged`.`store_id` as `Store Id`,"
+ " `store_ragged`.`store_id` as `Store Id (Key)`,"
+ " `promotion`.`media_type` as `Media Type`,"
+ " `promotion`.`promotion_name` as `Promotion Name`,"
+ " `customer`.`country` as `Country`,"
+ " `customer`.`state_province` as `State Province`,"
+ " `customer`.`city` as `City`,"
+ " " + nameExpStr + " as `Name`,"
+ " `customer`.`customer_id` as `Name (Key)`,"
+ " `customer`.`education` as `Education Level`,"
+ " `customer`.`gender` as `Gender`,"
+ " `customer`.`marital_status` as `Marital Status`,"
+ " `customer`.`yearly_income` as `Yearly Income`,"
+ " `sales_fact_1997`.`unit_sales` as `Unit Sales`"
+ " from `store` =as= `store`,"
+ " `sales_fact_1997` =as= `sales_fact_1997`,"
+ " `time_by_day` =as= `time_by_day`,"
+ " `product_class` =as= `product_class`,"
+ " `product` =as= `product`,"
+ " `store_ragged` =as= `store_ragged`,"
+ " `promotion` =as= `promotion`,"
+ " `customer` =as= `customer`"
+ " where `sales_fact_1997`.`store_id` = `store`.`store_id`"
+ " and `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`"
+ " and `time_by_day`.`the_year` = 1997"
+ " and `sales_fact_1997`.`product_id` = `product`.`product_id`"
+ " and `product`.`product_class_id` = `product_class`.`product_class_id`"
+ " and `sales_fact_1997`.`store_id` = `store_ragged`.`store_id`"
+ " and `sales_fact_1997`.`promotion_id` = `promotion`.`promotion_id`"
+ " and `sales_fact_1997`.`customer_id` = `customer`.`customer_id`"
+ " order by `store`.`store_country` ASC,"
+ " `store`.`store_state` ASC,"
+ " `store`.`store_city` ASC,"
+ " `store`.`store_name` ASC,"
+ " `store`.`store_sqft` ASC,"
+ " `store`.`store_type` ASC,"
+ " `time_by_day`.`the_year` ASC,"
+ " `time_by_day`.`quarter` ASC,"
+ " `time_by_day`.`month_of_year` ASC,"
+ " `time_by_day`.`week_of_year` ASC,"
+ " `time_by_day`.`day_of_month` ASC,"
+ " `product_class`.`product_family` ASC,"
+ " `product_class`.`product_department` ASC,"
+ " `product_class`.`product_category` ASC,"
+ " `product_class`.`product_subcategory` ASC,"
+ " `product`.`brand_name` ASC,"
+ " `product`.`product_name` ASC,"
+ " `store_ragged`.`store_id` ASC,"
+ " `promotion`.`media_type` ASC,"
+ " `promotion`.`promotion_name` ASC,"
+ " `customer`.`country` ASC,"
+ " `customer`.`state_province` ASC,"
+ " `customer`.`city` ASC,"
+ " " + nameExpStr + " ASC,"
+ " `customer`.`customer_id` ASC,"
+ " `customer`.`education` ASC,"
+ " `customer`.`gender` ASC,"
+ " `customer`.`marital_status` ASC,"
+ " `customer`.`yearly_income` ASC";
getTestContext().assertSqlEquals(expectedSql, sql, 86837);
}
/**
* Tests that long levels do not result in column aliases larger than the
* database can handle. For example, Access allows maximum of 64; Oracle
* allows 30.
*
* <p>Testcase for bug 1893959, "Generated drill-through columns too long
* for DBMS".
*
* @throws Exception on error
*/
public void testTruncateLevelName() throws Exception {
TestContext testContext = TestContext.instance().createSubstitutingCube(
"Sales",
" <Dimension name=\"Education Level2\" foreignKey=\"customer_id\">\n"
+ " <Hierarchy hasAll=\"true\" primaryKey=\"customer_id\">\n"
+ " <Table name=\"customer\"/>\n"
+ " <Level name=\"Education Level but with a very long name that will be too long if converted directly into a column\" column=\"education\" uniqueMembers=\"true\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>",
null);
Result result = testContext.executeQuery(
"SELECT {[Measures].[Unit Sales]} on columns,\n"
+ "{[Education Level2].Children} on rows\n"
+ "FROM [Sales]\n"
+ "WHERE ([Time].[1997].[Q1].[1], [Product].[Non-Consumable].[Carousel].[Specialty].[Sunglasses].[ADJ].[ADJ Rosy Sunglasses]) ");
String sql = result.getCell(new int[] {0, 0}).getDrillThroughSQL(false);
// Check that SQL is valid.
java.sql.Connection connection = null;
try {
DataSource dataSource = getConnection().getDataSource();
connection = dataSource.getConnection();
final Statement statement = connection.createStatement();
final ResultSet resultSet = statement.executeQuery(sql);
final int columnCount = resultSet.getMetaData().getColumnCount();
final Dialect dialect = testContext.getDialect();
if (dialect.getDatabaseProduct() == Dialect.DatabaseProduct.DERBY) {
// derby counts ORDER BY columns as columns. insane!
assertEquals(11, columnCount);
} else {
assertEquals(6, columnCount);
}
final String columnName = resultSet.getMetaData().getColumnLabel(5);
assertTrue(
columnName,
columnName.startsWith("Education Level but with a"));
int n = 0;
while (resultSet.next()) {
++n;
}
assertEquals(2, n);
} finally {
if (connection != null) {
connection.close();
}
}
}
public void testDrillThroughExprs() {
assertCanDrillThrough(
true,
"Sales",
"CoalesceEmpty([Measures].[Unit Sales], [Measures].[Store Sales])");
assertCanDrillThrough(
true,
"Sales",
"[Measures].[Unit Sales] + [Measures].[Unit Sales]");
assertCanDrillThrough(
true,
"Sales",
"[Measures].[Unit Sales] / ([Measures].[Unit Sales] - 5.0)");
assertCanDrillThrough(
true,
"Sales",
"[Measures].[Unit Sales] * [Measures].[Unit Sales]");
// constants are drillable - in a virtual cube it means take the first
// cube
assertCanDrillThrough(
true,
"Warehouse and Sales",
"2.0");
assertCanDrillThrough(
true,
"Warehouse and Sales",
"[Measures].[Unit Sales] * 2.0");
// in virtual cube, mixture of measures from two cubes is not drillable
assertCanDrillThrough(
false,
"Warehouse and Sales",
"[Measures].[Unit Sales] + [Measures].[Units Ordered]");
// expr with measures both from [Sales] is drillable
assertCanDrillThrough(
true,
"Warehouse and Sales",
"[Measures].[Unit Sales] + [Measures].[Store Sales]");
// expr with measures both from [Warehouse] is drillable
assertCanDrillThrough(
true,
"Warehouse and Sales",
"[Measures].[Warehouse Cost] + [Measures].[Units Ordered]");
// <Member>.Children not drillable
assertCanDrillThrough(
false,
"Sales",
"Sum([Product].Children)");
// Sets of members not drillable
assertCanDrillThrough(
false,
"Sales",
"Sum({[Store].[USA], [Store].[Canada].[BC]})");
// Tuples not drillable
assertCanDrillThrough(
false,
"Sales",
"([Time].[1997].[Q1], [Measures].[Unit Sales])");
}
public void testDrillthroughMaxRows() throws SQLException {
assertMaxRows("", 29);
assertMaxRows("maxrows 1000", 29);
assertMaxRows("maxrows 0", 29);
assertMaxRows("maxrows 3", 3);
assertMaxRows("maxrows 10 firstrowset 6", 4);
assertMaxRows("firstrowset 20", 9);
assertMaxRows("firstrowset 30", 0);
}
private void assertMaxRows(String firstMaxRow, int expectedCount)
throws SQLException
{
final ResultSet resultSet = getTestContext().executeStatement(
"drillthrough\n"
+ firstMaxRow
+ " select\n"
+ "non empty{[Customers].[USA].[CA]} on 0,\n"
+ "non empty {[Product].[Drink].[Beverages].[Pure Juice Beverages].[Juice]} on 1\n"
+ "from\n"
+ "[Sales]\n"
+ "where([Measures].[Sales Count], [Time].[1997].[Q3].[8])");
int actualCount = 0;
while (resultSet.next()) {
++actualCount;
}
assertEquals(expectedCount, actualCount);
resultSet.close();
}
public void testDrillthroughNegativeMaxRowsFails() throws SQLException {
try {
final ResultSet resultSet = getTestContext().executeStatement(
"DRILLTHROUGH MAXROWS -3\n"
+ "SELECT {[Customers].[USA].[CA].[Berkeley]} ON 0,\n"
+ "{[Time].[1997]} ON 1\n"
+ "FROM Sales");
fail("expected error, got " + resultSet);
} catch (SQLException e) {
TestContext.checkThrowable(
e, "Syntax error at line 1, column 22, token '-'");
}
}
public void testDrillThroughCalculatedMemberMeasure() {
try {
final ResultSet resultSet = getTestContext().executeStatement(
"DRILLTHROUGH\n"
+ "SELECT {[Customers].[USA].[CA].[Berkeley]} ON 0,\n"
+ "{[Time].[1997]} ON 1\n"
+ "FROM Sales\n"
+ "RETURN [Measures].[Profit]");
fail("expected error, got " + resultSet);
} catch (Exception e) {
TestContext.checkThrowable(
e,
"Can't perform drillthrough operations because '[Measures].[Profit]' is a calculated member.");
}
}
public void testDrillThroughNotDrillableFails() {
try {
final ResultSet resultSet = getTestContext().executeStatement(
"DRILLTHROUGH\n"
+ "WITH MEMBER [Measures].[Foo] "
+ " AS [Measures].[Unit Sales]\n"
+ " + ([Measures].[Unit Sales], [Time].[Time].PrevMember)\n"
+ "SELECT {[Customers].[USA].[CA].[Berkeley]} ON 0,\n"
+ "{[Time].[1997]} ON 1\n"
+ "FROM Sales\n"
+ "WHERE [Measures].[Foo]");
fail("expected error, got " + resultSet);
} catch (Exception e) {
TestContext.checkThrowable(
e, "Cannot do DrillThrough operation on the cell");
}
}
/**
* Asserts that a cell based on the given measure expression has a given
* drillability.
*
* @param canDrillThrough Whether we expect the cell to be drillable
* @param cubeName Cube name
* @param expr Scalar expression
*/
private void assertCanDrillThrough(
boolean canDrillThrough,
String cubeName,
String expr)
{
Result result = executeQuery(
"WITH MEMBER [Measures].[Foo] AS '" + expr + "'\n"
+ "SELECT {[Measures].[Foo]} on columns,\n"
+ " {[Product].Children} on rows\n"
+ "from [" + cubeName + "]");
final Cell cell = result.getCell(new int[] {0, 0});
assertEquals(canDrillThrough, cell.canDrillThrough());
final String sql = cell.getDrillThroughSQL(false);
if (canDrillThrough) {
assertNotNull(sql);
} else {
assertNull(sql);
}
}
public void testDrillThroughOneAxis() {
Result result = executeQuery(
"SELECT [Measures].[Unit Sales] on 0\n"
+ "from Sales");
final Cell cell = result.getCell(new int[]{0});
assertTrue(cell.canDrillThrough());
assertEquals(86837, cell.getDrillThroughCount());
}
public void testDrillThroughCalcMemberInSlicer() {
Result result = executeQuery(
"WITH MEMBER [Product].[Aggregate Food Drink] AS \n"
+ " Aggregate({[Product].[Food], [Product].[Drink]})\n"
+ "SELECT [Measures].[Unit Sales] on 0\n"
+ "from Sales\n"
+ "WHERE [Product].[Aggregate Food Drink]");
final Cell cell = result.getCell(new int[]{0});
assertFalse(cell.canDrillThrough());
}
/**
* Test case for MONDRIAN-791.
*/
public void testDrillThroughMultiPositionCompoundSlicer() {
propSaver.set(propSaver.properties.GenerateFormattedSql, true);
// A query with a simple multi-position compound slicer
Result result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE {[Time].[1997].[Q1], [Time].[1997].[Q2]}");
Cell cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
String sql = cell.getDrillThroughSQL(false);
String expectedSql;
switch (getTestContext().getDialect().getDatabaseProduct()) {
case MYSQL:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day as time_by_day,\n"
+ " sales_fact_1997 as sales_fact_1997\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " (((time_by_day.the_year, time_by_day.quarter) in ((1997, 'Q1'), (1997, 'Q2'))))";
break;
case ORACLE:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day time_by_day,\n"
+ " sales_fact_1997 sales_fact_1997\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " ((time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (time_by_day.quarter = 'Q2' and time_by_day.the_year = 1997))";
break;
default:
return;
}
getTestContext().assertSqlEquals(expectedSql, sql, 41956);
// A query with a slightly more complex multi-position compound slicer
result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE Crossjoin(Crossjoin({[Gender].[F]}, {[Marital Status].[M]}),"
+ " {[Time].[1997].[Q1], [Time].[1997].[Q2]})");
cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
sql = cell.getDrillThroughSQL(false);
// Note that gender and marital status get their own predicates,
// independent of the time portion of the slicer
switch (getTestContext().getDialect().getDatabaseProduct()) {
case MYSQL:
expectedSql =
"select\n"
+ " customer.marital_status as Marital Status,\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " customer.gender as Gender,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " customer as customer,\n"
+ " sales_fact_1997 as sales_fact_1997,\n"
+ " time_by_day as time_by_day\n"
+ "where\n"
+ " sales_fact_1997.customer_id = customer.customer_id\n"
+ "and\n"
+ " customer.marital_status = 'M'\n"
+ "and\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " (((time_by_day.the_year, time_by_day.quarter, customer.gender) in ((1997, 'Q1', 'F'), (1997, 'Q2', 'F'))))\n"
+ "order by\n"
+ " customer.marital_status ASC";
break;
case ORACLE:
expectedSql =
"select\n"
+ " customer.marital_status as Marital Status,\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " customer.gender as Gender,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " customer customer,\n"
+ " sales_fact_1997 sales_fact_1997,\n"
+ " time_by_day time_by_day\n"
+ "where\n"
+ " sales_fact_1997.customer_id = customer.customer_id\n"
+ "and\n"
+ " customer.marital_status = 'M'\n"
+ "and\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " ((customer.gender = 'F' and time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (customer.gender = 'F' and time_by_day.quarter = 'Q2' and time_by_day.the_year = 1997))\n"
+ "order by\n"
+ " customer.marital_status ASC";
break;
default:
return;
}
getTestContext().assertSqlEquals(expectedSql, sql, 10430);
// A query with an even more complex multi-position compound slicer
// (gender must be in the slicer predicate along with time)
result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE Union(Crossjoin({[Gender].[F]}, {[Time].[1997].[Q1]}),"
+ " Crossjoin({[Gender].[M]}, {[Time].[1997].[Q2]}))");
cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
sql = cell.getDrillThroughSQL(false);
// Note that gender and marital status get their own predicates,
// independent of the time portion of the slicer
switch (getTestContext().getDialect().getDatabaseProduct()) {
case MYSQL:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " customer.gender as Gender,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day as time_by_day,\n"
+ " sales_fact_1997 as sales_fact_1997,\n"
+ " customer as customer\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " sales_fact_1997.customer_id = customer.customer_id\n"
+ "and\n"
+ " (((time_by_day.the_year, time_by_day.quarter, customer.gender) in ((1997, 'Q1', 'F'), (1997, 'Q2', 'M'))))";
break;
case ORACLE:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " customer.gender as Gender,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day time_by_day,\n"
+ " sales_fact_1997 sales_fact_1997,\n"
+ " customer customer\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " sales_fact_1997.customer_id = customer.customer_id\n"
+ "and\n"
+ " ((customer.gender = 'F' and time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (customer.gender = 'M' and time_by_day.quarter = 'Q2' and time_by_day.the_year = 1997))";
break;
default:
return;
}
getTestContext().assertSqlEquals(expectedSql, sql, 20971);
// A query with a simple multi-position compound slicer with
// different levels (overlapping)
result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE {[Time].[1997].[Q1], [Time].[1997].[Q1].[1]}");
cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
sql = cell.getDrillThroughSQL(false);
// With overlapping slicer members, the first slicer predicate is
// redundant, but does not affect the query's results
switch (getTestContext().getDialect().getDatabaseProduct()) {
case MYSQL:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " time_by_day.month_of_year as Month,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day as time_by_day,\n"
+ " sales_fact_1997 as sales_fact_1997\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " ((time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (time_by_day.month_of_year = 1 and time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997))";
break;
case ORACLE:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " time_by_day.month_of_year as Month,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day time_by_day,\n"
+ " sales_fact_1997 sales_fact_1997\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " ((time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (time_by_day.month_of_year = 1 and time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997))";
break;
default:
return;
}
getTestContext().assertSqlEquals(expectedSql, sql, 21588);
// A query with a simple multi-position compound slicer with
// different levels (non-overlapping)
result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE {[Time].[1997].[Q1].[1], [Time].[1997].[Q2]}");
cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
sql = cell.getDrillThroughSQL(false);
switch (getTestContext().getDialect().getDatabaseProduct()) {
case MYSQL:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " time_by_day.month_of_year as Month,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day as time_by_day,\n"
+ " sales_fact_1997 as sales_fact_1997\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " ((time_by_day.month_of_year = 1 and time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (time_by_day.quarter = 'Q2' and time_by_day.the_year = 1997))";
break;
case ORACLE:
expectedSql =
"select\n"
+ " time_by_day.the_year as Year,\n"
+ " time_by_day.quarter as Quarter,\n"
+ " time_by_day.month_of_year as Month,\n"
+ " sales_fact_1997.unit_sales as Unit Sales\n"
+ "from\n"
+ " time_by_day time_by_day,\n"
+ " sales_fact_1997 sales_fact_1997\n"
+ "where\n"
+ " sales_fact_1997.time_id = time_by_day.time_id\n"
+ "and\n"
+ " ((time_by_day.month_of_year = 1 and time_by_day.quarter = 'Q1' and time_by_day.the_year = 1997) or (time_by_day.quarter = 'Q2' and time_by_day.the_year = 1997))";
break;
default:
return;
}
getTestContext().assertSqlEquals(expectedSql, sql, 27402);
}
public void testDrillthroughDisable() {
propSaver.set(
MondrianProperties.instance().EnableDrillThrough,
true);
Result result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE {[Time].[1997].[Q1], [Time].[1997].[Q2]}");
Cell cell = result.getCell(new int[]{0, 0});
assertTrue(cell.canDrillThrough());
propSaver.set(
MondrianProperties.instance().EnableDrillThrough,
false);
result =
executeQuery(
"SELECT {[Measures].[Unit Sales]} ON COLUMNS,\n"
+ " {[Product].[All Products]} ON ROWS\n"
+ "FROM [Sales]\n"
+ "WHERE {[Time].[1997].[Q1], [Time].[1997].[Q2]}");
cell = result.getCell(new int[]{0, 0});
assertFalse(cell.canDrillThrough());
try {
cell.getDrillThroughSQL(false);
fail();
} catch (MondrianException e) {
assertTrue(
e.getMessage().contains(
"Can't perform drillthrough operations because"));
}
}
}
// End DrillThroughTest.java
|
package cpw.mods.fml.client;
import static org.lwjgl.opengl.GL11.*;
import java.awt.image.BufferedImage;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.src.BaseMod;
import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Block;
import net.minecraft.src.ClientRegistry;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GameSettings;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.IInventory;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.KeyBinding;
import net.minecraft.src.MLProp;
import net.minecraft.src.ModTextureStatic;
import net.minecraft.src.NetClientHandler;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet;
import net.minecraft.src.Packet1Login;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.Packet3Chat;
import net.minecraft.src.Profiler;
import net.minecraft.src.Render;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.RenderEngine;
import net.minecraft.src.RenderManager;
import net.minecraft.src.RenderPlayer;
import net.minecraft.src.SidedProxy;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.TextureFX;
import net.minecraft.src.TexturePackBase;
import net.minecraft.src.World;
import net.minecraft.src.WorldType;
import argo.jdom.JdomParser;
import argo.jdom.JsonNode;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLModLoaderContainer;
import cpw.mods.fml.common.IFMLSidedHandler;
import cpw.mods.fml.common.IKeyHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModContainer.TickType;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ProxyInjector;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.common.modloader.ModProperty;
import cpw.mods.fml.common.registry.FMLRegistry;
/**
* Handles primary communication from hooked code into the system
*
* The FML entry point is {@link #onPreLoad(MinecraftServer)} called from
* {@link MinecraftServer}
*
* Obfuscated code should focus on this class and other members of the "server"
* (or "client") code
*
* The actual mod loading is handled at arms length by {@link Loader}
*
* It is expected that a similar class will exist for each target environment:
* Bukkit and Client side.
*
* It should not be directly modified.
*
* @author cpw
*
*/
public class FMLClientHandler implements IFMLSidedHandler
{
/**
* The singleton
*/
private static final FMLClientHandler INSTANCE = new FMLClientHandler();
/**
* A reference to the server itself
*/
private Minecraft client;
/**
* A handy list of the default overworld biomes
*/
private BiomeGenBase[] defaultOverworldBiomes;
private int nextRenderId = 30;
private TexturePackBase fallbackTexturePack;
private NetClientHandler networkClient;
private ModContainer animationCallbackMod;
// Cached lookups
private HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
private HashMap<Integer, BlockRenderInfo> blockModelIds = new HashMap<Integer, BlockRenderInfo>();
private HashMap<KeyBinding, ModContainer> keyBindings = new HashMap<KeyBinding, ModContainer>();
private HashSet<OverrideInfo> animationSet = new HashSet<OverrideInfo>();
private List<TextureFX> addedTextureFX = new ArrayList<TextureFX>();
private boolean firstTick;
/**
* Called to start the whole game off from
* {@link MinecraftServer#startServer}
*
* @param minecraftServer
*/
private OptifineModContainer optifineContainer;
public void onPreLoad(Minecraft minecraft)
{
client = minecraft;
ReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().registerSidedDelegate(this);
FMLRegistry.registerRegistry(new ClientRegistry());
try
{
Class<?> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader());
optifineContainer = new OptifineModContainer(optifineConfig);
}
catch (Exception e)
{
// OPTIFINE not found
optifineContainer = null;
}
if (optifineContainer != null)
{
ModMetadata optifineMetadata;
try
{
optifineMetadata = readMetadataFrom(Loader.instance().getModClassLoader().getResourceAsStream("optifinemod.info"), optifineContainer);
optifineContainer.setMetadata(optifineMetadata);
}
catch (Exception e)
{
//not available
}
FMLCommonHandler.instance().getFMLLogger().info(String.format("Forge Mod Loader has detected optifine %s, enabling compatibility features",optifineContainer.getVersion()));
}
Loader.instance().loadMods();
}
/**
* Called a bit later on during initialization to finish loading mods
* Also initializes key bindings
*
*/
public void onLoadComplete()
{
client.field_6315_n.func_1065_b();
Loader.instance().initializeMods();
for (ModContainer mod : Loader.getModList()) {
mod.gatherRenderers(RenderManager.field_1233_a.getRendererList());
for (Render r : RenderManager.field_1233_a.getRendererList().values()) {
r.func_4009_a(RenderManager.field_1233_a);
}
}
// Load the key bindings into the settings table
GameSettings gs = client.field_6304_y;
KeyBinding[] modKeyBindings = harvestKeyBindings();
KeyBinding[] allKeys = new KeyBinding[gs.field_1564_t.length + modKeyBindings.length];
System.arraycopy(gs.field_1564_t, 0, allKeys, 0, gs.field_1564_t.length);
System.arraycopy(modKeyBindings, 0, allKeys, gs.field_1564_t.length, modKeyBindings.length);
gs.field_1564_t = allKeys;
gs.func_6519_a();
// Mark this as a "first tick"
firstTick = true;
}
public KeyBinding[] harvestKeyBindings() {
List<IKeyHandler> allKeys=FMLCommonHandler.instance().gatherKeyBindings();
KeyBinding[] keys=new KeyBinding[allKeys.size()];
int i=0;
for (IKeyHandler key : allKeys) {
keys[i++]=(KeyBinding)key.getKeyBinding();
keyBindings.put((KeyBinding) key.getKeyBinding(), key.getOwningContainer());
}
return keys;
}
/**
* Every tick just before world and other ticks occur
*/
public void onPreWorldTick()
{
if (client.field_6324_e != null) {
FMLCommonHandler.instance().worldTickStart();
FMLCommonHandler.instance().tickStart(TickType.WORLDGUI, 0.0f, client.field_6313_p);
}
}
/**
* Every tick just after world and other ticks occur
*/
public void onPostWorldTick()
{
if (client.field_6324_e != null) {
FMLCommonHandler.instance().worldTickEnd();
FMLCommonHandler.instance().tickEnd(TickType.WORLDGUI, 0.0f, client.field_6313_p);
}
}
public void onWorldLoadTick()
{
if (client.field_6324_e != null) {
if (firstTick)
{
loadTextures(fallbackTexturePack);
firstTick = false;
}
FMLCommonHandler.instance().tickStart(TickType.WORLDLOADTICK);
FMLCommonHandler.instance().tickStart(TickType.GUILOADTICK);
}
}
public void onRenderTickStart(float partialTickTime)
{
FMLCommonHandler.instance().tickStart(TickType.RENDER, partialTickTime);
FMLCommonHandler.instance().tickStart(TickType.GUI, partialTickTime, client.field_6313_p);
}
public void onRenderTickEnd(float partialTickTime)
{
FMLCommonHandler.instance().tickEnd(TickType.RENDER, partialTickTime);
FMLCommonHandler.instance().tickEnd(TickType.GUI, partialTickTime, client.field_6313_p);
}
/**
* Get the server instance
*
* @return
*/
public Minecraft getClient()
{
return client;
}
/**
* Get a handle to the client's logger instance
* The client actually doesn't have one- so we return null
*/
public Logger getMinecraftLogger()
{
return null;
}
/**
* Called from ChunkProvider when a chunk needs to be populated
*
* To avoid polluting the worldgen seed, we generate a new random from the
* world seed and generate a seed from that
*
* @param chunkProvider
* @param chunkX
* @param chunkZ
* @param world
* @param generator
*/
public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator)
{
Random fmlRandom = new Random(world.func_22138_q());
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ world.func_22138_q());
for (ModContainer mod : Loader.getModList())
{
if (mod.generatesWorld())
{
mod.getWorldGenerator().generate(fmlRandom, chunkX, chunkZ, world, generator, chunkProvider);
}
}
}
/**
* Is the offered class and instance of BaseMod and therefore a ModLoader
* mod?
*/
public boolean isModLoaderMod(Class<?> clazz)
{
return BaseMod.class.isAssignableFrom(clazz);
}
/**
* Load the supplied mod class into a mod container
*/
public ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile)
{
@SuppressWarnings("unchecked")
Class<? extends BaseMod> bmClazz = (Class<? extends BaseMod>) clazz;
return new ModLoaderModContainer(bmClazz, canonicalFile);
}
/**
* Called to notify that an item was picked up from the world
*
* @param entityItem
* @param entityPlayer
*/
public void notifyItemPickup(EntityItem entityItem, EntityPlayer entityPlayer)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsPickupNotification())
{
mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer);
}
}
}
/**
* Attempt to dispense the item as an entity other than just as a the item
* itself
*
* @param world
* @param x
* @param y
* @param z
* @param xVelocity
* @param zVelocity
* @param item
* @return
*/
public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, xVelocity, zVelocity, world, item))
{
return true;
}
}
return false;
}
/**
* @return the instance
*/
public static FMLClientHandler instance()
{
return INSTANCE;
}
/**
* Build a list of default overworld biomes
*
* @return
*/
public BiomeGenBase[] getDefaultOverworldBiomes()
{
if (defaultOverworldBiomes == null)
{
ArrayList<BiomeGenBase> biomes = new ArrayList<BiomeGenBase>(20);
for (int i = 0; i < 23; i++)
{
if ("Sky".equals(BiomeGenBase.field_35486_a[i].field_6504_m) || "Hell".equals(BiomeGenBase.field_35486_a[i].field_6504_m))
{
continue;
}
biomes.add(BiomeGenBase.field_35486_a[i]);
}
defaultOverworldBiomes = new BiomeGenBase[biomes.size()];
biomes.toArray(defaultOverworldBiomes);
}
return defaultOverworldBiomes;
}
/**
* Called when an item is crafted
*
* @param player
* @param craftedItem
* @param craftingGrid
*/
public void onItemCrafted(EntityPlayer player, ItemStack craftedItem, IInventory craftingGrid)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsCraftingNotification())
{
mod.getCraftingHandler().onCrafting(player, craftedItem, craftingGrid);
}
}
}
/**
* Called when an item is smelted
*
* @param player
* @param smeltedItem
*/
public void onItemSmelted(EntityPlayer player, ItemStack smeltedItem)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsCraftingNotification())
{
mod.getCraftingHandler().onSmelting(player, smeltedItem);
}
}
}
/**
* Called when a chat packet is received
*
* @param chat
* @param player
* @return true if you want the packet to stop processing and not echo to
* the rest of the world
*/
public boolean handleChatPacket(Packet3Chat chat)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat))
{
return true;
}
}
return false;
}
public void handleServerLogin(Packet1Login loginPacket, NetClientHandler handler, NetworkManager networkManager)
{
this.networkClient=handler;
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.field_44012_a = "REGISTER";
packet.field_44011_c = FMLCommonHandler.instance().getPacketRegistry();
packet.field_44010_b = packet.field_44011_c.length;
if (packet.field_44010_b > 0)
{
networkManager.func_972_a(packet);
}
for (ModContainer mod : Loader.getModList()) {
mod.getNetworkHandler().onServerLogin(handler);
}
}
/**
* Called when a packet 250 packet is received from the player
*
* @param packet
* @param player
*/
public void handlePacket250(Packet250CustomPayload packet)
{
if ("REGISTER".equals(packet.field_44012_a) || "UNREGISTER".equals(packet.field_44012_a))
{
handleServerRegistration(packet);
return;
}
ModContainer mod = FMLCommonHandler.instance().getModForChannel(packet.field_44012_a);
if (mod != null)
{
mod.getNetworkHandler().onPacket250Packet(packet);
}
}
/**
* Handle register requests for packet 250 channels
*
* @param packet
*/
private void handleServerRegistration(Packet250CustomPayload packet)
{
if (packet.field_44011_c == null)
{
return;
}
try
{
for (String channel : new String(packet.field_44011_c, "UTF8").split("\0"))
{
// Skip it if we don't know it
if (FMLCommonHandler.instance().getModForChannel(channel) == null)
{
continue;
}
if ("REGISTER".equals(packet.field_44012_a))
{
FMLCommonHandler.instance().activateChannel(client.field_6322_g,channel);
}
else
{
FMLCommonHandler.instance().deactivateChannel(client.field_6322_g,channel);
}
}
}
catch (UnsupportedEncodingException e)
{
getMinecraftLogger().warning("Received invalid registration packet");
}
}
@Override
public File getMinecraftRootDirectory()
{
return client.field_6297_D;
}
/**
* @param player
*/
public void announceLogout(EntityPlayer player)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsPlayerTracking())
{
mod.getPlayerTracker().onPlayerLogout(player);
}
}
}
/**
* @param p_28168_1_
*/
public void announceDimensionChange(EntityPlayer player)
{
for (ModContainer mod : Loader.getModList())
{
if (mod.wantsPlayerTracking())
{
mod.getPlayerTracker().onPlayerChangedDimension(player);
}
}
}
/**
* @param biome
*/
public void addBiomeToDefaultWorldGenerator(BiomeGenBase biome)
{
WorldType.field_48635_b.addNewBiome(biome);
}
/**
* Return the minecraft instance
*/
@Override
public Object getMinecraftInstance()
{
return client;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.IFMLSidedHandler#getCurrentLanguage()
*/
@Override
public String getCurrentLanguage()
{
return StringTranslate.func_20162_a().func_44024_c();
}
public Properties getCurrentLanguageTable() {
return StringTranslate.func_20162_a().getTranslationTable();
}
/**
* @param armor
* @return
*/
public int addNewArmourRendererPrefix(String armor)
{
return RenderPlayer.addNewArmourPrefix(armor);
}
public void addNewTextureOverride(String textureToOverride, String overridingTexturePath, int location) {
if (!overrideInfo.containsKey(textureToOverride))
{
overrideInfo.put(textureToOverride, new ArrayList<OverrideInfo>());
}
ArrayList<OverrideInfo> list = overrideInfo.get(textureToOverride);
OverrideInfo info = new OverrideInfo();
info.index = location;
info.override = overridingTexturePath;
info.texture = textureToOverride;
list.add(info);
FMLCommonHandler.instance().getFMLLogger().log(Level.FINE, String.format("Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride)));
}
/**
* @param mod
* @param inventoryRenderer
* @return
*/
public int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
{
ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
int renderId=nextRenderId++;
BlockRenderInfo bri=new BlockRenderInfo(renderId, inventoryRenderer, mlmc);
blockModelIds.put(renderId, bri);
return renderId;
}
/**
* @param renderEngine
* @param path
* @return
*/
public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
{
InputStream image=client.field_6298_C.field_6534_a.func_6481_a(path);
if (image==null) {
throw new RuntimeException(String.format("The requested image path %s is not found",path));
}
BufferedImage result=ImageIO.read(image);
if (result==null)
{
throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
}
return result;
}
/**
* @param player
* @param gui
*/
public void displayGuiScreen(EntityPlayer player, GuiScreen gui)
{
if (client.field_22009_h==player && gui != null) {
client.func_6272_a(gui);
}
}
/**
* @param mod
* @param keyHandler
* @param allowRepeat
*/
public void registerKeyHandler(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
{
ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod);
mlmc.addKeyHandler(new KeyBindingHandler(keyHandler, allowRepeat, mlmc));
}
/**
* @param renderer
* @param world
* @param x
* @param y
* @param z
* @param block
* @param modelId
* @return
*/
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
{
if (!blockModelIds.containsKey(modelId)) {
return false;
}
BlockRenderInfo bri = blockModelIds.get(modelId);
return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
}
/**
* @param renderer
* @param block
* @param metadata
* @param modelID
*/
public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
{
if (!blockModelIds.containsKey(modelID)) {
return;
}
BlockRenderInfo bri=blockModelIds.get(modelID);
bri.renderInventoryBlock(block, metadata, modelID, renderer);
}
/**
* @param p_1219_0_
* @return
*/
public boolean renderItemAsFull3DBlock(int modelId)
{
BlockRenderInfo bri = blockModelIds.get(modelId);
if (bri!=null) {
return bri.shouldRender3DInInventory();
}
return false;
}
public void registerTextureOverrides(RenderEngine renderer) {
for (ModContainer mod : Loader.getModList()) {
registerAnimatedTexturesFor(mod);
}
for (OverrideInfo animationOverride : animationSet) {
renderer.func_1066_a(animationOverride.textureFX);
addedTextureFX.add(animationOverride.textureFX);
FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_1126_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_1128_f));
}
for (String fileToOverride : overrideInfo.keySet()) {
for (OverrideInfo override : overrideInfo.get(fileToOverride)) {
try
{
BufferedImage image=loadImageFromTexturePack(renderer, override.override);
ModTextureStatic mts=new ModTextureStatic(override.index, 1, override.texture, image);
renderer.func_1066_a(mts);
addedTextureFX.add(mts);
FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", override.index, mts.field_1126_b, override.texture, mts.field_1128_f));
}
catch (IOException e)
{
FMLCommonHandler.instance().getFMLLogger().throwing("FMLClientHandler", "registerTextureOverrides", e);
}
}
}
}
/**
* @param mod
*/
private void registerAnimatedTexturesFor(ModContainer mod)
{
this.animationCallbackMod=mod;
mod.requestAnimations();
this.animationCallbackMod=null;
}
public String getObjectName(Object instance) {
String objectName;
if (instance instanceof Item) {
objectName=((Item)instance).func_20009_a();
} else if (instance instanceof Block) {
objectName=((Block)instance).func_20013_i();
} else if (instance instanceof ItemStack) {
objectName=Item.field_233_c[((ItemStack)instance).field_1617_c].func_21011_b((ItemStack)instance);
} else {
throw new IllegalArgumentException(String.format("Illegal object for naming %s",instance));
}
objectName+=".name";
return objectName;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.IFMLSidedHandler#readMetadataFrom(java.io.InputStream, cpw.mods.fml.common.ModContainer)
*/
@Override
public ModMetadata readMetadataFrom(InputStream input, ModContainer mod) throws Exception
{
JsonNode root=new JdomParser().func_27366_a(new InputStreamReader(input));
List<JsonNode> lst=root.func_27217_b();
JsonNode modinfo = null;
for (JsonNode tmodinfo : lst) {
if (mod.getName().equals(tmodinfo.func_27213_a("modid"))) {
modinfo = tmodinfo;
break;
}
}
if (modinfo == null) {
FMLCommonHandler.instance().getFMLLogger().fine(String.format("Unable to process JSON modinfo file for %s", mod.getName()));
return null;
}
ModMetadata meta=new ModMetadata(mod);
try {
meta.name=modinfo.func_27213_a("name");
meta.description=modinfo.func_27213_a("description");
meta.version=modinfo.func_27213_a("version");
meta.credits=modinfo.func_27213_a("credits");
List authors=modinfo.func_27217_b("authors");
StringBuilder sb=new StringBuilder();
for (int i=0; i<authors.size(); i++) {
meta.authorList.add(((JsonNode)authors.get(i)).func_27216_b());
}
meta.logoFile=modinfo.func_27213_a("logoFile");
meta.url=modinfo.func_27213_a("url");
meta.updateUrl=modinfo.func_27213_a("updateUrl");
meta.parent=modinfo.func_27213_a("parent");
List screenshots=modinfo.func_27217_b("screenshots");
meta.screenshots=new String[screenshots.size()];
for (int i=0; i<screenshots.size(); i++) {
meta.screenshots[i]=((JsonNode)screenshots.get(i)).func_27216_b();
}
} catch (Exception e) {
FMLCommonHandler.instance().getFMLLogger().log(Level.FINE, String.format("An error occured reading the info file for %s",mod.getName()), e);
}
return meta;
}
public void pruneOldTextureFX(TexturePackBase var1, List<TextureFX> effects)
{
ListIterator<TextureFX> li = addedTextureFX.listIterator();
while (li.hasNext())
{
TextureFX tex = li.next();
if (tex instanceof FMLTextureFX)
{
if (((FMLTextureFX)tex).unregister(client.field_6315_n, effects))
{
li.remove();
}
}
else
{
effects.remove(tex);
li.remove();
}
}
}
/**
* @param p_6531_1_
*/
public void loadTextures(TexturePackBase texturePack)
{
registerTextureOverrides(client.field_6315_n);
}
/**
* @param field_6539_c
*/
public void onEarlyTexturePackLoad(TexturePackBase fallback)
{
if (client==null) {
// We're far too early- let's wait
this.fallbackTexturePack=fallback;
} else {
loadTextures(fallback);
}
}
/**
* @param packet
*/
public void sendPacket(Packet packet)
{
if (this.networkClient!=null) {
this.networkClient.func_847_a(packet);
}
}
/**
* @param anim
*/
public void addAnimation(TextureFX anim)
{
if (animationCallbackMod==null) {
return;
}
OverrideInfo info=new OverrideInfo();
info.index=anim.field_1126_b;
info.imageIndex=anim.field_1128_f;
info.textureFX=anim;
if (animationSet.contains(info)) {
animationSet.remove(info);
}
animationSet.add(info);
}
@Override
public void profileStart(String profileLabel) {
Profiler.func_40663_a(profileLabel);
}
@Override
public void profileEnd() {
Profiler.func_40662_b();
}
public void preGameLoad(String user, String sessionToken)
{
// Currently this does nothing, but it's possible I could relaunch Minecraft in a new classloader if I wished
Minecraft.fmlReentry(user, sessionToken);
}
public void onTexturePackChange(RenderEngine engine, TexturePackBase texturepack, List<TextureFX> effects)
{
FMLClientHandler.instance().pruneOldTextureFX(texturepack, effects);
for (TextureFX tex : effects)
{
if (tex instanceof ITextureFX)
{
((ITextureFX)tex).onTexturePackChanged(engine, texturepack, getTextureDimensions(tex));
}
}
FMLClientHandler.instance().loadTextures(texturepack);
}
private HashMap<Integer, Dimension> textureDims = new HashMap<Integer, Dimension>();
private IdentityHashMap<TextureFX, Integer> effectTextures = new IdentityHashMap<TextureFX, Integer>();
public void setTextureDimensions(int id, int width, int height, List<TextureFX> effects)
{
Dimension dim = new Dimension(width, height);
textureDims.put(id, dim);
for (TextureFX tex : effects)
{
if (getEffectTexture(tex) == id && tex instanceof ITextureFX)
{
((ITextureFX)tex).onTextureDimensionsUpdate(width, height);
}
}
}
public Dimension getTextureDimensions(TextureFX effect)
{
return getTextureDimensions(getEffectTexture(effect));
}
public Dimension getTextureDimensions(int id)
{
return textureDims.get(id);
}
public int getEffectTexture(TextureFX effect)
{
Integer id = effectTextures.get(effect);
if (id != null)
{
return id;
}
int old = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
effect.func_782_a(client.field_6315_n);
id = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
GL11.glBindTexture(GL_TEXTURE_2D, old);
effectTextures.put(effect, id);
return id;
}
public boolean onUpdateTextureEffect(TextureFX effect)
{
Logger log = FMLCommonHandler.instance().getFMLLogger();
ITextureFX ifx = (effect instanceof ITextureFX ? ((ITextureFX)effect) : null);
if (ifx != null && ifx.getErrored())
{
return false;
}
String name = effect.getClass().getSimpleName();
Profiler.func_40663_a(name);
try
{
if (optifineContainer == null)
{
effect.func_783_a();
}
}
catch (Exception e)
{
log.warning(String.format("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name));
if (ifx != null)
{
ifx.setErrored(true);
}
Profiler.func_40662_b();
return false;
}
Profiler.func_40662_b();
Dimension dim = getTextureDimensions(effect);
int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
if (effect.field_1127_a.length != target)
{
log.warning(String.format("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_1127_a.length, target));
if (ifx != null)
{
ifx.setErrored(true);
}
return false;
}
return true;
}
public void onPreRegisterEffect(TextureFX effect)
{
Dimension dim = getTextureDimensions(effect);
if (effect instanceof ITextureFX)
{
((ITextureFX)effect).onTextureDimensionsUpdate(dim.width, dim.height);
}
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.IFMLSidedHandler#getModLoaderPropertyFor(java.lang.reflect.Field)
*/
@Override
public ModProperty getModLoaderPropertyFor(Field f)
{
if (f.isAnnotationPresent(MLProp.class))
{
MLProp prop = f.getAnnotation(MLProp.class);
return new ModProperty(prop.info(), prop.min(), prop.max(), prop.name());
}
return null;
}
/**
* @param mods
*/
public void addSpecialModEntries(ArrayList<ModContainer> mods)
{
mods.add(new FMLModLoaderContainer());
if (optifineContainer!=null) {
mods.add(optifineContainer);
}
}
@Override
public List<String> getAdditionalBrandingInformation()
{
if (optifineContainer!=null)
{
return Arrays.asList(String.format("Optifine %s",optifineContainer.getVersion()));
} else {
return Collections.emptyList();
}
}
@Override
public Side getSide()
{
return Side.CLIENT;
}
@Override
public ProxyInjector findSidedProxyOn(cpw.mods.fml.common.modloader.BaseMod mod)
{
for (Field f : mod.getClass().getDeclaredFields())
{
if (f.isAnnotationPresent(SidedProxy.class))
{
SidedProxy sp = f.getAnnotation(SidedProxy.class);
return new ProxyInjector(sp.clientSide(), sp.serverSide(), sp.bukkitSide(), f);
}
}
return null;
}
}
|
package cpw.mods.fml.client;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.src.GuiButton;
import net.minecraft.src.Tessellator;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public abstract class GuiScrollingList
{
private final Minecraft client;
protected final int listWidth;
protected final int listHeight;
protected final int top;
protected final int bottom;
private final int right;
protected final int left;
protected final int slotHeight;
private int scrollUpActionId;
private int scrollDownActionId;
protected int mouseX;
protected int mouseY;
private float initialMouseClickY = -2.0F;
private float scrollFactor;
private float scrollDistance;
private int selectedIndex = -1;
private long lastClickTime = 0L;
private boolean field_25123_p = true;
private boolean field_27262_q;
private int field_27261_r;
public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)
{
this.client = client;
this.listWidth = width;
this.listHeight = height;
this.top = top;
this.bottom = bottom;
this.slotHeight = entryHeight;
this.left = left;
this.right = width + this.left;
}
public void func_27258_a(boolean p_27258_1_)
{
this.field_25123_p = p_27258_1_;
}
protected void func_27259_a(boolean p_27259_1_, int p_27259_2_)
{
this.field_27262_q = p_27259_1_;
this.field_27261_r = p_27259_2_;
if (!p_27259_1_)
{
this.field_27261_r = 0;
}
}
protected abstract int getSize();
protected abstract void elementClicked(int index, boolean doubleClick);
protected abstract boolean isSelected(int index);
protected int getContentHeight()
{
return this.getSize() * this.slotHeight + this.field_27261_r;
}
protected abstract void drawBackground();
protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5);
protected void func_27260_a(int p_27260_1_, int p_27260_2_, Tessellator p_27260_3_) {}
protected void func_27255_a(int p_27255_1_, int p_27255_2_) {}
protected void func_27257_b(int p_27257_1_, int p_27257_2_) {}
public int func_27256_c(int p_27256_1_, int p_27256_2_)
{
int var3 = this.listWidth / 2 - 110;
int var4 = this.listWidth / 2 + 110;
int var5 = p_27256_2_ - this.top - this.field_27261_r + (int)this.scrollDistance - 4;
int var6 = var5 / this.slotHeight;
return p_27256_1_ >= var3 && p_27256_1_ <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1;
}
public void registerScrollButtons(List p_22240_1_, int p_22240_2_, int p_22240_3_)
{
this.scrollUpActionId = p_22240_2_;
this.scrollDownActionId = p_22240_3_;
}
private void applyScrollLimits()
{
int var1 = this.getContentHeight() - (this.bottom - this.top - 4);
if (var1 < 0)
{
var1 /= 2;
}
if (this.scrollDistance < 0.0F)
{
this.scrollDistance = 0.0F;
}
if (this.scrollDistance > (float)var1)
{
this.scrollDistance = (float)var1;
}
}
public void actionPerformed(GuiButton button)
{
if (button.field_937_g)
{
if (button.field_938_f == this.scrollUpActionId)
{
this.scrollDistance -= (float)(this.slotHeight * 2 / 3);
this.initialMouseClickY = -2.0F;
this.applyScrollLimits();
}
else if (button.field_938_f == this.scrollDownActionId)
{
this.scrollDistance += (float)(this.slotHeight * 2 / 3);
this.initialMouseClickY = -2.0F;
this.applyScrollLimits();
}
}
}
public void drawScreen(int mouseX, int mouseY, float p_22243_3_)
{
this.mouseX = mouseX;
this.mouseY = mouseY;
this.drawBackground();
int listLength = this.getSize();
int scrollBarXStart = this.left + this.listWidth - 6;
int scrollBarXEnd = scrollBarXStart + 6;
int boxLeft = this.left;
int boxRight = scrollBarXStart-1;
int var10;
int var11;
int var13;
int var19;
if (Mouse.isButtonDown(0))
{
if (this.initialMouseClickY == -1.0F)
{
boolean var7 = true;
if (mouseY >= this.top && mouseY <= this.bottom)
{
var10 = mouseY - this.top - this.field_27261_r + (int)this.scrollDistance - 4;
var11 = var10 / this.slotHeight;
if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength)
{
boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L;
this.elementClicked(var11, var12);
this.selectedIndex = var11;
this.lastClickTime = System.currentTimeMillis();
}
else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0)
{
this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int)this.scrollDistance - 4);
var7 = false;
}
if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd)
{
this.scrollFactor = -1.0F;
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
if (var19 < 1)
{
var19 = 1;
}
var13 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight());
if (var13 < 32)
{
var13 = 32;
}
if (var13 > this.bottom - this.top - 8)
{
var13 = this.bottom - this.top - 8;
}
this.scrollFactor /= (float)(this.bottom - this.top - var13) / (float)var19;
}
else
{
this.scrollFactor = 1.0F;
}
if (var7)
{
this.initialMouseClickY = (float)mouseY;
}
else
{
this.initialMouseClickY = -2.0F;
}
}
else
{
this.initialMouseClickY = -2.0F;
}
}
else if (this.initialMouseClickY >= 0.0F)
{
this.scrollDistance -= ((float)mouseY - this.initialMouseClickY) * this.scrollFactor;
this.initialMouseClickY = (float)mouseY;
}
}
else
{
while (Mouse.next())
{
int var16 = Mouse.getEventDWheel();
if (var16 != 0)
{
if (var16 > 0)
{
var16 = -1;
}
else if (var16 < 0)
{
var16 = 1;
}
this.scrollDistance += (float)(var16 * this.slotHeight / 2);
}
}
this.initialMouseClickY = -1.0F;
}
this.applyScrollLimits();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_FOG);
Tessellator var18 = Tessellator.field_1512_a;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_6315_n.func_1070_a("/gui/background.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var17 = 32.0F;
var18.func_977_b();
var18.func_990_b(2105376);
var18.func_983_a((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
var18.func_983_a((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
var18.func_983_a((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
var18.func_983_a((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
var18.func_982_a();
// boxRight = this.listWidth / 2 - 92 - 16;
var10 = this.top + 4 - (int)this.scrollDistance;
if (this.field_27262_q)
{
this.func_27260_a(boxRight, var10, var18);
}
int var14;
for (var11 = 0; var11 < listLength; ++var11)
{
var19 = var10 + var11 * this.slotHeight + this.field_27261_r;
var13 = this.slotHeight - 4;
if (var19 <= this.bottom && var19 + var13 >= this.top)
{
if (this.field_25123_p && this.isSelected(var11))
{
var14 = boxLeft;
int var15 = boxRight;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
var18.func_977_b();
var18.func_990_b(8421504);
var18.func_983_a((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
var18.func_983_a((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D);
var18.func_990_b(0);
var18.func_983_a((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
var18.func_983_a((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D);
var18.func_982_a();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
this.drawSlot(var11, boxRight, var19, var13, var18);
}
}
GL11.glDisable(GL11.GL_DEPTH_TEST);
byte var20 = 4;
this.overlayBackground(0, this.top, 255, 255);
this.overlayBackground(this.bottom, this.listHeight, 255, 255);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D);
var18.func_977_b();
var18.func_6513_a(0, 0);
var18.func_983_a((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D);
var18.func_6513_a(0, 255);
var18.func_983_a((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D);
var18.func_982_a();
var18.func_977_b();
var18.func_6513_a(0, 255);
var18.func_983_a((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D);
var18.func_6513_a(0, 0);
var18.func_983_a((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D);
var18.func_982_a();
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
if (var19 > 0)
{
var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
if (var13 < 32)
{
var13 = 32;
}
if (var13 > this.bottom - this.top - 8)
{
var13 = this.bottom - this.top - 8;
}
var14 = (int)this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top;
if (var14 < this.top)
{
var14 = this.top;
}
var18.func_977_b();
var18.func_6513_a(0, 255);
var18.func_983_a((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D);
var18.func_983_a((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D);
var18.func_982_a();
var18.func_977_b();
var18.func_6513_a(8421504, 255);
var18.func_983_a((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D);
var18.func_983_a((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
var18.func_982_a();
var18.func_977_b();
var18.func_6513_a(12632256, 255);
var18.func_983_a((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
var18.func_983_a((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
var18.func_983_a((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D);
var18.func_983_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
var18.func_982_a();
}
this.func_27257_b(mouseX, mouseY);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
}
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_)
{
Tessellator var5 = Tessellator.field_1512_a;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_6315_n.func_1070_a("/gui/background.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var6 = 32.0F;
var5.func_977_b();
var5.func_6513_a(4210752, p_22239_4_);
var5.func_983_a(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6));
var5.func_983_a((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6));
var5.func_6513_a(4210752, p_22239_3_);
var5.func_983_a((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6));
var5.func_983_a(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6));
var5.func_982_a();
}
}
|
package io.spine.base;
import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.Timestamp;
import io.spine.annotation.Internal;
import javax.annotation.concurrent.ThreadSafe;
import java.time.Instant;
import java.time.ZoneId;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
/**
* Utilities for working with time information.
*/
public final class Time {
private static Provider timeProvider = SystemTimeProvider.INSTANCE;
/** Prevents instantiation of this utility class. */
private Time() {
}
/**
* Obtains current time via the current {@link Time.Provider}.
*
* @return current time
* @see #setProvider(Provider)
*/
public static synchronized Timestamp currentTime() {
Timestamp result = timeProvider.currentTime();
return result;
}
/**
* Obtains system time.
*
* <p>The values returned are guaranteed to be different for the consecutive calls in scope
* of a single JVM. This is achieved by incrementing the default system time millis
* by the emulated nanosecond value.
*
* <p>The nanoseconds are computed in a thread-safe incremental way starting at zero
* and ending by {@code 999 999}, leaving the millisecond value intact.
*
* <p>Unlike {@link #currentTime()}, this method <strong>always</strong> relies on the system
* milliseconds.
*
* @return current system time
*/
public static Timestamp systemTime() {
return SystemTimeProvider.INSTANCE.currentTime();
}
/**
* Obtains the current time zone ID.
*
* @return the {@link ZoneId} of the current time zone
*/
public static synchronized ZoneId currentTimeZone() {
return timeProvider.currentZone();
}
/**
* Sets provider of the current time.
*
* <p>The most common scenario for using this method is test cases of code that deals
* with current time.
*
* @param provider
* the provider to set
*/
@Internal
@VisibleForTesting
public static synchronized void setProvider(Provider provider) {
timeProvider = checkNotNull(provider);
}
/**
* Sets the default current time provider that obtains current time based on the system
* millis and the emulated nanosecond value.
*
* @see #systemTime() for more details
*/
public static synchronized void resetProvider() {
timeProvider = SystemTimeProvider.INSTANCE;
}
/**
* The provider of the current time.
*
* <p>Implement this interface and pass the resulting class to {@link #setProvider(Provider)}
* in order to change the {@link Time#currentTime()} results.
*/
@Internal
public interface Provider {
/**
* Obtains the current time in UTC.
*/
Timestamp currentTime();
/**
* Obtains the current time zone ID.
*
* @implSpec The default implementation uses the {@link ZoneId#systemDefault()}
* zone.
*/
default ZoneId currentZone() {
return ZoneId.systemDefault();
}
}
/**
* Default implementation of current time provider based on {@link Instant#now()} and
* the emulated nanosecond value.
*
* @see IncrementalNanos for more details on the nanosecond emulation
*/
@VisibleForTesting
static class SystemTimeProvider implements Provider {
public static final int NANOSECONDS_IN_MILLISECOND = 1_000_000;
@VisibleForTesting
static final Provider INSTANCE = new SystemTimeProvider();
/** Prevent instantiation from outside. */
private SystemTimeProvider() {
}
@Override
public Timestamp currentTime() {
long millis = System.currentTimeMillis();
long seconds = (millis / 1000);
int nanos = (int) (millis % 1000) * NANOSECONDS_IN_MILLISECOND;
int nanosOnly = IncrementalNanos.valueForTime(seconds, nanos);
Timestamp result = Timestamp
.newBuilder()
.setSeconds(seconds)
.setNanos(nanos + nanosOnly)
.build();
return result;
}
}
/**
* Provides an incremental value of nanoseconds for the local JVM.
*
* <p>In most cases, the JVM and underlying OS provides the millisecond-level precision at best.
* Therefore, the messages produced in such a virtual machine are often stamped
* with the same time value. However, most of the message-ordering routines require
* the distinct time values for proper work.
*
* <p>This class is designed to emulate the nanoseconds and provide incremental values
* for the consecutive calls.
*
* <p>Due to the limitations of the most storage engines, which round the time values to
* the nearest or the lowest microsecond, the nanosecond values produced by
* this class are incremented by {@code 1 000} nanoseconds, i.e. by {@code 1} microsecond
* per call.
*
* <p>The returned nanosecond value starts at {@code 0} and never exceeds {@code 999 999}.
* It is designed to keep the millisecond value provided by a typical-JVM system clock intact.
*
* <p>The nanosecond value is reset for each new passed {@code seconds} and {@code nanos}
* values.
* That allows to receive {@code 1 000} distinct time values per millisecond.
*
* <p>In case the upper bound of the nanos is reached, meaning that there were more than
* {@code 1 000} calls to this class within a millisecond, the nanosecond value is reset
* back to {@code 0}.
*/
@ThreadSafe
static final class IncrementalNanos {
private static final int MAX_VALUE = 1_000_000;
@SuppressWarnings("NumericCastThatLosesPrecision")
private static final int NANOS_PER_MICROSECOND = (int) MICROSECONDS.toNanos(1);
private static final IncrementalNanos instance = new IncrementalNanos();
private int counter;
private long previousSeconds;
private int previousNanos;
private synchronized int getNextValue(long seconds, int nanos) {
if (previousSeconds == seconds && previousNanos == nanos) {
counter += NANOS_PER_MICROSECOND;
counter = counter % MAX_VALUE;
} else {
counter = 0;
}
previousSeconds = seconds;
previousNanos = nanos;
return counter;
}
/**
* Obtains the next nanosecond value.
*/
static int valueForTime(long seconds, int nanos) {
return instance.getNextValue(seconds, nanos);
}
}
}
|
package jlibs.nblr.rules;
import java.util.*;
/**
* @author Santhosh Kumar T
*/
public class Paths extends ArrayList<Path>{
public final Path owner;
public final int depth;
public Paths(Path owner){
this.owner = owner;
if(owner!=null){
owner.children = this;
depth = owner.depth+1;
}else
depth = 1;
}
public boolean add(Path path){
if(owner==null)
path.branch = size();
else
path.branch = owner.branch;
path.parent = owner;
path.depth = depth;
return super.add(path);
}
public List<Path> leafs(){
List<Path> list = new ArrayList<Path>();
leafs(list);
return list;
}
private void leafs(List<Path> list){
for(Path path: this){
if(path.children==null)
list.add(path);
else
path.children.leafs(list);
}
}
@SuppressWarnings({"SimplifiableIfStatement"})
private static boolean clashes(Path p1, Path p2){
if(p1.matcher()==null && p2.matcher()==null)
throw new IllegalStateException("Ambiguous Routes: "+p1+" AND "+p2);
if(p1.matcher()!=null && p2.matcher()!=null){
if(p1.fallback() || p2.fallback())
return false;
else
return p1.clashesWith(p2);
}
return false;
}
public static Paths travel(Node fromNode){
Paths rootPaths = new Paths(null);
List<Path> list = new ArrayList<Path>();
while(true){
if(list.size()==0){
rootPaths.populate(fromNode, new ArrayDeque<Object>());
list.addAll(rootPaths);
}else{
List<Path> newList = new ArrayList<Path>();
for(Path path: list){
if(path.matcher()!=null){
Paths paths = new Paths(path);
paths.populate((Node)path.get(path.size()-1));
newList.addAll(paths);
}
}
list = newList;
}
TreeSet<Integer> clashingIndexes = new TreeSet<Integer>();
for(int ibranch=0; ibranch<rootPaths.size()-1; ibranch++){
for(int jbranch=ibranch+1; jbranch<rootPaths.size(); jbranch++){
int i = 0;
for(Path ipath: list){
if(ipath.branch==ibranch){
int j = 0;
for(Path jpath: list){
if(jpath.branch==jbranch){
if(clashes(ipath, jpath)){
if(ipath.hasLoop() && jpath.hasLoop())
throw new IllegalStateException("Infinite lookAhead needed: "+ipath+" and "+jpath);
clashingIndexes.add(i);
clashingIndexes.add(j);
}
}
j++;
}
}
i++;
}
}
}
if(clashingIndexes.size()==0)
return rootPaths;
List<Path> clashingPaths = new ArrayList<Path>(clashingIndexes.size());
for(int id: clashingIndexes)
clashingPaths.add(list.get(id));
list = clashingPaths;
}
}
private void populate(Node fromNode){
populate(fromNode, new ArrayDeque<Object>());
}
private void populate(Node fromNode, Deque<Object> stack){
if(stack.contains(fromNode))
throw new IllegalStateException("infinite loop detected");
stack.push(fromNode);
if(fromNode.outgoing.size()>0){
for(Edge edge: fromNode.outgoing){
stack.push(edge);
if(edge.matcher!=null){
stack.push(edge.target);
add(new Path(stack));
stack.pop();
}else if(edge.ruleTarget!=null)
populate(edge.ruleTarget.node(), stack);
else
populate(edge.target, stack);
stack.pop();
}
}else{
int rulesPopped = 0;
boolean wasNode = false;
Node target = null;
for(Object obj: stack){
if(obj instanceof Node){
if(wasNode)
rulesPopped++;
wasNode = true;
}else if(obj instanceof Edge){
wasNode = false;
Edge edge = (Edge)obj;
if(edge.ruleTarget!=null){
if(rulesPopped==0){
target = edge.target;
break;
}else
rulesPopped
}
}
}
Path p = this.owner;
while(p!=null && target==null){
wasNode = false;
for(int i=p.size()-1; i>=0; i
Object obj = p.get(i);
if(obj instanceof Node){
if(wasNode)
rulesPopped++;
wasNode = true;
}else if(obj instanceof Edge){
wasNode = false;
Edge edge = (Edge)obj;
if(edge.ruleTarget!=null){
if(rulesPopped==0){
target = edge.target;
break;
}else
rulesPopped
}
}
}
p = p.parent;
}
if(target==null){
add(new Path(stack));
}else
populate(target, stack);
}
stack.pop();
}
}
|
package properties.competition;
import static structure.impl.other.Quantification.FORALL;
import properties.Property;
import properties.PropertyMaker;
import properties.papers.DaCapo;
import properties.papers.HasNextQEA;
import structure.intf.Assignment;
import structure.intf.Guard;
import structure.intf.QEA;
import creation.QEABuilder;
public class JavaMOP implements PropertyMaker {
@Override
public QEA make(Property property) {
switch (property) {
case JAVAMOP_ONE:
return makeOne();
case JAVAMOP_TWO:
return makeTwo();
case JAVAMOP_THREE:
return makeThree();
case JAVAMOP_FOUR:
return makeFour();
}
return null;
}
public QEA makeOne() {
// This is just the HasNext property we know and love
QEA qea = new HasNextQEA();
qea.setName("JAVAMOP_ONE");
return qea;
}
public QEA makeTwo() {
/*
* Note - this has a disjoint alphabet, we should implement this
* optimisation!
*/
QEABuilder q = new QEABuilder("JAVAMOP_TWO");
int LOCK = 1;
int UNLOCK = 2;
int thread = -1;
int lock = -2;
int count = 1;
q.addQuantification(FORALL, thread);
q.addQuantification(FORALL, lock);
q.addTransition(1, LOCK, new int[] { thread, lock },
Assignment.setVal(count, 1), 2);
q.addTransition(2, LOCK, new int[] { thread, lock },
Assignment.increment(count), 2);
q.addTransition(2, UNLOCK, new int[] { thread, lock },
Guard.isGreaterThanConstant(count, 1),
Assignment.decrement(count), 2);
q.addTransition(2, UNLOCK, new int[] { thread, lock },
Guard.isSemEqualToConstant(count, 1),
Assignment.setVal(count, 0), 1);
q.addFinalStates(1);
QEA qea = q.make();
qea.record_event_name("lock", LOCK);
qea.record_event_name("unlock", UNLOCK);
return qea;
}
public QEA makeThree() {
QEABuilder q = new QEABuilder("JAVAMOP_THREE");
int A = 1;
int B = 2;
int C = 3;
int a = 1;
int b = 2;
int c = 3;
// If we move away from state 1 they are no longer equal
q.addTransition(
1,
A,
Assignment.list(Assignment.incrementOrSet(a),
Assignment.ensure(b, 0),
Assignment.ensure(c, 0)), 2);
q.addTransition(
1,
B,
Assignment.list(Assignment.incrementOrSet(b),
Assignment.ensure(a, 0),
Assignment.ensure(c, 0)), 2);
q.addTransition(
1,
C,
Assignment.list(Assignment.incrementOrSet(c),
Assignment.ensure(a, 0),
Assignment.ensure(b, 0)), 2);
// If we are one less than the two others then we go to state 1
q.addTransition(
2,
A,
Guard.and(Guard.differenceEqualToVal(b, a, 1),
Guard.differenceEqualToVal(c, a, 1)),
Assignment.increment(a), 1);
q.addTransition(
2,
B,
Guard.and(Guard.differenceEqualToVal(a, b, 1),
Guard.differenceEqualToVal(c, b, 1)),
Assignment.increment(b), 1);
q.addTransition(
2,
C,
Guard.and(Guard.differenceEqualToVal(a, c, 1),
Guard.differenceEqualToVal(b, c, 1)),
Assignment.increment(c), 1);
// Otherwise we stay still and increment
q.addTransition(
2,
A,
Guard.or(Guard.differenceNotEqualToVal(b, a, 1),
Guard.differenceNotEqualToVal(c, a, 1)),
Assignment.increment(a), 2);
q.addTransition(
2,
B,
Guard.or(Guard.differenceNotEqualToVal(a, b, 1),
Guard.differenceNotEqualToVal(c, b, 1)),
Assignment.increment(b), 2);
q.addTransition(
2,
C,
Guard.or(Guard.differenceNotEqualToVal(a, c, 1),
Guard.differenceNotEqualToVal(b, c, 1)),
Assignment.increment(c), 2);
q.addFinalStates(1);
QEA qea = q.make();
qea.record_event_name("a", A);
qea.record_event_name("b", B);
qea.record_event_name("c", C);
return qea;
}
public QEA makeFour() {
QEA qea = DaCapo.makeUnsafeMapIter();
qea.setName("JAVAMOP_FOUR");
return qea;
}
}
|
package structure.impl;
import monitoring.impl.configs.NonDetConfig;
/**
* This class represents a simple Quantified Event Automaton (QEA) with the
* following characteristics:
* <ul>
* <li>There is at most one quantified variable
* <li>The transitions in the function delta consist of a start state, an event
* and a set of end states, no guards or assigns are considered
* <li>The QEA can is non-deterministic
* </ul>
*
* @author Helena Cuenca
* @author Giles Reger
*/
public class SimpleNonDetQEA extends SimpleQEA {
private int[][][] delta;
public SimpleNonDetQEA(int numStates, int numEvents, int initialState,
Quantification quantification) {
super(numStates, initialState, quantification);
delta = new int[numStates + 1][numEvents + 1][];
}
/**
* Adds a transition to the transition function delta of this QEA
*
* @param startState
* Start state for the transition
* @param event
* Name of the event
* @param endState
* End state for the transition
*/
public void addTransition(int startState, int event, int endState) {
if (delta[startState][event] == null) {
delta[startState][event] = new int[] { endState };
} else {
// Resize end states array
int[] newEndStates = new int[delta[startState][event].length + 1];
System.arraycopy(delta[startState][event], 0, newEndStates, 0,
delta[startState][event].length);
newEndStates[delta[startState][event].length] = endState;
delta[startState][event] = newEndStates;
}
}
/**
* Adds a set of transitions to the transition function delta of this QEA
*
* @param startState
* Start state for the transition
* @param event
* Name of the event
* @param endStates
* Array of end states for the transition
*/
public void addTransitions(int startState, int event, int[] endStates) {
// TODO Most methods addTransition(s) contain the same logic
if (delta[startState][event] == null) {
delta[startState][event] = endStates;
} else {
// Resize transitions array
int prevTransCount = delta[startState][event].length;
int[] newEndStates = new int[prevTransCount + endStates.length];
System.arraycopy(delta[startState][event], 0, newEndStates, 0,
delta[startState][event].length);
System.arraycopy(endStates, 0, newEndStates, prevTransCount,
endStates.length);
delta[startState][event] = newEndStates;
}
}
/**
* Retrieves the final configuration for a given start configuration and an
* event, according to the transition function delta of this QEA
*
* @param config
* Start configuration containing the set of start states
* @param event
* Name of the event
* @return End configuration containing the set of end states
*/
public NonDetConfig getNextConfig(NonDetConfig config, int event) {
if (config.getStates().length == 1) { // Only one state in the start
// configuration
config.setStates(delta[config.getStates()[0]][event]);
} else { // More than one state in the start configuration
// Get a reference to the start states
int[] startStates = config.getStates();
// Create a boolean array of size equal to the number of states
boolean[] endStatesBool = new boolean[delta.length];
// Initialise end states count
int endStatesCount = 0;
// Iterate over the multiple arrays of end states
for (int startState : startStates) {
int[] intermEndStates = delta[startState][event];
if (intermEndStates != null) {
// Iterate over the intermediate arrays of end states
for (int intermEndState : intermEndStates) {
if (!endStatesBool[intermEndState]) {
endStatesBool[intermEndState] = true;
endStatesCount++;
}
}
}
}
// System.out.println("endStatesBool: "+java.util.Arrays.toString(endStatesBool));
// Remove state 0 if there are other end states
// Because state 0 is the failure state, and can be safely removed
if (endStatesBool[0] && endStatesCount > 1) {
endStatesBool[0] = false;
endStatesCount
}
int[] endStates;
// Check if the number of end states is the same as start states
if (endStatesCount == startStates.length) { // Same size
// Use the same array
endStates = startStates;
} else { // Different number of start states and end states
// Create a new array with the right size
endStates = new int[endStatesCount];
}
// Populate array of end states
int j = 0;
for (int i = 0; i < endStatesBool.length; i++) {
if (endStatesBool[i]) {
endStates[j] = i;
j++;
}
}
config.setStates(endStates);
}
return config;
}
/**
* Determines if the set of states in the specified configuration contains
* at least one final state
*
* @param config
* Configuration encapsulating the set of states to be checked
* @return <code>true</code> if the set of states in the specified
* configuration contains at least one final state;
* <code>false</code> otherwise
*/
public boolean containsFinalState(NonDetConfig config) {
for (int i = 0; i < config.getStates().length; i++) {
if (isStateFinal(config.getStates()[i])) {
return true;
}
}
return false;
}
@Override
public int[] getEventsAlphabet() {
int[] a = new int[delta[0].length - 1];
for (int i = 0; i < a.length; i++) {
a[i] = i + 1;
}
return a;
}
@Override
public boolean isDeterministic() {
return false;
}
}
|
package v2.core;
import io.networkreaders.exceptions.InvalidPolicyTagException;
/**
* The policy interface provides the necessary methods to define a routing policy. Policy must be immutable classes
* otherwise there might be some unexpected behaviour.
*/
public interface Policy {
/**
* Creates a self attribute.
*
* @return instance of a self attribute implementation.
*/
Attribute createSelf();
/**
* Creates a label for this policy based on the string tag given.
*
* @param tag tag that defines the label to be created.
* @return label instance according to the string tag.
*/
Label createLabel(String tag) throws InvalidPolicyTagException;
}
|
// Dataset.java
package imagej.data;
import imagej.data.event.DatasetChangedEvent;
import imagej.data.event.DatasetCreatedEvent;
import imagej.data.event.DatasetDeletedEvent;
import imagej.event.Events;
import imagej.util.Log;
import imagej.util.Rect;
import net.imglib2.Cursor;
import net.imglib2.RandomAccess;
import net.imglib2.display.ColorTable16;
import net.imglib2.display.ColorTable8;
import net.imglib2.img.Axis;
import net.imglib2.img.Img;
import net.imglib2.img.ImgPlus;
import net.imglib2.img.Metadata;
import net.imglib2.img.basictypeaccess.PlanarAccess;
import net.imglib2.img.basictypeaccess.array.ArrayDataAccess;
import net.imglib2.img.basictypeaccess.array.ByteArray;
import net.imglib2.img.basictypeaccess.array.DoubleArray;
import net.imglib2.img.basictypeaccess.array.FloatArray;
import net.imglib2.img.basictypeaccess.array.IntArray;
import net.imglib2.img.basictypeaccess.array.LongArray;
import net.imglib2.img.basictypeaccess.array.ShortArray;
import net.imglib2.img.planar.PlanarImg;
import net.imglib2.img.planar.PlanarImgFactory;
import net.imglib2.type.NativeType;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.IntegerType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.ByteType;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.type.numeric.integer.LongType;
import net.imglib2.type.numeric.integer.ShortType;
import net.imglib2.type.numeric.integer.Unsigned12BitType;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.type.numeric.integer.UnsignedIntType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.type.numeric.real.FloatType;
/**
* Dataset is the primary image data structure in ImageJ. A Dataset wraps an
* ImgLib {@link ImgPlus}. It also provides a number of convenience methods,
* such as the ability to access pixels on a plane-by-plane basis, and create
* new Datasets of various types easily.
*
* @author Curtis Rueden
* @author Barry DeZonia
*/
public class Dataset implements Comparable<Dataset>, Metadata {
private ImgPlus<? extends RealType<?>> imgPlus;
private boolean rgbMerged;
// FIXME TEMP - the current selection for this Dataset. Temporarily located
// here for plugin testing purposes. Really should be viewcentric.
private Rect selection;
public void setSelection(final int minX, final int minY, final int maxX,
final int maxY)
{
selection.x = minX;
selection.y = minY;
selection.width = maxX - minX + 1;
selection.height = maxY - minY + 1;
}
public Rect getSelection() {
return selection;
}
// END FIXME TEMP
public Dataset(final ImgPlus<? extends RealType<?>> imgPlus) {
this.imgPlus = imgPlus;
rgbMerged = false;
selection = new Rect();
Events.publish(new DatasetCreatedEvent(this));
}
/**
* For use in legacy layer only, this flag allows the various legacy layer
* image translators to support color images correctly.
*/
public void setRGBMerged(final boolean rgbMerged) {
this.rgbMerged = rgbMerged;
}
/**
* For use in legacy layer only, this flag allows the various legacy layer
* image translators to support color images correctly.
*/
public boolean isRGBMerged() {
return rgbMerged;
}
public ImgPlus<? extends RealType<?>> getImgPlus() {
return imgPlus;
}
public void setImgPlus(final ImgPlus<? extends RealType<?>> imgPlus) {
if (this.imgPlus.numDimensions() != imgPlus.numDimensions()) {
throw new IllegalArgumentException("Invalid dimensionality: expected " +
this.imgPlus.numDimensions() + " but was " + imgPlus.numDimensions());
}
this.imgPlus = imgPlus;
// NB - keeping all the old metadata for now. TODO - revisit this?
// NB - keeping isRgbMerged status for now. TODO - revisit this?
selection = new Rect();
update();
}
/** Gets the dimensional extents of the dataset. */
public long[] getDims() {
final long[] dims = new long[imgPlus.numDimensions()];
imgPlus.dimensions(dims);
return dims;
}
/** Gets the dimensional extents of the dataset. */
public Axis[] getAxes() {
final Axis[] axes = new Axis[imgPlus.numDimensions()];
axes(axes);
return axes;
}
public Object getPlane(final int no) {
final Img<? extends RealType<?>> img = imgPlus.getImg();
if (!(img instanceof PlanarAccess)) return null;
// TODO - extract a copy the plane if it cannot be obtained by reference
final PlanarAccess<?> planarAccess = (PlanarAccess<?>) img;
final Object plane = planarAccess.getPlane(no);
if (!(plane instanceof ArrayDataAccess)) return null;
return ((ArrayDataAccess<?>) plane).getCurrentStorageArray();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setPlane(final int no, final Object plane) {
final Img<? extends RealType<?>> img = imgPlus.getImg();
if (!(img instanceof PlanarAccess)) {
// cannot set by reference
Log.error("Cannot set plane for non-planar image");
return;
}
// TODO - copy the plane if it cannot be set by reference
final PlanarAccess planarAccess = (PlanarAccess) img;
ArrayDataAccess<?> array = null;
if (plane instanceof byte[]) {
array = new ByteArray((byte[]) plane);
}
else if (plane instanceof short[]) {
array = new ShortArray((short[]) plane);
}
else if (plane instanceof int[]) {
array = new IntArray((int[]) plane);
}
else if (plane instanceof float[]) {
array = new FloatArray((float[]) plane);
}
else if (plane instanceof long[]) {
array = new LongArray((long[]) plane);
}
else if (plane instanceof double[]) {
array = new DoubleArray((double[]) plane);
}
planarAccess.setPlane(no, array);
}
public double getDoubleValue(final long[] pos) {
// NB: This method is slow... will change anyway with ImgLib2.
final RandomAccess<? extends RealType<?>> cursor = imgPlus.randomAccess();
cursor.setPosition(pos);
final double value = cursor.get().getRealDouble();
return value;
}
public RealType<?> getType() {
return imgPlus.firstElement();
}
public boolean isSigned() {
return getType().getMinValue() < 0;
}
public boolean isInteger() {
return getType() instanceof IntegerType;
}
/** Gets a string description of the dataset's pixel type. */
public String getTypeLabel() {
if (isRGBMerged()) return "RGB";
final int bitsPerPixel = getType().getBitsPerPixel();
final String category =
isInteger() ? isSigned() ? "signed" : "unsigned" : "real";
return bitsPerPixel + "-bit (" + category + ")";
}
/** Creates a copy of the dataset. */
public Dataset duplicate() {
final Dataset d = duplicateBlank();
copyInto(d);
return d;
}
/** Creates a copy of the dataset, but without copying any pixel values. */
@SuppressWarnings({ "rawtypes", "unchecked" })
public Dataset duplicateBlank() {
final ImgPlus untypedImg = imgPlus;
final Dataset d = new Dataset(createBlankCopy(untypedImg));
d.setRGBMerged(isRGBMerged());
return d;
}
/** Copies the dataset's pixels into the given target dataset. */
public void copyInto(final Dataset target) {
final Cursor<? extends RealType<?>> in = imgPlus.localizingCursor();
final RandomAccess<? extends RealType<?>> out =
target.getImgPlus().randomAccess();
final long[] position = new long[imgPlus.numDimensions()];
while (in.hasNext()) {
in.next();
final double value = in.get().getRealDouble();
in.localize(position);
out.setPosition(position);
out.get().setReal(value);
}
}
/** Informs interested parties that the dataset has changed somehow. */
public void update() {
Events.publish(new DatasetChangedEvent(this));
}
/**
* Deletes the given dataset, cleaning up resources and removing it from the
* object manager.
*/
public void delete() {
Events.publish(new DatasetDeletedEvent(this));
}
@Override
public String toString() {
return imgPlus.getName();
}
// -- Comparable methods --
@Override
public int compareTo(final Dataset dataset) {
return imgPlus.getName().compareTo(dataset.imgPlus.getName());
}
// -- Metadata methods --
@Override
public String getName() {
return imgPlus.getName();
}
@Override
public void setName(final String name) {
imgPlus.setName(name);
}
@Override
public int getAxisIndex(final Axis axis) {
return imgPlus.getAxisIndex(axis);
}
@Override
public Axis axis(final int d) {
return imgPlus.axis(d);
}
@Override
public void axes(final Axis[] axes) {
imgPlus.axes(axes);
}
@Override
public void setAxis(final Axis axis, final int d) {
imgPlus.setAxis(axis, d);
}
@Override
public double calibration(final int d) {
return imgPlus.calibration(d);
}
@Override
public void calibration(final double[] cal) {
imgPlus.calibration(cal);
}
@Override
public void setCalibration(final double cal, final int d) {
imgPlus.setCalibration(cal, d);
}
@Override
public int getValidBits() {
return imgPlus.getValidBits();
}
@Override
public void setValidBits(final int bits) {
imgPlus.setValidBits(bits);
}
@Override
public int getCompositeChannelCount() {
return imgPlus.getCompositeChannelCount();
}
@Override
public void setCompositeChannelCount(final int count) {
imgPlus.setCompositeChannelCount(count);
}
@Override
public ColorTable8 getColorTable8(final int no) {
return imgPlus.getColorTable8(no);
}
@Override
public void setColorTable(final ColorTable8 lut, final int no) {
imgPlus.setColorTable(lut, no);
}
@Override
public ColorTable16 getColorTable16(int no) {
return imgPlus.getColorTable16(no);
}
@Override
public void setColorTable(ColorTable16 lut, int no) {
imgPlus.setColorTable(lut, no);
}
@Override
public void setColorTableCount(final int count) {
imgPlus.setColorTableCount(count);
}
// -- Utility methods --
public static Dataset create(final long[] dims, final String name,
final Axis[] axes, final int bitsPerPixel, final boolean signed,
final boolean floating)
{
if (bitsPerPixel == 1) {
if (signed || floating) invalidParams(bitsPerPixel, signed, floating);
return create(new BitType(), dims, name, axes);
}
if (bitsPerPixel == 8) {
if (floating) invalidParams(bitsPerPixel, signed, floating);
if (signed) return create(new ByteType(), dims, name, axes);
return create(new UnsignedByteType(), dims, name, axes);
}
if (bitsPerPixel == 12) {
if (signed || floating) invalidParams(bitsPerPixel, signed, floating);
return create(new Unsigned12BitType(), dims, name, axes);
}
if (bitsPerPixel == 16) {
if (floating) invalidParams(bitsPerPixel, signed, floating);
if (signed) return create(new ShortType(), dims, name, axes);
return create(new UnsignedShortType(), dims, name, axes);
}
if (bitsPerPixel == 32) {
if (floating) {
if (!signed) invalidParams(bitsPerPixel, signed, floating);
return create(new FloatType(), dims, name, axes);
}
if (signed) return create(new IntType(), dims, name, axes);
return create(new UnsignedIntType(), dims, name, axes);
}
if (bitsPerPixel == 64) {
if (!signed) invalidParams(bitsPerPixel, signed, floating);
if (floating) return create(new DoubleType(), dims, name, axes);
return create(new LongType(), dims, name, axes);
}
invalidParams(bitsPerPixel, signed, floating);
return null;
}
/**
* Creates a new dataset.
*
* @param <T> The type of the dataset.
* @param type The type of the dataset.
* @param dims The dataset's dimensional extents.
* @param name The dataset's name.
* @param axes The dataset's dimensional axis labels.
* @return The newly created dataset.
*/
public static <T extends RealType<T> & NativeType<T>> Dataset create(
final T type, final long[] dims, final String name, final Axis[] axes)
{
final PlanarImgFactory<T> imgFactory = new PlanarImgFactory<T>();
final PlanarImg<T, ?> planarImg = imgFactory.create(dims, type);
final ImgPlus<T> imgPlus = new ImgPlus<T>(planarImg, name, axes, null);
return new Dataset(imgPlus);
}
// -- Helper methods --
private static void invalidParams(final int bitsPerPixel,
final boolean signed, final boolean floating)
{
throw new IllegalArgumentException("Invalid parameters: bitsPerPixel=" +
bitsPerPixel + ", signed=" + signed + ", floating=" + floating);
}
/** Makes an image that has same type, container, and dimensions as refImage. */
private static <T extends RealType<T>> ImgPlus<T> createBlankCopy(
final ImgPlus<T> img)
{
final long[] dimensions = new long[img.numDimensions()];
img.dimensions(dimensions);
final Img<T> blankImg =
img.factory().create(dimensions, img.firstElement());
return new ImgPlus<T>(blankImg, img);
}
}
|
package net.i2p.client;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import net.i2p.I2PAppContext;
import net.i2p.data.DataFormatException;
import net.i2p.data.Destination;
import net.i2p.data.Hash;
import net.i2p.data.LeaseSet;
import net.i2p.data.PrivateKey;
import net.i2p.data.SessionKey;
import net.i2p.data.SessionTag;
import net.i2p.data.SigningPrivateKey;
import net.i2p.data.i2cp.GetDateMessage;
import net.i2p.data.i2cp.I2CPMessage;
import net.i2p.data.i2cp.I2CPMessageException;
import net.i2p.data.i2cp.I2CPMessageReader;
import net.i2p.data.i2cp.MessagePayloadMessage;
import net.i2p.data.i2cp.SessionId;
import net.i2p.util.I2PThread;
import net.i2p.util.InternalSocket;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
/**
* Implementation of an I2P session running over TCP. This class is NOT thread safe -
* only one thread should send messages at any given time
*
* @author jrandom
*/
abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessageEventListener {
protected Log _log;
/** who we are */
private Destination _myDestination;
/** private key for decryption */
private PrivateKey _privateKey;
/** private key for signing */
private SigningPrivateKey _signingPrivateKey;
/** configuration options */
private Properties _options;
/** this session's Id */
private SessionId _sessionId;
/** currently granted lease set, or null */
private LeaseSet _leaseSet;
/** hostname of router */
protected String _hostname;
/** port num to router */
protected int _portNum;
/** socket for comm */
protected Socket _socket;
/** reader that always searches for messages */
protected I2CPMessageReader _reader;
/** writer message queue */
protected ClientWriterRunner _writer;
/** where we pipe our messages */
protected /* FIXME final FIXME */OutputStream _out;
/** who we send events to */
protected I2PSessionListener _sessionListener;
/** class that generates new messages */
protected I2CPMessageProducer _producer;
/** map of Long --> MessagePayloadMessage */
protected Map<Long, MessagePayloadMessage> _availableMessages;
protected I2PClientMessageHandlerMap _handlerMap;
/** used to seperate things out so we can get rid of singletons */
protected I2PAppContext _context;
/** monitor for waiting until a lease set has been granted */
private final Object _leaseSetWait = new Object();
/** whether the session connection has already been closed (or not yet opened) */
protected boolean _closed;
/** whether the session connection is in the process of being closed */
protected boolean _closing;
/** have we received the current date from the router yet? */
private boolean _dateReceived;
/** lock that we wait upon, that the SetDateMessageHandler notifies */
private final Object _dateReceivedLock = new Object();
/** whether the session connection is in the process of being opened */
protected boolean _opening;
/** monitor for waiting until opened */
private final Object _openingWait = new Object();
/**
* thread that we tell when new messages are available who then tells us
* to fetch them. The point of this is so that the fetch doesn't block the
* reading of other messages (in turn, potentially leading to deadlock)
*
*/
protected AvailabilityNotifier _availabilityNotifier;
private long _lastActivity;
private boolean _isReduced;
void dateUpdated() {
_dateReceived = true;
synchronized (_dateReceivedLock) {
_dateReceivedLock.notifyAll();
}
}
public static final int LISTEN_PORT = 7654;
/** for extension */
public I2PSessionImpl() {}
/**
* Create a new session, reading the Destination, PrivateKey, and SigningPrivateKey
* from the destKeyStream, and using the specified options to connect to the router
*
* @throws I2PSessionException if there is a problem loading the private keys or
*/
public I2PSessionImpl(I2PAppContext context, InputStream destKeyStream, Properties options) throws I2PSessionException {
_context = context;
_log = context.logManager().getLog(I2PSessionImpl.class);
_handlerMap = new I2PClientMessageHandlerMap(context);
_closed = true;
_opening = false;
_closing = false;
_producer = new I2CPMessageProducer(context);
_availabilityNotifier = new AvailabilityNotifier();
_availableMessages = new ConcurrentHashMap();
try {
readDestination(destKeyStream);
} catch (DataFormatException dfe) {
throw new I2PSessionException("Error reading the destination key stream", dfe);
} catch (IOException ioe) {
throw new I2PSessionException("Error reading the destination key stream", ioe);
}
if (options == null)
options = System.getProperties();
loadConfig(options);
_sessionId = null;
_leaseSet = null;
}
/**
* Parse the config for anything we know about.
* Also fill in the authorization properties if missing.
*/
protected void loadConfig(Properties options) {
_options = new Properties();
_options.putAll(filter(options));
_hostname = _options.getProperty(I2PClient.PROP_TCP_HOST, "127.0.0.1");
String portNum = _options.getProperty(I2PClient.PROP_TCP_PORT, LISTEN_PORT + "");
try {
_portNum = Integer.parseInt(portNum);
} catch (NumberFormatException nfe) {
if (_log.shouldLog(Log.WARN))
_log.warn(getPrefix() + "Invalid port number specified, defaulting to "
+ LISTEN_PORT, nfe);
_portNum = LISTEN_PORT;
}
// auto-add auth if required, not set in the options, and we are in the same JVM
if (_context.isRouterContext() &&
Boolean.valueOf(_context.getProperty("i2cp.auth")).booleanValue() &&
((!options.containsKey("i2cp.username")) || (!options.containsKey("i2cp.password")))) {
String configUser = _context.getProperty("i2cp.username");
String configPW = _context.getProperty("i2cp.password");
if (configUser != null && configPW != null) {
_options.setProperty("i2cp.username", configUser);
_options.setProperty("i2cp.password", configPW);
}
}
}
private Properties filter(Properties options) {
Properties rv = new Properties();
for (Iterator iter = options.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
String val = options.getProperty(key);
if (key.startsWith("java") ||
key.startsWith("user") ||
key.startsWith("os") ||
key.startsWith("sun") ||
key.startsWith("file") ||
key.startsWith("line") ||
key.startsWith("wrapper")) {
if (_log.shouldLog(Log.DEBUG)) _log.debug("Skipping property: " + key);
} else if ((key.length() > 255) || (val.length() > 255)) {
if (_log.shouldLog(Log.WARN))
_log.warn(getPrefix() + "Not passing on property ["
+ key
+ "] in the session configuration as the value is too long (max = 255): "
+ val);
} else {
rv.setProperty(key, val);
}
}
return rv;
}
void setLeaseSet(LeaseSet ls) {
_leaseSet = ls;
if (ls != null) {
synchronized (_leaseSetWait) {
_leaseSetWait.notifyAll();
}
}
}
LeaseSet getLeaseSet() {
return _leaseSet;
}
void setOpening(boolean ls) {
_opening = ls;
synchronized (_openingWait) {
_openingWait.notifyAll();
}
}
boolean getOpening() {
return _opening;
}
/**
* Load up the destKeyFile for our Destination, PrivateKey, and SigningPrivateKey
*
* @throws DataFormatException if the file is in the wrong format or keys are invalid
* @throws IOException if there is a problem reading the file
*/
private void readDestination(InputStream destKeyStream) throws DataFormatException, IOException {
_myDestination = new Destination();
_privateKey = new PrivateKey();
_signingPrivateKey = new SigningPrivateKey();
_myDestination.readBytes(destKeyStream);
_privateKey.readBytes(destKeyStream);
_signingPrivateKey.readBytes(destKeyStream);
}
/**
* Connect to the router and establish a session. This call blocks until
* a session is granted.
*
* @throws I2PSessionException if there is a configuration error or the router is
* not reachable
*/
public void connect() throws I2PSessionException {
setOpening(true);
_closed = false;
_availabilityNotifier.stopNotifying();
I2PThread notifier = new I2PThread(_availabilityNotifier);
notifier.setName("Notifier " + _myDestination.calculateHash().toBase64().substring(0,4));
notifier.setDaemon(true);
notifier.start();
if ( (_options != null) &&
(I2PClient.PROP_RELIABILITY_GUARANTEED.equals(_options.getProperty(I2PClient.PROP_RELIABILITY, I2PClient.PROP_RELIABILITY_BEST_EFFORT))) ) {
if (_log.shouldLog(Log.ERROR))
_log.error("I2CP guaranteed delivery mode has been removed, using best effort.");
}
long startConnect = _context.clock().now();
try {
// If we are in the router JVM, connect using the interal pseudo-socket
_socket = InternalSocket.getSocket(_hostname, _portNum);
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
_out = _socket.getOutputStream();
synchronized (_out) {
_out.write(I2PClient.PROTOCOL_BYTE);
_out.flush();
}
_writer = new ClientWriterRunner(_out, this);
InputStream in = _socket.getInputStream();
_reader = new I2CPMessageReader(in, this);
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "before startReading");
_reader.startReading();
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Before getDate");
sendMessage(new GetDateMessage());
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After getDate / begin waiting for a response");
int waitcount = 0;
while (!_dateReceived) {
if (waitcount++ > 30) {
closeSocket();
throw new IOException("no date handshake");
}
try {
synchronized (_dateReceivedLock) {
_dateReceivedLock.wait(1000);
}
} catch (InterruptedException ie) { // nop
}
}
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After received a SetDate response");
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Before producer.connect()");
_producer.connect(this);
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After producer.connect()");
// wait until we have created a lease set
waitcount = 0;
while (_leaseSet == null) {
if (waitcount++ > 5*60) {
try {
_producer.disconnect(this);
} catch (I2PSessionException ipe) {}
closeSocket();
throw new IOException("no leaseset");
}
synchronized (_leaseSetWait) {
try {
_leaseSetWait.wait(1000);
} catch (InterruptedException ie) { // nop
}
}
}
long connected = _context.clock().now();
if (_log.shouldLog(Log.INFO))
_log.info(getPrefix() + "Lease set created with inbound tunnels after "
+ (connected - startConnect)
+ "ms - ready to participate in the network!");
startIdleMonitor();
setOpening(false);
} catch (UnknownHostException uhe) {
_closed = true;
setOpening(false);
throw new I2PSessionException(getPrefix() + "Invalid session configuration", uhe);
} catch (IOException ioe) {
_closed = true;
setOpening(false);
throw new I2PSessionException(getPrefix() + "Problem connecting to " + _hostname + " on port " + _portNum, ioe);
}
}
/**
* Pull the unencrypted data from the message that we've already prefetched and
* notified the user that its available.
*
*/
public byte[] receiveMessage(int msgId) throws I2PSessionException {
MessagePayloadMessage msg = _availableMessages.remove(new Long(msgId));
if (msg == null) {
_log.error("Receive message " + msgId + " had no matches");
return null;
}
updateActivity();
return msg.getPayload().getUnencryptedData();
}
/**
* Report abuse with regards to the given messageId
*/
public void reportAbuse(int msgId, int severity) throws I2PSessionException {
if (isClosed()) throw new I2PSessionException(getPrefix() + "Already closed");
_producer.reportAbuse(this, msgId, severity);
}
/**
* Send the data to the destination.
* TODO: this currently always returns true, regardless of whether the message was
* delivered successfully. make this wait for at least ACCEPTED
*
*/
public abstract boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException;
/**
* @param keyUsed unused - no end-to-end crypto
* @param tagsSent unused - no end-to-end crypto
*/
public abstract boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed,
Set tagsSent) throws I2PSessionException;
public abstract void receiveStatus(int msgId, long nonce, int status);
/**
* Recieve a payload message and let the app know its available
*/
public void addNewMessage(MessagePayloadMessage msg) {
Long mid = new Long(msg.getMessageId());
_availableMessages.put(mid, msg);
long id = msg.getMessageId();
byte data[] = msg.getPayload().getUnencryptedData();
if ((data == null) || (data.length <= 0)) {
if (_log.shouldLog(Log.CRIT))
_log.log(Log.CRIT, getPrefix() + "addNewMessage of a message with no unencrypted data",
new Exception("Empty message"));
} else {
int size = data.length;
_availabilityNotifier.available(id, size);
if (_log.shouldLog(Log.INFO))
_log.info(getPrefix() + "Notified availability for session " + _sessionId + ", message " + id);
}
SimpleScheduler.getInstance().addEvent(new VerifyUsage(mid), 30*1000);
}
protected class VerifyUsage implements SimpleTimer.TimedEvent {
private Long _msgId;
public VerifyUsage(Long id) { _msgId = id; }
public void timeReached() {
MessagePayloadMessage removed = _availableMessages.remove(_msgId);
if (removed != null && !isClosed())
_log.error("Message NOT removed! id=" + _msgId + ": " + removed);
}
}
protected class AvailabilityNotifier implements Runnable {
private List _pendingIds;
private List _pendingSizes;
private boolean _alive;
public AvailabilityNotifier() {
_pendingIds = new ArrayList(2);
_pendingSizes = new ArrayList(2);
}
public void stopNotifying() {
_alive = false;
synchronized (AvailabilityNotifier.this) {
AvailabilityNotifier.this.notifyAll();
}
}
public void available(long msgId, int size) {
synchronized (AvailabilityNotifier.this) {
_pendingIds.add(new Long(msgId));
_pendingSizes.add(Integer.valueOf(size));
AvailabilityNotifier.this.notifyAll();
}
}
public void run() {
_alive = true;
while (_alive) {
Long msgId = null;
Integer size = null;
synchronized (AvailabilityNotifier.this) {
if (_pendingIds.isEmpty()) {
try {
AvailabilityNotifier.this.wait();
} catch (InterruptedException ie) { // nop
}
}
if (!_pendingIds.isEmpty()) {
msgId = (Long)_pendingIds.remove(0);
size = (Integer)_pendingSizes.remove(0);
}
}
if ( (msgId != null) && (size != null) ) {
if (_sessionListener != null) {
try {
long before = System.currentTimeMillis();
_sessionListener.messageAvailable(I2PSessionImpl.this, msgId.intValue(), size.intValue());
long duration = System.currentTimeMillis() - before;
if ((duration > 100) && _log.shouldLog(Log.INFO))
_log.info("Message availability notification for " + msgId.intValue() + " took "
+ duration + " to " + _sessionListener);
} catch (Exception e) {
_log.log(Log.CRIT, "Error notifying app of message availability", e);
}
} else {
_log.log(Log.CRIT, "Unable to notify an app that " + msgId + " of size " + size + " is available!");
}
}
}
}
}
/**
* Recieve notification of some I2CP message and handle it if possible
*
*/
public void messageReceived(I2CPMessageReader reader, I2CPMessage message) {
I2CPMessageHandler handler = _handlerMap.getHandler(message.getType());
if (handler == null) {
if (_log.shouldLog(Log.WARN))
_log.warn(getPrefix() + "Unknown message or unhandleable message received: type = "
+ message.getType());
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug(getPrefix() + "Message received of type " + message.getType()
+ " to be handled by " + handler);
handler.handleMessage(message, this);
}
}
/**
* Recieve notifiation of an error reading the I2CP stream
*
*/
public void readError(I2CPMessageReader reader, Exception error) {
propogateError("There was an error reading data", error);
disconnect();
}
/**
* Retrieve the destination of the session
*/
public Destination getMyDestination() { return _myDestination; }
/**
* Retrieve the decryption PrivateKey
*/
public PrivateKey getDecryptionKey() { return _privateKey; }
/**
* Retrieve the signing SigningPrivateKey
*/
public SigningPrivateKey getPrivateKey() { return _signingPrivateKey; }
/**
* Retrieve the helper that generates I2CP messages
*/
I2CPMessageProducer getProducer() { return _producer; }
/**
* Retrieve the configuration options
*/
Properties getOptions() { return _options; }
/**
* Retrieve the session's ID
*/
SessionId getSessionId() { return _sessionId; }
void setSessionId(SessionId id) { _sessionId = id; }
/** configure the listener */
public void setSessionListener(I2PSessionListener lsnr) { _sessionListener = lsnr; }
/** has the session been closed (or not yet connected)? */
public boolean isClosed() { return _closed; }
/**
* Deliver an I2CP message to the router
*
* @throws I2PSessionException if the message is malformed or there is an error writing it out
*/
void sendMessage(I2CPMessage message) throws I2PSessionException {
if (isClosed() || _writer == null)
throw new I2PSessionException("Already closed");
_writer.addMessage(message);
}
/**
* Pass off the error to the listener
* Misspelled, oh well.
*/
void propogateError(String msg, Throwable error) {
if (_log.shouldLog(Log.ERROR))
_log.error(getPrefix() + "Error occurred: " + msg + " - " + error.getMessage());
if (_log.shouldLog(Log.ERROR))
_log.error(getPrefix() + " cause", error);
if (_sessionListener != null) _sessionListener.errorOccurred(this, msg, error);
}
/**
* Tear down the session, and do NOT reconnect.
*
* Blocks if session has not been fully started.
*/
public void destroySession() {
destroySession(true);
}
/**
* Tear down the session, and do NOT reconnect.
*
* Blocks if session has not been fully started.
*/
public void destroySession(boolean sendDisconnect) {
while (_opening) {
synchronized (_openingWait) {
try {
_openingWait.wait(1000);
} catch (InterruptedException ie) { // nop
}
}
}
if (_closed) return;
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Destroy the session", new Exception("DestroySession()"));
_closing = true; // we use this to prevent a race
if (sendDisconnect && _producer != null) { // only null if overridden by I2PSimpleSession
try {
_producer.disconnect(this);
} catch (I2PSessionException ipe) {
propogateError("Error destroying the session", ipe);
}
}
_availabilityNotifier.stopNotifying();
_closed = true;
_closing = false;
closeSocket();
if (_sessionListener != null) _sessionListener.disconnected(this);
}
/**
* Close the socket carefully
*
*/
private void closeSocket() {
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Closing the socket", new Exception("closeSocket"));
_closed = true;
if (_reader != null) {
_reader.stopReading();
_reader = null;
}
if (_writer != null) {
_writer.stopWriting();
_writer = null;
}
if (_socket != null) {
try {
_socket.close();
} catch (IOException ioe) {
propogateError("Caught an IO error closing the socket. ignored", ioe);
} finally {
_socket = null; // so when propogateError calls closeSocket, it doesnt loop
}
}
}
/**
* Recieve notification that the I2CP connection was disconnected
*/
public void disconnected(I2CPMessageReader reader) {
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnected", new Exception("Disconnected"));
disconnect();
}
protected void disconnect() {
if (_closed || _closing) return;
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnect() called", new Exception("Disconnect"));
if (shouldReconnect()) {
if (reconnect()) {
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "I2CP reconnection successful");
return;
}
if (_log.shouldLog(Log.ERROR)) _log.error(getPrefix() + "I2CP reconnection failed");
}
if (_log.shouldLog(Log.ERROR))
_log.error(getPrefix() + "Disconned from the router, and not trying to reconnect further. I hope you're not hoping anything else will happen");
if (_sessionListener != null) _sessionListener.disconnected(this);
_closed = true;
closeSocket();
}
private final static int MAX_RECONNECT_DELAY = 320*1000;
private final static int BASE_RECONNECT_DELAY = 10*1000;
protected boolean shouldReconnect() {
return true;
}
protected boolean reconnect() {
closeSocket();
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Reconnecting...");
int i = 0;
while (true) {
long delay = BASE_RECONNECT_DELAY << i;
i++;
if ( (delay > MAX_RECONNECT_DELAY) || (delay <= 0) )
delay = MAX_RECONNECT_DELAY;
try { Thread.sleep(delay); } catch (InterruptedException ie) {}
try {
connect();
if (_log.shouldLog(Log.INFO))
_log.info(getPrefix() + "Reconnected on attempt " + i);
return true;
} catch (I2PSessionException ise) {
if (_log.shouldLog(Log.ERROR))
_log.error(getPrefix() + "Error reconnecting on attempt " + i, ise);
}
}
}
protected String getPrefix() { return "[" + (_sessionId == null ? -1 : _sessionId.getSessionId()) + "]: "; }
public Destination lookupDest(Hash h) throws I2PSessionException {
return null;
}
public int[] bandwidthLimits() throws I2PSessionException {
return null;
}
protected void updateActivity() {
_lastActivity = _context.clock().now();
if (_isReduced) {
_isReduced = false;
if (_log.shouldLog(Log.WARN))
_log.warn(getPrefix() + "Restoring original tunnel quantity");
try {
_producer.updateTunnels(this, 0);
} catch (I2PSessionException ise) {
_log.error(getPrefix() + "bork restore from reduced");
}
}
}
public long lastActivity() {
return _lastActivity;
}
public void setReduced() {
_isReduced = true;
}
private void startIdleMonitor() {
_isReduced = false;
boolean reduce = Boolean.valueOf(_options.getProperty("i2cp.reduceOnIdle")).booleanValue();
boolean close = Boolean.valueOf(_options.getProperty("i2cp.closeOnIdle")).booleanValue();
if (reduce || close) {
updateActivity();
SimpleScheduler.getInstance().addEvent(new SessionIdleTimer(_context, this, reduce, close), SessionIdleTimer.MINIMUM_TIME);
}
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(32);
buf.append("Session: ");
if (_myDestination != null)
buf.append(_myDestination.calculateHash().toBase64().substring(0, 4));
else
buf.append("[null dest]");
buf.append(getPrefix());
return buf.toString();
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.