@Override public void gotCode(final String name, final String code) { _put(name, new Code(code)); }
@Override public Code decode(final BsonReader bsonReader, final DecoderContext decoderContext) { return new Code(bsonReader.readJavaScript()); }
@Override public Document convert(NamedMongoScript source) { if (source == null) { return new Document(); } Document document = new Document(); document.put("_id", source.getName()); document.put("value", new Code(source.getCode())); return document; } }
putCode(name, new Code((String) initialValue));
o = new CodeWScope((String) b.get("$code"), (DBObject) b.get("$scope")); } else { o = new Code((String) b.get("$code"));
@Override public Document convert(NamedMongoScript source) { if (source == null) { return new Document(); } Document document = new Document(); document.put("_id", source.getName()); document.put("value", new Code(source.getCode())); return document; } }
return callback.createDBRef(dbPointer.getNamespace(), dbPointer.getId()); case JAVASCRIPT: return new Code(reader.readJavaScript()); case SYMBOL: return new Symbol(reader.readSymbol());
if (O[ID].code == null) { O[ID].code = new Code(); // <-- you didn't tell us. } // Then you could O[ID].code.MapFile = new short[data.length / 4][4];
success: function(user) { $scope.currentUser = user; var Code = Parse.Object.extend("Codes"); var myCode = new Code(); myCode.set("text", "This is a dummy test"); myCode.save().then(function(createdCode){ var relation = user.relation("Codes"); relation.add(createdCode); user.save(); $scope.$apply(); }, function(error){ // handle error here. }); }
final Code code = new Code("function myFunction() { return 123; }");
Code functionCode = new Code ("function(x) {return x}") ; DBObject doc = new BasicDBObject("_id","echoFunction").append("value",functionCode);
public class GUI extends JFrame { Draw panel = new Draw(this); Code c = new Code(this); ... ... }
public void gotCode(String name, String code) { _put(name, new Code(code)); }
public void __setstate__(final HashMap<String, Object> state) { // CHECKSTYLE:ON Object scope = state.get("_Code__scope"); if (!(scope instanceof Map)) { throw new PickleException( "Expected a Map for key \"_Code__scope\", not a " + scope.getClass().getName()); } Map scopeMap = (Map) scope; if (!scopeMap.isEmpty()) { this.value = new CodeWScope(this.code, new BasicBSONObject(scopeMap)); } else { this.value = new Code(this.code); } }
Code code = new Code(); code.setA((byte) 'a'); code.setB((byte) 'b'); ... JNATest.printStruct(code.getPointer()); code.free(); // free the memory allocated in the constructor
/** * Create a storage procedure. * * @param code The code of storage procedure * @throws BaseException If error happens. */ public void crtJSProcedure(String code) throws BaseException { if (null == code || code.equals("")) { throw new BaseException(SDBError.SDB_INVALIDARG, code); } BSONObject options = new BasicBSONObject(); Code codeObj = new Code(code); options.put(SdbConstants.FIELD_NAME_FUNC, codeObj); options.put(SdbConstants.FMP_FUNC_TYPE, FMP_FUNC_TYPE_JS); AdminRequest request = new AdminRequest(AdminCommand.CREATE_PROCEDURE, options); SdbReply response = requestAndResponse(request); throwIfError(response); }
private String playerName = ""; private int numberOfPegs = 0; private boolean gameRunning = "True"; private Display display; public static void main(String[] args) { Game game = new Game(); game.setupGame(); game.playGame(); } public void setupGame() { display = new Display(); Code code = new Code(); display.showGreeting(); playerName = display.getUserInput("Enter your name: "); numberOfPegs = Integer.parseInt(display.getUserInput("How many pegs would you like?")); code.generateNewCode(numberOfPegs); } public void playGame() { String result = display.getGuess(); }
/** * Test if {@link JavaScript} objects can be deserialized * @throws Exception if something goes wrong */ @Test public void parseCode() throws Exception { BSONObject scope = new BasicBSONObject(); scope.put("Int32", 5); BSONObject o = new BasicBSONObject(); o.put("Code1", new CodeWScope("alert('test');", scope)); o.put("Code2", new Code("alert('Hello');")); Map<?, ?> data = parseBsonObject(o); assertEquals(2, data.size()); JavaScript c1 = (JavaScript)data.get("Code1"); JavaScript c2 = (JavaScript)data.get("Code2"); assertEquals("alert('test');", c1.getCode()); assertEquals("alert('Hello');", c2.getCode()); Map<String, Object> c1scope = c1.getScope(); assertEquals(5, c1scope.get("Int32")); }
/** * Tests if {@code JavaScript} objects can be deserialized * @throws Exception if something goes wrong */ @Test public void javascript() throws Exception { Code code = new Code("code"); TC.J obj = generateAndParse(code, TC.J.class); assertEquals(code.getCode(), obj.obj.getCode()); CodeWScope codews = new CodeWScope("code", new BasicBSONObject("key", "value")); obj = generateAndParse(codews, TC.J.class); assertEquals(code.getCode(), obj.obj.getCode()); assertEquals(codews.getScope().toMap(), obj.obj.getScope()); }