rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
this.envPrefix = envPrefix; this.account = account;
public void init(HttpServletRequest req, String envPrefix, String account, boolean debug) throws WebdavIntfException { try { this.envPrefix = envPrefix; this.account = account; this.debug = debug; trans = new IcalTrans(debug); } catch (Throwable t) { throw new WebdavIntfException(t); } }
trans = new IcalTrans(debug);
trans = new BwIcalTrans(envPrefix, debug);
public void init(HttpServletRequest req, String envPrefix, String account, boolean debug) throws WebdavIntfException { try { this.envPrefix = envPrefix; this.account = account; this.debug = debug; trans = new IcalTrans(debug); } catch (Throwable t) { throw new WebdavIntfException(t); } }
return refreshEvent(fetchEvent(ev, form), request, form);
return "success";
public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (form.getGuest()) { return "notFound"; } CalSvcI svci = form.fetchSvci(); BwCalendar cal = null; BwCalSuite calSuite = null; EventInfo ei = null; BwEvent ev = null; String rpar = getReqPar(request, "guid"); String calPath = getReqPar(request, "calPath"); if (rpar != null) { // Assume event ei = findEvent(request, form); if (ei == null) { // Do nothing form.getErr().emit("org.bedework.client.error.nosuchevent"); return "doNothing"; } ev = ei.getEvent(); } else if (calPath != null) { // calendar cal = svci.getCalendar(calPath); if (cal == null) { form.getErr().emit("org.bedework.client.error.nosuchcalendar", calPath); return "notFound"; } } else { String calSuiteName = getReqPar(request, "calSuiteName"); if (calSuiteName == null) { // bogus request return "notFound"; } calSuite = svci.getCalSuite(calSuiteName); if (calSuite == null) { form.getErr().emit("org.bedework.client.error.nosuchcalendarsuite", calSuite); return "notFound"; } } String whoTypeStr = request.getParameter("whoType"); int whoType = -1; boolean needWho = false; if (whoTypeStr == null) { whoType = Ace.whoTypeUser; needWho = true; } else if (whoTypeStr.equals("owner")) { whoType = Ace.whoTypeOwner; } else if (whoTypeStr.equals("user")) { whoType = Ace.whoTypeUser; needWho = true; } else if (whoTypeStr.equals("group")) { whoType = Ace.whoTypeGroup; needWho = true; //form.getErr().emit("org.bedework.client.error.unimplemented"); //return "error"; } else if (whoTypeStr.equals("unauth")) { whoType = Ace.whoTypeUnauthenticated; } else if (whoTypeStr.equals("other")) { whoType = Ace.whoTypeOther; } else { form.getErr().emit("org.bedework.client.error.badwhotype"); return "error"; } String who = request.getParameter("who"); /* if (who != null) { BwUser user = svci.findUser(who); if (user == null) { form.getErr().emit("org.bedework.client.error.usernotfound"); return "notFound"; } } else { who = null; } */ if (needWho && (who == null)) { form.getErr().emit("org.bedework.client.error.missingwho"); return "error"; } ArrayList aces = new ArrayList(); String how = getReqPar(request, "how"); if (how == null) { form.getErr().emit("org.bedework.client.error.nohowaccess"); return "error"; } char[] howchs = how.toCharArray(); for (int hi = 0; hi < howchs.length; hi++) { char howch = howchs[hi]; boolean found = false; for (int pi = 0; pi <= PrivilegeDefs.privMaxType; pi++) { if (howch == PrivilegeDefs.privEncoding[pi]) { aces.add(new Ace(who, false, whoType, Privileges.makePriv(pi))); found = true; break; } } if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; } } if (ev != null) { svci.changeAccess(ev, aces); } else if (calSuite != null) { svci.changeAccess(calSuite, aces); } else { svci.changeAccess(cal, aces); //svci.updateCalendar(cal); } return refreshEvent(fetchEvent(ev, form), request, form); }
if ((siblingPos < 0) || (siblingPos > (subCount - 1))) { if (!parentView.isRoot()) { return null; }
if ((diff == 0) || (siblingPos < 0) || (siblingPos > (subCount - 1))) { return null;
public IdeaView getSibling(int difference) { MapComponent parent = getParent(); if (!(parent instanceof IdeaView)) { return null; } IdeaView parentView = (IdeaView)parent; int pos = parentView.getSubViews().indexOf(this); int subCount = parentView.getSubViews().size(); int diff = difference % subCount; int siblingPos = pos + diff; if ((siblingPos < 0) || (siblingPos > (subCount - 1))) { if (!parentView.isRoot()) { return null; } } siblingPos = (siblingPos + subCount) % subCount; return parentView.getSubViews().get(siblingPos); }
redo = true; repaint();
public void removeAllFlags(){ flagPlotters = new HashMap(); }
super(name, maxSize);
super(name, 1);
public ExpandingThreadPool(String name, int maxSize){ super(name, maxSize); this.maxSize = maxSize; }
form.getMsg().emit("org.bedework.client.message.sponsor.alreadyexists");
form.getErr().emit("org.bedework.client.error.sponsor.alreadyexists");
public String doAction(HttpServletRequest request, BwSession sess, PEActionForm form) throws Throwable { /** Check access */ if (!form.getAuthorisedUser()) { return "noAccess"; } String reqpar = request.getParameter("delete"); if (reqpar != null) { return "delete"; } CalSvcI svci = form.getCalSvcI(); boolean add = form.getAddingSponsor(); /** We are just updating from the current form values. */ BwSponsor sp = form.getSponsor(); if (!BwWebUtil.validateSponsor(sp, form.getErr())) { return "retry"; } /* if the sponsor exists use it otherwise add one. */ if (!add && (sp.getId() <= CalFacadeDefs.maxReservedSponsorId)) { // claim it doesn't exist form.getErr().emit("org.bedework.client.error.nosuchsponsor", sp.getId()); return "noSuchSponsor"; } boolean added = false; if (add) { added = svci.addSponsor(sp); } else { svci.replaceSponsor(sp); } updateAuthPrefs(form, null, sp, null, null); if (add) { if (added) { form.getMsg().emit("org.bedework.client.message.sponsor.added"); } else { form.getMsg().emit("org.bedework.client.message.sponsor.alreadyexists"); } } else { form.getMsg().emit("org.bedework.client.message.sponsor.updated"); } return "continue"; }
pkgNode.getChildren().add(clsNode);
pkgNode.addLeafSortedByDescription(clsNode);
private static void addClassNodes(Collection<UMLClassMetadata> umlClasses, LazyActionTreeNode pkgNode){ //build class nodes int bcIndex = pkgNode.getAction().indexOf("&treeBreadCrumbs="); String pkgBreadCrumb = pkgNode.getAction().subSequence(bcIndex, pkgNode.getAction().length()-3).toString(); for (Iterator clsIter = umlClasses.iterator(); clsIter.hasNext(); ) { UMLClassMetadata umlClass = (UMLClassMetadata)clsIter.next(); LazyActionTreeNode clsNode = new LazyActionTreeNode("Class Node", umlClass.getName(), "javascript:classSearchAction('P_PARAM_TYPE=CLASS&P_IDSEQ=" + umlClass.getId() + pkgBreadCrumb + ">>" + umlClass.getName() +" ')", umlClass.getId(), false); pkgNode.getChildren().add(clsNode); } }
projectNode.getChildren().add(subprojectNode);
projectNode.addLeafSortedByDescription(subprojectNode);
private static void addProject(Project project, LazyActionTreeNode pNode){ if (project == null) return; if (project.getClassificationScheme().getLatestVersionIndicator().equalsIgnoreCase("YES")) { Collection<SubProject> subProjects = project.getSubProjectCollection(); Collection<UMLPackageMetadata> pkgs = project.getUMLPackageMetadataCollection(); Context projContext = project.getClassificationScheme().getContext(); LazyActionTreeNode projectNode = new LazyActionTreeNode("Project Folder", project.getLongName(), "javascript:classSearchAction('P_PARAM_TYPE=PROJECT&P_IDSEQ=" + project.getId() + "&treeBreadCrumbs=caDSR Contexts>>" + projContext.getName() + ">>Projects>>" + project.getLongName() + " ')", project.getId(), false); projectNode.setToolTip(project.getClassificationScheme().getPreferredDefinition()); pNode.getChildren().add(projectNode); // build sub project nodes if (subProjects != null) { for (Iterator subprojIter = subProjects.iterator(); subprojIter.hasNext(); ) { SubProject subProject = (SubProject)subprojIter.next(); LazyActionTreeNode subprojectNode = new LazyActionTreeNode("SubProject Folder", subProject.getName(), "javascript:classSearchAction('P_PARAM_TYPE=SUBPROJECT&P_IDSEQ=" + subProject.getId() + "&treeBreadCrumbs=caDSR Contexts>>" + projContext.getName() + ">>Projects>>" + project.getLongName() + ">>" + subProject.getName() + " ')", subProject.getId(), false); projectNode.getChildren().add(subprojectNode); // build package nodes under sub project addPackageNodes(subProject.getUMLPackageMetadataCollection(), subprojectNode); } } // then build package nodes directly under project addPackageNodes(pkgs, projectNode); } }
public LazyActionTreeNode(String type, String description, String actionURL, String identifier, boolean leaf) { super(type, description, identifier, leaf); _action = actionURL;
public LazyActionTreeNode() {
public LazyActionTreeNode(String type, String description, String actionURL, String identifier, boolean leaf) { super(type, description, identifier, leaf); _action = actionURL; }
if (basket != null && !basket.isEmpty()) { basket.clear(); } basket = null; }
if (basket != null && !basket.isEmpty()) { basket.clear(); } if (extraData != null && !extraData.isEmpty()) { extraData.clear(); } basket = null; extraData = null; }
public void emptyBasket() { if (basket != null && !basket.isEmpty()) { basket.clear(); } basket = null; }
ReaderFactory factory = ReaderFactory.getInstance(); try { IdeaReader reader = factory.read(new File("etc/test.opml")); ideaMap.setIdea(reader.getIdea()); } catch(ReaderException re) { re.printStackTrace(); }
private void buildModel() {// ReaderFactory factory = ReaderFactory.getInstance();// try {// IdeaReader reader = factory.read(new File("etc/test.opml"));// ideaMap.setIdea(reader.getIdea());// } catch(ReaderException re) {// re.printStackTrace();// } // Idea idea = new Idea("Persistence");// ideaMap.setIdea(idea);// Idea mistakes = new Idea("Mistakes");// Idea platforms = new Idea("Platforms");// mistakes.add(platforms);// Idea attempts = new Idea("Attempts");// platforms.add(attempts);// Idea continual = new Idea("Continual");// attempts.add(continual);// Idea further = new Idea("Further");// attempts.add(further);// Idea enjoyed = new Idea("Enjoyed");// attempts.add(enjoyed);// Idea thousands = new Idea("Thousands");// mistakes.add(thousands);// Idea making = new Idea("Making");// mistakes.add(making);// Idea progress = new Idea("Progress");// mistakes.add(progress);// Idea learning = new Idea("Learning");// idea.add(learning);// Idea love = new Idea("Love");// learning.add(love);// love.add(mistakes);// idea.add(mistakes); final int lines = 35; final Idea idea = new Idea("Test pattern"); ideaMap.setIdea(idea); (new Thread(){public void run() { for (int i = 0; i < lines; i++) { Idea fred2 = new Idea(" i = " + i); synchronized(idea) { idea.add(fred2); } //try { Thread.sleep(100);} catch(Exception e){} } Idea sub = idea.getSubIdeas().get(0); Idea subIdea0 = null; for (int i = 0; i < 4; i++) { subIdea0 = new Idea("i = " + i); sub.add(subIdea0); try { Thread.sleep(1000);} catch(Exception e){} } try { Thread.sleep(10000);} catch(Exception e){} Idea s2 = subIdea0; for (int i = 0; i < 6; i++) { Idea subIdea2 = new Idea("i = " + i); s2.add(subIdea2); try { Thread.sleep(1000);} catch(Exception e){} } }}).start(); }
final int lines = 35; final Idea idea = new Idea("Test pattern"); ideaMap.setIdea(idea); (new Thread(){public void run() { for (int i = 0; i < lines; i++) { Idea fred2 = new Idea(" i = " + i); synchronized(idea) { idea.add(fred2); } } Idea sub = idea.getSubIdeas().get(0); Idea subIdea0 = null; for (int i = 0; i < 4; i++) { subIdea0 = new Idea("i = " + i); sub.add(subIdea0); try { Thread.sleep(1000);} catch(Exception e){} } try { Thread.sleep(10000);} catch(Exception e){} Idea s2 = subIdea0; for (int i = 0; i < 6; i++) { Idea subIdea2 = new Idea("i = " + i); s2.add(subIdea2); try { Thread.sleep(1000);} catch(Exception e){} } }}).start();
private void buildModel() {// ReaderFactory factory = ReaderFactory.getInstance();// try {// IdeaReader reader = factory.read(new File("etc/test.opml"));// ideaMap.setIdea(reader.getIdea());// } catch(ReaderException re) {// re.printStackTrace();// } // Idea idea = new Idea("Persistence");// ideaMap.setIdea(idea);// Idea mistakes = new Idea("Mistakes");// Idea platforms = new Idea("Platforms");// mistakes.add(platforms);// Idea attempts = new Idea("Attempts");// platforms.add(attempts);// Idea continual = new Idea("Continual");// attempts.add(continual);// Idea further = new Idea("Further");// attempts.add(further);// Idea enjoyed = new Idea("Enjoyed");// attempts.add(enjoyed);// Idea thousands = new Idea("Thousands");// mistakes.add(thousands);// Idea making = new Idea("Making");// mistakes.add(making);// Idea progress = new Idea("Progress");// mistakes.add(progress);// Idea learning = new Idea("Learning");// idea.add(learning);// Idea love = new Idea("Love");// learning.add(love);// love.add(mistakes);// idea.add(mistakes); final int lines = 35; final Idea idea = new Idea("Test pattern"); ideaMap.setIdea(idea); (new Thread(){public void run() { for (int i = 0; i < lines; i++) { Idea fred2 = new Idea(" i = " + i); synchronized(idea) { idea.add(fred2); } //try { Thread.sleep(100);} catch(Exception e){} } Idea sub = idea.getSubIdeas().get(0); Idea subIdea0 = null; for (int i = 0; i < 4; i++) { subIdea0 = new Idea("i = " + i); sub.add(subIdea0); try { Thread.sleep(1000);} catch(Exception e){} } try { Thread.sleep(10000);} catch(Exception e){} Idea s2 = subIdea0; for (int i = 0; i < 6; i++) { Idea subIdea2 = new Idea("i = " + i); s2.add(subIdea2); try { Thread.sleep(1000);} catch(Exception e){} } }}).start(); }
Main.getMainFrame().scoreSheet.resetUsedRowsHack();
public void setMode(int mode) { if (mode <= Main.MODE_IN_LOBBY) { gameBoardData.init(); scoreSheetCaptionData.init(); scoreSheetHoteltypeData.init(); } if (mode < Main.MODE_IN_LOBBY) { userListPresenter.init(); } }
public int insertSubEntry(PreparedStatement stmt, LocalSeismogram localSeismogram, int index,int dbid,byte[] data) throws SQLException {
public int insertSubEntry(PreparedStatement stmt, MicroSecondDate begin, MicroSecondDate end, int index,int dbid,byte[] data) throws SQLException {
public int insertSubEntry(PreparedStatement stmt, LocalSeismogram localSeismogram, int index,int dbid,byte[] data) throws SQLException { stmt.setInt(index++, dbid); stmt.setBytes(index++, data); stmt.setTimestamp(index++, ((edu.iris.Fissures.seismogramDC.LocalSeismogramImpl)localSeismogram).getBeginTime().getTimestamp()); stmt.setTimestamp(index++, ((edu.iris.Fissures.seismogramDC.LocalSeismogramImpl)localSeismogram).getEndTime().getTimestamp()); return index; }
stmt.setTimestamp(index++, ((edu.iris.Fissures.seismogramDC.LocalSeismogramImpl)localSeismogram).getBeginTime().getTimestamp()); stmt.setTimestamp(index++, ((edu.iris.Fissures.seismogramDC.LocalSeismogramImpl)localSeismogram).getEndTime().getTimestamp());
stmt.setTimestamp(index++, begin.getTimestamp()); stmt.setTimestamp(index++, end.getTimestamp());
public int insertSubEntry(PreparedStatement stmt, LocalSeismogram localSeismogram, int index,int dbid,byte[] data) throws SQLException { stmt.setInt(index++, dbid); stmt.setBytes(index++, data); stmt.setTimestamp(index++, ((edu.iris.Fissures.seismogramDC.LocalSeismogramImpl)localSeismogram).getBeginTime().getTimestamp()); stmt.setTimestamp(index++, ((edu.iris.Fissures.seismogramDC.LocalSeismogramImpl)localSeismogram).getEndTime().getTimestamp()); return index; }
insertSubEntry(putSubEntryStmt, localSeismograms[counter], 1, dbid, data);
insertSubEntry(putSubEntryStmt, begin[counter], end[counter], 1, dbid, data);
public int put( edu.iris.Fissures.Plottable plottable[], edu.iris.Fissures.IfNetwork.ChannelId channel_id, edu.iris.Fissures.Dimension pixel_size, int year, int jday, String status) throws SQLException, IOException{ int dbid = 0; //first put the entry into the main table plottable cache //and store the dbid for that entry. int index; dbid = getDBIdStmt(channel_id, year, jday); if( dbid == -1) { dbid = nextId(); putStmt.setInt(1, dbid); index = insert(putStmt, 2, channel_id, year, jday); index = insertDimension(putStmt, index, pixel_size); index = insertTime(putStmt, index); getCurrentTime(); // if( calendar.get(Calendar.DAY_OF_YEAR) > jday && // calendar.get(Calendar.YEAR) >= year) { // if(getCurrentTime()*1000 > (new // MicroSecondDate(seis.getEndTime())).getMicroSecondTime()){ // putStmt.setString(index++, "COMPLETE"); //} else putStmt.setString(index++, status); putStmt.executeUpdate(); conn.commit(); } else { // getCurrentTime(); //if( calendar.get(Calendar.DAY_OF_YEAR) > jday && // calendar.get(Calendar.YEAR) >= year) // updateStatusStmt.setString(1, "COMPLETE"); //else updateStatusStmt.setString(1, status); updateStatusStmt.setInt(2, dbid); updateStatusStmt.executeUpdate(); conn.commit(); } //Now iterate through the array of plottables and //create largeobjectid using large object manager and creat large // objects //and insert the dbid and oid corressponding into the //table plottablecacheentries. for(int counter = 0; counter < plottable.length; counter++) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(baos); os.writeObject(plottable[counter]); os.flush(); os.close(); byte[] data = baos.toByteArray(); insertSubEntry(putSubEntryStmt, localSeismograms[counter], 1, dbid, data); putSubEntryStmt.executeUpdate(); conn.commit(); } return dbid; }
containers[i].addListener(this);
if (containers[i].isPanel()) { containers[i].addListener(this); }
public TabBar() { setTabPlacement(MainConfiguration.getInt("gui.tabs.placement", TOP)); //$NON-NLS-1$ addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON3) { menu.show(pointerToThisForListeners, e.getX(), e.getY()); } } public void mouseReleased(MouseEvent e) { } }); addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { forwardFocusInWindow(); } }); ModuleContainer[] containers = ModuleLoader.getLoadedModules(); for (int i = 0; i < containers.length; i++) { containers[i].addListener(this); } ModuleLoader.addListener(this); }
FissuresNamingServiceImpl fissuresNamingService = new FissuresNamingServiceImpl(orb);
FissuresNamingService fissuresNamingService = new FissuresNamingService(orb);
public Channel[] retrieve_grouping(org.omg.CORBA_2_3.ORB orb, ChannelId channelId) { Channel[] group; try { FissuresNamingServiceImpl fissuresNamingService = new FissuresNamingServiceImpl(orb); NetworkDC[] networkReferences = fissuresNamingService.getNetworkDCObjects(); // ChannelId channelId = channel.get_id(); for(int counter = 0; counter < networkReferences.length; counter++) { try { NetworkAccess networkAccess = networkReferences[counter].a_finder().retrieve_by_id(channelId.network_id); Channel channel = networkAccess.retrieve_channel(channelId); Channel[] channels = networkAccess.retrieve_for_station(channel.my_site.my_station.get_id()); ChannelGrouperImpl channelGrouperImpl = new ChannelGrouperImpl(); group = channelGrouperImpl.retrieve_grouping(channels, channel); if(group.length == 3) return group; } catch(Throwable e) { e.printStackTrace(); continue; } } } catch(Exception e) { e.printStackTrace(); return new Channel[0]; } return null; }
SimplePlotUtil.flipArray(pixels[1], size.height);
public Shape draw(Dimension size){ if(visible){ try{ MicroSecondTimeRange overTimeRange = timeConfig.getTimeRange(seis). getOversizedTimeRange(BasicSeismogramDisplay.OVERSIZED_SCALE); int[][] pixels = SimplePlotUtil.compressYvalues(filteredSeis, overTimeRange, ampConfig.getAmpRange(seis), size); SimplePlotUtil.scaleYvalues(pixels, filteredSeis, overTimeRange, ampConfig.getAmpRange(seis), size); int[] xPixels = pixels[0]; int[] yPixels = pixels[1]; if(xPixels.length >= 2){ GeneralPath currentShape = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPixels.length - 1); currentShape.moveTo(xPixels[0], yPixels[0]); for(int i = 1; i < xPixels.length; i++) currentShape.lineTo(xPixels[i], yPixels[i]); return currentShape; }else if(xPixels.length == 1){ GeneralPath currentShape = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 2); currentShape.moveTo(0, yPixels[0]); currentShape.lineTo(size.width, yPixels[0]); return currentShape; } }catch(Exception e){ e.printStackTrace(); } } return new GeneralPath(); }
this.ideaMap.requestFocusInWindow();
public Mainframe() { setTitle(resBundle.getString("app.name")); Settings s = Settings.getInstance(); setBounds(s.getWindowLeft(), s.getWindowTop(), s.getWindowWidth(), s.getWindowHeight()); buildView(); buildModel(); }
jTextField.meta_invoke(jTextField, AGSymbol.alloc("new"), new NATTable(new ATObject[] { NATNumber.atValue(80) }));
jTextField.meta_invoke(jTextField, AGSymbol.jAlloc("new"), new NATTable(new ATObject[] { NATNumber.atValue(80) }));
public void testBugfixOverloadedConstructor() throws InterpreterException { // def jTextField := jLobby.javax.swing.JTextField; ATObject jTextField = JavaClass.wrapperFor(JTextField.class); // jTextField.new(80) jTextField.meta_invoke(jTextField, AGSymbol.alloc("new"), new NATTable(new ATObject[] { NATNumber.atValue(80) })); }
ATObject method = atTestObject.meta_select(atTestObject, AGSymbol.alloc("overloadedmatch2")); ATObject castedMethod = method.meta_invoke(method, AGSymbol.alloc("cast"), new NATTable(new ATObject[] { atTestClass }));
ATObject method = atTestObject.meta_select(atTestObject, AGSymbol.jAlloc("overloadedmatch2")); ATObject castedMethod = method.meta_invoke(method, AGSymbol.jAlloc("cast"), new NATTable(new ATObject[] { atTestClass }));
public void testCasting() { try { // invokes overloadedmatch2(SymbiosisTest) via explicit casting ATObject method = atTestObject.meta_select(atTestObject, AGSymbol.alloc("overloadedmatch2")); ATObject castedMethod = method.meta_invoke(method, AGSymbol.alloc("cast"), new NATTable(new ATObject[] { atTestClass })); castedMethod.base_asMethod().base_apply(new NATTable(new ATObject[] { atTestObject }), null); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(55, instance.meta_select(instance, AGSymbol.alloc("xtest")).asNativeNumber().javaValue);
assertEquals(55, instance.meta_select(instance, AGSymbol.jAlloc("xtest")).asNativeNumber().javaValue);
public void testCreationViaJavaObject() { try { // def instance := atTestObject.new(55) ATObject instance = atTestObject.meta_newInstance( new NATTable(new ATObject[] { NATNumber.atValue(55) })); assertEquals(55, instance.meta_select(instance, AGSymbol.alloc("xtest")).asNativeNumber().javaValue); assertEquals(atTestClass, instance.meta_getDynamicParent()); assertEquals(jTestObject.xtest, atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")).asNativeNumber().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
AGSymbol.alloc("xtest")).asNativeNumber().javaValue);
AGSymbol.jAlloc("xtest")).asNativeNumber().javaValue);
public void testCreationViaJavaObject() { try { // def instance := atTestObject.new(55) ATObject instance = atTestObject.meta_newInstance( new NATTable(new ATObject[] { NATNumber.atValue(55) })); assertEquals(55, instance.meta_select(instance, AGSymbol.alloc("xtest")).asNativeNumber().javaValue); assertEquals(atTestClass, instance.meta_getDynamicParent()); assertEquals(jTestObject.xtest, atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")).asNativeNumber().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(10, instance.meta_select(instance, AGSymbol.alloc("xtest")).asNativeNumber().javaValue); assertEquals(11, instance.meta_select(instance, AGSymbol.alloc("ytest")).asNativeNumber().javaValue);
assertEquals(10, instance.meta_select(instance, AGSymbol.jAlloc("xtest")).asNativeNumber().javaValue); assertEquals(11, instance.meta_select(instance, AGSymbol.jAlloc("ytest")).asNativeNumber().javaValue);
public void testCustomInstanceCreation() { try { // def atTestClass.init(x) { def o := super.init(x); def o.ytest := y; o } ATClosure init = evalAndReturn("def init(x,y) { def o := super.init(x); def o.ytest := y; o }; init").base_asClosure(); atTestClass.meta_addMethod(init.base_getMethod()); // def instance := atTestClass.new(10, 11) ATObject instance = atTestClass.meta_newInstance(new NATTable(new ATObject[] { NATNumber.atValue(10), NATNumber.atValue(11) })); assertEquals(10, instance.meta_select(instance, AGSymbol.alloc("xtest")).asNativeNumber().javaValue); assertEquals(11, instance.meta_select(instance, AGSymbol.alloc("ytest")).asNativeNumber().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), new NATTable(new ATObject[] { NATNil._INSTANCE_ }));
atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("gettertest"), new NATTable(new ATObject[] { NATNil._INSTANCE_ }));
public void testFaultyArity() { try { atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), new NATTable(new ATObject[] { NATNil._INSTANCE_ })); fail("Expected an arity mismatch exception"); } catch(XArityMismatch e) { // expected exception: success } catch(InterpreterException e) { fail(e.getMessage()); } }
ATField result = atTestObject.meta_grabField(AGSymbol.alloc("xtest")).base_asField();
ATField result = atTestObject.meta_grabField(AGSymbol.jAlloc("xtest")).base_asField();
public void testFirstClassFields() { try { // def result := (reflect: atTestObject).grabField("xtest") ATField result = atTestObject.meta_grabField(AGSymbol.alloc("xtest")).base_asField(); assertEquals("xtest", result.base_getName().toString()); assertEquals(TEST_OBJECT_INIT, result.base_getValue().asNativeNumber().javaValue); // result := (reflect: atTestClass).grabField("ytest") result = atTestClass.meta_grabField(AGSymbol.alloc("ytest")).base_asField(); assertEquals("ytest", result.base_getName().toString()); assertEquals(ytest, result.base_getValue().asNativeText().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
result = atTestClass.meta_grabField(AGSymbol.alloc("ytest")).base_asField();
result = atTestClass.meta_grabField(AGSymbol.jAlloc("ytest")).base_asField();
public void testFirstClassFields() { try { // def result := (reflect: atTestObject).grabField("xtest") ATField result = atTestObject.meta_grabField(AGSymbol.alloc("xtest")).base_asField(); assertEquals("xtest", result.base_getName().toString()); assertEquals(TEST_OBJECT_INIT, result.base_getValue().asNativeNumber().javaValue); // result := (reflect: atTestClass).grabField("ytest") result = atTestClass.meta_grabField(AGSymbol.alloc("ytest")).base_asField(); assertEquals("ytest", result.base_getName().toString()); assertEquals(ytest, result.base_getValue().asNativeText().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
ATMethod result = atTestObject.meta_grabMethod(AGSymbol.alloc("gettertest")).base_asMethod();
ATMethod result = atTestObject.meta_grabMethod(AGSymbol.jAlloc("gettertest")).base_asMethod();
public void testFirstClassMethods() { try { // def result := (reflect: atTestObject).grabMethod("gettertest") ATMethod result = atTestObject.meta_grabMethod(AGSymbol.alloc("gettertest")).base_asMethod(); assertEquals("gettertest", result.base_getName().toString()); // assert (42 == result()) assertEquals(TEST_OBJECT_INIT, result.base_apply(NATTable.EMPTY, null).asNativeNumber().javaValue); // result := (reflect: atTestClass).grabMethod("prefix") result = atTestClass.meta_grabMethod(AGSymbol.alloc("prefix")).base_asMethod(); assertEquals("prefix", result.base_getName().toString()); // assert ("AmbientTalk" == result("")) assertEquals(ytest, result.base_apply(new NATTable(new ATObject[] { NATText.atValue("") }), null).asNativeText().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
result = atTestClass.meta_grabMethod(AGSymbol.alloc("prefix")).base_asMethod();
result = atTestClass.meta_grabMethod(AGSymbol.jAlloc("prefix")).base_asMethod();
public void testFirstClassMethods() { try { // def result := (reflect: atTestObject).grabMethod("gettertest") ATMethod result = atTestObject.meta_grabMethod(AGSymbol.alloc("gettertest")).base_asMethod(); assertEquals("gettertest", result.base_getName().toString()); // assert (42 == result()) assertEquals(TEST_OBJECT_INIT, result.base_apply(NATTable.EMPTY, null).asNativeNumber().javaValue); // result := (reflect: atTestClass).grabMethod("prefix") result = atTestClass.meta_grabMethod(AGSymbol.alloc("prefix")).base_asMethod(); assertEquals("prefix", result.base_getName().toString()); // assert ("AmbientTalk" == result("")) assertEquals(ytest, result.base_apply(new NATTable(new ATObject[] { NATText.atValue("") }), null).asNativeText().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATFraction.atValue(0.1) }));
atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("settertest"), new NATTable(new ATObject[] { NATFraction.atValue(0.1) }));
public void testIllegalArgs() { try { atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATFraction.atValue(0.1) })); fail("Expected an illegal argument exception"); } catch(XTypeMismatch e) { // Java expects an int, so AT expects a native number, but is given a native fraction if (e.getExpectedType() == NATNumber.class) { // expected exception: success } else { fail(e.getMessage()); } } catch(InterpreterException e) { fail(e.getMessage()); } }
atTestClass.meta_assignField(atTestClass, AGSymbol.alloc("TEST_OBJECT_INIT"), NATNumber.atValue(0));
atTestClass.meta_assignField(atTestClass, AGSymbol.jAlloc("TEST_OBJECT_INIT"), NATNumber.atValue(0));
public void testIllegalAssignment() { try { atTestClass.meta_assignField(atTestClass, AGSymbol.alloc("TEST_OBJECT_INIT"), NATNumber.atValue(0)); fail("Expected an illegal assignment exception"); } catch(XUnassignableField e) { // expected exception: success } catch(InterpreterException e) { fail(e.getMessage()); } }
AGSymbol.alloc("class"), new NATTable(new ATObject[] { AGSymbol.alloc("lowercaseClassTest") }));
AGSymbol.jAlloc("class"), new NATTable(new ATObject[] { AGSymbol.jAlloc("lowercaseClassTest") }));
public void testJLobbyExplicitClassLoading() throws InterpreterException { ATObject eduVubAtObjectsSymbiosisPkg = new JavaPackage("edu.vub.at.objects.symbiosis."); // load the class manually: invoke pkg.class("lowercaseClassTest") ATObject cls = eduVubAtObjectsSymbiosisPkg.meta_invoke( eduVubAtObjectsSymbiosisPkg, AGSymbol.alloc("class"), new NATTable(new ATObject[] { AGSymbol.alloc("lowercaseClassTest") })); assertEquals(JavaClass.class, cls.getClass()); assertTrue(eduVubAtObjectsSymbiosisPkg.meta_respondsTo( AGSymbol.alloc("lowercaseClassTest")).asNativeBoolean().javaValue); }
AGSymbol.alloc("lowercaseClassTest")).asNativeBoolean().javaValue);
AGSymbol.jAlloc("lowercaseClassTest")).asNativeBoolean().javaValue);
public void testJLobbyExplicitClassLoading() throws InterpreterException { ATObject eduVubAtObjectsSymbiosisPkg = new JavaPackage("edu.vub.at.objects.symbiosis."); // load the class manually: invoke pkg.class("lowercaseClassTest") ATObject cls = eduVubAtObjectsSymbiosisPkg.meta_invoke( eduVubAtObjectsSymbiosisPkg, AGSymbol.alloc("class"), new NATTable(new ATObject[] { AGSymbol.alloc("lowercaseClassTest") })); assertEquals(JavaClass.class, cls.getClass()); assertTrue(eduVubAtObjectsSymbiosisPkg.meta_respondsTo( AGSymbol.alloc("lowercaseClassTest")).asNativeBoolean().javaValue); }
ATObject fooPkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("foo"));
ATObject fooPkg = jLobby_.meta_select(jLobby_, AGSymbol.jAlloc("foo"));
public void testJLobbyExplicitPackageLoading() throws InterpreterException { // def fooPkg := jLobby.foo; ATObject fooPkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("foo")); // def BarPkg := foo.package(`Bar); ATObject BarPkg = fooPkg.meta_invoke(fooPkg, AGSymbol.alloc("package"), new NATTable(new ATObject[] { AGSymbol.alloc("Bar") })); assertEquals(JavaPackage.class, BarPkg.getClass()); assertTrue(fooPkg.meta_respondsTo(AGSymbol.alloc("Bar")).asNativeBoolean().javaValue); }
AGSymbol.alloc("package"), new NATTable(new ATObject[] { AGSymbol.alloc("Bar") }));
AGSymbol.jAlloc("package"), new NATTable(new ATObject[] { AGSymbol.jAlloc("Bar") }));
public void testJLobbyExplicitPackageLoading() throws InterpreterException { // def fooPkg := jLobby.foo; ATObject fooPkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("foo")); // def BarPkg := foo.package(`Bar); ATObject BarPkg = fooPkg.meta_invoke(fooPkg, AGSymbol.alloc("package"), new NATTable(new ATObject[] { AGSymbol.alloc("Bar") })); assertEquals(JavaPackage.class, BarPkg.getClass()); assertTrue(fooPkg.meta_respondsTo(AGSymbol.alloc("Bar")).asNativeBoolean().javaValue); }
assertTrue(fooPkg.meta_respondsTo(AGSymbol.alloc("Bar")).asNativeBoolean().javaValue);
assertTrue(fooPkg.meta_respondsTo(AGSymbol.jAlloc("Bar")).asNativeBoolean().javaValue);
public void testJLobbyExplicitPackageLoading() throws InterpreterException { // def fooPkg := jLobby.foo; ATObject fooPkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("foo")); // def BarPkg := foo.package(`Bar); ATObject BarPkg = fooPkg.meta_invoke(fooPkg, AGSymbol.alloc("package"), new NATTable(new ATObject[] { AGSymbol.alloc("Bar") })); assertEquals(JavaPackage.class, BarPkg.getClass()); assertTrue(fooPkg.meta_respondsTo(AGSymbol.alloc("Bar")).asNativeBoolean().javaValue); }
jLobby_.meta_select(jLobby_, AGSymbol.alloc("Foo"));
jLobby_.meta_select(jLobby_, AGSymbol.jAlloc("Foo"));
public void testJLobbyNonexistentClassLoading() throws InterpreterException { try { jLobby_.meta_select(jLobby_, AGSymbol.alloc("Foo")); fail("expected a class not found exception"); } catch (XClassNotFound e) { // success: expected exception } }
ATObject jpkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("java"));
ATObject jpkg = jLobby_.meta_select(jLobby_, AGSymbol.jAlloc("java"));
public void testJLobbyPackageLoading() throws InterpreterException { ATObject jpkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("java")); assertEquals(JavaPackage.class, jpkg.getClass()); assertTrue(jLobby_.meta_respondsTo(AGSymbol.alloc("java")).asNativeBoolean().javaValue); ATObject jlpkg = jpkg.meta_select(jpkg, AGSymbol.alloc("lang")); assertEquals(JavaPackage.class, jlpkg.getClass()); assertTrue(jpkg.meta_respondsTo(AGSymbol.alloc("lang")).asNativeBoolean().javaValue); ATObject jObject = jlpkg.meta_select(jlpkg, AGSymbol.alloc("Object")); assertEquals(JavaClass.class, jObject.getClass()); assertTrue(jlpkg.meta_respondsTo(AGSymbol.alloc("Object")).asNativeBoolean().javaValue); }
assertTrue(jLobby_.meta_respondsTo(AGSymbol.alloc("java")).asNativeBoolean().javaValue); ATObject jlpkg = jpkg.meta_select(jpkg, AGSymbol.alloc("lang"));
assertTrue(jLobby_.meta_respondsTo(AGSymbol.jAlloc("java")).asNativeBoolean().javaValue); ATObject jlpkg = jpkg.meta_select(jpkg, AGSymbol.jAlloc("lang"));
public void testJLobbyPackageLoading() throws InterpreterException { ATObject jpkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("java")); assertEquals(JavaPackage.class, jpkg.getClass()); assertTrue(jLobby_.meta_respondsTo(AGSymbol.alloc("java")).asNativeBoolean().javaValue); ATObject jlpkg = jpkg.meta_select(jpkg, AGSymbol.alloc("lang")); assertEquals(JavaPackage.class, jlpkg.getClass()); assertTrue(jpkg.meta_respondsTo(AGSymbol.alloc("lang")).asNativeBoolean().javaValue); ATObject jObject = jlpkg.meta_select(jlpkg, AGSymbol.alloc("Object")); assertEquals(JavaClass.class, jObject.getClass()); assertTrue(jlpkg.meta_respondsTo(AGSymbol.alloc("Object")).asNativeBoolean().javaValue); }
assertTrue(jpkg.meta_respondsTo(AGSymbol.alloc("lang")).asNativeBoolean().javaValue); ATObject jObject = jlpkg.meta_select(jlpkg, AGSymbol.alloc("Object"));
assertTrue(jpkg.meta_respondsTo(AGSymbol.jAlloc("lang")).asNativeBoolean().javaValue); ATObject jObject = jlpkg.meta_select(jlpkg, AGSymbol.jAlloc("Object"));
public void testJLobbyPackageLoading() throws InterpreterException { ATObject jpkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("java")); assertEquals(JavaPackage.class, jpkg.getClass()); assertTrue(jLobby_.meta_respondsTo(AGSymbol.alloc("java")).asNativeBoolean().javaValue); ATObject jlpkg = jpkg.meta_select(jpkg, AGSymbol.alloc("lang")); assertEquals(JavaPackage.class, jlpkg.getClass()); assertTrue(jpkg.meta_respondsTo(AGSymbol.alloc("lang")).asNativeBoolean().javaValue); ATObject jObject = jlpkg.meta_select(jlpkg, AGSymbol.alloc("Object")); assertEquals(JavaClass.class, jObject.getClass()); assertTrue(jlpkg.meta_respondsTo(AGSymbol.alloc("Object")).asNativeBoolean().javaValue); }
assertTrue(jlpkg.meta_respondsTo(AGSymbol.alloc("Object")).asNativeBoolean().javaValue);
assertTrue(jlpkg.meta_respondsTo(AGSymbol.jAlloc("Object")).asNativeBoolean().javaValue);
public void testJLobbyPackageLoading() throws InterpreterException { ATObject jpkg = jLobby_.meta_select(jLobby_, AGSymbol.alloc("java")); assertEquals(JavaPackage.class, jpkg.getClass()); assertTrue(jLobby_.meta_respondsTo(AGSymbol.alloc("java")).asNativeBoolean().javaValue); ATObject jlpkg = jpkg.meta_select(jpkg, AGSymbol.alloc("lang")); assertEquals(JavaPackage.class, jlpkg.getClass()); assertTrue(jpkg.meta_respondsTo(AGSymbol.alloc("lang")).asNativeBoolean().javaValue); ATObject jObject = jlpkg.meta_select(jlpkg, AGSymbol.alloc("Object")); assertEquals(JavaClass.class, jObject.getClass()); assertTrue(jlpkg.meta_respondsTo(AGSymbol.alloc("Object")).asNativeBoolean().javaValue); }
atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("foo"),
atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("foo"),
public void testNonExistentMethod() { try { // invokes foo(1) => error atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("foo"), new NATTable(new ATObject[] { NATNumber.ONE })); fail("Expected a selector not found exception"); } catch (XSelectorNotFound e) { // success: expected exception } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedmatch2"),
atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("overloadedmatch2"),
public void testOverloadedInvWithMultipleMatches() { try { // invokes overloadedmatch2(Object|SymbiosisTest) => error atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedmatch2"), new NATTable(new ATObject[] { atTestObject })); fail("Expected a symbiosis exception"); } catch (XSymbiosisFailure e) { // success: expected exception } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedtest"),
atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("overloadedtest"),
public void testOverloadedInvWithNoMatch() { try { // invokes overloadedtest(NATObject) => error atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedtest"), new NATTable(new ATObject[] { new NATObject() })); fail("Expected a symbiosis exception"); } catch (XSymbiosisFailure e) { // success: expected exception } catch (InterpreterException e) { fail(e.getMessage()); } }
AGSymbol.alloc("overloadedtest"),
AGSymbol.jAlloc("overloadedtest"),
public void testOverloadedInvWithOneMatch() { try { // invokes overloadedtest(int) ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedtest"), new NATTable(new ATObject[] { NATNumber.ZERO })); assertEquals("(int)", result.asNativeText().javaValue); // invokes overloadedtest(SymbiosisTest) result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedtest"), new NATTable(new ATObject[] { atTestObject })); assertEquals("(SymbiosisTest)", result.asNativeText().javaValue); // invokes overloadedtest() result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedtest"), NATTable.EMPTY); assertEquals("()", result.asNativeText().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestClass.meta_defineField(AGSymbol.alloc("z"), NATNumber.ONE);
atTestClass.meta_defineField(AGSymbol.jAlloc("z"), NATNumber.ONE);
public void testSymbiontClassAdditions() { try { // (reflect: atTestClass).defineField("z", 1) atTestClass.meta_defineField(AGSymbol.alloc("z"), NATNumber.ONE); // assert(atTestClass.z == 1) assertEquals(NATNumber.ONE, atTestClass.meta_select(atTestClass, AGSymbol.alloc("z"))); // assert(aTestObject.z == 1) -> delegation to class assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("z"))); // (reflect: atTestClass).addMethod(<method:"get",[],{self.xtest}>) ATMethod get = evalAndReturn("def get() { self.xtest }; get").base_asClosure().base_getMethod(); atTestClass.meta_addMethod(get); // assert(atTestObject.xtest == atTestObject.get()) assertEquals(atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")), atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("get"), NATTable.EMPTY)); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(NATNumber.ONE, atTestClass.meta_select(atTestClass, AGSymbol.alloc("z")));
assertEquals(NATNumber.ONE, atTestClass.meta_select(atTestClass, AGSymbol.jAlloc("z")));
public void testSymbiontClassAdditions() { try { // (reflect: atTestClass).defineField("z", 1) atTestClass.meta_defineField(AGSymbol.alloc("z"), NATNumber.ONE); // assert(atTestClass.z == 1) assertEquals(NATNumber.ONE, atTestClass.meta_select(atTestClass, AGSymbol.alloc("z"))); // assert(aTestObject.z == 1) -> delegation to class assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("z"))); // (reflect: atTestClass).addMethod(<method:"get",[],{self.xtest}>) ATMethod get = evalAndReturn("def get() { self.xtest }; get").base_asClosure().base_getMethod(); atTestClass.meta_addMethod(get); // assert(atTestObject.xtest == atTestObject.get()) assertEquals(atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")), atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("get"), NATTable.EMPTY)); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("z")));
assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.jAlloc("z")));
public void testSymbiontClassAdditions() { try { // (reflect: atTestClass).defineField("z", 1) atTestClass.meta_defineField(AGSymbol.alloc("z"), NATNumber.ONE); // assert(atTestClass.z == 1) assertEquals(NATNumber.ONE, atTestClass.meta_select(atTestClass, AGSymbol.alloc("z"))); // assert(aTestObject.z == 1) -> delegation to class assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("z"))); // (reflect: atTestClass).addMethod(<method:"get",[],{self.xtest}>) ATMethod get = evalAndReturn("def get() { self.xtest }; get").base_asClosure().base_getMethod(); atTestClass.meta_addMethod(get); // assert(atTestObject.xtest == atTestObject.get()) assertEquals(atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")), atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("get"), NATTable.EMPTY)); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")), atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("get"), NATTable.EMPTY));
assertEquals(atTestObject.meta_select(atTestObject, AGSymbol.jAlloc("xtest")), atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("get"), NATTable.EMPTY));
public void testSymbiontClassAdditions() { try { // (reflect: atTestClass).defineField("z", 1) atTestClass.meta_defineField(AGSymbol.alloc("z"), NATNumber.ONE); // assert(atTestClass.z == 1) assertEquals(NATNumber.ONE, atTestClass.meta_select(atTestClass, AGSymbol.alloc("z"))); // assert(aTestObject.z == 1) -> delegation to class assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("z"))); // (reflect: atTestClass).addMethod(<method:"get",[],{self.xtest}>) ATMethod get = evalAndReturn("def get() { self.xtest }; get").base_asClosure().base_getMethod(); atTestClass.meta_addMethod(get); // assert(atTestObject.xtest == atTestObject.get()) assertEquals(atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")), atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("get"), NATTable.EMPTY)); } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestObject.meta_defineField(AGSymbol.alloc("xtest"), NATNumber.ONE);
atTestObject.meta_defineField(AGSymbol.jAlloc("xtest"), NATNumber.ONE);
public void testSymbiontDuplicates() { try { try { // def atTestObject.xtest := 1 atTestObject.meta_defineField(AGSymbol.alloc("xtest"), NATNumber.ONE); fail("expected a duplicate slot exception"); } catch (XDuplicateSlot e) { // expected exception: success } try { // def atTestObject.gettertest() { nil } ATMethod getter = evalAndReturn("def gettertest() { nil }; gettertest").base_asClosure().base_getMethod(); atTestObject.meta_addMethod(getter); fail("expected a duplicate slot exception"); } catch (XDuplicateSlot e) { // expected exception: success } } catch (InterpreterException e) { fail(e.getMessage()); } }
atTestObject.meta_defineField(AGSymbol.alloc("x"), NATNumber.ONE);
atTestObject.meta_defineField(AGSymbol.jAlloc("x"), NATNumber.ONE);
public void testSymbiontInstanceAdditions() { try { // (reflect: atTestObject).defineField("x", 1) atTestObject.meta_defineField(AGSymbol.alloc("x"), NATNumber.ONE); // assert(atTestObject.x == 1) assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("x"))); // (reflect: atTestObject).addMethod(<method:"foo",[x],{x}>) ATMethod foo = evalAndReturn("def foo(x) { x }; foo").base_asClosure().base_getMethod(); atTestObject.meta_addMethod(foo); // assert(atTestObject.foo(0) == 0) assertEquals(NATNumber.ZERO, atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("foo"), new NATTable(new ATObject[] { NATNumber.ZERO }))); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("x")));
assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.jAlloc("x")));
public void testSymbiontInstanceAdditions() { try { // (reflect: atTestObject).defineField("x", 1) atTestObject.meta_defineField(AGSymbol.alloc("x"), NATNumber.ONE); // assert(atTestObject.x == 1) assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("x"))); // (reflect: atTestObject).addMethod(<method:"foo",[x],{x}>) ATMethod foo = evalAndReturn("def foo(x) { x }; foo").base_asClosure().base_getMethod(); atTestObject.meta_addMethod(foo); // assert(atTestObject.foo(0) == 0) assertEquals(NATNumber.ZERO, atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("foo"), new NATTable(new ATObject[] { NATNumber.ZERO }))); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(NATNumber.ZERO, atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("foo"),
assertEquals(NATNumber.ZERO, atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("foo"),
public void testSymbiontInstanceAdditions() { try { // (reflect: atTestObject).defineField("x", 1) atTestObject.meta_defineField(AGSymbol.alloc("x"), NATNumber.ONE); // assert(atTestObject.x == 1) assertEquals(NATNumber.ONE, atTestObject.meta_select(atTestObject, AGSymbol.alloc("x"))); // (reflect: atTestObject).addMethod(<method:"foo",[x],{x}>) ATMethod foo = evalAndReturn("def foo(x) { x }; foo").base_asClosure().base_getMethod(); atTestObject.meta_addMethod(foo); // assert(atTestObject.foo(0) == 0) assertEquals(NATNumber.ZERO, atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("foo"), new NATTable(new ATObject[] { NATNumber.ZERO }))); } catch (InterpreterException e) { fail(e.getMessage()); } }
AGSymbol.alloc("overloadedvararg"),
AGSymbol.jAlloc("overloadedvararg"),
public void testVarArgInvocation() { try { ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("overloadedvararg"), new NATTable(new ATObject[] { NATNumber.ZERO, NATNumber.ONE })); assertEquals(NATNil._INSTANCE_, result); } catch (InterpreterException e) { fail(e.getMessage()); } }
ATObject result = atTestClass.meta_invoke(atTestClass, AGSymbol.alloc("prefix"), new NATTable(new ATObject[] { prefix }));
ATObject result = atTestClass.meta_invoke(atTestClass, AGSymbol.jAlloc("prefix"), new NATTable(new ATObject[] { prefix }));
public void testWorkingClassInvocation() { try { // def result := atTestClass.prefix("Hello, "); assert("Hello, " + ytest == result) String txt = "Hello, "; NATText prefix = NATText.atValue(txt); ATObject result = atTestClass.meta_invoke(atTestClass, AGSymbol.alloc("prefix"), new NATTable(new ATObject[] { prefix })); assertEquals(txt + ytest, result.asNativeText().javaValue); // result := atTestClass.ytest; assert(result == ytest); result = atTestClass.meta_select(atTestClass, AGSymbol.alloc("ytest")); assertEquals(ytest, result.asNativeText().javaValue); // atTestClass.ytest := "Hello, "; assert(ytest == "Hello, ") result = atTestClass.meta_assignField(atTestClass, AGSymbol.alloc("ytest"), prefix); assertEquals(NATNil._INSTANCE_, result); assertEquals(txt, ytest); } catch (InterpreterException e) { fail(e.getMessage()); } }
result = atTestClass.meta_select(atTestClass, AGSymbol.alloc("ytest"));
result = atTestClass.meta_select(atTestClass, AGSymbol.jAlloc("ytest"));
public void testWorkingClassInvocation() { try { // def result := atTestClass.prefix("Hello, "); assert("Hello, " + ytest == result) String txt = "Hello, "; NATText prefix = NATText.atValue(txt); ATObject result = atTestClass.meta_invoke(atTestClass, AGSymbol.alloc("prefix"), new NATTable(new ATObject[] { prefix })); assertEquals(txt + ytest, result.asNativeText().javaValue); // result := atTestClass.ytest; assert(result == ytest); result = atTestClass.meta_select(atTestClass, AGSymbol.alloc("ytest")); assertEquals(ytest, result.asNativeText().javaValue); // atTestClass.ytest := "Hello, "; assert(ytest == "Hello, ") result = atTestClass.meta_assignField(atTestClass, AGSymbol.alloc("ytest"), prefix); assertEquals(NATNil._INSTANCE_, result); assertEquals(txt, ytest); } catch (InterpreterException e) { fail(e.getMessage()); } }
result = atTestClass.meta_assignField(atTestClass, AGSymbol.alloc("ytest"), prefix);
result = atTestClass.meta_assignField(atTestClass, AGSymbol.jAlloc("ytest"), prefix);
public void testWorkingClassInvocation() { try { // def result := atTestClass.prefix("Hello, "); assert("Hello, " + ytest == result) String txt = "Hello, "; NATText prefix = NATText.atValue(txt); ATObject result = atTestClass.meta_invoke(atTestClass, AGSymbol.alloc("prefix"), new NATTable(new ATObject[] { prefix })); assertEquals(txt + ytest, result.asNativeText().javaValue); // result := atTestClass.ytest; assert(result == ytest); result = atTestClass.meta_select(atTestClass, AGSymbol.alloc("ytest")); assertEquals(ytest, result.asNativeText().javaValue); // atTestClass.ytest := "Hello, "; assert(ytest == "Hello, ") result = atTestClass.meta_assignField(atTestClass, AGSymbol.alloc("ytest"), prefix); assertEquals(NATNil._INSTANCE_, result); assertEquals(txt, ytest); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertEquals(NATNumber.ONE, instance.meta_select(instance, AGSymbol.alloc("xtest")));
assertEquals(NATNumber.ONE, instance.meta_select(instance, AGSymbol.jAlloc("xtest")));
public void testWorkingInstanceCreation() { try { // def instance := atTestClass.new(1) ATObject instance = atTestClass.meta_newInstance(new NATTable(new ATObject[] { NATNumber.ONE })); assertEquals(JavaObject.class, instance.getClass()); assertEquals(NATNumber.ONE, instance.meta_select(instance, AGSymbol.alloc("xtest"))); Object realInstance = instance.asJavaObjectUnderSymbiosis().getWrappedObject(); assertEquals(SymbiosisTest.class, realInstance.getClass()); assertEquals(1, ((SymbiosisTest) realInstance).xtest); } catch (InterpreterException e) { fail(e.getMessage()); } }
ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), NATTable.EMPTY);
ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("gettertest"), NATTable.EMPTY);
public void testWorkingInstanceInvocation() { try { // def result := atTestObject.gettertest(); assert(42 == result) ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), NATTable.EMPTY); assertEquals(TEST_OBJECT_INIT, result.asNativeNumber().javaValue); // result := atTestObject.settertest(1); assert(result == nil); assert(atTestObject.xtest == 1) result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATNumber.ONE })); assertEquals(NATNil._INSTANCE_, result); assertEquals(1, jTestObject.xtest); result = atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")); assertEquals(NATNumber.ONE, result); assertTrue(atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("identitytest"), new NATTable(new ATObject[] { atTestObject })).asNativeBoolean().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATNumber.ONE }));
result = atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("settertest"), new NATTable(new ATObject[] { NATNumber.ONE }));
public void testWorkingInstanceInvocation() { try { // def result := atTestObject.gettertest(); assert(42 == result) ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), NATTable.EMPTY); assertEquals(TEST_OBJECT_INIT, result.asNativeNumber().javaValue); // result := atTestObject.settertest(1); assert(result == nil); assert(atTestObject.xtest == 1) result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATNumber.ONE })); assertEquals(NATNil._INSTANCE_, result); assertEquals(1, jTestObject.xtest); result = atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")); assertEquals(NATNumber.ONE, result); assertTrue(atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("identitytest"), new NATTable(new ATObject[] { atTestObject })).asNativeBoolean().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
result = atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest"));
result = atTestObject.meta_select(atTestObject, AGSymbol.jAlloc("xtest"));
public void testWorkingInstanceInvocation() { try { // def result := atTestObject.gettertest(); assert(42 == result) ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), NATTable.EMPTY); assertEquals(TEST_OBJECT_INIT, result.asNativeNumber().javaValue); // result := atTestObject.settertest(1); assert(result == nil); assert(atTestObject.xtest == 1) result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATNumber.ONE })); assertEquals(NATNil._INSTANCE_, result); assertEquals(1, jTestObject.xtest); result = atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")); assertEquals(NATNumber.ONE, result); assertTrue(atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("identitytest"), new NATTable(new ATObject[] { atTestObject })).asNativeBoolean().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
assertTrue(atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("identitytest"),
assertTrue(atTestObject.meta_invoke(atTestObject, AGSymbol.jAlloc("identitytest"),
public void testWorkingInstanceInvocation() { try { // def result := atTestObject.gettertest(); assert(42 == result) ATObject result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("gettertest"), NATTable.EMPTY); assertEquals(TEST_OBJECT_INIT, result.asNativeNumber().javaValue); // result := atTestObject.settertest(1); assert(result == nil); assert(atTestObject.xtest == 1) result = atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("settertest"), new NATTable(new ATObject[] { NATNumber.ONE })); assertEquals(NATNil._INSTANCE_, result); assertEquals(1, jTestObject.xtest); result = atTestObject.meta_select(atTestObject, AGSymbol.alloc("xtest")); assertEquals(NATNumber.ONE, result); assertTrue(atTestObject.meta_invoke(atTestObject, AGSymbol.alloc("identitytest"), new NATTable(new ATObject[] { atTestObject })).asNativeBoolean().javaValue); } catch (InterpreterException e) { fail(e.getMessage()); } }
String queryToBeReplacedId = iwc.getParameter(KEY_CHOSEN_QUERY);
Object queryToBeReplacedId = iwc.getParameter(KEY_CHOSEN_QUERY);
private void parseAction(IWContext iwc) throws NumberFormatException, IDOStoreException, IOException, RemoteException { if (iwc.isParameterSet(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID)) { layoutFolderId = iwc.getParameter(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID); } else { return; } if (iwc.isParameterSet(KEY_QUERY_UPLOAD_IS_SUBMITTED)) { String queryToBeReplacedId = iwc.getParameter(KEY_CHOSEN_QUERY); if (VALUE_DO_NOT_REPLACE_A_QUERY.equals(queryToBeReplacedId)) { queryToBeReplacedId = null; } UploadFile uploadFile = iwc.getUploadedFile(); ICFile icFile = MediaBusiness.saveMediaToDBUploadFolder(uploadFile,iwc); String name = iwc.getParameter(KEY_QUERY_NAME); String permission = iwc.getParameter(KEY_PERMISSION); boolean isPrivate = PRIVATE.equals(permission); QueryService queryService = (QueryService) IBOLookup.getServiceInstance(iwc, QueryService.class); UserQuery userQuery = queryService.storeQuery(name, icFile, isPrivate, new Integer(queryToBeReplacedId), iwc); userQueryId = ((Integer) userQuery.getPrimaryKey()).intValue(); } }
UserQuery userQuery = queryService.storeQuery(name, icFile, isPrivate, new Integer(queryToBeReplacedId), iwc);
UserQuery userQuery = queryService.storeQuery(name, icFile, isPrivate, queryToBeReplacedId, iwc);
private void parseAction(IWContext iwc) throws NumberFormatException, IDOStoreException, IOException, RemoteException { if (iwc.isParameterSet(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID)) { layoutFolderId = iwc.getParameter(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID); } else { return; } if (iwc.isParameterSet(KEY_QUERY_UPLOAD_IS_SUBMITTED)) { String queryToBeReplacedId = iwc.getParameter(KEY_CHOSEN_QUERY); if (VALUE_DO_NOT_REPLACE_A_QUERY.equals(queryToBeReplacedId)) { queryToBeReplacedId = null; } UploadFile uploadFile = iwc.getUploadedFile(); ICFile icFile = MediaBusiness.saveMediaToDBUploadFolder(uploadFile,iwc); String name = iwc.getParameter(KEY_QUERY_NAME); String permission = iwc.getParameter(KEY_PERMISSION); boolean isPrivate = PRIVATE.equals(permission); QueryService queryService = (QueryService) IBOLookup.getServiceInstance(iwc, QueryService.class); UserQuery userQuery = queryService.storeQuery(name, icFile, isPrivate, new Integer(queryToBeReplacedId), iwc); userQueryId = ((Integer) userQuery.getPrimaryKey()).intValue(); } }
Graphics2D copy = (Graphics2D)g;
Graphics2D copy = (Graphics2D)g.create();
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D copy = (Graphics2D)g; if (copy != null) { try { Font f = new Font("SansSerif", Font.PLAIN, 9); copy.setFont(f); // in case there are borders inside of this one Insets insets = ((JComponent)c).getInsets(); /*System.out.println(); System.out.println("x: " + x + " y: " + y + " itop: " + insets.top); System.out.println("ileft: " + insets.left + " ibottom: " + insets.bottom + " iright: " + insets.right); System.out.println("top: " + top + " right: " + right + " bottom: " + bottom); System.out.println("left: " + left);*/ FontMetrics fm = copy.getFontMetrics(); String labelTemp; // top int numTicks; int pixelLoc; if (topScaleMap != null) { numTicks = topScaleMap.getNumTicks(); for (int i=0; i<numTicks; i++) { pixelLoc = insets.left + topScaleMap.getPixelLocation(i); if(topScaleMap.isMajorTick(i)) copy.draw(new Line2D.Float(pixelLoc, top, pixelLoc, top - majorTickLength)); else copy.draw(new Line2D.Float(pixelLoc, top, pixelLoc, top - minorTickLength)); labelTemp = topScaleMap.getLabel(i); if (labelTemp != null && labelTemp.length() != 0) { copy.drawString(labelTemp, pixelLoc - (labelTemp.length() * 2), top - majorTickLength- fm.getLeading()); } } } // left if (leftScaleMap != null) { numTicks = leftScaleMap.getNumTicks(); for (int i=0; i<numTicks; i++) { pixelLoc = height - leftScaleMap.getPixelLocation(i) - bottom; if (leftScaleMap.isMajorTick(i)) { copy.draw(new Line2D.Float(insets.left -majorTickLength - insets.right, pixelLoc, insets.left - insets.right, pixelLoc)); } else { copy.draw(new Line2D.Float(insets.left - insets.right - minorTickLength, pixelLoc, insets.left - insets.right, pixelLoc)); } labelTemp = leftScaleMap.getLabel(i); if (labelTemp != null && labelTemp.length() != 0) { if(i == 0) copy.drawString(labelTemp, insets.left - insets.right - 45, pixelLoc + 5); else if(i == numTicks - 1) copy.drawString(labelTemp, insets.left - insets.right - 45, pixelLoc + 5); else copy.drawString(labelTemp, insets.left - insets.right - 45, pixelLoc); } } } // bottom if (bottomScaleMap != null) { numTicks = bottomScaleMap.getNumTicks(); for (int i=0; i<numTicks; i++) { pixelLoc = insets.left + bottomScaleMap.getPixelLocation(i); if (bottomScaleMap.isMajorTick(i)) { copy.draw(new Line2D.Float(pixelLoc, height-bottom, pixelLoc, height-bottom+majorTickLength)); } else { copy.draw(new Line2D.Float(pixelLoc, height-bottom, pixelLoc, height-bottom+minorTickLength)); } labelTemp = bottomScaleMap.getLabel(i); if (labelTemp != null && labelTemp.length() != 0) { copy.drawString(labelTemp, pixelLoc, height-fm.getLeading()); } } } // right if (rightScaleMap != null) { numTicks = rightScaleMap.getNumTicks(); for (int i=0; i<numTicks; i++) { pixelLoc = height - rightScaleMap.getPixelLocation(i) - bottom; System.out.println("HScaleBorder pixelLoc="+pixelLoc); copy.draw(new Line2D.Float(pixelLoc, c.getSize().height-bottom, pixelLoc, c.getSize().height-bottom/2)); labelTemp = rightScaleMap.getLabel(i); if (labelTemp != null && labelTemp.length() != 0) { copy.drawString(labelTemp, pixelLoc, c.getSize().height-fm.getLeading()); } } } } finally { copy.dispose(); } } }
String name = request.getParameter("name");
String name = getReqPar(request, "name");
public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { CalSvcI svc = form.fetchSvci(); String name = request.getParameter("name"); if (name == null) { form.getErr().emit("org.bedework.client.error.missingfield", "name"); return "error"; } BwView view = svc.findView(name); if (view == null) { form.getErr().emit("org.bedework.client.error.notfound", name); return "notFound"; } form.setView(view); form.setSubscriptions(svc.getSubscriptions()); String reqpar = request.getParameter("delete"); if (reqpar != null) { return "delete"; } return "success"; }
return "error";
return "retry";
public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { CalSvcI svc = form.fetchSvci(); String name = request.getParameter("name"); if (name == null) { form.getErr().emit("org.bedework.client.error.missingfield", "name"); return "error"; } BwView view = svc.findView(name); if (view == null) { form.getErr().emit("org.bedework.client.error.notfound", name); return "notFound"; } form.setView(view); form.setSubscriptions(svc.getSubscriptions()); String reqpar = request.getParameter("delete"); if (reqpar != null) { return "delete"; } return "success"; }
String reqpar = request.getParameter("delete");
String reqpar = getReqPar(request, "delete");
public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { CalSvcI svc = form.fetchSvci(); String name = request.getParameter("name"); if (name == null) { form.getErr().emit("org.bedework.client.error.missingfield", "name"); return "error"; } BwView view = svc.findView(name); if (view == null) { form.getErr().emit("org.bedework.client.error.notfound", name); return "notFound"; } form.setView(view); form.setSubscriptions(svc.getSubscriptions()); String reqpar = request.getParameter("delete"); if (reqpar != null) { return "delete"; } return "success"; }
System.out.println("Location of Seismogram: " + header.getSensorLat() + " " + header.getSensorLong());
public static Channel getChannel(PSNEventRecord evRec){ ChannelId channelId = getChannelId(evRec); PSNHeader header = evRec.getFixedHeader(); float stationElevation = (float)header.getSensorElevation(); if (stationElevation == -12345.0f){ stationElevation = 0; } Location loc = new Location((float)header.getSensorLat(), (float)header.getSensorLong(), new QuantityImpl(stationElevation, UnitImpl.METER), new QuantityImpl(0, UnitImpl.METER), LocationType.GEOGRAPHIC); Orientation orient = new Orientation((float)header.getCompAz(), (float)(header.getCompIncident() - 90)); SamplingImpl samp = new SamplingImpl(1, new TimeInterval((1/header.getSampleRate()), UnitImpl.SECOND)); TimeRange effective = new TimeRange(channelId.network_id.begin_time, new Time(edu.iris.Fissures.TIME_UNKNOWN.value, 0)); NetworkAttr netAttr = new NetworkAttrImpl(channelId.network_id, channelId.network_id.network_code, "", "", effective); StationId stationId = new StationId(channelId.network_id, channelId.station_code, channelId.network_id.begin_time); Station station = new StationImpl(stationId, channelId.station_code, loc, effective, "", "", "from psn", netAttr); SiteId siteId = new SiteId(channelId.network_id, channelId.station_code, channelId.site_code, channelId.network_id.begin_time); Site site = new SiteImpl(siteId, loc, effective, station, "from psn"); return new ChannelImpl(channelId, channelId.channel_code, orient, samp, effective, site); }
System.out.println("Location of Event: " + evInfo.getLat() + " " +evInfo.getLon());
public static EventAccessOperations getEvent(PSNDataFile psnData){ PSNVariableHeader varHeader = psnData.getEventRecords()[0].getVariableHeader(); if (varHeader.hasEventInfo()){ PSNEventInfo evInfo = varHeader.getEventInfo()[0]; MicroSecondDate originTime = microSecondDateFromPSN(evInfo.getTime()); EventAttr attr = new EventAttrImpl("PSN Event"); attr.region = new FlinnEngdahlRegionImpl(FlinnEngdahlType.GEOGRAPHIC_REGION, 0); Origin[] origins = new Origin[1]; Location loc; loc = new Location((float)evInfo.getLat(), (float)evInfo.getLon(), new QuantityImpl(0, UnitImpl.METER), new QuantityImpl(evInfo.getDepthKM(), UnitImpl.KILOMETER), LocationType.GEOGRAPHIC); origins[0] = new OriginImpl("genid:" + Math.round(Math.random()*Integer.MAX_VALUE), "", "", originTime.getFissuresTime(), loc, new Magnitude[0], new ParameterRef[0]); EventAccessOperations evo = new CacheEvent(attr, origins, origins[0]); return evo; } else return null; }
getHow().setPrivilege(val);
public void addPriv(Privilege val) { getPrivs().add(val); }
if (notWho != that.notWho) { if (notWho) { return -1; } return 1;
int res = compareWho(that); if (res == 0) { res = getHow().compareTo(that.getHow());
public int compareTo(Object o) { if (this == o) { return 0; } if (!(o instanceof Ace)) { return 1; } Ace that = (Ace)o; if (notWho != that.notWho) { if (notWho) { return -1; } return 1; } if (whoType < that.whoType) { return -1; } if (whoType > that.whoType) { return 1; } return compareWho(who, that.who); }
if (whoType < that.whoType) { return -1; } if (whoType > that.whoType) { return 1; } return compareWho(who, that.who);
return res;
public int compareTo(Object o) { if (this == o) { return 0; } if (!(o instanceof Ace)) { return 1; } Ace that = (Ace)o; if (notWho != that.notWho) { if (notWho) { return -1; } return 1; } if (whoType < that.whoType) { return -1; } if (whoType > that.whoType) { return 1; } return compareWho(who, that.who); }
private int compareWho(String who1, String who2) { if ((who1 == null) && (who2 == null)) { return 0;
public int compareWho(Ace whoMatch) { if (notWho != whoMatch.notWho) { if (notWho) { return -1; } return 1;
private int compareWho(String who1, String who2) { if ((who1 == null) && (who2 == null)) { return 0; } if (who1 == null) { return -1; } if (who2 == null) { return 1; } return who1.compareTo(who2); }
if (who1 == null) {
if (whoType < whoMatch.whoType) {
private int compareWho(String who1, String who2) { if ((who1 == null) && (who2 == null)) { return 0; } if (who1 == null) { return -1; } if (who2 == null) { return 1; } return who1.compareTo(who2); }
if (who2 == null) {
if (whoType > whoMatch.whoType) {
private int compareWho(String who1, String who2) { if ((who1 == null) && (who2 == null)) { return 0; } if (who1 == null) { return -1; } if (who2 == null) { return 1; } return who1.compareTo(who2); }
return who1.compareTo(who2);
return compareWho(who, whoMatch.who);
private int compareWho(String who1, String who2) { if ((who1 == null) && (who2 == null)) { return 0; } if (who1 == null) { return -1; } if (who2 == null) { return 1; } return who1.compareTo(who2); }
if (this == o) { return true; } if (!(o instanceof Ace)) { return false; } Ace that = (Ace)o; return sameWho(who, that.who) && (notWho == that.notWho) && (whoType == that.whoType);
return compareTo(o) == 0;
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Ace)) { return false; } Ace that = (Ace)o; return sameWho(who, that.who) && (notWho == that.notWho) && (whoType == that.whoType); }
if (how == null) { how = new PrivilegeSet(); }
public PrivilegeSet getHow() { return how; }
public void setPrivilege(Privilege priv) {
public void setPrivilege(int index, char val) {
public void setPrivilege(Privilege priv) { if (privileges == null) { privileges = (char[])defaultNonOwnerPrivileges.getPrivileges().clone(); } if (priv.getDenial()) { privileges[priv.getIndex()] = denied; } else { privileges[priv.getIndex()] = allowed; } }
if (priv.getDenial()) { privileges[priv.getIndex()] = denied; } else { privileges[priv.getIndex()] = allowed; }
privileges[index] = val;
public void setPrivilege(Privilege priv) { if (privileges == null) { privileges = (char[])defaultNonOwnerPrivileges.getPrivileges().clone(); } if (priv.getDenial()) { privileges[priv.getIndex()] = denied; } else { privileges[priv.getIndex()] = allowed; } }
public PrivilegeSet() { privileges = (char[])defaultNonOwnerPrivileges.getPrivileges().clone();
public PrivilegeSet(char privAllState, char privReadState, char privReadAclState, char privReadCurrentUserPrivilegeSetState, char privReadFreeBusyState, char privWriteState, char privWriteAclState, char privWritePropertiesState, char privWriteContentState, char privBindState, char privUnbindState, char privUnlockState, char privNoneState) { privileges = new char[privMaxType + 1]; privileges[privAll] = privAllState; privileges[privRead] = privReadState; privileges[privReadAcl] = privReadAclState; privileges[privReadCurrentUserPrivilegeSet] = privReadCurrentUserPrivilegeSetState; privileges[privReadFreeBusy] = privReadFreeBusyState; privileges[privWrite] = privWriteState; privileges[privWriteAcl] = privWriteAclState; privileges[privWriteProperties] = privWritePropertiesState; privileges[privWriteContent] = privWriteContentState; privileges[privBind] = privBindState; privileges[privUnbind] = privUnbindState; privileges[privUnlock] = privUnlockState; privileges[privNone] = privNoneState;
public PrivilegeSet() { privileges = (char[])defaultNonOwnerPrivileges.getPrivileges().clone(); }
dataSetIdCache = null;
public void addDataSet(edu.sc.seis.fissuresUtil.xml.DataSet dataset, AuditInfo[] audit) { dataSetIdCache = null; if (dataset instanceof XMLDataSet) { XMLDataSet xds = (XMLDataSet)dataset; Element element = xds.getElement(); if (element.getOwnerDocument().equals(config.getOwnerDocument())) { config.appendChild(element); //logger.debug("dataset append "+config.getChildNodes().getLength()); } else { // not from the same document, must clone Node copyNode = config.getOwnerDocument().importNode(element, true); config.appendChild(copyNode); //logger.debug("dataset import "+config.getChildNodes().getLength()); NodeList nl = config.getChildNodes(); for (int i=0; i<nl.getLength(); i++) { //logger.debug("node "+nl.item(i).getLocalName()); } // end of for (int i=0; i<nl.getLenght(); i++) } // end of else } else { logger.warn("Attempt to add non-XML dataset"); } // end of else }
logger.debug("dataset append "+config.getChildNodes().getLength());
public void addDataSet(edu.sc.seis.fissuresUtil.xml.DataSet dataset, AuditInfo[] audit) { dataSetIdCache = null; if (dataset instanceof XMLDataSet) { XMLDataSet xds = (XMLDataSet)dataset; Element element = xds.getElement(); if (element.getOwnerDocument().equals(config.getOwnerDocument())) { config.appendChild(element); //logger.debug("dataset append "+config.getChildNodes().getLength()); } else { // not from the same document, must clone Node copyNode = config.getOwnerDocument().importNode(element, true); config.appendChild(copyNode); //logger.debug("dataset import "+config.getChildNodes().getLength()); NodeList nl = config.getChildNodes(); for (int i=0; i<nl.getLength(); i++) { //logger.debug("node "+nl.item(i).getLocalName()); } // end of for (int i=0; i<nl.getLenght(); i++) } // end of else } else { logger.warn("Attempt to add non-XML dataset"); } // end of else }
logger.debug("dataset import "+config.getChildNodes().getLength());
public void addDataSet(edu.sc.seis.fissuresUtil.xml.DataSet dataset, AuditInfo[] audit) { dataSetIdCache = null; if (dataset instanceof XMLDataSet) { XMLDataSet xds = (XMLDataSet)dataset; Element element = xds.getElement(); if (element.getOwnerDocument().equals(config.getOwnerDocument())) { config.appendChild(element); //logger.debug("dataset append "+config.getChildNodes().getLength()); } else { // not from the same document, must clone Node copyNode = config.getOwnerDocument().importNode(element, true); config.appendChild(copyNode); //logger.debug("dataset import "+config.getChildNodes().getLength()); NodeList nl = config.getChildNodes(); for (int i=0; i<nl.getLength(); i++) { //logger.debug("node "+nl.item(i).getLocalName()); } // end of for (int i=0; i<nl.getLenght(); i++) } // end of else } else { logger.warn("Attempt to add non-XML dataset"); } // end of else }
dataSetCache.put(dataset.getId(), dataset); String[] ids = getDataSetIds(); dataSetIdCache = null; String[] tmp = new String[ids.length+1]; System.arraycopy(ids, 0, tmp, 0, ids.length); tmp[tmp.length-1] = dataset.getId(); dataSetIdCache = tmp;
public void addDataSet(edu.sc.seis.fissuresUtil.xml.DataSet dataset, AuditInfo[] audit) { dataSetIdCache = null; if (dataset instanceof XMLDataSet) { XMLDataSet xds = (XMLDataSet)dataset; Element element = xds.getElement(); if (element.getOwnerDocument().equals(config.getOwnerDocument())) { config.appendChild(element); //logger.debug("dataset append "+config.getChildNodes().getLength()); } else { // not from the same document, must clone Node copyNode = config.getOwnerDocument().importNode(element, true); config.appendChild(copyNode); //logger.debug("dataset import "+config.getChildNodes().getLength()); NodeList nl = config.getChildNodes(); for (int i=0; i<nl.getLength(); i++) { //logger.debug("node "+nl.item(i).getLocalName()); } // end of for (int i=0; i<nl.getLenght(); i++) } // end of else } else { logger.warn("Attempt to add non-XML dataset"); } // end of else }
addDataSet(dataset, audit);
public DataSet createChildDataSet(String id, String name, String owner, AuditInfo[] audit) { dataSetIdCache = null; name = XMLUtil.getUniqueName(getDataSetNames(), name); XMLDataSet dataset = new XMLDataSet(docBuilder, base, id, name, owner); //addDataSet(dataset, audit); return dataset; }
openSess();
openHibSess();
public void restoreUserInfo(BwUserInfo o) throws Throwable { if (globals.onlyUsers && (globals.onlyUsersMap.get(o.getUser().getAccount()) == null)) { return; } openSess(); save(o); closeSess(); }
save(o);
hibSave(o);
public void restoreUserInfo(BwUserInfo o) throws Throwable { if (globals.onlyUsers && (globals.onlyUsersMap.get(o.getUser().getAccount()) == null)) { return; } openSess(); save(o); closeSess(); }
closeSess();
closeHibSess();
public void restoreUserInfo(BwUserInfo o) throws Throwable { if (globals.onlyUsers && (globals.onlyUsersMap.get(o.getUser().getAccount()) == null)) { return; } openSess(); save(o); closeSess(); }
CalSvcI svci = form.fetchSvci(); String name = getReqPar(request, "viewName"); if (name == null) { name = svci.getUserPrefs().getPreferredView(); } if (name == null) { form.getErr().emit("org.bedework.client.error.nodefaultview");
if (!setView(getReqPar(request, "viewName"), form)) {
private String doView(HttpServletRequest request, BwActionFormBase form) throws Throwable { CalSvcI svci = form.fetchSvci(); String name = getReqPar(request, "viewName"); if (name == null) { name = svci.getUserPrefs().getPreferredView(); } if (name == null) { form.getErr().emit("org.bedework.client.error.nodefaultview"); return "noViewDef"; } if (!svci.setCurrentView(name)) { form.getErr().emit("org.bedework.client.error.unknownview"); return "noViewDef"; } form.setSelectionType(BedeworkDefs.selectionTypeView); form.refreshIsNeeded(); return "success"; }
if (!svci.setCurrentView(name)) { form.getErr().emit("org.bedework.client.error.unknownview"); return "noViewDef"; } form.setSelectionType(BedeworkDefs.selectionTypeView); form.refreshIsNeeded();
private String doView(HttpServletRequest request, BwActionFormBase form) throws Throwable { CalSvcI svci = form.fetchSvci(); String name = getReqPar(request, "viewName"); if (name == null) { name = svci.getUserPrefs().getPreferredView(); } if (name == null) { form.getErr().emit("org.bedework.client.error.nodefaultview"); return "noViewDef"; } if (!svci.setCurrentView(name)) { form.getErr().emit("org.bedework.client.error.unknownview"); return "noViewDef"; } form.setSelectionType(BedeworkDefs.selectionTypeView); form.refreshIsNeeded(); return "success"; }
null,
public Synchml(String account, String deviceId, URIgen uriGen, boolean debug) throws CalFacadeException { svci = new CalSvc(); this.deviceId = deviceId; this.debug = debug; CalSvcIPars pars = new CalSvcIPars(account, account, null, // XXX Requires an env prefix false, // public false, // caldav deviceId, // synchId debug); svci.init(pars); /** If we were limiting our view to a particular filter we would set that now. */ svci.open(); try { trans = new IcalTranslator(svci.getIcalCallback(), debug); synchInfo = svci.getSynchInfo(); if (synchInfo == null) { svci.beginTransaction(); synchInfo = new BwSynchInfo(); synchInfo.setUser(svci.getUser()); synchInfo.setDeviceId(deviceId); svci.addSynchInfo(synchInfo); svci.endTransaction(); } } finally { svci.close(); } }
if (request.isUserInRole(roles[i]))
if (request.isUserInRole(roles[i].trim()))
public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String[] roles = role.split(","); for (int i = 0; i < roles.length; i++) { if (request.isUserInRole(roles[i])) return SKIP_BODY; } return EVAL_BODY_INCLUDE; }
return ReduceTool.merge(request);
RequestFilter[] reduced = ReduceTool.merge(request); logger.debug("Reduced " + request.length + " to " + reduced.length); return reduced;
public RequestFilter[] findMatchingSeismograms(RequestFilter[] requestArray, boolean ignoreNetworkTimes) throws SQLException { List results = queryDatabaseForSeismograms(requestArray, false, ignoreNetworkTimes); RequestFilter[] request = (RequestFilter[])results.toArray(new RequestFilter[results.size()]); return ReduceTool.merge(request); }
throws IOException {
throws IOException, RT130FormatException {
private List getMatchingSeismogramsFromRefTek(String seismogramFile, ChannelId chanId, MicroSecondDate beginTime, MicroSecondDate endTime) throws IOException { RT130FileReader toSeismogramDataPacket = new RT130FileReader(seismogramFile, true); PacketType[] seismogramDataPacketArray; LocalSeismogramImpl[] seis; try { seismogramDataPacketArray = toSeismogramDataPacket.processRT130Data(); RT130ToLocalSeismogram toSeismogram = new RT130ToLocalSeismogram(); seis = toSeismogram.ConvertRT130ToLocalSeismogram(seismogramDataPacketArray); } catch(RT130FormatException e) { logger.debug("Problem occured while returning rt130 seismograms from the file listed in the database." + "\n" + "The problem file is located at " + seismogramFile); return new ArrayList(0); } List matchingSeis = new ArrayList(); for(int i = 0; i < seis.length; i++) { // Check to make sure the seismograms returned fall within the // requested time window, and compare the channel code of the // channel requested with the channel code of the dummy channel // created during the above file reading. If the codes are equal, // set the dummy channel equal to the channel requested (real // channel). if(seis[i].channel_id.channel_code.equals(chanId.channel_code) && seis[i].getBeginTime().before(endTime) && seis[i].getEndTime().after(beginTime)) { seis[i].channel_id = chanId; matchingSeis.add(seis[i]); } } return matchingSeis; }
PacketType[] seismogramDataPacketArray; LocalSeismogramImpl[] seis; try { seismogramDataPacketArray = toSeismogramDataPacket.processRT130Data(); RT130ToLocalSeismogram toSeismogram = new RT130ToLocalSeismogram(); seis = toSeismogram.ConvertRT130ToLocalSeismogram(seismogramDataPacketArray); } catch(RT130FormatException e) { logger.debug("Problem occured while returning rt130 seismograms from the file listed in the database." + "\n" + "The problem file is located at " + seismogramFile); return new ArrayList(0); }
PacketType[] seismogramDataPacketArray = toSeismogramDataPacket.processRT130Data(); RT130ToLocalSeismogram toSeismogram = new RT130ToLocalSeismogram(); LocalSeismogramImpl[] seis = toSeismogram.ConvertRT130ToLocalSeismogram(seismogramDataPacketArray); logger.debug("Got " + seis.length + " seismograms out of " + seismogramFile);
private List getMatchingSeismogramsFromRefTek(String seismogramFile, ChannelId chanId, MicroSecondDate beginTime, MicroSecondDate endTime) throws IOException { RT130FileReader toSeismogramDataPacket = new RT130FileReader(seismogramFile, true); PacketType[] seismogramDataPacketArray; LocalSeismogramImpl[] seis; try { seismogramDataPacketArray = toSeismogramDataPacket.processRT130Data(); RT130ToLocalSeismogram toSeismogram = new RT130ToLocalSeismogram(); seis = toSeismogram.ConvertRT130ToLocalSeismogram(seismogramDataPacketArray); } catch(RT130FormatException e) { logger.debug("Problem occured while returning rt130 seismograms from the file listed in the database." + "\n" + "The problem file is located at " + seismogramFile); return new ArrayList(0); } List matchingSeis = new ArrayList(); for(int i = 0; i < seis.length; i++) { // Check to make sure the seismograms returned fall within the // requested time window, and compare the channel code of the // channel requested with the channel code of the dummy channel // created during the above file reading. If the codes are equal, // set the dummy channel equal to the channel requested (real // channel). if(seis[i].channel_id.channel_code.equals(chanId.channel_code) && seis[i].getBeginTime().before(endTime) && seis[i].getEndTime().after(beginTime)) { seis[i].channel_id = chanId; matchingSeis.add(seis[i]); } } return matchingSeis; }
logger.debug(matchingSeis.size() + " were of the right channel code");
private List getMatchingSeismogramsFromRefTek(String seismogramFile, ChannelId chanId, MicroSecondDate beginTime, MicroSecondDate endTime) throws IOException { RT130FileReader toSeismogramDataPacket = new RT130FileReader(seismogramFile, true); PacketType[] seismogramDataPacketArray; LocalSeismogramImpl[] seis; try { seismogramDataPacketArray = toSeismogramDataPacket.processRT130Data(); RT130ToLocalSeismogram toSeismogram = new RT130ToLocalSeismogram(); seis = toSeismogram.ConvertRT130ToLocalSeismogram(seismogramDataPacketArray); } catch(RT130FormatException e) { logger.debug("Problem occured while returning rt130 seismograms from the file listed in the database." + "\n" + "The problem file is located at " + seismogramFile); return new ArrayList(0); } List matchingSeis = new ArrayList(); for(int i = 0; i < seis.length; i++) { // Check to make sure the seismograms returned fall within the // requested time window, and compare the channel code of the // channel requested with the channel code of the dummy channel // created during the above file reading. If the codes are equal, // set the dummy channel equal to the channel requested (real // channel). if(seis[i].channel_id.channel_code.equals(chanId.channel_code) && seis[i].getBeginTime().before(endTime) && seis[i].getEndTime().after(beginTime)) { seis[i].channel_id = chanId; matchingSeis.add(seis[i]); } } return matchingSeis; }