private void parseXMLdynamic( Knowledge original, Node capsule, String name, boolean allowOverrides) throws XPathExpressionException { boolean exists = original.getDynamic(name) != null; if (exists && !allowOverrides) return; if (!exists) { original.addDynamic(name); } Dynamic descriptible = original.getDynamic(name); extractXMLdescriptible(original, capsule, descriptible); int entrycount = (int) Math.floor( (Double) this.xp.evaluate("count(./" + ENTRY + ")", capsule, XPathConstants.NUMBER)); for (int n = 1; n <= entrycount; n++) // n begins to 1, ends up to count included { Node entry = (Node) this.xp.evaluate("./" + ENTRY + "[" + n + "]", capsule, XPathConstants.NODE); Node nameNode = entry.getAttributes().getNamedItem(SHEET); if (nameNode != null) { descriptible.addCouple(nameNode.getNodeValue(), Integer.parseInt(entry.getTextContent())); } } }
@Test public void profileSend() { Dynamic d = Dynamics.from(new Foo()); for (int i = 0; i < MAX_RUNS; i++) { d.chainingSend("foo", "s"); d.chainingSend("bar", "p"); } }
static boolean isAssignable(@NonNull Class<?> expected, @NonNull Class<?> actual) { if (expected.isAssignableFrom(actual)) { return true; } if (expected.isPrimitive()) { return Dynamic.unbox(expected).isAssignableFrom(actual); } return actual.isPrimitive() && expected.isAssignableFrom(Dynamic.unbox(actual)); }
/** * Create guestUser and administratorUser. * * @see org.melati.poem.JdbcTable#postInitialise() */ public void postInitialise() { super.postInitialise(); dynamicOne = (Dynamic) newPersistent(); dynamicOne.setName_unsafe("dynamicOne"); dynamicTwo = (Dynamic) newPersistent(); dynamicTwo.setName_unsafe("dynamicTwo"); dynamicOne = (Dynamic) getNameColumn().ensure(dynamicOne); dynamicTwo = (Dynamic) getNameColumn().ensure(dynamicTwo); }
/** * Compare an object to the world to identify any collisions. The obj is compared to blocks it is * directly overtop of. Returns null if no collisions are found. * * @param obj The entity to test against the world. * @param target The block type to test for * @return the first collision found, if any. Null if none. */ private Point getWorldCollision(Dynamic obj, Texture target) { Rectangle r = obj.getCollisionBox(); Point lowerLeft = new Point(r.x, r.y); Point upperRight = new Point(r.x + r.width - 1, r.y + r.height - 1); int cell = World.CELL_SIZE; // If x is negative, offset by 1. It sucks but is necessary. if (lowerLeft.x < 0) { lowerLeft.x -= cell; } if (upperRight.x < 0) { upperRight.x -= cell; } // Convert pixel coordinates to world coordinates. lowerLeft.x /= cell; lowerLeft.y /= cell; upperRight.x /= cell; upperRight.y /= cell; // Test for overlap with the target block type for (int x = (lowerLeft.x); x <= (upperRight.x); x++) { for (int y = (lowerLeft.y); y <= (upperRight.y); y++) { if (world.getCell(x, y) == target) { return new Point(x, y); } } } return null; }
/** * @param section * @return * @throws IOException */ public Dynamic[] getDynamicSections(final Section section) throws IOException { return Dynamic.create(this.ehdr, section, this.efile); }
@NonNull public static Method find(@NonNull String className, @NonNull String name, Class<?>... argTypes) throws DynamicException { return find(Dynamic.forName(className), name, argTypes); }
@Nullable public static <T> T invokeStatic( @NonNull String className, @NonNull String method, Object... args) throws DynamicException { return invokeStatic(Dynamic.forName(className), method, args); }
/** * Calculate the physics in our world for the given object. * * @param obj The object to move * @param timeStep The time since last evaluation in nanoseconds */ public void simulate(Dynamic obj, long timeStep) { /* Actions: * 1. apply drag * 2. add forces to object * - gravity (unless resting on block) * - arrow keys * * 3. apply forces to object. (done by the object) * * 4. a) move in x axis * 5. a) resolve collisions in x axis * * 4. b) move in y axis * 5. b) resolve collisions in y axis */ double seconds = timeStep / (double) NS_PER_S; // 1. apply drag obj.applyDrag(seconds); // 2. add forces obj.addForce(new Vector2D(0, GRAVITY)); obj.addForce(keyForce); // 3. apply forces obj.applyForces(seconds); // get velocity in preparation for step 4 Vector2D vel = obj.getVel(); hero.setImage(tp.get(Texture.hero)); // 4. a) move x obj.move((int) (vel.x * seconds), 0); // 5. a) resolve collisions in x Point bad = getWorldCollision(obj, Texture.brick); // bad = null; if (bad != null) { int resolution = world.escapeX(obj, vel.x * seconds, bad); obj.move(resolution, 0); obj.getVel().setX(0); } // 4. b) move y obj.move(0, (int) (vel.y * seconds)); // 5. b) resolve collisions in y bad = getWorldCollision(obj, Texture.brick); // bad = null; if (bad != null) { int resolution = world.escapeY(obj, vel.y * seconds, bad); if (vel.y < 0) { hero.setOnGround(true); hero.setImage(tp.get(Texture.heroGround)); } obj.move(0, resolution); obj.getVel().setY(0); } else { hero.setOnGround(false); } }
public void toXContent(XContentBuilder builder, Params params, ToXContent custom) throws IOException { builder.startObject(simpleName()); if (nested.isNested()) { builder.field("type", NESTED_CONTENT_TYPE); if (nested.isIncludeInParent()) { builder.field("include_in_parent", true); } if (nested.isIncludeInRoot()) { builder.field("include_in_root", true); } } else if (mappers.isEmpty() && custom == null) { // only write the object content type if there are no properties, otherwise, // it is automatically detected builder.field("type", CONTENT_TYPE); } if (dynamic != null) { builder.field("dynamic", dynamic.name().toLowerCase(Locale.ROOT)); } if (enabled != Defaults.ENABLED) { builder.field("enabled", enabled); } if (pathType != Defaults.PATH_TYPE) { builder.field("path", pathType.name().toLowerCase(Locale.ROOT)); } if (includeInAll != null) { builder.field("include_in_all", includeInAll); } if (custom != null) { custom.toXContent(builder, params); } doXContent(builder, params); // sort the mappers so we get consistent serialization format Mapper[] sortedMappers = Iterables.toArray(mappers.values(), Mapper.class); Arrays.sort( sortedMappers, new Comparator<Mapper>() { @Override public int compare(Mapper o1, Mapper o2) { return o1.name().compareTo(o2.name()); } }); int count = 0; for (Mapper mapper : sortedMappers) { if (!(mapper instanceof MetadataFieldMapper)) { if (count++ == 0) { builder.startObject("properties"); } mapper.toXContent(builder, params); } } if (count > 0) { builder.endObject(); } builder.endObject(); }
public void toXContent( XContentBuilder builder, Params params, ToXContent custom, Mapper... additionalMappers) throws IOException { builder.startObject(name); if (nested.isNested()) { builder.field("type", NESTED_CONTENT_TYPE); if (nested.isIncludeInParent()) { builder.field("include_in_parent", true); } if (nested.isIncludeInRoot()) { builder.field("include_in_root", true); } } else if (mappers .isEmpty()) { // only write the object content type if there are no properties, otherwise, // it is automatically detected builder.field("type", CONTENT_TYPE); } // grr, ugly! on root, dynamic defaults to TRUE, on children, it defaults to null to // inherit the root behavior if (this instanceof RootObjectMapper) { if (dynamic != Dynamic.TRUE) { builder.field("dynamic", dynamic.name().toLowerCase()); } } else { if (dynamic != Defaults.DYNAMIC) { builder.field("dynamic", dynamic.name().toLowerCase()); } } if (enabled != Defaults.ENABLED) { builder.field("enabled", enabled); } if (pathType != Defaults.PATH_TYPE) { builder.field("path", pathType.name().toLowerCase()); } if (includeInAll != null) { builder.field("include_in_all", includeInAll); } if (custom != null) { custom.toXContent(builder, params); } doXContent(builder, params); // sort the mappers so we get consistent serialization format TreeMap<String, Mapper> sortedMappers = new TreeMap<String, Mapper>(mappers); // check internal mappers first (this is only relevant for root object) for (Mapper mapper : sortedMappers.values()) { if (mapper instanceof InternalMapper) { mapper.toXContent(builder, params); } } if (additionalMappers != null && additionalMappers.length > 0) { TreeMap<String, Mapper> additionalSortedMappers = new TreeMap<String, Mapper>(); for (Mapper mapper : additionalMappers) { additionalSortedMappers.put(mapper.name(), mapper); } for (Mapper mapper : additionalSortedMappers.values()) { mapper.toXContent(builder, params); } } if (!mappers.isEmpty()) { builder.startObject("properties"); for (Mapper mapper : sortedMappers.values()) { if (!(mapper instanceof InternalMapper)) { mapper.toXContent(builder, params); } } builder.endObject(); } builder.endObject(); }
public static void main(String[] args) { Dynamic dyn = new Dynamic(); dyn.setInformation("Person", "firstname", "Sabrina"); System.out.println("Person"); }
@SubL(source = "sublisp/condition-macros.lisp", position = 3840) public static final SubLObject ignore_errors_handler() { Dynamic.sublisp_throw($kw14$IGNORE_ERRORS_TARGET, NIL); return NIL; }
public void toXContent( XContentBuilder builder, Params params, ToXContent custom, Mapper... additionalMappers) throws IOException { builder.startObject(name); if (nested.isNested()) { builder.field("type", NESTED_CONTENT_TYPE); if (nested.isIncludeInParent()) { builder.field("include_in_parent", true); } if (nested.isIncludeInRoot()) { builder.field("include_in_root", true); } } else if (mappers .isEmpty()) { // only write the object content type if there are no properties, otherwise, // it is automatically detected builder.field("type", CONTENT_TYPE); } if (dynamic != null) { builder.field("dynamic", dynamic.name().toLowerCase(Locale.ROOT)); } if (enabled != Defaults.ENABLED) { builder.field("enabled", enabled); } if (pathType != Defaults.PATH_TYPE) { builder.field("path", pathType.name().toLowerCase(Locale.ROOT)); } if (includeInAll != null) { builder.field("include_in_all", includeInAll); } if (custom != null) { custom.toXContent(builder, params); } doXContent(builder, params); // sort the mappers so we get consistent serialization format Mapper[] sortedMappers = Iterables.toArray(mappers.values(), Mapper.class); Arrays.sort( sortedMappers, new Comparator<Mapper>() { @Override public int compare(Mapper o1, Mapper o2) { return o1.name().compareTo(o2.name()); } }); // check internal mappers first (this is only relevant for root object) for (Mapper mapper : sortedMappers) { if (mapper instanceof InternalMapper) { mapper.toXContent(builder, params); } } if (additionalMappers != null && additionalMappers.length > 0) { TreeMap<String, Mapper> additionalSortedMappers = new TreeMap<>(); for (Mapper mapper : additionalMappers) { additionalSortedMappers.put(mapper.name(), mapper); } for (Mapper mapper : additionalSortedMappers.values()) { mapper.toXContent(builder, params); } } if (!mappers.isEmpty()) { builder.startObject("properties"); for (Mapper mapper : sortedMappers) { if (!(mapper instanceof InternalMapper)) { mapper.toXContent(builder, params); } } builder.endObject(); } builder.endObject(); }