本文整理汇总了Java中localhost.iillyyaa2033.nmud.core.utils.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于localhost.iillyyaa2033.nmud.core.utils包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
@Override
public void update(URI row, String[] values) {
String[] columns = columnsNamesFor(row);
if (columns.length > values.length) {
values = Arrays.copyOf(values, columns.length);
Utils.preserveFromNull(values);
}
try {
String query = "update "+getTable(row) + " set ";
for(int i = 0; i < columns.length-1; i++){
if(!"_id".equals(columns[i])) query += ""+columns[i]+" = '"+values[i]+"', ";
}
query += ""+columns[columns.length-1]+" = '"+values[columns.length-1]+"'";
query += " where _id = '"+getRow(row)+"'";
stmt.executeUpdate(query);
} catch (SQLException e) {
e(e);
}
}
示例2: save
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
public static void save(String path) throws Exception {
ArrayList<String> out = new ArrayList<String>();
for (int key : Dictionary.keys()) {
out.add(key +
SEPARATOR + Utils.ats(SEPARATOR, Dictionary.get(0, key).forms) +
SEPARATOR + WordUtils.encodeParams(Dictionary.get(0, key).flags) + "\n");
}
String[] o2 = out.toArray(new String[out.size()]);
Arrays.sort(o2);
File file = new File(path);
if (!file.exists())
throw new FileNotFoundException("File " + path + " doesnt exists!");
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
for(String s : o2){
osw.write(s);
}
osw.flush();
osw.close();
}
示例3: toString
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
public String toString(int form) {
String rz = null;
if (forms.length < form) {
Implementation.getImpl().notifyAboutException(new Exception("Illegal form " + form + " of word " + this.toString()
+ " (" + Utils.ats(", ", forms) + ")"));
rz = forms[0];
} else {
rz = forms[form];
}
if (rz == null) {
rz = "[ummaned]";
}
return rz.replace("_", " ");
}
示例4: linkDoor
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
private void linkDoor(int index, Entity parent, Entity door) {
double[] parentPosition = domains[index].getGlobalPositonOf(parent
.getId());
double[] exitPosition = getExitCoords(index, door);
String exit = domains[index].getEntityAt(exitPosition, true);
/*
* d("Linked: " + parent + " (" + door + ") → " +
* domains[index].getByIdWithFirstLvlChildOnly(exit) + " [" +
* Utils.ats(exitPosition) + "]");
*/
int nodeIdFrom = getNodeIndex(index, parent.getId());
int nodeIdTo = getNodeIndex(index, exit);
Link data = new Link();
data.doorId = door.getId();
data.moveLength = (float) Utils.distance(parentPosition, exitPosition);
graphs[index].addLink(nodeIdFrom, nodeIdTo, data);
}
示例5: insert
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
@Override
public URI insert(URI table, String[] columns, String[] values) {
if (columns.length > values.length) {
values = Arrays.copyOf(values, columns.length);
Utils.preserveFromNull(values);
}
String query = null;
try {
// Колонки
query = "INSERT INTO " + getTable(table) + " (";
for (int i = 0; i < columns.length - 1; i++) {
query += columns[i] + ", ";
}
query += columns[columns.length - 1] + ")";
// Значения
query += " VALUES (";
for (int i = 0; i < values.length - 1; i++) {
query += "'" + values[i].replace("\\", "\\\\").replace("'", "\\'") + "', ";
}
query += "'" + values[values.length - 1].replace("\\", "\\\\").replace("'", "\\'") + "');";
stmt.executeUpdate(query);
} catch (SQLException e) {
e(e);
// System.out.println("# ERROR WHILE INSERTING TO " + getTable(table) + " value[0] is " + values[0]);
System.out.println(query);
}
return null;
}
示例6: showNameDialog
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
private void showNameDialog() {
AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
ab.setTitle("Name");
LinearLayout ll = new LinearLayout(getActivity());
ll.setOrientation(LinearLayout.VERTICAL);
TextView text = new TextView(getActivity());
ll.addView(text);
text.setText(Utils.ats(entity.getName().forms));
text.setPadding(12, 12, 12, 12);
Button btn = new Button(getActivity());
ll.addView(btn);
btn.setText("Open dictionary");
ab.setView(ll);
final AlertDialog ad = ab.create();
ad.show();
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View p1) {
Intent i = new Intent(getActivity(), DictionaryActivity.class);
i.putExtra("dict-act", true);
startActivityForResult(i, 5);
ad.cancel();
}
});
}
示例7: setColor
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
private void setColor(Entity entity) {
String color = entity.getParam(Entity.P.EDITOR_COLOR);
if (color != null) {
if (!color.equals("null")) {
this.color = Color.parseColor(color);
}
}
String alpha = entity.getParam("editorOpacity");
if (alpha != null) {
if (!alpha.equals("null")) {
this.alpha = Utils.parseInt(alpha, 50);
}
}
}
示例8: getEntityAlpha
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
private int getEntityAlpha(Entity e) {
if (e.opacity < 0) {
e.opacity = Utils.parseInt(e.getParam("editorOpacity"), 50);
}
return e.opacity;
}
示例9: load
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
public static void load(String path) throws Exception {
File file = new File(path);
if (!file.exists())
throw new FileNotFoundException("File " + path + " doesnt exists!");
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
HashMap<Integer, Word> result = new HashMap<Integer, Word>();
String line = null;
while ((line = br.readLine()) != null) {
int ind = line.indexOf(SEPARATOR);
if (ind > 0) {
int num = Utils.parseInt(line.substring(0, ind), -1);
int type = 0;
int gen = 0;
String[] data = Utils.stringToStringArray(line.substring(ind), SEPARATOR);
ArrayList<String> pdata = new ArrayList<String>();
HashMap<String,Boolean> pparams = new HashMap<String,Boolean>();
for (int i = 0; i < data.length; i++) {
if (data[i] != null) {
if (data[i].startsWith(Word.PREFIX_FLAGS)) {
pparams.putAll(WordUtils.parseParams(data[i]));
} else {
pdata.add(data[i]);
}
}
}
result.put(num, new Word(type, gen, pdata.toArray(new String[pdata.size()]), pparams));
}
}
br.close();
Dictionary.set(result);
}
示例10: getHelp
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
private String getHelp(IHTTPSession session) {
String result = "";
switch (session.getMethod().name()) {
case "GET":
List<String> cmd = session.getParameters().get("cmd");
if (cmd != null) {
result = Utils.ats(cmd);
} else {
List<String> allcmd = session.getParameters().get("allcmd");
if (allcmd != null) {
StringBuilder sb = new StringBuilder();
UserScript[] cmds = parent.getAllCommands();
Arrays.sort(cmds, new Comparator<UserScript>(){
@Override
public int compare(UserScript p1, UserScript p2) {
return p1.getHumanName().compareTo(p2.getHumanName());
}
});
for (UserScript s : cmds) {
sb.append("<option value=\"").append(s.getHumanName()).append("\">");
}
result = sb.toString();
}
}
break;
}
return result;
}
示例11: paramsToString
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
static String paramsToString(Entity e) {
String result = "";
if (e.params != null) {
String[] set = e.params.keySet().toArray(new String[e.params.keySet().size()]);
Arrays.sort(set);
for (String key : set) {
if (Utils.containsInArray(paramsExcludedForSaving, key)) continue;
result += key + ":" + e.params.get(key) + ";";
}
}
return result;
}
示例12: showEditWord
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
void showEditWord(final int id, final int adapterId) {
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(ll.VERTICAL);
Word w = Dictionary.get(0, id);
final EditText field = new EditText(this);
field.setHint("форма1 форма2 форма3 ... формаN");
field.setText(Utils.ats(" ", w.forms));
ll.addView(field);
final CheckBox chSaveCase = new CheckBox(this);
chSaveCase.setText("Сохранять заглавные буквы");
chSaveCase.setChecked(w.getQuality(Word.Quality.saveCase));
ll.addView(chSaveCase);
new AlertDialog.Builder(this)
.setTitle("ID: " + id)
.setView(ll)
.setPositiveButton("ok", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
String text = field.getText().toString();
final String[] data = Utils.stringToStringArray(text);
HashMap<String,Boolean> map = new HashMap<String,Boolean>();
map.put(Word.Quality.saveCase, chSaveCase.isChecked());
if (data == null || data.length == 0) {
Toast.makeText(DictionaryActivity.this, "Необходимо указать хотя бы одну форму", Toast.LENGTH_LONG).show();
} else {
Dictionary.put(id, new Word(0, 0, data, map));
/* adapter.remove(adapter.getItem(adapterId));
adapter.insert("[" + id + "] «" + data[0] + "» - " + data.length + " форм", adapterId); */
doUpdateMeta();
}
}
})
.show();
}
示例13: showColorDialog
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
private void showColorDialog() {
final LinearLayout ll = new LinearLayout(getActivity());
ll.setOrientation(LinearLayout.VERTICAL);
final Set<String> hints = getActivity().getSharedPreferences("editor", Context.MODE_PRIVATE).getStringSet("EDITOR_COLORHINTS", new HashSet<String>());
final AutoCompleteTextView tg = new AutoCompleteTextView(getActivity());
tg.setHint("#RRGGBB");
ArrayAdapter<String> tgadapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, hints.toArray(new String[hints.size()]));
tg.setAdapter(tgadapter);
tg.setText(entity.getParam(Entity.P.EDITOR_COLOR));
ll.addView(tg);
final EditText alpha = new EditText(getActivity());
alpha.setHint("прозрачность (0-255)");
alpha.setText(entity.getParam("editorOpacity"));
ll.addView(alpha);
AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
ab.setTitle("New param");
ab.setView(ll);
ab.setPositiveButton("Ok", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface p1, int p2) {
if (entity.params == null) entity.params = new HashMap<String,String>();
String color = tg.getText().toString();
if (color.startsWith("#")) {
entity.params.put(Entity.P.EDITOR_COLOR, color);
hints.add(color);
getActivity().getSharedPreferences("editor", Context.MODE_PRIVATE).
edit().putStringSet("EDITOR_COLORHINTS", hints).apply();
refillAdapter();
} else {
Toast.makeText(getActivity(), "Incorrect color!", Toast.LENGTH_SHORT).show();
}
int al = Utils.parseInt(alpha.getText().toString(), -1);
if (al > -1) {
entity.opacity = al;
entity.addParam("editorOpacity", "" + al);
}
}
});
ab.setNegativeButton("Cancel", null);
ab.show();
}
示例14: onSingleTapConfirmed
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
@Override
public boolean onSingleTapConfirmed(MotionEvent event) {
Toast.makeText(MapActivity.this, Utils.ats(view.getCoordsOfPoint(event.getX(), event.getY())), Toast.LENGTH_SHORT).show();;
return true;
}
示例15: toString
import localhost.iillyyaa2033.nmud.core.utils.Utils; //导入依赖的package包/类
@Override
public String toString() {
return id + "[" + Utils.ats(position) + "]";
}