/** Description: */ public static void makeController() throws Exception { Configuration cfg = getCfg(); Template template = cfg.getTemplate("controller.html"); // 生成文件设置 String path = getJavaFileRoot() + File.separator + PropertyUtil.getValue("code.src.controller.root") + File.separator + key; mkdirs(path); path += File.separator + upperKey + "Controller.java"; FileWriter sw = new FileWriter(new File(path)); WeakHashMap<String, Object> data = new WeakHashMap<String, Object>(); data.put("packageName", controllerPackagePath); // 包名 data.put("pagePrefix", urlPrefix.substring(1)); data.put("urlPrefix", urlPrefix); data.put("key", key); data.put("UpperKey", upperKey); data.put("ZhKey", zhKey); data.put("author", author); data.put("createDate", createDate); data.put("EntityClass", entityPackagePath + "." + upperKey + "Entity"); data.put("serviceInterFace", servicePackagePath + ".I" + upperKey + "Service"); data.put("primaryKey", primaryKey.getName()); data.put("UpperPrimaryKey", StringUtil.upperFirst(primaryKey.getName())); template.process(data, sw); }
/** * Place the animal at the new location in the given field. * * @param newLocation The animal's new location. */ protected void setLocation(Location newLocation) { if (location != null) { field.clear(location); } location = newLocation; field.place(this, newLocation); }
static String initVBVar(Field field) { // Field.XML is not handled here switch (field.type) { case Field.BOOLEAN: return field.useName() + " = False"; case Field.BYTE: case Field.SHORT: case Field.INT: case Field.LONG: case Field.SEQUENCE: case Field.IDENTITY: return field.useName() + " = 0"; case Field.CHAR: case Field.ANSICHAR: case Field.USERSTAMP: case Field.TLOB: case Field.BLOB: return field.useName() + " = \"\""; case Field.DATE: case Field.DATETIME: case Field.TIME: case Field.TIMESTAMP: return field.useName() + " = Now"; case Field.FLOAT: case Field.DOUBLE: case Field.MONEY: return field.useName() + " = 0.0"; } return "as unsupported"; }
/* -------------------------------------------------------------- */ public void putTo(Buffer buffer) throws IOException { for (int i = 0; i < _fields.size(); i++) { Field field = _fields.get(i); if (field != null) field.putTo(buffer); } BufferUtil.putCRLF(buffer); }
public void build(String headerText, Fact fact) { if (fact instanceof FactData) { FactData factData = (FactData) fact; widget.setWidget(0, ++col, new SmallLabel("[" + factData.getName() + "]")); } else { col++; } widget.setWidget(0, 0, new ClickableLabel(headerText, createAddFieldButton(fact))); // Sets row name and delete button. for (final Field field : fact.getFieldData()) { // Avoid duplicate field rows, only one for each name. if (rowIndexByFieldName.doesNotContain(field.getName())) { newRow(fact, field.getName()); } // Sets row data int fieldRowIndex = rowIndexByFieldName.getRowIndex(field.getName()); widget.setWidget(fieldRowIndex, col, editableCell(field, fact, fact.getType())); } if (fact instanceof FactData) { DeleteFactColumnButton deleteFactColumnButton = new DeleteFactColumnButton((FactData) fact); widget.setWidget(rowIndexByFieldName.amountOrRows() + 1, col, deleteFactColumnButton); } }
public static DeltaDisjunct mat2modRels( DBM dbm, MyEnum keep, LinearTerm[] substitution, boolean isOctagon, IntegerInf maxK) { Matrix m = dbm.mat(); LinearRel lcs = new LinearRel(); int size = m.size(); boolean onlyZeroK = true; // coefficients of K always 0 for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) { if (i == j) continue; Field f = m.get(i, j); if (!f.isFinite()) continue; // skip $0-$0'<=0 and $0'-$0<=0 if (!isOctagon && ((i == size / 2 && j == 0) || (j == size / 2 && i == 0))) continue; LinearConstr lc = new LinearConstr(); lc.addLinTerm(substitution[i].times(1)); lc.addLinTerm(substitution[j].times(-1)); boolean zeroK = f.fillLinTerms(lc, DeltaClosure.v_k); onlyZeroK &= zeroK; lcs.add(lc); } } if (!onlyZeroK) { if (m.fs() instanceof FieldStatic.ParametricFS) lcs.addConstraint(DeltaClosure.lc_k); if (maxK.isFinite()) { lcs.add(DeltaClosure.maxKconstr(maxK.toInt())); } } if (DeltaClosure.DEBUG_LEVEL >= DeltaClosure.DEBUG_LOW) System.out.println(lcs.toSBClever(Variable.ePRINT_prime)); if (onlyZeroK) { Relation r = Relation.toMinType(lcs); Relation[] l; if (!r.contradictory()) l = new Relation[] {r}; else l = new Relation[0]; return new DeltaDisjunct(l, lcs, onlyZeroK); } else { Relation[] tmp = null; tmp = lcs.existElim1(DeltaClosure.v_k); // else keep null return new DeltaDisjunct(tmp, lcs, onlyZeroK); } }
/** Check that the assignment to a field is correct. */ protected void checkFieldAssign( FlowGraph graph, FieldAssign a, DataFlowItem dfIn, DataFlowItem dfOut) throws SemanticException { Field f = (Field) a.left(); FieldInstance fi = f.fieldInstance(); if (fi.flags().isFinal()) { if ((currCBI.currCodeDecl instanceof ConstructorDecl || currCBI.currCodeDecl instanceof Initializer) && isFieldsTargetAppropriate(f)) { // we are in a constructor or initializer block and // if the field is static then the target is the class // at hand, and if it is not static then the // target of the field is this. // So a final field in this situation can be // assigned to at most once. MinMaxInitCount initCount = (MinMaxInitCount) dfOut.initStatus.get(fi); if (InitCount.MANY.equals(initCount.getMax())) { throw new SemanticException( "field \"" + fi.name() + "\" might already have been assigned to", a.position()); } } else { // not in a constructor or intializer, or the target is // not appropriate. So we cannot assign // to a final field at all. throw new SemanticException( "Cannot assign a value " + "to final field \"" + fi.name() + "\"", a.position()); } } }
public static void main(String[] args) { TaskMethod2.action2(); Field field = new Field(); field.eraseField(); field.showField(); TaskMethod1.assertForResult(); double otvet = TaskMethod1.result(52, 34); System.out.println(otvet); double otvetTernarnij = TaskMethod1.resultTernarnij(52, 34); System.out.println(otvetTernarnij); Arr.testForArray(); Integer a = new Integer(500); Integer b = new Integer(500); TaskMethod2.action3(a, b); System.out.println(a + " a " + b); // double[] element = Arr.arrPlus10Percents(10, new double[] {0,1,2,3,4,5,6,7,8,9}); // System.out.print(element[4]); }
private static void generateSingle(Table table, Proc proc, PrintWriter outData) { String dataStruct; if (proc.isStd || proc.isStdExtended()) dataStruct = table.useName(); else dataStruct = table.useName() + proc.upperFirst(); String parameters = ""; boolean hasInput = (proc.inputs.size() > 0 || proc.dynamics.size() > 0); outData.println(" def " + proc.name + "(self):"); outData.println(" ''' Single returns boolean and record"); if (hasInput == true) { outData.println(" Input:"); for (int f = 0; f < proc.inputs.size(); f++) { Field field = (Field) proc.inputs.elementAt(f); outData.println(" " + field.useName()); parameters += ", " + field.useName() + "=" + defValue(field); } for (int f = 0; f < proc.dynamics.size(); f++) { String field = (String) proc.dynamics.elementAt(f); outData.println(" " + field); parameters += ", " + field + "=''"; } } outData.println(" Output:"); for (int f = 0; f < proc.outputs.size(); f++) { Field field = (Field) proc.outputs.elementAt(f); outData.println(" " + field.useName()); } outData.println(" '''"); outData.println( " return " + pymodFront + table.useName() + proc.upperFirst() + "(self)"); if (hasInput == true) generateInput(table.useName(), dataStruct, proc.name, parameters, outData); else generateCover(table.useName(), dataStruct, proc.name, outData); }
private static void initialize(TypeDataBase db) { if (VM.getVM().isServerCompiler()) { Type type = db.lookupType("Matcher"); Field f = type.getField("_regEncode"); matcherRegEncodeAddr = f.getStaticFieldAddress(); } }
public static Field create(String column, Operator operator, String value) { Field result = JavaScriptObject.createObject().cast(); result.column(column); result.operator(operator); result.value(value); return result; }
protected Object zza(Field field, Object obj) { Object obj1 = obj; if (Field.zzc(field) != null) { obj1 = field.convertBack(obj); } return obj1; }
public FieldDescriptorImpl(Project project, ObjectReference objRef, @NotNull Field field) { super(project); myObject = objRef; myField = field; myIsStatic = field.isStatic(); setLvalue(!field.isFinal()); }
/** * Get the full description of a class by using reflection * * @param clazz * @return */ public static String getDescription(Class<?> clazz) { ClassType type = TypeOracle.Instance.getClassType(clazz); if (type == null) return clazz.getName() + ": Not Reflection Information available."; StringBuilder sb = new StringBuilder(); printAnnotations(type, sb); sb.append(type.getName()).append("\n"); sb.append("\n"); sb.append("Fields:").append("\n"); for (Field field : type.getFields()) { printAnnotations(field, sb); sb.append(field.getTypeName()).append(" ").append(field.getName()).append("\n"); } sb.append("\n"); if (type.findConstructor() != null) { sb.append("Constructor:").append("\n"); sb.append(type.findConstructor().toString()).append("\n"); } else { sb.append("No default Contructor\n"); } sb.append("\n"); sb.append("Methods:").append("\n"); for (Method method : type.getMethods()) { printAnnotations(method, sb); sb.append(method.toString()).append("\n"); } return sb.toString(); }
public void setController(DockController controller) { this.controller = controller; controller.getDockTitleManager().registerDefault("chess-board", ChessDockTitle.FACTORY); displayerCollection.setController(controller); for (Field field : usedFieldList) field.updateTitle(); }
private void prepareForm(MetaAsset ma) { GWT.log("Preparing form for " + ma.getName(), null); form.removeAll(); currentFields = ma.getSearchableFields(); formFields = new ArrayList<Field<?>>(); enabledFields.clear(); for (MetaField metaField : currentFields) { Field newField = EditorFactory.createSearchField(metaField); if (newField == null) { logFieldNotSupported(metaField); continue; } newField.addKeyListener( new KeyListener() { @Override public void componentKeyPress(ComponentEvent event) { if (event.getKeyCode() == 13) { submitSearch(); } } }); formFields.add(newField); FieldSet fs = wrapField(newField, metaField, form); form.add(fs, new FormData("90%")); } layout(); }
@Override public void execute() { Card card = null; if (container instanceof Field) { Field field = (Field) container; if (item instanceof Card) { card = (Card) item; field.removeItem(); } else if (item instanceof OverRay) { OverRay overRay = (OverRay) item; Card topCard = overRay.getOverRayCards().topCard(); overRay.getOverRayCards().remove(topCard); if (overRay.getOverRayCards().size() == 0) { field.removeItem(); } } } else if (container instanceof HandCards) { card = (Card) item; ((HandCards) container).getCardList().remove(card); } if (card != null) { card.set(); Deck banished = (Deck) duel.getDuelFields().getField(FieldType.BANISHED).getItem(); banished.getCardList().push(card, true); duel.unSelect(); } }
private void initFields() { System.out.println(getClass().getSimpleName() + ": Init Fields..."); List<?> fieldNodes = fields.selectNodes("//dataroot/Fields"); for (Object o : fieldNodes) { Node node = (Node) o; String tag = node.selectSingleNode("Tag").getText(); String fieldName = node.selectSingleNode("FieldName").getText(); System.out.println("\t " + fieldName + "(" + tag + ")"); String type = node.selectSingleNode("Type").getText(); String desc = node.selectSingleNode("Desc").getText(); String notReqXML = node.selectSingleNode("NotReqXML").getText(); Field field = new Field(tag, fieldName, type, desc, notReqXML); allFields.put(field.getTag(), field); // Find enums List<?> enumNodes = enums.selectNodes("//dataroot/Enums[Tag=" + tag + "]"); Collections.sort(enumNodes, new EnumNodeComparator()); if (!enumNodes.isEmpty()) { for (Object enumO : enumNodes) { Node enumNode = (Node) enumO; String enumName = enumNode.selectSingleNode("Enum").getText(); System.out.println("\t\t " + enumName); String enumDesc = enumNode.selectSingleNode("Description").getText(); field.addEnum(new Enum(enumName, enumDesc)); } } } System.out.println(getClass().getSimpleName() + ": " + allFields.size() + " Fields found"); }
private static void printOct(DBM dbm, LinearTerm[] substitution, IntegerInf maxK) { StringBuffer sb = new StringBuffer(); if (maxK != null) { sb.append("k>=0, "); if (maxK.isFinite()) sb.append("k<=" + maxK.toInt() + ", "); } Matrix m = dbm.mat(); int size = m.size(); for (int i = 0; i < size; ++i) { for (int j = 2 * (i / 2); j < size; ++j) { if (i == j) continue; Field f = m.get(i, j); if (!f.isFinite()) continue; sb.append( "" + substitution[i].times(1).toSB(true) + substitution[j].times(-1).toSB(false) + "<=" + f.toString() + ", "); } } if (DeltaClosure.DEBUG_LEVEL >= DeltaClosure.DEBUG_LOW) System.out.println(sb); }
/** Returns an object of the same type as {@code o}, or null if it is not retained. */ private Object retainAll(Schema schema, MarkSet markSet, ProtoType type, Object o) { if (!markSet.contains(type)) { return null; // Prune this type. } else if (o instanceof Map) { ImmutableMap.Builder<ProtoMember, Object> builder = ImmutableMap.builder(); for (Map.Entry<?, ?> entry : ((Map<?, ?>) o).entrySet()) { ProtoMember protoMember = (ProtoMember) entry.getKey(); if (!markSet.contains(protoMember)) continue; // Prune this field. Field field = schema.getField(protoMember); Object retainedValue = retainAll(schema, markSet, field.type(), entry.getValue()); if (retainedValue != null) { builder.put(protoMember, retainedValue); // This retained field is non-empty. } } ImmutableMap<ProtoMember, Object> map = builder.build(); return !map.isEmpty() ? map : null; } else if (o instanceof List) { ImmutableList.Builder<Object> builder = ImmutableList.builder(); for (Object value : ((List) o)) { Object retainedValue = retainAll(schema, markSet, type, value); if (retainedValue != null) { builder.add(retainedValue); // This retained value is non-empty. } } ImmutableList<Object> list = builder.build(); return !list.isEmpty() ? list : null; } else { return o; } }
/** * Add to or set a field. If the field is allowed to have multiple values, add will add multiple * headers of the same name. * * @param name the name of the field * @param value the value of the field. * @exception IllegalArgumentException If the name is a single valued field and already has a * value. */ public void add(Buffer name, Buffer value) throws IllegalArgumentException { if (value == null) throw new IllegalArgumentException("null value"); if (!(name instanceof CachedBuffer)) name = HttpHeaders.CACHE.lookup(name); name = name.asImmutableBuffer(); if (!(value instanceof CachedBuffer) && HttpHeaderValues.hasKnownValues(HttpHeaders.CACHE.getOrdinal(name))) value = HttpHeaderValues.CACHE.lookup(value); value = value.asImmutableBuffer(); Field field = _names.get(name); Field last = null; while (field != null) { last = field; field = field._next; } // create the field field = new Field(name, value); _fields.add(field); // look for chain to add too if (last != null) last._next = field; else _names.put(name, field); }
static { HashMap<String, Field> map = new HashMap<>(); for (Field field : Field.values()) { map.put(field.getName(), field); } byName = map; }
@Override public void note(TFEvent e) { Field color = getModel().getColorField(); if (color != null && color != oldColor) { removeAll(); final FilterCategoryPanel p = new FilterCategoryPanel("Color Legend: '" + color.getName() + "'", color, this); add(p); Bag<String> data = DBUtils.countValues(getModel().getDB().all(), color); p.setData(data); p.dataList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { ValueFilter f = (ValueFilter) p.defineFilter(); getModel().setGrayFilter(f, this); } }); oldColor = color; revalidate(); return; } else if (color == null) { removeAll(); } repaint(); }
public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = Utils.getDataDir(InsertNestedFields.class); Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert few page breaks (just for testing) for (int i = 0; i < 5; i++) builder.insertBreak(BreakType.PAGE_BREAK); // Move DocumentBuilder cursor into the primary footer. builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY); // We want to insert a field like this: // { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" } Field field = builder.insertField("IF "); builder.moveTo(field.getSeparator()); builder.insertField("PAGE"); builder.write(" <> "); builder.insertField("NUMPAGES"); builder.write(" \"See Next Page\" \"Last Page\" "); // Finally update the outer field to recalcaluate the final value. Doing this will automatically // update // the inner fields at the same time. field.update(); doc.save(dataDir + "InsertNestedFields Out.docx"); System.out.println("Nested fields inserted into the document successfully."); }
/** * Look for rabbits adjacent to the current location. Only the first live rabbit is eaten. * * @return Where food was found, or null if it wasn't. */ private Location findFood() { Field field = getField(); List<Location> adjacent = field.adjacentLocations(getLocation()); Iterator<Location> it = adjacent.iterator(); while (it.hasNext()) { Location where = it.next(); Object animal = field.getObjectAt(where); if (animal instanceof Rabbit) { Rabbit rabbit = (Rabbit) animal; if (rabbit.isAlive()) { rabbit.setDead(); foodLevel = RABBIT_FOOD_VALUE; // Remove the dead rabbit from the field. return where; } } if (animal instanceof Fox) { Fox fox = (Fox) animal; if (fox.isAlive()) { fox.setDead(); foodLevel = WOLVES_FOOD_VALUE; // Remove the dead rabbit from the field. return where; } } } return null; }
public static void DecreasePlaceHolder(Field field) { List<Attr> attrs = field.getAttrs(); boolean isExists = false; for (int i = 0; i < attrs.size(); i++) { Attr attr = (Attr) attrs.get(i); if (!ConfigManager.PROPERTIES_PLACEHOLDER.equalsIgnoreCase(attr.getName())) { continue; } isExists = true; int len = Integer.parseInt(attr.getValue()); if (1 == len) { break; } attr.setValue(String.valueOf(len - 1)); field.setAttr(i, attr); return; } if (!isExists) { Attr attr = new Attr(); attr.setName(ConfigManager.PROPERTIES_PLACEHOLDER); attr.setValue(String.valueOf(1)); field.addAttr(attr); } }
/** * Returns a field with the given name if any exist in this document, or null. If multiple fields * exists with this name, this method returns the first value added. */ public final Field getField(String name) { for (int i = 0; i < fields.size(); i++) { Field field = (Field) fields.get(i); if (field.name().equals(name)) return field; } return null; }
public static void exchangePlaceHolder(Field before, Field after) { String beforeValue = ""; String afterValue = ""; int beforeIndex = 0; int afterIndex = 0; Attr beforeAttr = null; Attr afterAttr = null; List<Attr> beforeAttrs, afterAttrs; beforeAttrs = before.getAttrs(); for (int i = 0; i < beforeAttrs.size(); i++) { Attr attr = (Attr) beforeAttrs.get(i); if (!ConfigManager.PROPERTIES_LINEBR.equalsIgnoreCase(attr.getName())) { continue; } beforeValue = attr.getValue(); beforeIndex = i; beforeAttr = attr; } afterAttrs = after.getAttrs(); for (int i = 0; i < afterAttrs.size(); i++) { Attr attr = (Attr) afterAttrs.get(i); if (!ConfigManager.PROPERTIES_LINEBR.equalsIgnoreCase(attr.getName())) { continue; } afterValue = attr.getValue(); afterIndex = i; afterAttr = attr; } beforeAttr.setValue(afterValue); beforeAttrs.set(beforeIndex, beforeAttr); afterAttr.setValue(beforeValue); afterAttrs.set(afterIndex, afterAttr); }
protected boolean shouldDisplay( EvaluationContext context, @NotNull ObjectReference objInstance, @NotNull Field field) { final boolean isSynthetic = DebuggerUtils.isSynthetic(field); if (!SHOW_SYNTHETICS && isSynthetic) { return false; } if (SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES && isSynthetic) { try { final StackFrameProxy frameProxy = context.getFrameProxy(); if (frameProxy != null) { final Location location = frameProxy.location(); if (location != null && objInstance.equals(context.getThisObject()) && Comparing.equal(objInstance.referenceType(), location.declaringType()) && StringUtil.startsWith( field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) { return false; } } } catch (EvaluateException ignored) { } } if (!SHOW_STATIC && field.isStatic()) { return false; } if (!SHOW_STATIC_FINAL && field.isStatic() && field.isFinal()) { return false; } return true; }
/** Returns the number of optional fields (not counting the wildcard) */ public int noOptional() { int n = 0; for (Field field : fieldsByName) { if (field.isOptional()) n++; } return n; }