rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
public RecipeDetailsView getRecipeDetailsView() {
public RecipeDetailsView getRecipeDetailsView(String title) {
public RecipeDetailsView getRecipeDetailsView() { TabItem details = new TabItem(myFolder, SWT.NONE); details.setText("Recipe Details"); Group group = new Group(myFolder, SWT.NONE); details.setControl(group); return new SWTRecipeDetailsView(group); }
details.setText("Recipe Details");
details.setText(title);
public RecipeDetailsView getRecipeDetailsView() { TabItem details = new TabItem(myFolder, SWT.NONE); details.setText("Recipe Details"); Group group = new Group(myFolder, SWT.NONE); details.setControl(group); return new SWTRecipeDetailsView(group); }
myLayout = new FillLayout(); myLayout.type = SWT.VERTICAL;
myLayout = new FormLayout();
public void init() { myLayout = new FillLayout(); myLayout.type = SWT.VERTICAL; myShell.setLayout(myLayout); // @TODO Create a separate view/controller for the TabFolder myFolder = new TabFolder(myShell, SWT.NONE); }
myRecipeNavigationGroup = new Group(myShell, SWT.NONE);
public void init() { myLayout = new FillLayout(); myLayout.type = SWT.VERTICAL; myShell.setLayout(myLayout); // @TODO Create a separate view/controller for the TabFolder myFolder = new TabFolder(myShell, SWT.NONE); }
attach(myRecipeNavigationGroup, null, 0, 0, 0); attach(myFolder, myRecipeNavigationGroup, 0, 0, 5); myRecipeNavigationGroup.pack(); myFolder.layout(); myFolder.pack();
public void layout() { myShell.layout(); myShell.pack(); }
digester.addBeanPropertySetter("*/logentry/author");
digester.addBeanPropertySetter("*/logentry/author","user");
public SubversionChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException { // http://svn.collab.net/repos/svn/trunk/subversion/svn/schema/ Digester digester = new Digester(); ArrayList<LogEntry> r = new ArrayList<LogEntry>(); digester.push(r); digester.addObjectCreate("*/logentry", LogEntry.class); digester.addSetProperties("*/logentry"); digester.addBeanPropertySetter("*/logentry/author"); digester.addBeanPropertySetter("*/logentry/date"); digester.addBeanPropertySetter("*/logentry/msg"); digester.addSetNext("*/logentry","add"); digester.addObjectCreate("*/logentry/paths/path", Path.class); digester.addSetProperties("*/logentry/paths/path"); digester.addBeanPropertySetter("*/logentry/paths/path","value"); digester.addSetNext("*/logentry/paths/path","addPath"); digester.parse(changelogFile); return new SubversionChangeLogSet(build,r); }
public SubversionChangeLogSet(List<LogEntry> logs) {
SubversionChangeLogSet(Build build, List<LogEntry> logs) { this.build = build;
public SubversionChangeLogSet(List<LogEntry> logs) { this.logs = Collections.unmodifiableList(logs); }
Node processed = j.commandv.process(node,j);
Node processed = j.preprocess(node);
public Node parseProcSimpEval(String expr,Object expected) throws ParseException,Exception { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); Object res = j.evaluate(simp); if(!expected.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+expected+"\""); assertEquals("<"+expr+">",expected,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); return simp; }
public Node process(Node node,XJep xjep) throws ParseException
public Node process(Node node,XJep xj) throws ParseException
public Node process(Node node,XJep xjep) throws ParseException { this.xjep=xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
this.xjep=xjep;
this.xjep=xj;
public Node process(Node node,XJep xjep) throws ParseException { this.xjep=xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
seismos.put(seis, timeConfig.getTimeRange(seis));
public void addSeismogram(DataSetSeismogram seis){ timeConfig.addSeismogram(seis, timeFinder.getBeginTime(seis)); seismos.put(seis, timeConfig.getTimeRange(seis)); }
if(timeConfig.contains(seis)){
/*if(timeConfig.contains(seis)){
public boolean contains(DataSetSeismogram seis){ if(seismos.containsKey(seis)){ return true; } if(timeConfig.contains(seis)){ seismos.put(seis, timeConfig.getTimeRange(seis)); return true; } return false; }
}
}*/
public boolean contains(DataSetSeismogram seis){ if(seismos.containsKey(seis)){ return true; } if(timeConfig.contains(seis)){ seismos.put(seis, timeConfig.getTimeRange(seis)); return true; } return false; }
&& rec.getAlternateLocations() != null
private void parseBody() { if ( isParsed ) { return; } // Already read the header. int offset = 0; byte n = body[offset++]; short recordCount = (short)(n < 0 ? 256 + n : n); // parsing of port and ip is done on demand in getHostAddress() and // getHostIP() offset += 2; // skip port offset += 4; // skip ip try { long speed = IOUtil.unsignedInt2Long( IOUtil.deserializeIntLE(body, offset) ); remoteHostSpeed = speed; offset += 4; uniqueResultCount = 0; Set<URN> uniqueURNs = new HashSet<URN>(); records = new QueryResponseRecord[ recordCount ]; for (int i = 0; i < recordCount; i++) { QueryResponseRecord rec = new QueryResponseRecord(); offset = rec.deserialize(body, offset); if ( NLogger.isWarnEnabled( QueryResponseMsg.class ) && rec.getAlternateLocations().length > 15 ) { NLogger.warn( QueryResponseMsg.class, "QueryRespRecord with " + rec.getAlternateLocations().length + " alt locs..." ); } records[ i ] = rec; URN urn = rec.getURN(); if ( urn != null ) { uniqueURNs.add( urn ); } else { uniqueResultCount ++; } } uniqueResultCount += uniqueURNs.size(); // Handle Bearshare meta informations. The format is documented in // the GnutellaProtocol04.pdf document pushNeededFlag = QHD_UNKNOWN_FLAG; serverBusyFlag = QHD_UNKNOWN_FLAG; hasUploadedFlag = QHD_UNKNOWN_FLAG; uploadSpeedFlag = QHD_UNKNOWN_FLAG; // GGEP extensions isBrowseHostSupported = false; if ( offset <= (getHeader().getDataLength() - 16 - 4 - 2) ) { // parse meta data // Use ISO encoding for two bytes characters on some platforms. vendorCode = new String( body, offset, 4, "ISO-8859-1"); if ( !isVendorCodeValid( vendorCode ) ) { String hexVendorCode = HexConverter.toHexString( body, offset, 4 ); NLogger.warn(QueryResponseMsg.class, getHeader().getFromHost() + ": Illegal QHD vendor code found: " + vendorCode + " (" + hexVendorCode + "). Body: " + HexConverter.toHexString( body ) ); vendorCode = hexVendorCode; } offset += 4; int openDataLength = IOUtil.unsignedByte2int( body[ offset ] ); offset += 1; // parse upload speed, have uploaded, busy and push if ( openDataLength > 1) { // if we have a flag byte byte flag1 = body[ offset ]; byte flag2 = body[ offset + 1]; // check if push flag is meaningfull do it reversed from other checks if ( ( flag2 & PUSH_NEEDED_MASK ) != 0 ) { if ( ( flag1 & PUSH_NEEDED_MASK ) != 0 ) { pushNeededFlag = QHD_TRUE_FLAG; } else { pushNeededFlag = QHD_FALSE_FLAG; } } // check if server busy flag meaningfull if ((flag1 & SERVER_BUSY_MASK) != 0) { if ( (flag2 & SERVER_BUSY_MASK) != 0 ) { serverBusyFlag = QHD_TRUE_FLAG; } else { serverBusyFlag = QHD_FALSE_FLAG; } } // check if the uploaded flag is meaningfull if ((flag1 & HAS_UPLOADED_MASK) != 0) { if ( (flag2 & HAS_UPLOADED_MASK) != 0 ) { hasUploadedFlag = QHD_TRUE_FLAG; } else { hasUploadedFlag = QHD_FALSE_FLAG; } } if ((flag1 & UPLOAD_SPEED_MASK) != 0 ) { if ( (flag2 & UPLOAD_SPEED_MASK) != 0 ) { uploadSpeedFlag = QHD_TRUE_FLAG; } else { uploadSpeedFlag = QHD_FALSE_FLAG; } } if ((flag1 & GGEP_MASK) != 0 && (flag2 & GGEP_MASK) !=0 ) {// parse GGEP area should follow after open data area but // we can't be sure... int ggepMagicIndex = offset + 2; // search for real magic index while ( ggepMagicIndex < body.length ) { if ( body[ ggepMagicIndex ] == GGEPBlock.MAGIC_NUMBER ) { // found index! break; } ggepMagicIndex ++; } GGEPBlock[] ggepBlocks = null; try { // if there are GGEPs, see if Browse Host supported... ggepBlocks = GGEPBlock.parseGGEPBlocks( body, ggepMagicIndex ); isBrowseHostSupported = GGEPBlock.isExtensionHeaderInBlocks( ggepBlocks, GGEPBlock.BROWSE_HOST_HEADER_ID ); pushProxyAddresses = GGEPExtension.parsePushProxyExtensionData( ggepBlocks ); } catch ( InvalidGGEPBlockException exp ) {// ignore and continue parsing... NLogger.debug(QueryResponseMsg.class, exp, exp ); } } } // skip unknown open data length offset += openDataLength; //Parse private area of Limewire and Shareaza to read out chat //flag. If chatflag is 0x1 chat is supported, if 0x0 its not. int privateDataLength = body.length - offset - 16; if ( privateDataLength > 0 && ( vendorCode.equals("LIME") || vendorCode.equals("RAZA") || vendorCode.equals("PHEX") ) ) { byte flag = body[ offset ]; isChatSupported = ( flag & CHAT_SUPPORTED_MASK ) != 0; } //System.out.println( (mHeader.getDataLen() -16 - 4 -2) + " " + offset + " " + // /*new String( body, offset, mHeader.getDataLen() - offset) + " " +*/ // openDataLength + " " + pushNeededFlag + " " + serverBusyFlag + " " + // uploadSpeedFlag + " " + hasUploadedFlag + " " + vendorCode ); } parseRemoteClientID(); isParsed = true; } catch ( java.io.UnsupportedEncodingException exp ) { return; } }
if (param instanceof Number)
if (param instanceof Complex) { return ((Complex)param).tanh(); } else if (param instanceof Number)
public Object tanh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value)-Math.exp(-value))/(Math.pow(Math.E,value)+Math.pow(Math.E,-value))); } else if (param instanceof Complex) { return ((Complex)param).tanh(); } throw new ParseException("Invalid parameter type"); }
else if (param instanceof Complex) { return ((Complex)param).tanh(); }
public Object tanh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value)-Math.exp(-value))/(Math.pow(Math.E,value)+Math.pow(Math.E,-value))); } else if (param instanceof Complex) { return ((Complex)param).tanh(); } throw new ParseException("Invalid parameter type"); }
if (param instanceof Number)
if (param instanceof Complex) { return ((Complex)param).acos(); } else if (param instanceof Number)
public Object acos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.acos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).acos(); } throw new ParseException("Invalid parameter type"); }
} else if (param instanceof Complex) { return ((Complex)param).acos();
public Object acos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.acos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).acos(); } throw new ParseException("Invalid parameter type"); }
setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South");
public void itemStateChanged(ItemEvent ae) { if(ae.getStateChange() == ItemEvent.SELECTED) { String orientation = ((AbstractButton)ae.getItem()).getText(); view.setDisplayKey(orientation); if(orientation.equals(labelStrings[0])){ setHorizontalTitle("North-South"); setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South"); }else{ setHorizontalTitle("Up-Down"); setVerticalTitle("East-West"); } repaint(); } repaint(); }
setHorizontalTitle("Up-Down"); setVerticalTitle("East-West");
setVerticalTitle("Up-Down"); setHorizontalTitle("East-West");
public void itemStateChanged(ItemEvent ae) { if(ae.getStateChange() == ItemEvent.SELECTED) { String orientation = ((AbstractButton)ae.getItem()).getText(); view.setDisplayKey(orientation); if(orientation.equals(labelStrings[0])){ setHorizontalTitle("North-South"); setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South"); }else{ setHorizontalTitle("Up-Down"); setVerticalTitle("East-West"); } repaint(); } repaint(); }
hAmpScaleMap = new AmpScaleMapper(50, 4); vAmpScaleMap = new AmpScaleMapper(50, 4);
hAmpScaleMap = new UpdatingAmpScaleMapper(50, 4); vAmpScaleMap = new UpdatingAmpScaleMapper(50, 4);
public ParticleMotionDisplay(DataSetSeismogram datasetSeismogram, TimeConfig tc, Color color) { particleDisplayPanel = new JPanel(new BorderLayout()); radioPanel = new JPanel(new GridLayout(1, 0)); setLayout(new BorderLayout()); view = new ParticleMotionView(this); view.setSize(new Dimension(300, 300)); particleDisplayPanel.add(view); hAmpScaleMap = new AmpScaleMapper(50, 4); vAmpScaleMap = new AmpScaleMapper(50, 4); ScaleBorder scaleBorder = new ScaleBorder(); scaleBorder.setBottomScaleMapper(hAmpScaleMap); scaleBorder.setLeftScaleMapper(vAmpScaleMap); hTitleBorder = new BottomTitleBorder("X - axis Title"); vTitleBorder = new LeftTitleBorder("Y - axis Title"); Border titleBorder = BorderFactory.createCompoundBorder(hTitleBorder, vTitleBorder); Border bevelBorder = BorderFactory.createRaisedBevelBorder(); Border bevelTitleBorder = BorderFactory.createCompoundBorder(bevelBorder, titleBorder); Border lowBevelBorder = BorderFactory.createLoweredBevelBorder(); Border scaleBevelBorder = BorderFactory.createCompoundBorder(scaleBorder, lowBevelBorder); particleDisplayPanel.setBorder(BorderFactory.createCompoundBorder(bevelTitleBorder, scaleBevelBorder)); add(particleDisplayPanel); radioPanel.setVisible(false); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize(); } public void componentShown(ComponentEvent e) { resize(); } }); ParticleMotionDisplayThread t = new ParticleMotionDisplayThread(datasetSeismogram, tc, this, color); t.execute(); formRadioSetPanel(); initialized = t.getCompletion(); if(initialized){ setInitialButton(); } add(radioPanel, BorderLayout.SOUTH); }
logger.debug("Setting the size");
public void setSize(Dimension d) { logger.debug("Setting the size"); if (d.width < d.height) { super.setSize(new Dimension(d.width, d.width)); } else { super.setSize(new Dimension(d.height, d.height)); } }
else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(listOp,children,dim); return res; }
MatrixNodeI node1 = children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(listOp,children,dim); return res;
public MatrixNodeI preprocess( ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf) throws ParseException { MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null); Operator listOp = ((MatrixOperatorSet) jep.getOperatorSet()).getMList(); // What if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != listOp) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(listOp); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(listOp,children,dim); return res; } }
QueryResponseMsg message = null;
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
message = ( QueryResponseMsg )MessageProcessor.parseMessage(
QueryResponseMsg message = ( QueryResponseMsg )MessageProcessor.parseMessage(
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message );
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
throws InvalidMessageException
public synchronized void processQueryResponse( QueryResponseMsg msg ) { // TODO this can be optimized by checking for the msgID of the query.. for (int i = 0; i < searchList.size(); i++) { Search search = (Search)searchList.get( i ); if ( search instanceof BrowseHostResults ) { continue; } search.processResponse( msg ); } }
browseHostError = NO_ERROR;
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
browseHostError = BROWSE_HOST_ERROR;
browseHostStatus = BROWSE_HOST_ERROR;
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
browseHostError = CONNECTION_ERROR;
browseHostStatus = CONNECTION_ERROR;
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
result.nextBuildNumber = 1;
public synchronized Job doCreateJob( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { if(!Hudson.adminCheck(req,rsp)) return null; String name = req.getParameter("name").trim(); String className = req.getParameter("type"); String mode = req.getParameter("mode"); try { checkGoodName(name); } catch (ParseException e) { sendError(e,req,rsp); return null; } if(getJob(name)!=null) { sendError("A job already exists with the name '"+name+"'",req,rsp); return null; } if(mode==null) { rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } Job result; if(mode.equals("newJob")) { if(className==null) { // request forged? rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } try { Class type = Class.forName(className); // redirect to the project config screen result = createProject(type, name); } catch (ClassNotFoundException e) { e.printStackTrace(); rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } } else { Job src = getJob(req.getParameter("from")); if(src==null) { rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } result = createProject(src.getClass(),name); // copy config Copy cp = new Copy(); cp.setProject(new org.apache.tools.ant.Project()); cp.setTofile(result.getConfigFile()); cp.setFile(src.getConfigFile()); cp.setOverwrite(true); cp.execute(); // reload from the new config result = Job.load(this,result.root); jobs.put(name,result); } rsp.sendRedirect(req.getContextPath()+'/'+result.getUrl()+"configure"); return result; }
private RpCommand(short command){
RpCommand(short command){
private RpCommand(short command){ this.command = command; this.aux1 = -1; }
if (!rs.next() || "Hello World".equals(rs.getInt(1))) {
if (!rs.next() || !"Hello World".equals(rs.getString(1))) {
public boolean run() throws Exception { Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:"); Statement stat = conn.createStatement(); ResultSet rs; // test calling Function.create(conn, "f1", new Function() { public void xFunc() throws SQLException { val = 4; } }); stat.executeQuery("select f1();").close(); if (val != 4) { error = "f1 not called"; return false; } // test returning Function.create(conn, "f2", new Function() { public void xFunc() throws SQLException { result(4); } }); rs = stat.executeQuery("select f2();"); if (!rs.next() || rs.getInt(1) != 4) { error ="f2 bad"; return false; } rs.close(); for (int i=0; i < 20; i++) { rs = stat.executeQuery("select f2();"); if (!rs.next() || rs.getInt(1) != 4) { error ="f2 bad in loop"; return false; } rs.close(); } // test accessing arguments Function.create(conn, "f3", new Function() { public void xFunc() throws SQLException { result(value_int(0)); } }); rs = stat.executeQuery("select f3(7);"); if (!rs.next() || rs.getInt(1) != 7) { error ="f3 bad"; return false; } // test multiple arguments Function.create(conn, "f4", new Function() { public void xFunc() throws SQLException { int ret = 0; for (int i=0; i < args(); i++) ret += value_int(i); result(ret); } }); rs.close(); rs = stat.executeQuery("select f4(2, 3, 9, -5);"); if (!rs.next() || rs.getInt(1) != 9) { error ="f4 bad1"; return false; } rs.close(); rs = stat.executeQuery("select f4(2);"); if (!rs.next() || rs.getInt(1) != 2) { error ="f4 bad2"; return false; } rs.close(); rs = stat.executeQuery("select f4(-3, -4, -5);"); if (!rs.next() || rs.getInt(1)!=-12) { error ="f4 bad3"; return false; } // test different return types Function.create(conn, "f5", new Function() { public void xFunc() throws SQLException { result("Hello World"); } }); rs.close(); rs = stat.executeQuery("select f5();"); if (!rs.next() || !"Hello World".equals(rs.getString(1))) { error = "f5 bad"; return false; } Function.create(conn, "f6", new Function() { public void xFunc() throws SQLException { result(Long.MAX_VALUE); } }); rs.close(); rs = stat.executeQuery("select f6();"); if (!rs.next() || rs.getLong(1) != Long.MAX_VALUE) { error = "f6 bad"; return false; } Function.create(conn, "f7", new Function() { public void xFunc() throws SQLException {result(Double.MAX_VALUE);} }); rs.close(); rs = stat.executeQuery("select f7();"); if (!rs.next() || rs.getDouble(1) != Double.MAX_VALUE) { error = "f7 bad"; return false; } Function.create(conn, "f8", new Function() { public void xFunc() throws SQLException { result(b1); } }); rs.close(); rs = stat.executeQuery("select f8();"); if (!rs.next() || !same(b1, rs.getBytes(1))) { error = "f8 bad"; return false; } // TODO test different argument types Function.create(conn, "farg_int", new Function() { public void xFunc() throws SQLException { result(value_int(0)); } }); PreparedStatement prep; prep = conn.prepareStatement("select farg_int(?);"); prep.setInt(1, Integer.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Integer.MAX_VALUE != rs.getInt(1)) { error = "bad int arg"; return false; } prep.close(); Function.create(conn, "farg_long", new Function() { public void xFunc() throws SQLException { result(value_long(0)); } }); prep = conn.prepareStatement("select farg_long(?);"); prep.setLong(1, Long.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Long.MAX_VALUE != rs.getLong(1)) { error = "bad long arg"; return false; } prep.close(); Function.create(conn, "farg_double", new Function() { public void xFunc() throws SQLException { result(value_double(0));} }); prep = conn.prepareStatement("select farg_double(?);"); prep.setDouble(1, Double.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Double.MAX_VALUE != rs.getDouble(1)) { error = "bad double arg"; return false; } prep.close(); Function.create(conn, "farg_blob", new Function() { public void xFunc() throws SQLException { result(value_blob(0));} }); prep = conn.prepareStatement("select farg_blob(?);"); prep.setBytes(1, b1); rs = prep.executeQuery(); if (!rs.next() || !same(b1, rs.getBytes(1))) { error = "bad bytes arg"; return false; } prep.close(); Function.create(conn, "farg_string", new Function() { public void xFunc() throws SQLException { result(value_text(0));} }); prep = conn.prepareStatement("select farg_string(?);"); prep.setString(1, "Hello World"); rs = prep.executeQuery(); if (!rs.next() || "Hello World".equals(rs.getInt(1))) { error = "bad string arg"; return false; } prep.close(); // test errors rs.close(); Function.create(conn, "f9", new Function() { public void xFunc() throws SQLException { throw new SQLException("myErr"); } }); String msg = null; try { stat.executeQuery("select f9();"); } catch (SQLException e) { msg = e.getMessage(); } if (!"java.sql.SQLException: myErr".equals(msg)) { System.out.println(msg); error = "bad error"; return false; } // test triggers Function.create(conn, "inform", new Function() { protected void xFunc() throws SQLException { gotTrigger = value_int(0); } }); stat.executeUpdate("create table trigtest (c1);"); stat.executeUpdate( "create trigger trigt after insert on trigtest" + " begin select inform(new.c1); end;" ); stat.executeUpdate("insert into trigtest values (5);"); if (gotTrigger != 5) { error = "bad trigger"; return false; } conn.close(); return true; }
OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils();
public Node apply(ASTFunNode node, Node[] children) throws ParseException { OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils(); Operator lhsOp = tu.getOperator(children[0]); int n = tu.intValue(children[1]); Node sub1 = children[0].jjtGetChild(0); Node sub2 = children[0].jjtGetChild(1); if(lhsOp == opSet.getAdd() || lhsOp == opSet.getSubtract()) { /* (a+b)^n --> (a^n+nC1 a^(n-1) b + ....) */ if(n == 0) return nf.buildConstantNode(new Double(1)); if(n == 1) return children[0]; Node vals[] = new Node[(int) n+1]; /* a^n */ vals[0] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n)) ); if(n==2) { vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(2)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), xj.deepCopy(sub2))); } else { /* n * a^(n-1) * b */ vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-1))), xj.deepCopy(sub2))); } /* n * a * b^(n-1) */ if(n>=3) { vals[n-1] = nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n-1))))); } /* a^n */ vals[n] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n)) ); for(int i=2;i<n-1;++i) { /* (n,i) * a^(n-i) * b^i */ vals[i]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(XMath.binomial(n,i))), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-i))), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(i))))); }// for(int i=0;i<=n;++i)// {// System.out.print("val["+i+"] ");// xj.println(vals[i]);// } Node sums[] = new Node[n+1]; sums[n]=vals[n]; for(int i=n-1;i>=0;--i) { sums[i] = nf.buildOperatorNode( lhsOp, vals[i], sums[i+1]); }// xj.println(sums[0]); return sums[0]; } throw new ParseException("ExpandBrackets at least one child must be + or -"); }
Node vals[] = new Node[(int) n+1];
Node vals[] = new Node[n+1];
public Node apply(ASTFunNode node, Node[] children) throws ParseException { OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils(); Operator lhsOp = tu.getOperator(children[0]); int n = tu.intValue(children[1]); Node sub1 = children[0].jjtGetChild(0); Node sub2 = children[0].jjtGetChild(1); if(lhsOp == opSet.getAdd() || lhsOp == opSet.getSubtract()) { /* (a+b)^n --> (a^n+nC1 a^(n-1) b + ....) */ if(n == 0) return nf.buildConstantNode(new Double(1)); if(n == 1) return children[0]; Node vals[] = new Node[(int) n+1]; /* a^n */ vals[0] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n)) ); if(n==2) { vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(2)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), xj.deepCopy(sub2))); } else { /* n * a^(n-1) * b */ vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-1))), xj.deepCopy(sub2))); } /* n * a * b^(n-1) */ if(n>=3) { vals[n-1] = nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n-1))))); } /* a^n */ vals[n] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n)) ); for(int i=2;i<n-1;++i) { /* (n,i) * a^(n-i) * b^i */ vals[i]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(XMath.binomial(n,i))), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-i))), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(i))))); }// for(int i=0;i<=n;++i)// {// System.out.print("val["+i+"] ");// xj.println(vals[i]);// } Node sums[] = new Node[n+1]; sums[n]=vals[n]; for(int i=n-1;i>=0;--i) { sums[i] = nf.buildOperatorNode( lhsOp, vals[i], sums[i+1]); }// xj.println(sums[0]); return sums[0]; } throw new ParseException("ExpandBrackets at least one child must be + or -"); }
else return null;
return null;
public Operator getOperator(Node node) { if(isOperator(node)) return ((ASTFunNode) node).getOperator(); else return null; }
else return false;
return false;
public boolean isInteger(Node node) { if(isReal(node)) { Number val = (Number) ((ASTConstant) node).getValue(); double x = val.doubleValue(); double xInt = Math.rint(x); return x == xInt; } else return false; }
int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i]));
if(names!=null && homes!=null) { int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); }
public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); {// update JDK installations jdks.clear(); String[] names = req.getParameterValues("jdk_name"); String[] homes = req.getParameterValues("jdk_home"); int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); } } for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( BuildStepDescriptor d : BuildStep.PUBLISHERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config }
h.setDescription(descrBuf); descrBuf = "";
public void endElement(String namespaceURI, String sName, // simple name String qName // qualified name ) throws SAXException { if (importType == "STRANGEBREW") { if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("FERMENTABLES")) { r.addMalt(m); m = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("HOPS")) { r.addHop(h); h = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("MISC")) { r.addMisc(misc); misc = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("MASH")) { r.mash.addStep(type, startTemp, endTemp, "F", method, minutes, rampMin); } else if (qName.equalsIgnoreCase("FERMENTABLS") || qName.equalsIgnoreCase("HOPS") || qName.equalsIgnoreCase("DETAILS") || qName.equalsIgnoreCase("MISC")) { currentList = ""; } } else if (importType == "QBREW"){ if (qName.equalsIgnoreCase("GRAIN")){ r.addMalt(m); m = null; } else if (qName.equalsIgnoreCase("HOP")){ r.addHop(h); h = null; } } }
h.setDescription(s);
descrBuf = descrBuf + s;
void sbCharacters(String s){ if (currentList.equals("FERMENTABLES")) { if (currentElement.equalsIgnoreCase("MALT")) { m.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { m.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("POINTS")) { m.setPppg(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("COSTLB")) { m.setCost( s ); } else if (currentElement.equalsIgnoreCase("UNITS")) { m.setUnits(s); } else if (currentElement.equalsIgnoreCase("LOV")) { m.setLov(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { m.setDescription(s); } } else if (currentList.equalsIgnoreCase("HOPS")) { if (currentElement.equalsIgnoreCase("HOP")) { h.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { h.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ALPHA")) { h.setAlpha(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { h.setUnits(s); } else if (currentElement.equalsIgnoreCase("FORM")) { h.setType(s); } else if (currentElement.equalsIgnoreCase("COSTOZ")) { h.setCost( s ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { h.setDescription(s); } else if (currentElement.equalsIgnoreCase("TIME")) { h.setMinutes(Integer.parseInt(s)); } } else if (currentList.equalsIgnoreCase("MISC")) { if (currentElement.equalsIgnoreCase("NAME")) { misc.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { misc.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { misc.setUnits(s); } else if (currentElement.equalsIgnoreCase("COMMENTS")) { misc.setComments(s); } else if (currentElement.equalsIgnoreCase("COST_PER_U")) { // misc.setCost( Double.parseDouble(s) ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { misc.setDescription(s); } else if (currentElement.equalsIgnoreCase("TIME")) { misc.setTime(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("STAGE")) { misc.setStage(s); } } else if (currentList.equalsIgnoreCase("MASH")) { if (currentElement.equalsIgnoreCase("TYPE")) { type = s; } else if (currentElement.equalsIgnoreCase("TEMP")) { startTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("METHOD")) { method = s; } else if (currentElement.equalsIgnoreCase("MIN")) { minutes = Integer.parseInt(s); } else if (currentElement.equalsIgnoreCase("END_TEMP")) { endTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("RAMP_MIN")) { rampMin = Integer.parseInt(s); } } else if (currentList.equalsIgnoreCase("DETAILS")) { if (currentElement.equalsIgnoreCase("NAME")) { r.setName(s); } else if (currentElement.equalsIgnoreCase("EFFICIENCY")) { r.setEfficiency(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ATTENUATION")) { r.setAttenuation(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("PRESIZE")) { r.setPreBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE")) { r.setPostBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE_UNITS")) { r.setPreBoilVolUnits(s); r.setPostBoilVolUnits(s); } else if (currentElement.equalsIgnoreCase("STYLE")) { r.setStyle(s); } else if (currentElement.equalsIgnoreCase("BOIL_TIME")) { r.setBoilMinutes(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("HOPS_UNITS")) { r.setHopsUnits(s); } else if (currentElement.equalsIgnoreCase("MALT_UNITS")) { r.setMaltUnits(s); } else if (currentElement.equalsIgnoreCase("MASH_RATIO")) { r.setMashRatio(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("MASH_RATIO_U")) { r.setMashRatioU(s); } else if (currentElement.equalsIgnoreCase("BREWER")) { r.setBrewer(s); } else if (currentElement.equalsIgnoreCase("MASH")) { r.setMashed(Boolean.valueOf(s).booleanValue()); } else if (currentElement.equalsIgnoreCase("YEAST")) { r.setYeastName(s); } } else s = ""; }
assertEquals("", credential.getVerifyPassword());
public void testCredentialFactoryString() { Credential credential = factory.credentialFactory("UNIQUE"); assertEquals("UNIQUE", credential.getPrincipal()); assertEquals(8, credential.getPassword().length()); assertTrue(credential.getCreated().compareTo(new Date()) < 1000); assertSame(credential.getCreated(), credential.getLastModified()); assertNull(credential.getExpired()); assertEquals(CredentialType.NOT_ADDRESSABLE.getValue(), credential.getCredentialType()); assertEquals(Notification.BY_REQUEST.getValue(), credential.getNotification()); assertEquals(CredentialState.IDLE.getValue(), credential.getCredentialState()); assertEquals(Appellation.NOT_SUPPLIED.getValue(), credential.getPersonalData().getAppellation()); assertEquals(Gender.NOT_SUPPLIED.getValue(), credential.getPersonalData().getGender()); assertEquals(0, credential.getUsers().size()); }
DefaultEntity defaultEntity = factory.defaultEntityFactory(); assertEquals("", defaultEntity.getSupervisorName());
public void testDefaultEntityFactory() { // TODO Auto-generated method stub }
DefaultEntity defaultEntity = factory.defaultEntityFactory("UNIQUE"); assertEquals("UNIQUE", defaultEntity.getSupervisorName());
public void testDefaultEntityFactoryString() { // TODO Auto-generated method stub }
DefaultEntity defaultEntity = factory.defaultEntityFactory("UNIQUE", 0); assertEquals("UNIQUE", defaultEntity.getSupervisorName()); assertEquals(0, defaultEntity.getPriority()); java.util.Locale defaultLocale = java.util.Locale.getDefault(); assertEquals(defaultLocale.getLanguage(), defaultEntity.getLocale().getLanguage()); assertEquals(defaultLocale.getCountry(), defaultEntity.getLocale().getCountry()); assertEquals(LocaleType.COUNTRY.getValue(), defaultEntity.getLocale().getLocaleType()); assertEquals("UNIQUE", defaultEntity.getDefaultEntity().getAlias());
public void testDefaultEntityFactoryStringInt() { // TODO Auto-generated method stub }
Credential credential = factory.credentialFactory("UNIQUE"); Supervisor supervisor = factory.supervisorFactory(); Individual individual = factory.individualFactory(supervisor, credential); assertEquals("UNIQUE", individual.getAlias()); assertSame(credential, individual.getCredential());
public void testIndividualFactory() { // TODO Auto-generated method stub }
Supervisor supervisor = factory.supervisorFactory(); Organization organization = factory.organizationFactory(supervisor, "UNIQUE"); assertEquals("UNIQUE", organization.getAlias()); assertEquals("UNIQUE", organization.getBusinessName());
public void testOrganizationFactorySupervisorString() { // TODO Auto-generated method stub }
Supervisor supervisor = factory.supervisorFactory(); Organization organization = factory.organizationFactory(supervisor, "UNIQUE", "BSN_NAME"); assertEquals("UNIQUE", organization.getAlias()); assertEquals("BSN_NAME", organization.getBusinessName());
public void testOrganizationFactorySupervisorStringString() { // TODO Auto-generated method stub }
Supervisor supervisor = factory.supervisorFactory(); Credential credential = factory.credentialFactory("UNIQUE"); Entity entity = factory.entityFactory(supervisor, "UNIQUE_ENTITY"); User user = factory.userFactory(entity, credential); assertSame(entity, user.getEntity()); assertSame(credential, user.getCredential()); assertNull(user.getParent()); assertTrue(user.isAccountNonExpired()); assertTrue(user.isAccountNonLocked()); assertEquals(UserType.INTERNAL.getValue(), user.getUserType()); assertEquals(0, user.getRoles().size());
public void testUserFactoryEntityCredential() { // TODO Auto-generated method stub }
rsp.sendRedirect(req.getContextPath());
rsp.sendRedirect(req.getContextPath()+"/");
public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; interrupt(); rsp.sendRedirect(req.getContextPath()); }
j.dv.addStandardDiffRules();
j.addStandardDiffRules();
protected void setUp() { j = new DJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); //j.setTraverse(true); j.setAllowAssignment(true); j.setAllowUndeclared(true); j.setImplicitMul(true); j.dv.addStandardDiffRules(); }
buf.flip(); decoder.decode(buf,out,true); buf.compact();
decode(true);
public void close() throws IOException { buf.flip(); decoder.decode(buf,out,true); buf.compact(); flushOutput(); writer.close(); }
buf.compact();
public void close() throws IOException { buf.flip(); decoder.decode(buf,out,true); buf.compact(); flushOutput(); writer.close(); }
private void decode() throws IOException {
private void decode(boolean last) throws IOException {
private void decode() throws IOException { buf.flip(); while(true) { CoderResult r = decoder.decode(buf, out, false); if(r==CoderResult.OVERFLOW) { flushOutput(); continue; } if(r==CoderResult.UNDERFLOW) { buf.compact(); return; } // otherwise treat it as an error r.throwException(); } }
CoderResult r = decoder.decode(buf, out, false);
CoderResult r = decoder.decode(buf, out, last);
private void decode() throws IOException { buf.flip(); while(true) { CoderResult r = decoder.decode(buf, out, false); if(r==CoderResult.OVERFLOW) { flushOutput(); continue; } if(r==CoderResult.UNDERFLOW) { buf.compact(); return; } // otherwise treat it as an error r.throwException(); } }
decode();
decode(false);
public void flush() throws IOException { decode(); flushOutput(); writer.flush(); }
decode();
decode(false);
public void write(int b) throws IOException { if(buf.remaining()==0) decode(); buf.put((byte)b); }
loadRecipes(currentDir);
public FindDialog(JFrame frame) { super(frame); recipes = new ArrayList(); files = new ArrayList(); inst = (StrangeSwing) frame; currentDir = new java.io.File("."); initGUI(); dirLocationText.setText(currentDir.getAbsolutePath()); loadRecipes(currentDir); }
if (i > -1) {
if (i > -1 && i < recipes.size()) {
public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == cancelButton) { setVisible(false); dispose(); return; } else if (o == openButton) { int i = recipeTable.getSelectedRow(); if (i > -1) { inst.setRecipe((Recipe) recipes.get(i), (File) files.get(i)); } setVisible(false); dispose(); return; } }
if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) {
if (file.getPath().endsWith(".rec") || file.getPath().endsWith(".qbrew") || file.getPath().endsWith(".xml")) {
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file);
file = new File(fileName); OpenImport openImport = new OpenImport(); r = openImport.openFile(file); if (openImport.getFileType().equals("sb") || openImport.getFileType().equals("qbrew") || openImport.getFileType().equals("promash")) { recipes.add(r); files.add(file);
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
} else if (openImport.getFileType().equals("beerxml")) { ArrayList rs = openImport.getRecipes(); for (int j=0; j<rs.size(); j++){ recipes.add(rs.get(j)); files.add(file); } }
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
String recipeUnitsAbrv = new Quantity().getVolAbrv(myRecipe.getVolUnits()); String mashUnitsAbrv = new Quantity().getVolAbrv(myRecipe.mash.getMashVolUnits());
String recipeUnitsAbrv = Quantity.getVolAbrv(myRecipe.getVolUnits()); String mashUnitsAbrv = Quantity.getVolAbrv(myRecipe.mash.getMashVolUnits());
public void displayWater(){ String recipeUnitsAbrv = new Quantity().getVolAbrv(myRecipe.getVolUnits()); String mashUnitsAbrv = new Quantity().getVolAbrv(myRecipe.mash.getMashVolUnits()); totalWaterLbl.setText(myRecipe.getTotalWater()); totalUnitsLbl.setText(recipeUnitsAbrv); usedMashLbl.setText(myRecipe.mash.getTotalWaterStr()); usedInMashUnitsLbl.setText(mashUnitsAbrv); absorbedLbl.setText(myRecipe.mash.getAbsorbedStr()); absorbedUnitsLbl.setText(mashUnitsAbrv); spargeWithLbl.setText(myRecipe.getSparge()); spargeUnitsLbl.setText(mashUnitsAbrv); collectTxt.setValue(new Double(myRecipe.getPreBoilVol(myRecipe.getVolUnits()))); collectUnitsLbl.setText(recipeUnitsAbrv); postBoilTxt.setValue(new Double(myRecipe.getPostBoilVol(myRecipe.getVolUnits()))); postBoilUnitsLbl.setText(recipeUnitsAbrv); chillShrinkLbl.setText(myRecipe.getChillShrink()); kettleTxt.setValue(new Double(myRecipe.getKettleLoss())); kettleUnitsLbl.setText(recipeUnitsAbrv); trubLossTxt.setValue(new Double(myRecipe.getTrubLoss())); trubLossUnitsLbl.setText(recipeUnitsAbrv); miscLossTxt.setValue(new Double(myRecipe.getMiscLoss())); miscLosUnitsLbl.setText(recipeUnitsAbrv); finalVolTxt.setValue(new Double(myRecipe.getFinalWortVol())); finalUnitsLbl.setText(recipeUnitsAbrv); }
&& u[i].unit != s) {
&& !u[i].unit.equalsIgnoreCase(s)) {
private String getAbrvFromUnit(String t, String s){ int i=0; Converter[] u; if (t == "vol") u = volUnits; else // assume weight u = weightUnits; while (i < u.length && u[i].unit != s) { i++; } if (i >= u.length) return null; else return u[i].abrv; }
otherTxt.addActionListener(this);
} private void initGUI() { try { jPanel1 = new JPanel(); GridBagLayout jPanel1Layout = new GridBagLayout(); jPanel1Layout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; jPanel1Layout.rowHeights = new int[]{7, 7, 7, 7, 7, 7}; jPanel1Layout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel1Layout.columnWidths = new int[]{7, 7, 7, 7}; jPanel1.setLayout(jPanel1Layout); BoxLayout thisLayout = new BoxLayout(this, javax.swing.BoxLayout.X_AXIS); this.setLayout(thisLayout); this.add(jPanel1); jPanel1.setBorder(BorderFactory.createTitledBorder("Recipe Cost:")); jLabel1 = new JLabel(); jPanel1.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Grain:"); jLabel2 = new JLabel(); jPanel1.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Hops:"); jLabel3 = new JLabel(); jPanel1.add(jLabel3, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("Misc Ingr.:"); jLabel4 = new JLabel(); jPanel1.add(jLabel4, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Yeast:"); jLabel5 = new JLabel(); jPanel1.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("Other:"); jLabel6 = new JLabel(); jPanel1.add(jLabel6, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Total:"); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); grainLbl = new JLabel(); jPanel1.add(grainLbl, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grainLbl.setText("jLabel11"); hopsLbl = new JLabel(); jPanel1.add(hopsLbl, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); hopsLbl.setText("jLabel11"); yeastTxt = new JTextField(); jPanel1.add(yeastTxt, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); yeastTxt.setText("jLabel11"); miscLbl = new JLabel(); jPanel1.add(miscLbl, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); miscLbl.setText("jLabel11"); otherTxt = new JTextField(); jPanel1.add(otherTxt, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); otherTxt.setText("jLabel11"); totalLbl = new JLabel(); jPanel1.add(totalLbl, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); totalLbl.setText("jLabel11"); totalLbl.setFont(new java.awt.Font("Tahoma", 1, 11)); jPanel2 = new JPanel(); GridBagLayout jPanel2Layout = new GridBagLayout(); jPanel2Layout.rowWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout.rowHeights = new int[]{7, 7, 7, 7}; jPanel2Layout.columnWeights = new double[]{0.1, 0.1, 0.1, 0.1}; jPanel2Layout.columnWidths = new int[]{7, 7, 7, 7}; jPanel2.setLayout(jPanel2Layout); this.add(jPanel2); jPanel2.setBorder(BorderFactory.createTitledBorder("Bottle Cost:")); jLabel7 = new JLabel(); jPanel2.add(jLabel7, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Bottle Size:"); jLabel8 = new JLabel(); jPanel2.add(jLabel8, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel8.setText("Final Volume:"); jLabel9 = new JLabel(); jPanel2.add(jLabel9, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel9.setText("# Bottles:"); jLabel10 = new JLabel(); jPanel2.add(jLabel10, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel10.setText("Cost / Bottle:"); bottleSizeTxt = new JTextField(); jPanel2.add(bottleSizeTxt, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); bottleSizeTxt.setText("jTextField1"); bottleSizeUCmbModel = new ComboModel(); bottleSizeUCmbModel.setList(new Quantity().getListofUnits("vol")); bottleSizeUCmb = new JComboBox(); jPanel2.add(bottleSizeUCmb, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); bottleSizeUCmb.setModel(bottleSizeUCmbModel); finalVolLbl = new JLabel(); jPanel2.add(finalVolLbl, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); finalVolLbl.setText("jLabel11"); numBottlesLbl = new JLabel(); jPanel2.add(numBottlesLbl, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); numBottlesLbl.setText("jLabel11"); bottleCostLbl = new JLabel(); jPanel2.add(bottleCostLbl, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); bottleCostLbl.setText("jLabel11"); setPreferredSize(new Dimension(400, 300)); } catch (Exception e) { e.printStackTrace(); } }
.andReturn(isA(UserLog.class));
.andReturn(userLog);
public void testSwitchAuthorizedUserSuccess() { Credential credential = new Credential(); User[] users = createUsersWithSameCredential(credential, 2); UserLog userLog = new UserLog(); userLog.setUser(users[0]); UserDetailsAdapter secureUser = new UserDetailsAdapter(userLog); expect(mock.createAndPersistUserLog(users[1])) .andReturn(isA(UserLog.class)); replay(mock); assertTrue(simpleCoreMgr.switchAuthorizedUser(secureUser, "ENT1")); reset(mock); }
JPanel lowerRightPanel = new JPanel();
lowerRightPanel = new JPanel();
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel );
lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel );
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); }
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
setSearchListVisible( true );
setSearchListVisible( isSearchListVisible ); setFilterPanelVisible( isFilterPanelVisible );
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
actionList.add( new ToggleSearchListAction( true ) );
actionList.add( new ToggleSearchListAction( isSearchListVisible ) ); actionList.add( filterPanelToggleAction );
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
filterListBtn = new JToggleButton( Localizer.getString( "SearchTab_FilterList" ),
filterListBtn = new JToggleButton( Localizer.getString( "SearchTab_FilterRules" ),
public SearchFilterPanel( SearchTab tab ) { super(); searchTab = tab; setBorder( BorderFactory.createLineBorder( PhexColors.getBoxPanelBorderColor() ) ); setBackground( UIManager.getDefaults().getColor("window") ); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout( "p, fill:p:grow", // columns "d, fill:d:grow"); //rows PanelBuilder panelBuilder = new PanelBuilder( layout, this ); topLayoutPanel = new JPanel(); topLayoutPanel.setOpaque(false); layout = new FormLayout( "4dlu, p, fill:8dlu:grow, p, 4dlu", // columns "2dlu, p, 2dlu"); //rows PanelBuilder topBuilder = new PanelBuilder( layout, topLayoutPanel ); JLabel titelLabel = new JLabel( Localizer.getString( "SearchTab_SearchFilterOptions" ) ); Font currentFont = titelLabel.getFont(); Font enlargedFont = currentFont.deriveFont( Font.PLAIN, currentFont.getSize() + 2 ); titelLabel.setFont( enlargedFont ); topBuilder.add( titelLabel, cc.xy(2, 2) ); JButton closeBtn = new JButton( GUIRegistry.getInstance().getIconFactory().getIcon("Close") ); closeBtn.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) ); closeBtn.setBorder( GUIUtils.ROLLOVER_BUTTON_BORDER ); closeBtn.setRolloverEnabled( true ); closeBtn.setOpaque(false); topBuilder.add( closeBtn, cc.xy(4, 2) ); panelBuilder.add( topLayoutPanel, cc.xywh( 1, 1, 2, 1 ) ); leftLayoutPanel = new JPanel(); leftLayoutPanel.setBackground(getBackground()); leftLayoutPanel.setOpaque(false); layout = new FormLayout( "4dlu, p, 0dlu", // columns "23px, d, 0dlu, d, 23px"); //rows PanelBuilder leftBuilder = new PanelBuilder( layout, leftLayoutPanel ); ButtonGroup leftBtnGroup = new ButtonGroup(); quickFilterBtn = new JToggleButton( Localizer.getString( "SearchTab_QuickFilter" ), GUIRegistry.getInstance().getIconFactory().getIcon("Filter") ); quickFilterBtn.setBorder( new CompoundBorder( BorderFactory.createMatteBorder(2, 2, 1, 0, getBackground()), new EmptyBorder( 5, 7, 5, 11) ) ); leftBtnGroup.add(quickFilterBtn); updateLeftBtnProps(quickFilterBtn); leftBuilder.add( quickFilterBtn, cc.xy(2, 2) ); quickFilterBtn.addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e ) { activateQuickFilterPanel( ); } }); filterListBtn = new JToggleButton( Localizer.getString( "SearchTab_FilterList" ), IconFactory.EMPTY_IMAGE_16 ); filterListBtn.setBorder( new CompoundBorder( BorderFactory.createMatteBorder(1, 2, 2, 0, getBackground()), new EmptyBorder( 5, 7, 5, 11) ) ); leftBtnGroup.add(filterListBtn); updateLeftBtnProps(filterListBtn); leftBuilder.add( filterListBtn, cc.xy(2, 4) ); filterListBtn.addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e ) { activateFilterListPanel( ); } }); panelBuilder.add( leftLayoutPanel, cc.xywh( 1, 2, 1, 1 ) ); quickFilterPanel = new QuickFilterPanel(); filterListPanel = new FilterListPanel(); filterContentPanel = new JPanel( new BorderLayout() ); filterContentPanel.setOpaque(false); panelBuilder.add( filterContentPanel, cc.xywh( 2, 2, 1, 1 ) ); }
if( header.getDataLength() > ( pktDataLength - MsgHeader.DATA_LENGTH ) ) { NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Msg Header Data length is invalid " ); } header.countHop(); switch( header.getPayload() ) { case MsgHeader.PING_PAYLOAD : NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recvd Ping from : " + address ); handlePing( header, packetData, fromHost ); break; case MsgHeader.PONG_PAYLOAD : NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recvd Pong from : " + address ); handlePong( header, packetData, fromHost ); break; default: NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recvd unrecognized Msg from : " + address ); break; }
public void run() { DatagramPacket packet; while( true ) { packet = readMessage(); if( packet == null ) { continue; } byte[] packetData = packet.getData(); int pktDataLength = packet.getLength(); byte[] ip = packet.getAddress().getAddress(); int port = packet.getPort(); DestAddress address = new DefaultDestAddress( ip, port ); //the data size shud be atleast a message's Header length if( pktDataLength < MsgHeader.DATA_LENGTH ) { continue; } // //we only accept packets from hosts we are still connected to// //this is a sort of a crude restriction on the messages we can recieve // if( ! ( netContainer.isConnectedToHost( address ) ) )// {// continue;// } // TODO validate if the fromHost is a valid and acceptable source // we like to receive udp packages from. Host fromHost = hostMgr.getNetworkHostsContainer().getNetworkHost( address ); if( fromHost == null ) { fromHost = new Host( address ); } MsgHeader header = null; try { header = MsgHeader.createMsgHeader( packetData, 0 ); } catch ( Exception e ) { NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Failed to create udp pong from datagram ", e ); } // check if the header data length is valid if( header.getDataLength() > ( pktDataLength - MsgHeader.DATA_LENGTH ) ) { NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Msg Header Data length is invalid " ); } header.countHop(); // Now check the payload field and take appropriate action switch( header.getPayload() ) { case MsgHeader.PING_PAYLOAD : NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recvd Ping from : " + address ); handlePing( header, packetData, fromHost ); break; case MsgHeader.PONG_PAYLOAD : NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recvd Pong from : " + address ); handlePong( header, packetData, fromHost ); break; default: NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recvd unrecognized Msg from : " + address ); break; } } }
PingMsg udpPing = null;
private void handlePing( MsgHeader header, byte[] body, Host fromHost ) { PingMsg udpPing = null; try { udpPing = PingMsg.createUdpPingMsg( header, body, MsgHeader.DATA_LENGTH, fromHost ); NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recieved Udp Ping " + "Msg From " + fromHost + " : " + udpPing ); respondToPing( udpPing ); } catch ( InvalidMessageException exp ) { dropMessage( header, body, fromHost, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.UDP_INCOMING_MESSAGES, exp, exp ); } }
udpPing = PingMsg.createUdpPingMsg( header, body, MsgHeader.DATA_LENGTH, fromHost );
if ( header.getHopsTaken() > 1 ) { throw new InvalidMessageException( "Udp Ping traveled more then 1 hop." ); } PingMsg udpPing = PingMsg.createUdpPingMsg( header, body, MsgHeader.DATA_LENGTH, fromHost );
private void handlePing( MsgHeader header, byte[] body, Host fromHost ) { PingMsg udpPing = null; try { udpPing = PingMsg.createUdpPingMsg( header, body, MsgHeader.DATA_LENGTH, fromHost ); NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recieved Udp Ping " + "Msg From " + fromHost + " : " + udpPing ); respondToPing( udpPing ); } catch ( InvalidMessageException exp ) { dropMessage( header, body, fromHost, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.UDP_INCOMING_MESSAGES, exp, exp ); } }
catch ( InvalidMessageException e )
catch ( InvalidMessageException exp )
private void handlePong( MsgHeader header, byte[] data, Host fromHost ) { // first check if we had sent a ping to recieve a pong GUID guid = header.getMsgID(); DestAddress address = pingRoutingTable.getAndRemoveRouting( guid ); if( address == null ) { // did not find routing for this pong NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Recieved Udp Pong " + " with Guid not found in the routing table : " + header + " \n \t Ignoring pong"); return; } // thought of comparing the address in the table to the pong packet's address // but since its udp the packet can come from any interface of the packet's host // so just be happy that u sent a ping with the same guid PongMsg udpPong = null; try { udpPong = PongMsg.createUdpPongMsg( header, data, MsgHeader.DATA_LENGTH, fromHost ); NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recieved Udp Pong " + "Msg From " + fromHost + " : " + udpPong ); } catch ( InvalidMessageException e ) { //just ignore return; } byte[] pongIP = udpPong.getIP(); byte access = securityManager.controlHostIPAccess( pongIP ); if ( access == PhexSecurityManager.ACCESS_STRONGLY_DENIED ) { // drop message // dropMessage( udpPong, "IP access strongly denied." ); return; } // add address to host catcher... if ( access == PhexSecurityManager.ACCESS_GRANTED ) { boolean isNew = hostMgr.getCaughtHostsContainer().addCaughtHost( udpPong ); if ( isNew ) { PongCache.getInstance().addPong( udpPong ); } } }
dropMessage( header, data, fromHost, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.UDP_INCOMING_MESSAGES, exp, exp );
private void handlePong( MsgHeader header, byte[] data, Host fromHost ) { // first check if we had sent a ping to recieve a pong GUID guid = header.getMsgID(); DestAddress address = pingRoutingTable.getAndRemoveRouting( guid ); if( address == null ) { // did not find routing for this pong NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Recieved Udp Pong " + " with Guid not found in the routing table : " + header + " \n \t Ignoring pong"); return; } // thought of comparing the address in the table to the pong packet's address // but since its udp the packet can come from any interface of the packet's host // so just be happy that u sent a ping with the same guid PongMsg udpPong = null; try { udpPong = PongMsg.createUdpPongMsg( header, data, MsgHeader.DATA_LENGTH, fromHost ); NLogger.debug( NLoggerNames.UDP_INCOMING_MESSAGES, " Recieved Udp Pong " + "Msg From " + fromHost + " : " + udpPong ); } catch ( InvalidMessageException e ) { //just ignore return; } byte[] pongIP = udpPong.getIP(); byte access = securityManager.controlHostIPAccess( pongIP ); if ( access == PhexSecurityManager.ACCESS_STRONGLY_DENIED ) { // drop message // dropMessage( udpPong, "IP access strongly denied." ); return; } // add address to host catcher... if ( access == PhexSecurityManager.ACCESS_GRANTED ) { boolean isNew = hostMgr.getCaughtHostsContainer().addCaughtHost( udpPong ); if ( isNew ) { PongCache.getInstance().addPong( udpPong ); } } }
public static PongMsg createUdpPongMsg( MsgHeader msgHdr, byte[] data, int offset, Host fromHost ) throws InvalidMessageException { if( ! ( MessageProcessor.isValidUdpMsgHeader( msgHdr ) ) ) { NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Could not create udp pong " + "from given byte array. Message Verification failed " + new String( data ) ); throw new InvalidMessageException( " Could not create Msg Header " + "while trying to create udp pong Msg. Message Verification failed " ); } msgHdr.setFromHost( fromHost ); if( msgHdr.getDataLength() < MIN_PONG_DATA_LEN ) { throw new InvalidMessageException( " Could not create Msg Body while trying to" + " create udp pong Msg" ); } byte[] body = MessageProcessor.createBody( msgHdr, data, offset ); if ( body == null ) { throw new InvalidMessageException( " Could not create Msg Body while trying to" + " create udp pong Msg" ); } return new PongMsg( msgHdr, body ); }
public static PongMsg createUdpPongMsg( byte[] bytesMsg, Host fromHost ) throws InvalidMessageException { MsgHeader msgHdr = MsgHeader.createMsgHeader( bytesMsg, 0 ); return createUdpPongMsg( msgHdr, bytesMsg, MsgHeader.DATA_LENGTH, fromHost ); }
public static PongMsg createUdpPongMsg( MsgHeader msgHdr, byte[] data, int offset, Host fromHost ) throws InvalidMessageException { if( ! ( MessageProcessor.isValidUdpMsgHeader( msgHdr ) ) ) { NLogger.warn( NLoggerNames.UDP_INCOMING_MESSAGES, " Could not create udp pong " + "from given byte array. Message Verification failed " + new String( data ) ); throw new InvalidMessageException( " Could not create Msg Header " + "while trying to create udp pong Msg. Message Verification failed " ); } msgHdr.setFromHost( fromHost ); if( msgHdr.getDataLength() < MIN_PONG_DATA_LEN ) { throw new InvalidMessageException( " Could not create Msg Body while trying to" + " create udp pong Msg" ); } byte[] body = MessageProcessor.createBody( msgHdr, data, offset ); if ( body == null ) { throw new InvalidMessageException( " Could not create Msg Body while trying to" + " create udp pong Msg" ); } return new PongMsg( msgHdr, body ); }
sum = add(sum, param);
sum = add(param, sum);
public void run(Stack stack) throws ParseException { checkStack(stack);// check the stack Object sum = stack.pop(); Object param; int i = 1; // repeat summation for each one of the current parameters while (i < curNumberOfParameters) { // get the parameter from the stack param = stack.pop(); // add it to the sum sum = add(sum, param); i++; } stack.push(sum); return; }
super.addFunction("ele",new Ele());
public void addStandardFunctions() { super.addStandardFunctions(); }
if (param instanceof Number) {
if (param instanceof Complex) return ((Complex)param).tan(); else if (param instanceof Number)
public Object tan(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.tan(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).tan(); } throw new ParseException("Invalid parameter type"); }
} else if (param instanceof Complex) { return ((Complex)param).tan(); }
public Object tan(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.tan(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).tan(); } throw new ParseException("Invalid parameter type"); }
phase = new String(eightBytes);
phase = new String(PSNDataFile.chopToLength(eightBytes));
public PSNPhasePick(DataInputStream data) throws IOException{ dis = data; startTime = new PSNDateTime(dis); dis.readFully(eightBytes); phase = new String(eightBytes); flags = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); dispYPosition = SacTimeSeries.swapBytes(dis.readShort()); dis.readFully(sixteenBytes); travelTimeFileName = new String(sixteenBytes); tableDepth = SacTimeSeries.swapBytes(dis.readShort()); }
travelTimeFileName = new String(sixteenBytes);
travelTimeFileName = new String(PSNDataFile.chopToLength(sixteenBytes));
public PSNPhasePick(DataInputStream data) throws IOException{ dis = data; startTime = new PSNDateTime(dis); dis.readFully(eightBytes); phase = new String(eightBytes); flags = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); dispYPosition = SacTimeSeries.swapBytes(dis.readShort()); dis.readFully(sixteenBytes); travelTimeFileName = new String(sixteenBytes); tableDepth = SacTimeSeries.swapBytes(dis.readShort()); }
super(aView);
super(aView, aRecipe);
public MainController(MainView aView, Recipe aRecipe) { super(aView); myContents = aView; myRecipe = aRecipe; }
myRecipe = aRecipe;
public MainController(MainView aView, Recipe aRecipe) { super(aView); myContents = aView; myRecipe = aRecipe; }
myRecipeNavigation.dispose();
public void dispose() { myRecipeDetails.dispose(); myView.dispose(); }
RecipeDetailsView newView = myContents.getRecipeDetailsView(); myRecipeDetails = new RecipeDetailsController(newView, myRecipe);
RecipeNavigationView nv = myContents.getRecipeNavigationView(); myRecipeNavigation = new RecipeNavigationController(nv, myRecipe); myRecipeNavigation.init(); RecipeDetailsView dv = myContents.getRecipeDetailsView("Recipe Details"); myRecipeDetails = new RecipeDetailsController(dv, myRecipe);
public void init() { myView.init(); RecipeDetailsView newView = myContents.getRecipeDetailsView(); myRecipeDetails = new RecipeDetailsController(newView, myRecipe); myRecipeDetails.init(); myView.layout(); }
return Rotate.rotate(x, y, (180-distAz.baz)*Math.PI/180);
return Rotate.rotate(x, y, -1*(180+distAz.baz)*Math.PI/180);
public static float[][] rotateGCP(LocalSeismogramImpl x, LocalSeismogramImpl y, Location staLoc, Location evtLoc) { DistAz distAz = new DistAz(staLoc.latitude, staLoc.longitude, evtLoc.latitude, evtLoc.longitude); return Rotate.rotate(x, y, (180-distAz.baz)*Math.PI/180); }
buf.append("See ").append(baseUrl).append(build.getUrl()).append("\n\n");
buf.append("See ").append(baseUrl).append(Util.encode(build.getUrl())).append("\n\n");
private void appendBuildUrl(Build build, StringBuffer buf) { String baseUrl = DESCRIPTOR.getUrl(); if(baseUrl!=null) { buf.append("See ").append(baseUrl).append(build.getUrl()).append("\n\n"); } }
String expect = "where identity.identityType != 'G' and (" +
String expect = "and (" +
public void testCreateCriteriaAsStringFull() { filter.setNameOrAliasSearch("nameOrAliasSearch"); filter.setPrincipalSearch("principalSearch"); String criteria = identitySelectionStrategy.createCriteriaAsString(filter ); String expect = "where identity.identityType != 'G' and (" + "lower(identity.principal) like '%principalsearch%' " + "or lower(identity.optionalAlias) like '%nameoraliassearch%' " + "or lower(identity.firstName) like '%nameoraliassearch%' " + "or lower(identity.lastName) like '%nameoraliassearch%' )"; assertEquals(expect, criteria); }
String expect = "where identity.identityType != 'G' and (" +
String expect = "and (" +
public void testCreateCriteriaAsStringNameOrAlias() { filter.setNameOrAliasSearch("nameOrAliasSearch"); filter.setPrincipalSearch(""); String criteria = identitySelectionStrategy.createCriteriaAsString(filter ); String expect = "where identity.identityType != 'G' and (" + "lower(identity.optionalAlias) like '%nameoraliassearch%' " + "or lower(identity.firstName) like '%nameoraliassearch%' " + "or lower(identity.lastName) like '%nameoraliassearch%' )"; assertEquals(expect, criteria); }
String expect = "where identity.identityType != 'G' and (" +
String expect = "and (" +
public void testCreateCriteriaAsStringPrincipal() { filter.setNameOrAliasSearch(""); filter.setPrincipalSearch("principalSearch"); String criteria = identitySelectionStrategy.createCriteriaAsString(filter ); String expect = "where identity.identityType != 'G' and (" + "lower(identity.principal) like '%principalsearch%' )"; assertEquals(expect, criteria); }
case 0 :
case 0: return data.getMaltSteep(row); case 1: return data.getMaltMashed(row); case 2 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 1 :
case 3 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 2 :
case 4 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 3 :
case 5 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 4 :
case 6 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 5 :
case 7 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 6 :
case 8 :
public Object getValueAt(int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : // indicate this is a sugar: String s = ""; if (!data.getMaltMashed(row) && data.getMaltSteep(row)) s = "*"; return s + data.getMaltName(row); case 1 : return SBStringUtils.format(data .getMaltAmountAs(row, data.getMaltUnits(row)), 1); case 2 : return data.getMaltUnits(row); case 3 : return SBStringUtils.format(data.getMaltPppg(row), 3); case 4 : return SBStringUtils.format(data.getMaltLov(row), 0); case 5 : return new Double(data.getMaltCostPerU(row)); case 6 : return SBStringUtils.format(data.getMaltPercent(row), 1); } } catch (Exception e) { }; return ""; }
case 0 :
case 0: data.setMaltSteep(row, new Boolean (value.toString()).booleanValue()); break; case 1: data.setMaltMashed(row, new Boolean(value.toString()).booleanValue()); break; case 2 :
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : data.setMaltName(row, value.toString()); break; case 1 : data.setMaltAmount(row, Double.parseDouble(value.toString())); break; case 2 : // m.setUnits(value.toString()); break; case 3 : data.setMaltPppg(row, Double.parseDouble(value.toString())); break; case 4 : data.setMaltLov(row, Double.parseDouble(value.toString())); break; case 5 : data.setMaltCost(row, value.toString()); break; case 6 : // data.setMaltPercent(row, Double.parseDouble(value.toString())); break; } } catch (Exception e) { }; app.myRecipe.calcMaltTotals(); fireTableCellUpdated(row, col); fireTableDataChanged(); app.displayRecipe(); }