rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
} catch(org.omg.CORBA.ORBPackage.InvalidName ine) { throw new org.omg.CORBA.ORBPackage.InvalidName(); | AllVTFactory vt = new AllVTFactory(); vt.register(orb); org.omg.CORBA.Object rootObj = orb.resolve_initial_references("NameService"); if (rootObj == null) { logger.info("Name service object is null!"); return; | public FissuresNamingServiceImpl (java.util.Properties props) throws org.omg.CORBA.ORBPackage.InvalidName{ this.props = props; String[] args = new String[0]; try { orb = (org.omg.CORBA_2_3.ORB)org.omg.CORBA.ORB.init(args, props); // register valuetype factories AllVTFactory vt = new AllVTFactory(); vt.register(orb); // get a reference to the Naming Service root_context org.omg.CORBA.Object rootObj = orb.resolve_initial_references("NameService"); if (rootObj == null) { //logger.error logger.info("Name service object is null!"); return; } namingContext = NamingContextExtHelper.narrow(rootObj); //logger.info logger.info("got Name context"); } catch(org.omg.CORBA.ORBPackage.InvalidName ine) { throw new org.omg.CORBA.ORBPackage.InvalidName(); } } |
namingContext = NamingContextExtHelper.narrow(rootObj); logger.info("got Name context"); | public FissuresNamingServiceImpl (java.util.Properties props) throws org.omg.CORBA.ORBPackage.InvalidName{ this.props = props; String[] args = new String[0]; try { orb = (org.omg.CORBA_2_3.ORB)org.omg.CORBA.ORB.init(args, props); // register valuetype factories AllVTFactory vt = new AllVTFactory(); vt.register(orb); // get a reference to the Naming Service root_context org.omg.CORBA.Object rootObj = orb.resolve_initial_references("NameService"); if (rootObj == null) { //logger.error logger.info("Name service object is null!"); return; } namingContext = NamingContextExtHelper.narrow(rootObj); //logger.info logger.info("got Name context"); } catch(org.omg.CORBA.ORBPackage.InvalidName ine) { throw new org.omg.CORBA.ORBPackage.InvalidName(); } } |
|
public void rebind(String dns, String objectname, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, Exception { | public void rebind(String dns, String objectname, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { | public void rebind(String dns, String objectname, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, Exception { logger.info("The CLASS Name is "+obj.getClass().getName()); String interfacename = getInterfaceName(obj); dns = appendKindNames(dns); if(interfacename != null && interfacename.length() != 0) dns = dns + "/" + interfacename + ".interface"; if(objectname != null && objectname.length() != 0) { objectname = objectname + getVersion(); dns = dns + "/" + objectname + ".object"; } logger.info("the dns to be bind is "+dns); NameComponent[] ncName; try { ncName = namingContext.to_name(dns); } catch(org.omg.CosNaming.NamingContextPackage.InvalidName ine) { logger.info("INVALID NAME EXCEPTION IS CAUGHT"); throw new org.omg.CosNaming.NamingContextPackage.InvalidName();//"The DNS name "+dns+" that is passed is InValid "); //return false; } NameComponent[] ncName1 = new NameComponent[1]; NamingContext namingContextTemp = (NamingContext)namingContext; int counter; for(counter = 0; counter < ncName.length; counter++) { //NameComponent temp[] = new NameComponent[counter]; int subcounter; try { namingContext.rebind(namingContext.to_name(dns), obj); //namingContext.reslove(namingContext.to_name(dns)); } catch(org.omg.CosNaming.NamingContextPackage.NotFound nfe) { switch(nfe.why.value()) { case NotFoundReason._missing_node: ncName1[0] = nfe.rest_of_name[0]; logger.info("The id of the context is "+ncName1[0].id) ; subcounter = 0; for(int i = 0 ; i < ncName.length && !ncName[i].id.equals(ncName1[0].id); i++) { subcounter++; } NameComponent temp[] = new NameComponent[subcounter]; for(int i = 0 ; i < ncName.length && !ncName[i].id.equals(ncName1[0].id); i++) { temp[i] = ncName[i]; } try { if(subcounter != 0){ logger.info("resolving new naming context"); namingContextTemp = NamingContextExtHelper.narrow(namingContext.resolve(temp)); } if(ncName1[0].id.equals(interfacename)) ncName1[0].kind = "interface"; else if(ncName1[0].id.equals(objectname)) ncName1[0].kind = "object"; else ncName1[0].kind = "dns"; namingContextTemp.bind_new_context(ncName1); } catch(Exception ex) { logger.info("This Exception must not occur"); ex.printStackTrace(); throw new Exception(); } break; case NotFoundReason._not_context: logger.info("Not a Context"); logger.info(nfe.rest_of_name[0].id+" IS PASSED AS A CONTEXT. ACTUALLY IT IS ALREADY BOUND AS AN OBJECT"); throw new org.omg.CosNaming.NamingContextPackage.NotFound(nfe.why, nfe.rest_of_name); //break; case NotFoundReason._not_object: logger.info("Not an Object"); logger.info(nfe.rest_of_name[0].id+" IS PASSED AS AN OBJECT. ACTUALLY IT IS ALREADY BOUND AS A CONTEXT"); throw new org.omg.CosNaming.NamingContextPackage.NotFound(nfe.why, nfe.rest_of_name); } } catch(org.omg.CosNaming.NamingContextPackage.CannotProceed cpe) { logger.info("Caught Exception cannot proceed"); throw new org.omg.CosNaming.NamingContextPackage.CannotProceed(); } } } |
if(subcounter != 0){ logger.info("resolving new naming context"); namingContextTemp = NamingContextExtHelper.narrow(namingContext.resolve(temp)); } if(ncName1[0].id.equals(interfacename)) ncName1[0].kind = "interface"; else if(ncName1[0].id.equals(objectname)) ncName1[0].kind = "object"; else ncName1[0].kind = "dns"; | public void rebind(String dns, String objectname, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, Exception { logger.info("The CLASS Name is "+obj.getClass().getName()); String interfacename = getInterfaceName(obj); dns = appendKindNames(dns); if(interfacename != null && interfacename.length() != 0) dns = dns + "/" + interfacename + ".interface"; if(objectname != null && objectname.length() != 0) { objectname = objectname + getVersion(); dns = dns + "/" + objectname + ".object"; } logger.info("the dns to be bind is "+dns); NameComponent[] ncName; try { ncName = namingContext.to_name(dns); } catch(org.omg.CosNaming.NamingContextPackage.InvalidName ine) { logger.info("INVALID NAME EXCEPTION IS CAUGHT"); throw new org.omg.CosNaming.NamingContextPackage.InvalidName();//"The DNS name "+dns+" that is passed is InValid "); //return false; } NameComponent[] ncName1 = new NameComponent[1]; NamingContext namingContextTemp = (NamingContext)namingContext; int counter; for(counter = 0; counter < ncName.length; counter++) { //NameComponent temp[] = new NameComponent[counter]; int subcounter; try { namingContext.rebind(namingContext.to_name(dns), obj); //namingContext.reslove(namingContext.to_name(dns)); } catch(org.omg.CosNaming.NamingContextPackage.NotFound nfe) { switch(nfe.why.value()) { case NotFoundReason._missing_node: ncName1[0] = nfe.rest_of_name[0]; logger.info("The id of the context is "+ncName1[0].id) ; subcounter = 0; for(int i = 0 ; i < ncName.length && !ncName[i].id.equals(ncName1[0].id); i++) { subcounter++; } NameComponent temp[] = new NameComponent[subcounter]; for(int i = 0 ; i < ncName.length && !ncName[i].id.equals(ncName1[0].id); i++) { temp[i] = ncName[i]; } try { if(subcounter != 0){ logger.info("resolving new naming context"); namingContextTemp = NamingContextExtHelper.narrow(namingContext.resolve(temp)); } if(ncName1[0].id.equals(interfacename)) ncName1[0].kind = "interface"; else if(ncName1[0].id.equals(objectname)) ncName1[0].kind = "object"; else ncName1[0].kind = "dns"; namingContextTemp.bind_new_context(ncName1); } catch(Exception ex) { logger.info("This Exception must not occur"); ex.printStackTrace(); throw new Exception(); } break; case NotFoundReason._not_context: logger.info("Not a Context"); logger.info(nfe.rest_of_name[0].id+" IS PASSED AS A CONTEXT. ACTUALLY IT IS ALREADY BOUND AS AN OBJECT"); throw new org.omg.CosNaming.NamingContextPackage.NotFound(nfe.why, nfe.rest_of_name); //break; case NotFoundReason._not_object: logger.info("Not an Object"); logger.info(nfe.rest_of_name[0].id+" IS PASSED AS AN OBJECT. ACTUALLY IT IS ALREADY BOUND AS A CONTEXT"); throw new org.omg.CosNaming.NamingContextPackage.NotFound(nfe.why, nfe.rest_of_name); } } catch(org.omg.CosNaming.NamingContextPackage.CannotProceed cpe) { logger.info("Caught Exception cannot proceed"); throw new org.omg.CosNaming.NamingContextPackage.CannotProceed(); } } } |
|
} catch(Exception ex) { logger.info("This Exception must not occur"); ex.printStackTrace(); throw new Exception(); } | } catch (AlreadyBound e) { logger.error("Caught AlreadyBound, should not happen, ignoring...", e); } | public void rebind(String dns, String objectname, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, Exception { logger.info("The CLASS Name is "+obj.getClass().getName()); String interfacename = getInterfaceName(obj); dns = appendKindNames(dns); if(interfacename != null && interfacename.length() != 0) dns = dns + "/" + interfacename + ".interface"; if(objectname != null && objectname.length() != 0) { objectname = objectname + getVersion(); dns = dns + "/" + objectname + ".object"; } logger.info("the dns to be bind is "+dns); NameComponent[] ncName; try { ncName = namingContext.to_name(dns); } catch(org.omg.CosNaming.NamingContextPackage.InvalidName ine) { logger.info("INVALID NAME EXCEPTION IS CAUGHT"); throw new org.omg.CosNaming.NamingContextPackage.InvalidName();//"The DNS name "+dns+" that is passed is InValid "); //return false; } NameComponent[] ncName1 = new NameComponent[1]; NamingContext namingContextTemp = (NamingContext)namingContext; int counter; for(counter = 0; counter < ncName.length; counter++) { //NameComponent temp[] = new NameComponent[counter]; int subcounter; try { namingContext.rebind(namingContext.to_name(dns), obj); //namingContext.reslove(namingContext.to_name(dns)); } catch(org.omg.CosNaming.NamingContextPackage.NotFound nfe) { switch(nfe.why.value()) { case NotFoundReason._missing_node: ncName1[0] = nfe.rest_of_name[0]; logger.info("The id of the context is "+ncName1[0].id) ; subcounter = 0; for(int i = 0 ; i < ncName.length && !ncName[i].id.equals(ncName1[0].id); i++) { subcounter++; } NameComponent temp[] = new NameComponent[subcounter]; for(int i = 0 ; i < ncName.length && !ncName[i].id.equals(ncName1[0].id); i++) { temp[i] = ncName[i]; } try { if(subcounter != 0){ logger.info("resolving new naming context"); namingContextTemp = NamingContextExtHelper.narrow(namingContext.resolve(temp)); } if(ncName1[0].id.equals(interfacename)) ncName1[0].kind = "interface"; else if(ncName1[0].id.equals(objectname)) ncName1[0].kind = "object"; else ncName1[0].kind = "dns"; namingContextTemp.bind_new_context(ncName1); } catch(Exception ex) { logger.info("This Exception must not occur"); ex.printStackTrace(); throw new Exception(); } break; case NotFoundReason._not_context: logger.info("Not a Context"); logger.info(nfe.rest_of_name[0].id+" IS PASSED AS A CONTEXT. ACTUALLY IT IS ALREADY BOUND AS AN OBJECT"); throw new org.omg.CosNaming.NamingContextPackage.NotFound(nfe.why, nfe.rest_of_name); //break; case NotFoundReason._not_object: logger.info("Not an Object"); logger.info(nfe.rest_of_name[0].id+" IS PASSED AS AN OBJECT. ACTUALLY IT IS ALREADY BOUND AS A CONTEXT"); throw new org.omg.CosNaming.NamingContextPackage.NotFound(nfe.why, nfe.rest_of_name); } } catch(org.omg.CosNaming.NamingContextPackage.CannotProceed cpe) { logger.info("Caught Exception cannot proceed"); throw new org.omg.CosNaming.NamingContextPackage.CannotProceed(); } } } |
candidate.setAvailableRangeSet( availableRanges ); | try { candidate.setAvailableRangeSet( availableRanges ); } catch ( IllegalArgumentException exp ) { NLogger.error(NLoggerNames.Download_Engine, "Failed to parse X-Available-Ranges in " + candidate.getVendor() + " request: " + response.buildHTTPResponseString(), exp ); } | public void exchangeHTTPHandshake( SWDownloadSegment aSegment ) throws IOException, UnusableHostException, HTTPMessageException { NetworkManager networkMgr = NetworkManager.getInstance(); isDownloadSuccessful = false; segment = aSegment; long downloadOffset = segment.getTransferStartPosition(); OutputStreamWriter writer = new OutputStreamWriter( connection.getOutputStream() ); // reset to default input stream inStream = connection.getInputStream(); String requestUrl = candidate.getDownloadRequestUrl(); HTTPRequest request = new HTTPRequest( "GET", requestUrl, true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, candidate.getHostAddress().getFullHostName() ) ); request.addHeader( new HTTPHeader( GnutellaHeaderNames.LISTEN_IP, networkMgr.getLocalAddress().getFullHostName() ) ); long segmentEndOffset = segment.getEnd(); if ( segmentEndOffset == -1 ) {// create header with open end request.addHeader( new HTTPHeader( HTTPHeaderNames.RANGE, "bytes=" + downloadOffset + "-" ) ); } else { request.addHeader( new HTTPHeader( HTTPHeaderNames.RANGE, "bytes=" + downloadOffset + "-" + segmentEndOffset ) ); } request.addHeader( new HTTPHeader( GnutellaHeaderNames.X_QUEUE, "0.1" ) ); // request a HTTP keep alive connection, needed for queuing to work. request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "Keep-Alive" ) ); if ( candidate.isG2FeatureAdded() ) { request.addHeader( new HTTPHeader( "X-Features", "g2/1.0" ) ); } buildAltLocRequestHeader(request); if ( ServiceManager.sCfg.isChatEnabled ) { DestAddress ha = networkMgr.getLocalAddress(); IpAddress myIp = ha.getIpAddress(); if ( myIp == null || !myIp.isSiteLocalIP() ) { request.addHeader( new HTTPHeader( "Chat", ha.getFullHostName() ) ); } } String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(NLoggerNames.Download_Engine, "HTTP Request to: " + candidate.getHostAddress() + "\n" + httpRequestStr ); candidate.addToCandidateLog( "HTTP Request:\n" + httpRequestStr ); // write request... writer.write( httpRequestStr ); writer.flush(); HTTPResponse response = HTTPProcessor.parseHTTPResponse( connection ); if ( NLogger.isDebugEnabled( NLoggerNames.Download_Engine ) ) { NLogger.debug(NLoggerNames.Download_Engine, "HTTP Response from: " + candidate.getHostAddress() + "\n" + response.buildHTTPResponseString() ); } if ( ServiceManager.sCfg.downloadCandidateLogBufferSize > 0 ) { candidate.addToCandidateLog( "HTTP Response:\n" + response.buildHTTPResponseString() ); } HTTPHeader header = response.getHeader( HTTPHeaderNames.SERVER ); if ( header != null ) { candidate.setVendor( header.getValue() ); } header = response.getHeader( HTTPHeaderNames.TRANSFER_ENCODING ); if ( header != null ) { if ( header.getValue().equals("chunked") ) { inStream = new ChunkedInputStream( connection.getInputStream() ); } } replyContentRange = null; header = response.getHeader( HTTPHeaderNames.CONTENT_RANGE ); if ( header != null ) { replyContentRange = parseContentRange( header.getValue() ); // startPos of -1 indicates '*' (free to choose) if ( replyContentRange.startPos != -1 && replyContentRange.startPos != downloadOffset ) { throw new IOException( "Invalid 'CONTENT-RANGE' start offset." ); } } replyContentLength = -1; header = response.getHeader( HTTPHeaderNames.CONTENT_LENGTH ); if ( header != null ) { try { replyContentLength = header.longValue(); } catch ( NumberFormatException exp ) { //unknown } } URN downloadFileURN = downloadFile.getFileURN(); List<HTTPHeader> contentURNHeaders = new ArrayList<HTTPHeader>(); header = response.getHeader( GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN ); if ( header != null ) { contentURNHeaders.add( header ); } // Shareaza 1.8.10.4 send also a bitprint urn in multiple X-Content-URN headers! HTTPHeader[] headers = response.getHeaders( GnutellaHeaderNames.X_CONTENT_URN ); CollectionUtils.addAll( contentURNHeaders, headers ); if ( downloadFileURN != null ) { Iterator<HTTPHeader> contentURNIterator = contentURNHeaders.iterator(); while ( contentURNIterator.hasNext() ) { header = contentURNIterator.next(); String contentURNStr = header.getValue(); // check if I can understand urn. if ( URN.isValidURN( contentURNStr ) ) { URN contentURN = new URN( contentURNStr ); if ( !downloadFileURN.equals( contentURN ) ) { throw new IOException( "Required URN and content URN do not match." ); } } } } // check Limewire chat support header. header = response.getHeader( GnutellaHeaderNames.CHAT ); if ( header != null ) { candidate.setChatSupported( true ); } // read out REMOTE-IP header... to update my IP header = response.getHeader( GnutellaHeaderNames.REMOTE_IP ); if ( header != null ) { byte[] remoteIP = AddressUtils.parseIP( header.getValue() ); if ( remoteIP != null ) { IpAddress ip = new IpAddress( remoteIP ); DestAddress address = PresentationManager.getInstance().createHostAddress(ip, -1); networkMgr.updateLocalAddress( address ); } } int httpCode = response.getStatusCode(); // read available ranges header = response.getHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES ); if ( header != null ) { HTTPRangeSet availableRanges = HTTPRangeSet.parseHTTPRangeSet( header.getValue(), false ); if ( availableRanges == null ) {// failed to parse... give more detailed error report NLogger.error(NLoggerNames.Download_Engine, "Failed to parse X-Available-Ranges in " + candidate.getVendor() + " request: " + response.buildHTTPResponseString() ); } candidate.setAvailableRangeSet( availableRanges ); } else if ( httpCode >= 200 && httpCode < 300 && downloadFile.getTotalDataSize() != SWDownloadConstants.UNKNOWN_FILE_SIZE) {// OK header and no available range header.. we assume candidate // shares the whole file candidate.setAvailableRangeSet( new HTTPRangeSet( 0, downloadFile.getTotalDataSize() - 1) ); } // collect alternate locations... List<AlternateLocation> altLocList = new ArrayList<AlternateLocation>(); headers = response.getHeaders( GnutellaHeaderNames.ALT_LOC ); List<AlternateLocation> altLocTmpList = AltLocContainer.parseUriResAltLocFromHeaders( headers ); altLocList.addAll( altLocTmpList ); headers = response.getHeaders( GnutellaHeaderNames.X_ALT_LOC ); altLocTmpList = AltLocContainer.parseUriResAltLocFromHeaders( headers ); altLocList.addAll( altLocTmpList ); headers = response.getHeaders( GnutellaHeaderNames.X_ALT ); altLocTmpList = AltLocContainer.parseCompactIpAltLocFromHeaders( headers, downloadFileURN ); altLocList.addAll( altLocTmpList ); // TODO1 huh?? dont we pare X-NALT???? Iterator<AlternateLocation> iterator = altLocList.iterator(); while( iterator.hasNext() ) { downloadFile.addDownloadCandidate( iterator.next() ); } // collect push proxies. // first the old headers.. headers = response.getHeaders( "X-Pushproxies" ); handlePushProxyHeaders( headers ); headers = response.getHeaders( "X-Push-Proxies" ); handlePushProxyHeaders( headers ); // now the standard header headers = response.getHeaders( GnutellaHeaderNames.X_PUSH_PROXY ); handlePushProxyHeaders( headers ); updateKeepAliveSupport( response ); if ( httpCode >= 200 && httpCode < 300 ) {// code accepted // check if we can accept the urn... if ( contentURNHeaders.size() == 0 && requestUrl.startsWith(GnutellaRequest.GNUTELLA_URI_RES_PREFIX) ) {// we requested a download via /uri-res resource urn. // we expect that the result contains a x-gnutella-content-urn // or Shareaza X-Content-URN header. throw new IOException( "Response to uri-res request without valid Content-URN header." ); } // check if we need and can update our file and segment size. if ( downloadFile.getTotalDataSize() == SWDownloadConstants.UNKNOWN_FILE_SIZE ) { // we have a file with an unknown data size. For aditional check assert // certain parameters assert( segment.getTotalDataSize() == -1 ); // Now verify if we have the great chance to update our file data! if ( replyContentRange != null && replyContentRange.totalLength != SWDownloadConstants.UNKNOWN_FILE_SIZE ) { downloadFile.setFileSize( replyContentRange.totalLength ); // we learned the file size. To allow normal segment use // interrupt the download! stopDownload(); throw new ReconnectException(); } } // connection successfully finished NLogger.debug(NLoggerNames.Download_Engine, "HTTP Handshake successfull."); return; } // check error type else if ( httpCode == 503 ) {// 503 -> host is busy (this can also be returned when remotly queued) header = response.getHeader( GnutellaHeaderNames.X_QUEUE ); XQueueParameters xQueueParameters = null; if ( header != null ) { xQueueParameters = XQueueParameters.parseHTTPRangeSet( header.getValue() ); } // check for persistent connection (gtk-gnutella uses queuing with 'Connection: close') if ( xQueueParameters != null && isKeepAliveSupported ) { throw new RemotelyQueuedException( xQueueParameters ); } else { header = response.getHeader( HTTPHeaderNames.RETRY_AFTER ); if ( header != null ) { int delta = HTTPRetryAfter.parseDeltaInSeconds( header ); if ( delta > 0 ) { throw new HostBusyException( delta ); } } throw new HostBusyException(); } } else if ( httpCode == HTTPCodes.HTTP_401_UNAUTHORIZED || httpCode == HTTPCodes.HTTP_403_FORBIDDEN ) { if ( "Network Disabled".equals( response.getStatusReason() ) ) { if ( candidate.isG2FeatureAdded() ) { // already tried G2 but no success.. better give up and dont hammer.. throw new UnusableHostException( "Request Forbidden" ); } else { // we have not tried G2 but we could.. candidate.setG2FeatureAdded( true ); throw new HostBusyException( 60 * 5 ); } } else { throw new UnusableHostException( "Request Forbidden" ); } } else if ( httpCode == 408 ) { // 408 -> Time out. Try later? throw new HostBusyException(); } else if ( httpCode == 404 || httpCode == 410 ) {// 404: File not found / 410: Host not sharing throw new FileNotAvailableException(); } else if ( httpCode == 416 ) {// 416: Requested Range Unavailable header = response.getHeader( HTTPHeaderNames.RETRY_AFTER ); if ( header != null ) { int delta = HTTPRetryAfter.parseDeltaInSeconds( header ); if ( delta > 0 ) { throw new RangeUnavailableException( delta ); } } throw new RangeUnavailableException(); } else if ( httpCode == 500 ) { throw new UnusableHostException( "Internal Server Error" ); } else { throw new IOException( "Unknown HTTP code: " + httpCode ); } } |
candidate.setAvailableRangeSet( new HTTPRangeSet( 0, downloadFile.getTotalDataSize() - 1) ); | try { candidate.setAvailableRangeSet( new HTTPRangeSet( 0, downloadFile.getTotalDataSize() - 1) ); } catch ( IllegalArgumentException exp ) { NLogger.error(NLoggerNames.Download_Engine, "Failed to parse X-Available-Ranges in " + candidate.getVendor() + " request: " + response.buildHTTPResponseString(), exp ); } | public void exchangeHTTPHandshake( SWDownloadSegment aSegment ) throws IOException, UnusableHostException, HTTPMessageException { NetworkManager networkMgr = NetworkManager.getInstance(); isDownloadSuccessful = false; segment = aSegment; long downloadOffset = segment.getTransferStartPosition(); OutputStreamWriter writer = new OutputStreamWriter( connection.getOutputStream() ); // reset to default input stream inStream = connection.getInputStream(); String requestUrl = candidate.getDownloadRequestUrl(); HTTPRequest request = new HTTPRequest( "GET", requestUrl, true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, candidate.getHostAddress().getFullHostName() ) ); request.addHeader( new HTTPHeader( GnutellaHeaderNames.LISTEN_IP, networkMgr.getLocalAddress().getFullHostName() ) ); long segmentEndOffset = segment.getEnd(); if ( segmentEndOffset == -1 ) {// create header with open end request.addHeader( new HTTPHeader( HTTPHeaderNames.RANGE, "bytes=" + downloadOffset + "-" ) ); } else { request.addHeader( new HTTPHeader( HTTPHeaderNames.RANGE, "bytes=" + downloadOffset + "-" + segmentEndOffset ) ); } request.addHeader( new HTTPHeader( GnutellaHeaderNames.X_QUEUE, "0.1" ) ); // request a HTTP keep alive connection, needed for queuing to work. request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "Keep-Alive" ) ); if ( candidate.isG2FeatureAdded() ) { request.addHeader( new HTTPHeader( "X-Features", "g2/1.0" ) ); } buildAltLocRequestHeader(request); if ( ServiceManager.sCfg.isChatEnabled ) { DestAddress ha = networkMgr.getLocalAddress(); IpAddress myIp = ha.getIpAddress(); if ( myIp == null || !myIp.isSiteLocalIP() ) { request.addHeader( new HTTPHeader( "Chat", ha.getFullHostName() ) ); } } String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(NLoggerNames.Download_Engine, "HTTP Request to: " + candidate.getHostAddress() + "\n" + httpRequestStr ); candidate.addToCandidateLog( "HTTP Request:\n" + httpRequestStr ); // write request... writer.write( httpRequestStr ); writer.flush(); HTTPResponse response = HTTPProcessor.parseHTTPResponse( connection ); if ( NLogger.isDebugEnabled( NLoggerNames.Download_Engine ) ) { NLogger.debug(NLoggerNames.Download_Engine, "HTTP Response from: " + candidate.getHostAddress() + "\n" + response.buildHTTPResponseString() ); } if ( ServiceManager.sCfg.downloadCandidateLogBufferSize > 0 ) { candidate.addToCandidateLog( "HTTP Response:\n" + response.buildHTTPResponseString() ); } HTTPHeader header = response.getHeader( HTTPHeaderNames.SERVER ); if ( header != null ) { candidate.setVendor( header.getValue() ); } header = response.getHeader( HTTPHeaderNames.TRANSFER_ENCODING ); if ( header != null ) { if ( header.getValue().equals("chunked") ) { inStream = new ChunkedInputStream( connection.getInputStream() ); } } replyContentRange = null; header = response.getHeader( HTTPHeaderNames.CONTENT_RANGE ); if ( header != null ) { replyContentRange = parseContentRange( header.getValue() ); // startPos of -1 indicates '*' (free to choose) if ( replyContentRange.startPos != -1 && replyContentRange.startPos != downloadOffset ) { throw new IOException( "Invalid 'CONTENT-RANGE' start offset." ); } } replyContentLength = -1; header = response.getHeader( HTTPHeaderNames.CONTENT_LENGTH ); if ( header != null ) { try { replyContentLength = header.longValue(); } catch ( NumberFormatException exp ) { //unknown } } URN downloadFileURN = downloadFile.getFileURN(); List<HTTPHeader> contentURNHeaders = new ArrayList<HTTPHeader>(); header = response.getHeader( GnutellaHeaderNames.X_GNUTELLA_CONTENT_URN ); if ( header != null ) { contentURNHeaders.add( header ); } // Shareaza 1.8.10.4 send also a bitprint urn in multiple X-Content-URN headers! HTTPHeader[] headers = response.getHeaders( GnutellaHeaderNames.X_CONTENT_URN ); CollectionUtils.addAll( contentURNHeaders, headers ); if ( downloadFileURN != null ) { Iterator<HTTPHeader> contentURNIterator = contentURNHeaders.iterator(); while ( contentURNIterator.hasNext() ) { header = contentURNIterator.next(); String contentURNStr = header.getValue(); // check if I can understand urn. if ( URN.isValidURN( contentURNStr ) ) { URN contentURN = new URN( contentURNStr ); if ( !downloadFileURN.equals( contentURN ) ) { throw new IOException( "Required URN and content URN do not match." ); } } } } // check Limewire chat support header. header = response.getHeader( GnutellaHeaderNames.CHAT ); if ( header != null ) { candidate.setChatSupported( true ); } // read out REMOTE-IP header... to update my IP header = response.getHeader( GnutellaHeaderNames.REMOTE_IP ); if ( header != null ) { byte[] remoteIP = AddressUtils.parseIP( header.getValue() ); if ( remoteIP != null ) { IpAddress ip = new IpAddress( remoteIP ); DestAddress address = PresentationManager.getInstance().createHostAddress(ip, -1); networkMgr.updateLocalAddress( address ); } } int httpCode = response.getStatusCode(); // read available ranges header = response.getHeader( GnutellaHeaderNames.X_AVAILABLE_RANGES ); if ( header != null ) { HTTPRangeSet availableRanges = HTTPRangeSet.parseHTTPRangeSet( header.getValue(), false ); if ( availableRanges == null ) {// failed to parse... give more detailed error report NLogger.error(NLoggerNames.Download_Engine, "Failed to parse X-Available-Ranges in " + candidate.getVendor() + " request: " + response.buildHTTPResponseString() ); } candidate.setAvailableRangeSet( availableRanges ); } else if ( httpCode >= 200 && httpCode < 300 && downloadFile.getTotalDataSize() != SWDownloadConstants.UNKNOWN_FILE_SIZE) {// OK header and no available range header.. we assume candidate // shares the whole file candidate.setAvailableRangeSet( new HTTPRangeSet( 0, downloadFile.getTotalDataSize() - 1) ); } // collect alternate locations... List<AlternateLocation> altLocList = new ArrayList<AlternateLocation>(); headers = response.getHeaders( GnutellaHeaderNames.ALT_LOC ); List<AlternateLocation> altLocTmpList = AltLocContainer.parseUriResAltLocFromHeaders( headers ); altLocList.addAll( altLocTmpList ); headers = response.getHeaders( GnutellaHeaderNames.X_ALT_LOC ); altLocTmpList = AltLocContainer.parseUriResAltLocFromHeaders( headers ); altLocList.addAll( altLocTmpList ); headers = response.getHeaders( GnutellaHeaderNames.X_ALT ); altLocTmpList = AltLocContainer.parseCompactIpAltLocFromHeaders( headers, downloadFileURN ); altLocList.addAll( altLocTmpList ); // TODO1 huh?? dont we pare X-NALT???? Iterator<AlternateLocation> iterator = altLocList.iterator(); while( iterator.hasNext() ) { downloadFile.addDownloadCandidate( iterator.next() ); } // collect push proxies. // first the old headers.. headers = response.getHeaders( "X-Pushproxies" ); handlePushProxyHeaders( headers ); headers = response.getHeaders( "X-Push-Proxies" ); handlePushProxyHeaders( headers ); // now the standard header headers = response.getHeaders( GnutellaHeaderNames.X_PUSH_PROXY ); handlePushProxyHeaders( headers ); updateKeepAliveSupport( response ); if ( httpCode >= 200 && httpCode < 300 ) {// code accepted // check if we can accept the urn... if ( contentURNHeaders.size() == 0 && requestUrl.startsWith(GnutellaRequest.GNUTELLA_URI_RES_PREFIX) ) {// we requested a download via /uri-res resource urn. // we expect that the result contains a x-gnutella-content-urn // or Shareaza X-Content-URN header. throw new IOException( "Response to uri-res request without valid Content-URN header." ); } // check if we need and can update our file and segment size. if ( downloadFile.getTotalDataSize() == SWDownloadConstants.UNKNOWN_FILE_SIZE ) { // we have a file with an unknown data size. For aditional check assert // certain parameters assert( segment.getTotalDataSize() == -1 ); // Now verify if we have the great chance to update our file data! if ( replyContentRange != null && replyContentRange.totalLength != SWDownloadConstants.UNKNOWN_FILE_SIZE ) { downloadFile.setFileSize( replyContentRange.totalLength ); // we learned the file size. To allow normal segment use // interrupt the download! stopDownload(); throw new ReconnectException(); } } // connection successfully finished NLogger.debug(NLoggerNames.Download_Engine, "HTTP Handshake successfull."); return; } // check error type else if ( httpCode == 503 ) {// 503 -> host is busy (this can also be returned when remotly queued) header = response.getHeader( GnutellaHeaderNames.X_QUEUE ); XQueueParameters xQueueParameters = null; if ( header != null ) { xQueueParameters = XQueueParameters.parseHTTPRangeSet( header.getValue() ); } // check for persistent connection (gtk-gnutella uses queuing with 'Connection: close') if ( xQueueParameters != null && isKeepAliveSupported ) { throw new RemotelyQueuedException( xQueueParameters ); } else { header = response.getHeader( HTTPHeaderNames.RETRY_AFTER ); if ( header != null ) { int delta = HTTPRetryAfter.parseDeltaInSeconds( header ); if ( delta > 0 ) { throw new HostBusyException( delta ); } } throw new HostBusyException(); } } else if ( httpCode == HTTPCodes.HTTP_401_UNAUTHORIZED || httpCode == HTTPCodes.HTTP_403_FORBIDDEN ) { if ( "Network Disabled".equals( response.getStatusReason() ) ) { if ( candidate.isG2FeatureAdded() ) { // already tried G2 but no success.. better give up and dont hammer.. throw new UnusableHostException( "Request Forbidden" ); } else { // we have not tried G2 but we could.. candidate.setG2FeatureAdded( true ); throw new HostBusyException( 60 * 5 ); } } else { throw new UnusableHostException( "Request Forbidden" ); } } else if ( httpCode == 408 ) { // 408 -> Time out. Try later? throw new HostBusyException(); } else if ( httpCode == 404 || httpCode == 410 ) {// 404: File not found / 410: Host not sharing throw new FileNotAvailableException(); } else if ( httpCode == 416 ) {// 416: Requested Range Unavailable header = response.getHeader( HTTPHeaderNames.RETRY_AFTER ); if ( header != null ) { int delta = HTTPRetryAfter.parseDeltaInSeconds( header ); if ( delta > 0 ) { throw new RangeUnavailableException( delta ); } } throw new RangeUnavailableException(); } else if ( httpCode == 500 ) { throw new UnusableHostException( "Internal Server Error" ); } else { throw new IOException( "Unknown HTTP code: " + httpCode ); } } |
public void setValidValue(boolean val) { validValue = val; } | public void setValidValue(boolean val) { if(isConstant()) return; validValue = val; } | public void setValidValue(boolean val) { validValue = val; } |
return new Variable(name,value); | Variable var = new Variable(name,value); return var; | public Variable createVariable(String name, Object value) { return new Variable(name,value); } |
Writer w = new OutputStreamWriter(new FileOutputStream(new File(getRootDir(),"build.xml")),"UTF-8"); | Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(getRootDir(),"build.xml")),"UTF-8")); | public synchronized void save() throws IOException { Writer w = new OutputStreamWriter(new FileOutputStream(new File(getRootDir(),"build.xml")),"UTF-8"); w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); createConfiguredStream().toXML(this,w); w.close(); } |
final String dateRange = ">=" + outputDate.format(m_start); | final String dateRange = ">=" + outputDate.format(safeStart); | public void execute() throws BuildException { File savedDir = m_dir; // may be altered in validate try { validate(); final Properties userList = new Properties(); loadUserlist(userList); for (Enumeration e = m_cvsUsers.elements(); e.hasMoreElements();) { final CvsUser user = (CvsUser) e.nextElement(); user.validate(); userList.put(user.getUserID(), user.getDisplayname()); } setCommand("log"); if (getTag() != null) { CvsVersion myCvsVersion = new CvsVersion(); myCvsVersion.setProject(getProject()); myCvsVersion.setTaskName("cvsversion"); myCvsVersion.setCvsRoot(getCvsRoot()); myCvsVersion.setCvsRsh(getCvsRsh()); myCvsVersion.setPassfile(getPassFile()); myCvsVersion.setDest(m_dir); myCvsVersion.execute(); if (myCvsVersion.supportsCvsLogWithSOption()) { addCommandArgument("-S"); } } if (null != m_start) { final SimpleDateFormat outputDate = new SimpleDateFormat("yyyy-MM-dd"); // We want something of the form: -d ">=YYYY-MM-dd" final String dateRange = ">=" + outputDate.format(m_start); // Supply '-d' as a separate argument - Bug# 14397 addCommandArgument("-d"); addCommandArgument(dateRange); } // Check if list of files to check has been specified if (!m_filesets.isEmpty()) { for (String file : m_filesets) { addCommandArgument(file); } } final ChangeLogParser parser = new ChangeLogParser(this); final RedirectingStreamHandler handler = new RedirectingStreamHandler(parser); log(getCommand(), Project.MSG_VERBOSE); setDest(m_dir); setExecuteStreamHandler(handler); try { super.execute(); } finally { final String errors = handler.getErrors(); if (null != errors && errors.length()!=0) { log(errors, Project.MSG_ERR); } } final CVSEntry[] entrySet = parser.getEntrySetAsArray(); final CVSEntry[] filteredEntrySet = filterEntrySet(entrySet); replaceAuthorIdWithName(userList, filteredEntrySet); writeChangeLog(filteredEntrySet); } finally { m_dir = savedDir; } } |
disabled = req.getParameter("disable")!=null; | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { try { if(!Hudson.adminCheck(req,rsp)) return; int scmidx = Integer.parseInt(req.getParameter("scm")); scm = SCMManager.getSupportedSCMs()[scmidx].newInstance(req); jdk = req.getParameter("jdk"); if(req.getParameter("hasCustomQuietPeriod")!=null) { quietPeriod = Integer.parseInt(req.getParameter("quiet_period")); } else { quietPeriod = null; } if(req.getParameter("hasSlaveAffinity")!=null) { canRoam = false; assignedNode = req.getParameter("slave"); if(assignedNode !=null) { if(Hudson.getInstance().getSlave(assignedNode)==null) { assignedNode = null; // no such slave } } } else { canRoam = true; assignedNode = null; } buildDescribable(req, BuildStep.BUILDERS, builders, "builder"); buildDescribable(req, BuildStep.PUBLISHERS, publishers, "publisher"); for (Trigger t : triggers) t.stop(); buildDescribable(req, Trigger.TRIGGERS, triggers, "trigger"); for (Trigger t : triggers) t.start(this); super.doConfigSubmit(req,rsp); } catch (InstantiationException e) { sendError(e,req,rsp); } } |
|
return true; | return !isDisabled(); | public boolean isBuildable() { return true; } |
getParent().getQueue().add(this); | if(!disabled) getParent().getQueue().add(this); | public void scheduleBuild() { getParent().getQueue().add(this); } |
if(!local.mkdirs()) | if(!local.mkdirs() && !local.exists()) | public void mkdirs() throws IOException { if(!local.mkdirs()) throw new IOException("Failed to mkdirs: "+local); } |
if(awtProblem) { rsp.sendRedirect2(req.getContextPath()+"/images/headless.png"); return; } | public void doGraph( StaplerRequest req, StaplerResponse rsp) throws IOException { try { if(req.checkIfModified(owner.getTimestamp(),rsp)) return; class BuildLabel implements Comparable<BuildLabel> { private final Build build; public BuildLabel(Build build) { this.build = build; } public int compareTo(BuildLabel that) { return this.build.number-that.build.number; } public boolean equals(Object o) { BuildLabel that = (BuildLabel) o; return build==that.build; } public int hashCode() { return build.hashCode(); } public String toString() { return build.getDisplayName(); } } boolean failureOnly = Boolean.valueOf(req.getParameter("failureOnly")); DataSetBuilder<String,BuildLabel> dsb = new DataSetBuilder<String,BuildLabel>(); for( TestResultAction a=this; a!=null; a=a.getPreviousResult() ) { dsb.add( a.getFailCount(), "failed", new BuildLabel(a.owner)); if(!failureOnly) dsb.add( a.getTotalCount()-a.getFailCount(),"total", new BuildLabel(a.owner)); } String w = req.getParameter("width"); if(w==null) w="500"; String h = req.getParameter("height"); if(h==null) h="200"; BufferedImage image = createChart(dsb.build()).createBufferedImage(Integer.parseInt(w),Integer.parseInt(h)); rsp.setContentType("image/png"); ServletOutputStream os = rsp.getOutputStream(); ImageIO.write(image, "PNG", os); os.close(); } catch(HeadlessException e) { // not available. send out error message rsp.sendRedirect2(req.getContextPath()+"/images/headless.png"); } } |
|
public ByteCopier(InputStream in, OutputStream out) { | public ByteCopier(String threadName, InputStream in, OutputStream out) { super(threadName); | public ByteCopier(InputStream in, OutputStream out) { this.in = in; this.out = out; } |
public Copier(InputStream in, OutputStream out) { | public Copier(String threadName, InputStream in, OutputStream out) { super(threadName); | public Copier(InputStream in, OutputStream out) { this.in = in; this.out = out; } |
if(!checkBits(bits[1],cal.get(Calendar.HOUR))) | if(!checkBits(bits[1],cal.get(Calendar.HOUR_OF_DAY))) | boolean check(Calendar cal) { if(!checkBits(bits[0],cal.get(Calendar.MINUTE))) return false; if(!checkBits(bits[1],cal.get(Calendar.HOUR))) return false; if(!checkBits(bits[2],cal.get(Calendar.DAY_OF_MONTH))) return false; if(!checkBits(bits[3],cal.get(Calendar.MONTH)+1)) return false; if(!checkBits(dayOfWeek,cal.get(Calendar.DAY_OF_WEEK)-1)) return false; return true; } |
public void addStyle(String name, Color foreground, Color background, boolean bold) | public void addStyle(String name, Color foreground) | public void addStyle(String name, Color foreground, Color background, boolean bold) { if (m_textPane == null) return; StyledDocument doc = m_textPane.getStyledDocument(); StyleContext context = StyleContext.getDefaultStyleContext(); Style def = context.getStyle(StyleContext.DEFAULT_STYLE); Style style = doc.addStyle(name, def); if (foreground != null) StyleConstants.setForeground(style, foreground); if (background != null) StyleConstants.setForeground(style, background); StyleConstants.setBold(style, bold); if (m_noLineSpacing) StyleConstants.setLineSpacing(style, 0f); } |
if (m_textPane == null) return; StyledDocument doc = m_textPane.getStyledDocument(); StyleContext context = StyleContext.getDefaultStyleContext(); Style def = context.getStyle(StyleContext.DEFAULT_STYLE); Style style = doc.addStyle(name, def); if (foreground != null) StyleConstants.setForeground(style, foreground); if (background != null) StyleConstants.setForeground(style, background); StyleConstants.setBold(style, bold); if (m_noLineSpacing) StyleConstants.setLineSpacing(style, 0f); | addStyle(name, foreground, null, false); | public void addStyle(String name, Color foreground, Color background, boolean bold) { if (m_textPane == null) return; StyledDocument doc = m_textPane.getStyledDocument(); StyleContext context = StyleContext.getDefaultStyleContext(); Style def = context.getStyle(StyleContext.DEFAULT_STYLE); Style style = doc.addStyle(name, def); if (foreground != null) StyleConstants.setForeground(style, foreground); if (background != null) StyleConstants.setForeground(style, background); StyleConstants.setBold(style, bold); if (m_noLineSpacing) StyleConstants.setLineSpacing(style, 0f); } |
if(printPartialEquations && deriv.hasEquation()) | if(((mode & PRINT_PARTIAL_EQNS)!=0) && deriv.hasEquation()) | public Object visit(ASTVarNode node, Object data) throws ParseException { Variable var = node.getVar(); if(var instanceof PartialDerivative) { PartialDerivative deriv = (PartialDerivative) var; if(printPartialEquations && deriv.hasEquation()) deriv.getEquation().jjtAccept(this,null); else sb.append(node.getName()); } else if(var instanceof DVariable) { DVariable dvar = (DVariable) var; if(printVariableEquations && dvar.hasEquation()) dvar.getEquation().jjtAccept(this,null); else sb.append(node.getName()); } else sb.append(node.getName()); return data; } |
if(printVariableEquations && dvar.hasEquation()) | if(((mode & PRINT_VARIABLE_EQNS)!=0) && dvar.hasEquation()) | public Object visit(ASTVarNode node, Object data) throws ParseException { Variable var = node.getVar(); if(var instanceof PartialDerivative) { PartialDerivative deriv = (PartialDerivative) var; if(printPartialEquations && deriv.hasEquation()) deriv.getEquation().jjtAccept(this,null); else sb.append(node.getName()); } else if(var instanceof DVariable) { DVariable dvar = (DVariable) var; if(printVariableEquations && dvar.hasEquation()) dvar.getEquation().jjtAccept(this,null); else sb.append(node.getName()); } else sb.append(node.getName()); return data; } |
public Object visit(ASTVarNode node, Object data) throws ParseException { sb.append(node.getName()); return data; } | public Object visit(ASTFunNode node, Object data) throws ParseException { if(!node.isOperator()) return visitFun(node); if(node instanceof PrintRulesI) { ((PrintRulesI) node).append(node,this); return null; } if(node.getOperator()==null) { throw new ParseException("Null operator in print for "+node); } if(specialRules.containsKey(node.getOperator())) { ((PrintRulesI) specialRules.get(node.getOperator())).append(node,this); return null; } if(node.getPFMC() instanceof org.nfunk.jep.function.List) { append("["); for(int i=0;i<node.jjtGetNumChildren();++i) { if(i>0) append(","); node.jjtGetChild(i).jjtAccept(this, null); } append("]"); return null; } if(((XOperator) node.getOperator()).isUnary()) return visitUnary(node,data); if(((XOperator) node.getOperator()).isBinary()) { XOperator top = (XOperator) node.getOperator(); if(node.jjtGetNumChildren()!=2) return visitNaryBinary(node,top); Node lhs = node.jjtGetChild(0); Node rhs = node.jjtGetChild(1); if(testLeft(top,lhs)) printBrackets(lhs); else printNoBrackets(lhs); sb.append(node.getOperator().getSymbol()); if(testRight(top,rhs)) printBrackets(rhs); else printNoBrackets(rhs); } return null; } | public Object visit(ASTVarNode node, Object data) throws ParseException { sb.append(node.getName()); return data; } |
public void fireUploadFileChanged(UploadState file) | private void fireUploadFileChanged(final int position) | public void fireUploadFileChanged(UploadState file) { synchronized (uploadStateList) { int position = uploadStateList.indexOf( file ); if ( position >= 0 ) { fireUploadFileChanged( position ); } } } |
synchronized (uploadStateList) | AsynchronousDispatcher.invokeLater( new Runnable() | public void fireUploadFileChanged(UploadState file) { synchronized (uploadStateList) { int position = uploadStateList.indexOf( file ); if ( position >= 0 ) { fireUploadFileChanged( position ); } } } |
int position = uploadStateList.indexOf( file ); if ( position >= 0 ) | public void run() | public void fireUploadFileChanged(UploadState file) { synchronized (uploadStateList) { int position = uploadStateList.indexOf( file ); if ( position >= 0 ) { fireUploadFileChanged( position ); } } } |
fireUploadFileChanged( position ); | Object[] listeners = listenerList.toArray(); UploadFilesChangeListener listener; for (int i = listeners.length - 1; i >= 0; i--) { listener = (UploadFilesChangeListener) listeners[i]; listener.uploadFileChanged( position ); } | public void fireUploadFileChanged(UploadState file) { synchronized (uploadStateList) { int position = uploadStateList.indexOf( file ); if ( position >= 0 ) { fireUploadFileChanged( position ); } } } |
} | } ); | public void fireUploadFileChanged(UploadState file) { synchronized (uploadStateList) { int position = uploadStateList.indexOf( file ); if ( position >= 0 ) { fireUploadFileChanged( position ); } } } |
int r = new Proc(new String[]{"ln","-s",getRootDir().getPath(),"../lastSuccessful"}, | int r = new Proc(new String[]{ "ln","-s","builds/"+getId(),"../lastSuccessful"}, | public void run() { run(new Runner() { public Result run(BuildListener listener) throws IOException { if(!project.checkout(Build.this,listener)) return Result.FAILURE; if(!project.getScm().calcChangeLog(Build.this,new File(getRootDir(),"changelog.xml"),listener)) return Result.FAILURE; if(!preBuild(listener,project.getBuilders())) return Result.FAILURE; if(!preBuild(listener,project.getPublishers())) return Result.FAILURE; if(!build(listener,project.getBuilders())) return Result.FAILURE; if(!isWindows()) { try { // ignore a failure. new Proc(new String[]{"rm","../latest"},new String[0],listener.getLogger(),getProject().getBuildDir()).join(); int r = new Proc(new String[]{"ln","-s",getRootDir().getPath(),"../lastSuccessful"}, new String[0],listener.getLogger(),getProject().getBuildDir()).join(); if(r!=0) listener.getLogger().println("ln failed: "+r); } catch (IOException e) { PrintStream log = listener.getLogger(); log.println("ln failed"); e.printStackTrace( log ); } } return Result.SUCCESS; } public void post(BuildListener listener) { build(listener,project.getPublishers()); } }); } |
int r = new Proc(new String[]{"ln","-s",getRootDir().getPath(),"../lastSuccessful"}, | int r = new Proc(new String[]{ "ln","-s","builds/"+getId(),"../lastSuccessful"}, | public Result run(BuildListener listener) throws IOException { if(!project.checkout(Build.this,listener)) return Result.FAILURE; if(!project.getScm().calcChangeLog(Build.this,new File(getRootDir(),"changelog.xml"),listener)) return Result.FAILURE; if(!preBuild(listener,project.getBuilders())) return Result.FAILURE; if(!preBuild(listener,project.getPublishers())) return Result.FAILURE; if(!build(listener,project.getBuilders())) return Result.FAILURE; if(!isWindows()) { try { // ignore a failure. new Proc(new String[]{"rm","../latest"},new String[0],listener.getLogger(),getProject().getBuildDir()).join(); int r = new Proc(new String[]{"ln","-s",getRootDir().getPath(),"../lastSuccessful"}, new String[0],listener.getLogger(),getProject().getBuildDir()).join(); if(r!=0) listener.getLogger().println("ln failed: "+r); } catch (IOException e) { PrintStream log = listener.getLogger(); log.println("ln failed"); e.printStackTrace( log ); } } return Result.SUCCESS; } |
if(path==null) path = EnvVars.masterEnvVars.get("PATH"); | public void buildEnvVars(Map<String,String> env) { String path = env.get("PATH"); if(path==null) path = getBinDir().getPath(); else path = getBinDir().getPath()+File.pathSeparator+path; env.put("PATH",path); env.put("JAVA_HOME",javaHome); } |
|
public XJep newInstance(SymbolTable st) | public XJep newInstance() | public XJep newInstance(SymbolTable st) { XJep newJep = new XJep(this); newJep.symTab = st; return newJep; } |
newJep.symTab = st; | public XJep newInstance(SymbolTable st) { XJep newJep = new XJep(this); newJep.symTab = st; return newJep; } |
|
public ASTVarNode buildVariableNode(Variable var) throws ParseException | public ASTVarNode buildVariableNode(ASTVarNode node) throws ParseException | public ASTVarNode buildVariableNode(Variable var) throws ParseException { ASTVarNode node = new ASTVarNode(ParserTreeConstants.JJTVARNODE); node.setVar(var); return node; } |
ASTVarNode node = new ASTVarNode(ParserTreeConstants.JJTVARNODE); node.setVar(var); return node; | return buildVariableNode(node.getVar()); | public ASTVarNode buildVariableNode(Variable var) throws ParseException { ASTVarNode node = new ASTVarNode(ParserTreeConstants.JJTVARNODE); node.setVar(var); return node; } |
public Node rewrite(Node node,XJep xjep,RewriteRuleI rules[],boolean simplify) throws ParseException,IllegalArgumentException | public Node rewrite(Node node,XJep xjep,RewriteRuleI inrules[],boolean simplify) throws ParseException,IllegalArgumentException | public Node rewrite(Node node,XJep xjep,RewriteRuleI rules[],boolean simplify) throws ParseException,IllegalArgumentException { xj = xjep; nf = xjep.getNodeFactory(); opSet = xjep.getOperatorSet(); tu = xjep.getTreeUtils(); this.rules = rules; this.simp = simplify; if(this.rules.length==0) return node; if (node == null) throw new IllegalArgumentException( "topNode parameter is null"); Node res = (Node) node.jjtAccept(this,null); return res; } |
nf = xjep.getNodeFactory(); opSet = xjep.getOperatorSet(); tu = xjep.getTreeUtils(); this.rules = rules; | this.rules = inrules; | public Node rewrite(Node node,XJep xjep,RewriteRuleI rules[],boolean simplify) throws ParseException,IllegalArgumentException { xj = xjep; nf = xjep.getNodeFactory(); opSet = xjep.getOperatorSet(); tu = xjep.getTreeUtils(); this.rules = rules; this.simp = simplify; if(this.rules.length==0) return node; if (node == null) throw new IllegalArgumentException( "topNode parameter is null"); Node res = (Node) node.jjtAccept(this,null); return res; } |
tunLoss = cToF(tunLossF); | tunLoss = tunLossF * 1.8; | public void calcMashSchedule() { // Method to run through the mash table and calculate values double strikeTemp = 0; double targetTemp = 0; double endTemp = 0; double waterAddedQTS = 0; double waterEquiv = 0; double mr = mashRatio; double currentTemp = grainTempF; double displTemp = 0; double tunLoss = tunLossF; // figure out a better way to do this, eg: themal mass double decoct = 0; int totalMashTime = 0; double totalSpargeTime = 0; double mashWaterQTS = 0; double mashVolQTS = 0; String stepType; int numSparge = 0; // convert mash ratio to qts/lb if in l/kg if (mashRatioU.equalsIgnoreCase("l/kg")) { mr *= 0.479325; } // convert CurrentTemp to F if (mashTempU == "C") { currentTemp = cToF(currentTemp); tunLoss = cToF(tunLossF); } // perform calcs on first record if (steps.isEmpty()) return; // sort the list Collections.sort(steps, new stepComparator()); MashStep stp = ((MashStep) steps.get(0)); targetTemp = stp.startTemp; endTemp = stp.endTemp; strikeTemp = calcStrikeTemp(targetTemp, currentTemp, mr, tunLoss); waterAddedQTS = mr * maltWeightLbs; waterEquiv = maltWeightLbs * (0.192 + mr); mashVolQTS = calcMashVol(maltWeightLbs, mr); totalMashTime += stp.minutes; mashWaterQTS += waterAddedQTS; stp.infuseVol.setUnits("qt"); stp.infuseVol.setAmount(waterAddedQTS); stp.method = "infusion"; // subtract the water added from the Water Equiv so that they are correct when added in the next part of the loop waterEquiv -= waterAddedQTS; // Updated the water added if (tempUnits == "C") strikeTemp = fToC(strikeTemp); stp.directions = "Mash in with " + df1.format(stp.infuseVol.getValueAs(volUnits)) + " " + volUnits + " of water at " + df1.format(strikeTemp) + " " + tempUnits; // set TargetTemp to the end temp targetTemp = stp.endTemp; for (int i = 1; i < steps.size(); i++) { stp = ((MashStep) steps.get(i)); currentTemp = targetTemp; // switch targetTemp = stp.startTemp; // do calcs if (stp.method.equals("infusion")) { // calculate an infusion step decoct = 0; waterEquiv += waterAddedQTS; // add previous addition to get WE strikeTemp = boilTempF; // boiling water // Updated the water added waterAddedQTS = calcWaterAddition(targetTemp, currentTemp, waterEquiv, boilTempF); stp.infuseVol.setUnits("qt"); stp.infuseVol.setAmount(waterAddedQTS); if (tempUnits == "C") strikeTemp = 100; stp.directions = "Add " + df1.format(stp.infuseVol.getValueAs(volUnits)) + " " + volUnits + " of water at " + df1.format(strikeTemp) + " " + tempUnits; mashWaterQTS += waterAddedQTS; mashVolQTS += waterAddedQTS; } else if (stp.method.indexOf("decoction") > 0) { // calculate a decoction step waterEquiv += waterAddedQTS; // add previous addition to get WE waterAddedQTS = 0; strikeTemp = boilTempF; // boiling water double ratio=0.75; if (stp.method.indexOf("thick") > 0) ratio = 0.6; else if (stp.method.indexOf("thin") > 0) ratio = 0.9; // Calculate volume (qts) of mash to remove decoct = calcDecoction2(targetTemp, currentTemp, mashWaterQTS, ratio); stp.decoctVol.setUnits("qt"); stp.decoctVol.setAmount(decoct); // Updated the decoction, convert to right units & make directions stp.directions = "Remove " + df1.format(stp.decoctVol.getValueAs(volUnits)) + " " + volUnits + " of mash, boil, and return to mash."; } else if (stp.method.equals("direct")) { // calculate a direct heat step decoct = 0; waterEquiv += waterAddedQTS; // add previous addition to get WE waterAddedQTS = 0; stp.directions = "Add direct heat until mash reaches " + displTemp + " " + tempUnits + "."; } if (stp.method.equals("sparge")) { // Count it numSparge++; } else totalMashTime += stp.minutes; stp.infuseVol.setUnits("qt"); stp.infuseVol.setAmount(waterAddedQTS); stp.decoctVol.setUnits("qt"); stp.decoctVol.setAmount(decoct); // set target temp to end temp for next step targetTemp = stp.endTemp; } // while not eof waterEquiv += waterAddedQTS; // add previous addition to get WE totalTime = totalMashTime; volQts = mashVolQTS; // water use stats: absorbedQTS = maltWeightLbs * 0.55; // figure from HBD // spargeTotalQTS = (myRecipe.getPreBoilVol("qt")) - (mashWaterQTS - absorbedQTS); totalWaterQTS = mashWaterQTS; // TODO: sparge stuff should get figured here: } |
return fToC(tunLossF); | return ( tunLossF / 1.8 ); | public double getTunLoss() { if (tempUnits.equals("F")) return tunLossF; else return fToC(tunLossF); } |
tunLossF = cToF(t); | tunLossF = t * 1.8; | public void setTunLoss(double t){ if (tempUnits.equals("F")) tunLossF = t; else tunLossF = cToF(t); calcMashSchedule(); } |
sb.append(SBStringUtils.xmlElement("VOLUME", getMashTotalVol(), 4)); | public String toXml() { StringBuffer sb = new StringBuffer(); sb.append(" <MASH>\n"); for (int i = 0; i < steps.size(); i++) { MashStep st = (MashStep) steps.get(i); sb.append(" <ITEM>\n"); sb.append(" <TYPE>" + st.type + "</TYPE>\n"); sb.append(" <TEMP>" + st.startTemp + "</TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_TEMP>" + SBStringUtils.format(fToC(st.startTemp), 1) + "</DISPL_TEMP>\n"); else sb.append(" <DISPL_TEMP>" + st.startTemp + "</DISPL_TEMP>\n"); sb.append(" <END_TEMP>" + st.endTemp + "</END_TEMP>\n"); if (tempUnits.equals("C")) sb.append(" <DISPL_END_TEMP>" + SBStringUtils.format(fToC(st.endTemp), 1) + "</DISPL_END_TEMP>\n"); else sb.append(" <DISPL_END_TEMP>" + st.endTemp + "</DISPL_END_TEMP>\n"); sb.append(" <MIN>" + st.minutes + "</MIN>\n"); sb.append(" <RAMP_MIN>" + st.rampMin + "</RAMP_MIN>\n"); sb.append(" <METHOD>" + st.method + "</METHOD>\n"); sb.append(" <DIRECTIONS>" + st.directions + "</DIRECTIONS>\n"); sb.append(" </ITEM>\n"); } sb.append(" </MASH>\n"); return sb.toString(); } |
|
mashModel.setData(myRecipe.getMash()); tblMash.updateUI(); | public void displayMash() { if (myRecipe != null) { recipeNameLabel.setText(myRecipe.getName()); mashModel.setData(myRecipe.getMash()); tblMash.updateUI(); volUnitsComboModel.addOrInsert(myRecipe.mash.getMashVolUnits()); // temp units: if (myRecipe.mash.getMashTempUnits().equals("F")) tempFrb.setSelected(true); else tempCrb.setSelected(true); grainTempULabel.setText(myRecipe.mash.getMashTempUnits()); tempLostULabel.setText(myRecipe.mash.getMashTempUnits()); // set totals: String mashWeightTotal = SBStringUtils.df1.format(myRecipe.getTotalMash()) + " " + myRecipe.getMaltUnits(); totalMashLabel.setText(mashWeightTotal); totalTimeLabel.setText(new Integer(myRecipe.mash.getMashTotalTime()).toString()); volLabel.setText(myRecipe.mash.getMashTotalVol()); grainTempText.setText(new Double(myRecipe.mash.getGrainTemp()).toString()); int i = tblMash.getSelectedRow(); if (i>-1){ directionsTextArea.setText(myRecipe.mash.getStepDirections(i)); } displayWater(); } } |
|
tblMash.setAutoCreateColumnsFromModel(false); tblMash.getTableHeader().setReorderingAllowed(false); | private void initGUI() { try { GridBagLayout thisLayout = new GridBagLayout(); thisLayout.columnWeights = new double[] {0.1, 0.1, 0.1}; thisLayout.columnWidths = new int[] {7, 7, 7}; thisLayout.rowWeights = new double[] {0.1, 0.8, 0.1, 0.1, 0.1, 0.1}; thisLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7}; getContentPane().setLayout(thisLayout); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("Mash Manager"); { { } titlePanel = new JPanel(); FlowLayout titlePanelLayout = new FlowLayout(); titlePanelLayout.setAlignment(FlowLayout.LEFT); titlePanel.setLayout(titlePanelLayout); this.getContentPane().add( titlePanel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { titleLabel = new JLabel(); titlePanel.add(titleLabel); titleLabel.setText("Mash schedule for:"); titleLabel.setFont(new java.awt.Font("Dialog", 0, 12)); } { recipeNameLabel = new JLabel(); titlePanel.add(recipeNameLabel); recipeNameLabel.setText("Recipe Name"); } } { tablePanel = new JPanel(); BorderLayout pnlTableLayout = new BorderLayout(); tablePanel.setLayout(pnlTableLayout); this.getContentPane().add( tablePanel, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); tablePanel.setName(""); tablePanel.setBorder(BorderFactory.createTitledBorder("Mash Steps")); { jScrollPane1 = new JScrollPane(); tablePanel.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(424, -32)); { mashModel = new MashTableModel(this); tblMash = new JTable(); jScrollPane1.setViewportView(tblMash); tblMash.setModel(mashModel); tblMash.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { int i = tblMash.getSelectedRow(); directionsTextArea.setText(myRecipe.mash.getStepDirections(i)); } }); // set up type combo String [] types = {"acid","gluten","protein","beta","alpha","mashout"}; JComboBox typesComboBox = new JComboBox(types); TableColumn mashColumn = tblMash.getColumnModel().getColumn(0); mashColumn.setCellEditor(new DefaultCellEditor(typesComboBox)); // set up method combo String [] methods = {"infusion","decoction","direct"}; JComboBox methodComboBox = new JComboBox(methods); mashColumn = tblMash.getColumnModel().getColumn(1); mashColumn.setCellEditor(new DefaultCellEditor(methodComboBox)); } } { buttonsPanel = new JPanel(); FlowLayout buttonsPanelLayout = new FlowLayout(); buttonsPanelLayout.setAlignment(FlowLayout.LEFT); buttonsPanel.setLayout(buttonsPanelLayout); tablePanel.add(buttonsPanel, BorderLayout.SOUTH); { addStepButton = new JButton(); buttonsPanel.add(addStepButton); addStepButton.setText("+"); addStepButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { addStepButtonActionPerformed(evt); } }); } { delStepButton = new JButton(); buttonsPanel.add(delStepButton); delStepButton.setText("-"); delStepButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { delStepButtonActionPerformed(evt); } }); } { weightPanel = new JPanel(); BoxLayout statsPanelLayout = new BoxLayout(weightPanel, javax.swing.BoxLayout.X_AXIS); weightPanel.setLayout(statsPanelLayout); buttonsPanel.add(weightPanel); weightPanel.setBorder(BorderFactory.createTitledBorder("Total Weight")); weightPanel.setPreferredSize(new java.awt.Dimension(98, 39)); { totalMashLabel = new JLabel(); weightPanel.add(totalMashLabel); totalMashLabel.setPreferredSize(new java.awt.Dimension(118, 13)); totalMashLabel.setText("total"); } } { timePanel = new JPanel(); BoxLayout timePanelLayout = new BoxLayout(timePanel, javax.swing.BoxLayout.X_AXIS); timePanel.setLayout(timePanelLayout); buttonsPanel.add(timePanel); timePanel.setBorder(BorderFactory.createTitledBorder("Total Min")); timePanel.setPreferredSize(new java.awt.Dimension(79, 43)); { totalTimeLabel = new JLabel(); timePanel.add(totalTimeLabel); totalTimeLabel.setText("Time"); totalTimeLabel.setPreferredSize(new java.awt.Dimension(111, 17)); } } { volPanel = new JPanel(); BoxLayout volPanelLayout = new BoxLayout(volPanel, javax.swing.BoxLayout.X_AXIS); volPanel.setLayout(volPanelLayout); buttonsPanel.add(volPanel); volPanel.setBorder(BorderFactory.createTitledBorder("Total Vol")); volPanel.setPreferredSize(new java.awt.Dimension(117, 42)); { volLabel = new JLabel(); volPanel.add(volLabel); volLabel.setText("10"); } } } } { settingsPanel = new JPanel(); FlowLayout settingsPanelLayout = new FlowLayout(); settingsPanelLayout.setAlignment(FlowLayout.LEFT); settingsPanel.setLayout(settingsPanelLayout); this.getContentPane().add( settingsPanel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { tempPanel = new JPanel(); settingsPanel.add(tempPanel); tempPanel.setBorder(BorderFactory.createTitledBorder("Temp Units")); { tempFrb = new JRadioButton(); tempPanel.add(tempFrb); tempFrb.setText("F"); tempFrb.addActionListener(this); } { tempCrb = new JRadioButton(); tempPanel.add(tempCrb); tempCrb.setText("C"); tempCrb.addActionListener(this); } tempUnitsButtonGroup = new ButtonGroup(); tempUnitsButtonGroup.add(tempFrb); tempUnitsButtonGroup.add(tempCrb); } { volUnitsPanel = new JPanel(); settingsPanel.add(volUnitsPanel); volUnitsPanel.setBorder(BorderFactory.createTitledBorder("Vol Units")); { // volList = new ArrayList(q.getListofUnits("vol")); volUnitsComboModel = new ComboModel(); volUnitsComboModel.setList(new Quantity().getListofUnits("vol")); volUnitsCombo = new JComboBox(); volUnitsPanel.add(volUnitsCombo); volUnitsCombo.setModel(volUnitsComboModel); volUnitsCombo.addActionListener(this); } } { ratioPanel = new JPanel(); settingsPanel.add(ratioPanel); ratioPanel.setBorder(BorderFactory.createTitledBorder("Mash Ratio")); { ratioLabel = new JLabel(); ratioPanel.add(ratioLabel); ratioLabel.setText("1:"); } { ratioText = new JTextField(); ratioPanel.add(ratioText); ratioText.setText("1.25"); ratioText.addFocusListener(this); ratioText.addActionListener(this); } { ComboBoxModel ratioUnitsComboModel = new DefaultComboBoxModel(new String[] { "qt/lb", "l/kg" }); ratioUnitsCombo = new JComboBox(); ratioPanel.add(ratioUnitsCombo); ratioUnitsCombo.setModel(ratioUnitsComboModel); ratioUnitsCombo.addActionListener(this); } } } { directionsPanel = new JPanel(); getContentPane().add(directionsPanel, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); BorderLayout directionsPanelLayout = new BorderLayout(); directionsPanel.setLayout(directionsPanelLayout); directionsPanel.setBorder(BorderFactory.createTitledBorder("Directions")); directionsPanel.setPreferredSize(new java.awt.Dimension(181, 75)); { directionsTextArea = new JTextArea(); directionsPanel.add(directionsTextArea, BorderLayout.CENTER); directionsTextArea.setText("Directions"); directionsTextArea.setPreferredSize(new java.awt.Dimension(171, 38)); directionsTextArea.setEditable(false); directionsTextArea.setLineWrap(true); } } { pnlButtons = new JPanel(); FlowLayout pnlButtonsLayout = new FlowLayout(); pnlButtonsLayout.setAlignment(FlowLayout.RIGHT); pnlButtons.setLayout(pnlButtonsLayout); getContentPane().add(pnlButtons, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); { btnOk = new JButton(); pnlButtons.add(btnOk); btnOk.setText("OK"); btnOk.addActionListener(this); } } { moreSettingsPanel = new JPanel(); FlowLayout moreSettingsPanelLayout = new FlowLayout(); moreSettingsPanelLayout.setAlignment(FlowLayout.LEFT); moreSettingsPanel.setLayout(moreSettingsPanelLayout); this.getContentPane().add( moreSettingsPanel, new GridBagConstraints( 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); } { waterUsePanel = new JPanel(); GridBagLayout waterUsePanelLayout = new GridBagLayout(); waterUsePanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; waterUsePanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; waterUsePanelLayout.columnWeights = new double[] {0.1, 0.1}; waterUsePanelLayout.columnWidths = new int[] {7, 7}; waterUsePanel.setLayout(waterUsePanelLayout); getContentPane().add(waterUsePanel, new GridBagConstraints(2, 1, 1, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); waterUsePanel.setBorder(BorderFactory.createTitledBorder(null, "Water Use:", TitledBorder.LEADING, TitledBorder.TOP)); { jLabel1 = new JLabel(); waterUsePanel.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel1.setText("Total Water Used:"); } { jLabel2 = new JLabel(); waterUsePanel.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel2.setText("Used in Mash:"); } { jLabel3 = new JLabel(); waterUsePanel.add(jLabel3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel3.setText("Absorbed in Mash"); } { jLabel4 = new JLabel(); waterUsePanel.add(jLabel4, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel4.setText("Sparge With:"); } { jLabel5 = new JLabel(); waterUsePanel.add(jLabel5, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel5.setText("To Collect:"); } { jLabel6 = new JLabel(); waterUsePanel.add(jLabel6, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel6.setText("Post Boil:"); } { jLabel7 = new JLabel(); waterUsePanel.add(jLabel7, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel7.setText("Left in Kettle:"); } { jLabel8 = new JLabel(); waterUsePanel.add(jLabel8, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel8.setText("Chill Shrinkage:"); } { jLabel9 = new JLabel(); waterUsePanel.add(jLabel9, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel9.setText("Lost in Trub:"); } { jLabel10 = new JLabel(); waterUsePanel.add(jLabel10, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel10.setText("Misc. Losses:"); } { jLabel11 = new JLabel(); waterUsePanel.add(jLabel11, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jLabel11.setText("Final Beer Volume:"); } { totalWaterLbl = new JLabel(); waterUsePanel.add(totalWaterLbl, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); totalWaterLbl.setText("0"); } { absorbedLbl = new JLabel(); waterUsePanel.add(absorbedLbl, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); absorbedLbl.setText("jLabel13"); } { usedMashLbl = new JLabel(); waterUsePanel.add(usedMashLbl, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); usedMashLbl.setText("absorbedUnitsLbl"); } { spargeWithLbl = new JLabel(); waterUsePanel.add(spargeWithLbl, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); spargeWithLbl.setText("l"); } { collectUnitsLbl = new JLabel(); waterUsePanel.add(collectUnitsLbl, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); collectUnitsLbl.setText("l"); } { spargeUnitsLbl = new JLabel(); waterUsePanel.add(spargeUnitsLbl, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); spargeUnitsLbl.setText("l"); } { absorbedUnitsLbl = new JLabel(); waterUsePanel.add(absorbedUnitsLbl, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); absorbedUnitsLbl.setText("l"); } { usedInMashUnitsLbl = new JLabel(); waterUsePanel.add(usedInMashUnitsLbl, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); usedInMashUnitsLbl.setText("l"); } { totalUnitsLbl = new JLabel(); waterUsePanel.add(totalUnitsLbl, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); totalUnitsLbl.setText("l"); } { postBoilUnitsLbl = new JLabel(); waterUsePanel.add(postBoilUnitsLbl, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); postBoilUnitsLbl.setText("l"); } { collectTxt = new JFormattedTextField(); collectTxt.addFocusListener(this); collectTxt.addActionListener(this); waterUsePanel.add(collectTxt, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); collectTxt.setText("l"); } { postBoilTxt = new JFormattedTextField(); postBoilTxt.addFocusListener(this); postBoilTxt.addActionListener(this); waterUsePanel.add(postBoilTxt, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); postBoilTxt.setText("l"); } { chillShrinkLbl = new JLabel(); waterUsePanel.add(chillShrinkLbl, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); chillShrinkLbl.setText("l"); } { kettleTxt = new JFormattedTextField(); kettleTxt.addFocusListener(this); kettleTxt.addActionListener(this); waterUsePanel.add(kettleTxt, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); kettleTxt.setText("1"); } { kettleUnitsLbl = new JLabel(); waterUsePanel.add(kettleUnitsLbl, new GridBagConstraints(2, 7, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); kettleUnitsLbl.setText("l"); } { trubLossTxt = new JFormattedTextField(); trubLossTxt.addFocusListener(this); trubLossTxt.addActionListener(this); waterUsePanel.add(trubLossTxt, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); trubLossTxt.setText("jTextField1"); } { miscLossTxt = new JFormattedTextField(); miscLossTxt.addFocusListener(this); miscLossTxt.addActionListener(this); waterUsePanel.add(miscLossTxt, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); miscLossTxt.setText("jTextField1"); } { finalVolTxt = new JFormattedTextField(); finalVolTxt.addFocusListener(this); finalVolTxt.addActionListener(this); waterUsePanel.add(finalVolTxt, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); finalVolTxt.setText("jTextField1"); } { trubLossUnitsLbl = new JLabel(); waterUsePanel.add(trubLossUnitsLbl, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); trubLossUnitsLbl.setText("l"); } { miscLosUnitsLbl = new JLabel(); waterUsePanel.add(miscLosUnitsLbl, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); miscLosUnitsLbl.setText("l"); } { finalUnitsLbl = new JLabel(); waterUsePanel.add(finalUnitsLbl, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); finalUnitsLbl.setText("l"); } } { grainTempPanel = new JPanel(); getContentPane().add(grainTempPanel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); BoxLayout grainTempPanelLayout = new BoxLayout( grainTempPanel, javax.swing.BoxLayout.X_AXIS); grainTempPanel.setLayout(grainTempPanelLayout); grainTempPanel.setBorder(BorderFactory.createTitledBorder("Grain Temp")); grainTempPanel.setPreferredSize(new java.awt.Dimension(94, 45)); { grainTempText = new JTextField(); grainTempPanel.add(grainTempText); grainTempText.setText("10"); grainTempText.setPreferredSize(new java.awt.Dimension(67, 15)); grainTempText.addFocusListener(this); grainTempText.addActionListener(this); } { grainTempULabel = new JLabel(); grainTempPanel.add(grainTempULabel); grainTempULabel.setText("F"); } } { tempLostPanel = new JPanel(); getContentPane().add(tempLostPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); BoxLayout tempLostPanelLayout = new BoxLayout( tempLostPanel, javax.swing.BoxLayout.X_AXIS); tempLostPanel.setLayout(tempLostPanelLayout); tempLostPanel.setPreferredSize(new java.awt.Dimension(104, 45)); tempLostPanel.setBorder(BorderFactory.createTitledBorder("Tun Temp Lost")); { tempLostText = new JTextField(); tempLostPanel.add(tempLostText); tempLostText.setText("3"); tempLostText.setEditable(false); tempLostText.addFocusListener(this); tempLostText.addActionListener(this); } { tempLostULabel = new JLabel(); tempLostPanel.add(tempLostULabel); tempLostULabel.setText("F"); } } pack(); this.setSize(468, 400); } catch (Exception e) { e.printStackTrace(); } } |
|
grainTempF = cToF(t); | grainTempF = BrewCalcs.cToF(t); | public void setGrainTemp(double t){ if (tempUnits.equals("F")) grainTempF = t; else grainTempF = cToF(t); calcMashSchedule(); } |
return fToC(grainTempF); | return BrewCalcs.fToC(grainTempF); | public double getGrainTemp() { if (tempUnits.equals("F")) return grainTempF; else return fToC(grainTempF); } |
public String getVolAbrv(String unit) { return getAbrvFromUnit(getTypeFromUnit(unit), unit); | public static String getVolAbrv(String unit) { Quantity q = new Quantity(); q.setUnits(unit); return q.abrv; | public String getVolAbrv(String unit) { return getAbrvFromUnit(getTypeFromUnit(unit), unit); } |
public Dimensions calcDim(Dimensions l,Dimensions r) { if(l.equals(Dimensions.ONE) && r.equals(Dimensions.ONE)) return Dimensions.ONE; if(l.is0D() ) return r; if(r.is0D() ) return l; if(l.is1D() && r.is1D() ) return null; if(l.is2D() && r.is1D() ) | public Dimensions calcDim(Dimensions l,Dimensions r) { int lrank = l.rank(); int rrank = r.rank(); switch(lrank) | public Dimensions calcDim(Dimensions l,Dimensions r) { if(l.equals(Dimensions.ONE) && r.equals(Dimensions.ONE)) return Dimensions.ONE; if(l.is0D() ) return r; // scalar mult on left if(r.is0D() ) return l; // scalar mult on right if(l.is1D() && r.is1D() ) return null; // error for vector * vector if(l.is2D() && r.is1D() ) // matrix times vector { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim()); else return null; } if(l.is1D() && r.is2D() ) // vector times matrix { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(r.getLastDim()); else return null; } if(l.is2D() && r.is2D() ) // matrix times matrix { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim(),r.getLastDim()); else return null; } if(l.getLastDim() == r.getFirstDim()) // Something else { int dims[] = new int[l.rank()+r.rank()-2]; int j = 0; for(int i=0;i<l.rank()-1;++i) dims[j++]=l.getIthDim(i); for(int i=1;i<r.rank();++i) dims[j++]=r.getIthDim(i); return Dimensions.valueOf(dims); } else return null; } |
if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim()); else return null; | case 0: return r; case 1: switch(rrank) { case 0: return l; case 1: return Dimensions.valueOf(l.getFirstDim(),r.getFirstDim()); case 2: if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(r.getLastDim()); else return null; default: } break; case 2: switch(rrank) { case 0: return l; case 1: if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim()); else return null; case 2: if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim(),r.getLastDim()); else return null; default: } break; default: switch(rrank) { case 0: return l; } | public Dimensions calcDim(Dimensions l,Dimensions r) { if(l.equals(Dimensions.ONE) && r.equals(Dimensions.ONE)) return Dimensions.ONE; if(l.is0D() ) return r; // scalar mult on left if(r.is0D() ) return l; // scalar mult on right if(l.is1D() && r.is1D() ) return null; // error for vector * vector if(l.is2D() && r.is1D() ) // matrix times vector { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim()); else return null; } if(l.is1D() && r.is2D() ) // vector times matrix { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(r.getLastDim()); else return null; } if(l.is2D() && r.is2D() ) // matrix times matrix { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim(),r.getLastDim()); else return null; } if(l.getLastDim() == r.getFirstDim()) // Something else { int dims[] = new int[l.rank()+r.rank()-2]; int j = 0; for(int i=0;i<l.rank()-1;++i) dims[j++]=l.getIthDim(i); for(int i=1;i<r.rank();++i) dims[j++]=r.getIthDim(i); return Dimensions.valueOf(dims); } else return null; } |
if(l.is1D() && r.is2D() ) { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(r.getLastDim()); else return null; } if(l.is2D() && r.is2D() ) { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim(),r.getLastDim()); else return null; } if(l.getLastDim() == r.getFirstDim()) { int dims[] = new int[l.rank()+r.rank()-2]; int j = 0; for(int i=0;i<l.rank()-1;++i) dims[j++]=l.getIthDim(i); for(int i=1;i<r.rank();++i) dims[j++]=r.getIthDim(i); return Dimensions.valueOf(dims); } else return null; | return null; | public Dimensions calcDim(Dimensions l,Dimensions r) { if(l.equals(Dimensions.ONE) && r.equals(Dimensions.ONE)) return Dimensions.ONE; if(l.is0D() ) return r; // scalar mult on left if(r.is0D() ) return l; // scalar mult on right if(l.is1D() && r.is1D() ) return null; // error for vector * vector if(l.is2D() && r.is1D() ) // matrix times vector { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim()); else return null; } if(l.is1D() && r.is2D() ) // vector times matrix { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(r.getLastDim()); else return null; } if(l.is2D() && r.is2D() ) // matrix times matrix { if(l.getLastDim() == r.getFirstDim()) return Dimensions.valueOf(l.getFirstDim(),r.getLastDim()); else return null; } if(l.getLastDim() == r.getFirstDim()) // Something else { int dims[] = new int[l.rank()+r.rank()-2]; int j = 0; for(int i=0;i<l.rank()-1;++i) dims[j++]=l.getIthDim(i); for(int i=1;i<r.rank();++i) dims[j++]=r.getIthDim(i); return Dimensions.valueOf(dims); } else return null; } |
if(res instanceof MVector && param1 instanceof Matrix && param2 instanceof MVector) return calcValue((MVector) res,(Matrix) param1,(MVector) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Matrix) return calcValue((MVector) res,(MVector) param1,(Matrix) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof MVector) return calcValue((MVector) res,(MVector) param1,(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Matrix) return calcValue((Matrix) res,(Matrix) param1,(Matrix) param2); else if(res instanceof Scaler && param1 instanceof Scaler && param2 instanceof Scaler) return calcValue((Scaler) res,(Scaler) param1,(Scaler) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Scaler) return calcValue((MVector) res,(MVector) param1,((Scaler) param2).getEle(0)); else if(res instanceof MVector && param1 instanceof Scaler && param2 instanceof MVector) return calcValue((MVector) res,((Scaler) param1).getEle(0),(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Scaler) return calcValue((Matrix) res,(Matrix) param1,((Scaler) param2).getEle(0)); else if(res instanceof Matrix && param1 instanceof Scaler && param2 instanceof Matrix) return calcValue((Matrix) res,((Scaler) param1).getEle(0),(Matrix) param2); | if(param1 instanceof Scaler) { if(param2 instanceof Scaler) { res.setEle(0,super.mul(param1.getEle(0),param2.getEle(0))); } else if(param2 instanceof MVector) { for(int i=0;i<param2.getDim().getFirstDim();++i) res.setEle(i,super.mul(param1.getEle(0),param2.getEle(i))); } else if(param2 instanceof Matrix) { Matrix r = (Matrix) param2; Matrix mres = (Matrix) res; for(int i=0;i<r.getNumRows();++i) for(int j=0;j<r.getNumCols();++j) mres.setEle(i,j,super.mul(param1.getEle(0),r.getEle(i,j))); } else { for(int i=0;i<param2.getDim().numEles();++i) res.setEle(i,super.mul(param1.getEle(0),param2.getEle(i))); } } else if(param1 instanceof MVector) { if(param2 instanceof Scaler) { for(int i=0;i<param1.getDim().getFirstDim();++i) res.setEle(i,super.mul(param1.getEle(i),param2.getEle(0))); } else if(param2 instanceof MVector) { Matrix mat = (Matrix) res; for(int i=0;i<param1.getDim().getFirstDim();++i) for(int j=0;j<param2.getDim().getFirstDim();++j) mat.setEle(i,j,super.mul(param1.getEle(i),param2.getEle(j))); } else if(param2 instanceof Matrix) { MVector lhs = (MVector) param1; Matrix rhs = (Matrix) param2; if(lhs.getNumEles() != rhs.getNumRows()) throw new ParseException("Multiply Matrix , Vector: Miss match in sizes ("+lhs.getNumEles()+","+rhs.getNumRows()+")!"); for(int i=0;i<rhs.getNumCols();++i) { Object val = super.mul(lhs.getEle(0),rhs.getEle(0,i)); for(int j=1;j<rhs.getNumRows();++j) val = add.add(val, super.mul(lhs.getEle(j),rhs.getEle(j,i))); res.setEle(i,val); } } else { throw new ParseException("Sorry I don't know how to multiply a vector by a tensor"); } } else if(param1 instanceof Matrix) { if(param2 instanceof Scaler) { Matrix l = (Matrix) param1; Matrix mres = (Matrix) res; for(int i=0;i<l.getNumRows();++i) for(int j=0;j<l.getNumCols();++j) mres.setEle(i,j,super.mul(l.getEle(i,j),param2.getEle(0))); } else if(param2 instanceof MVector) { Matrix lhs = (Matrix) param1; MVector rhs = (MVector) param2; if(lhs.getNumCols() != rhs.getNumEles()) throw new ParseException("Mat * Vec: Miss match in sizes ("+lhs.getNumCols()+","+rhs.getNumEles()+") when trying to add vectors!"); for(int i=0;i<lhs.getNumRows();++i) { Object val = super.mul(lhs.getEle(i,0),rhs.getEle(0)); for(int j=1;j<lhs.getNumCols();++j) val = add.add(val,super.mul(lhs.getEle(i,j),rhs.getEle(j))); res.setEle(i,val); } } else if(param2 instanceof Matrix) { Matrix lhs = (Matrix) param1; Matrix rhs = (Matrix) param2; Matrix mres = (Matrix) res; if(lhs.getNumCols() != rhs.getNumRows()) throw new ParseException("Multiply matrix,matrix: Miss match in number of dims ("+lhs.getNumCols()+","+rhs.getNumRows()+")!"); int lnr = lhs.getNumRows(); int lnc = lhs.getNumCols(); int rnc = rhs.getNumCols(); Object ldata[][] = lhs.getEles(); Object rdata[][] = rhs.getEles(); Object resdata[][] = mres.getEles(); for(int i=0;i<lnr;++i) for(int j=0;j<rnc;++j) { Object val = mul(ldata[i][0],rdata[0][j]); for(int k=1;k<lnc;++k) val = add.add(val, mul(ldata[i][k],rdata[k][j])); resdata[i][j] = val; } } else throw new ParseException("Sorry I don't know how to multiply a matrix by a tensor"); } | public MatrixValueI calcValue(MatrixValueI res,MatrixValueI param1,MatrixValueI param2) throws ParseException { if(res instanceof MVector && param1 instanceof Matrix && param2 instanceof MVector) return calcValue((MVector) res,(Matrix) param1,(MVector) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Matrix) return calcValue((MVector) res,(MVector) param1,(Matrix) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof MVector) return calcValue((MVector) res,(MVector) param1,(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Matrix) return calcValue((Matrix) res,(Matrix) param1,(Matrix) param2); else if(res instanceof Scaler && param1 instanceof Scaler && param2 instanceof Scaler) return calcValue((Scaler) res,(Scaler) param1,(Scaler) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Scaler) return calcValue((MVector) res,(MVector) param1,((Scaler) param2).getEle(0)); else if(res instanceof MVector && param1 instanceof Scaler && param2 instanceof MVector) return calcValue((MVector) res,((Scaler) param1).getEle(0),(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Scaler) return calcValue((Matrix) res,(Matrix) param1,((Scaler) param2).getEle(0)); else if(res instanceof Matrix && param1 instanceof Scaler && param2 instanceof Matrix) return calcValue((Matrix) res,((Scaler) param1).getEle(0),(Matrix) param2); else { Object val = super.mul(param1,param2); res.setEle(0,val); return res; } } |
Object val = super.mul(param1,param2); res.setEle(0,val); return res; | if(param2 instanceof Scaler) { for(int i=0;i<param2.getDim().numEles();++i) res.setEle(i,super.mul(param1.getEle(i),param2.getEle(0))); } else throw new ParseException("Sorry I don't know how to multiply a tensor by a vector"); | public MatrixValueI calcValue(MatrixValueI res,MatrixValueI param1,MatrixValueI param2) throws ParseException { if(res instanceof MVector && param1 instanceof Matrix && param2 instanceof MVector) return calcValue((MVector) res,(Matrix) param1,(MVector) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Matrix) return calcValue((MVector) res,(MVector) param1,(Matrix) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof MVector) return calcValue((MVector) res,(MVector) param1,(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Matrix) return calcValue((Matrix) res,(Matrix) param1,(Matrix) param2); else if(res instanceof Scaler && param1 instanceof Scaler && param2 instanceof Scaler) return calcValue((Scaler) res,(Scaler) param1,(Scaler) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Scaler) return calcValue((MVector) res,(MVector) param1,((Scaler) param2).getEle(0)); else if(res instanceof MVector && param1 instanceof Scaler && param2 instanceof MVector) return calcValue((MVector) res,((Scaler) param1).getEle(0),(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Scaler) return calcValue((Matrix) res,(Matrix) param1,((Scaler) param2).getEle(0)); else if(res instanceof Matrix && param1 instanceof Scaler && param2 instanceof Matrix) return calcValue((Matrix) res,((Scaler) param1).getEle(0),(Matrix) param2); else { Object val = super.mul(param1,param2); res.setEle(0,val); return res; } } |
return res; | public MatrixValueI calcValue(MatrixValueI res,MatrixValueI param1,MatrixValueI param2) throws ParseException { if(res instanceof MVector && param1 instanceof Matrix && param2 instanceof MVector) return calcValue((MVector) res,(Matrix) param1,(MVector) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Matrix) return calcValue((MVector) res,(MVector) param1,(Matrix) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof MVector) return calcValue((MVector) res,(MVector) param1,(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Matrix) return calcValue((Matrix) res,(Matrix) param1,(Matrix) param2); else if(res instanceof Scaler && param1 instanceof Scaler && param2 instanceof Scaler) return calcValue((Scaler) res,(Scaler) param1,(Scaler) param2); else if(res instanceof MVector && param1 instanceof MVector && param2 instanceof Scaler) return calcValue((MVector) res,(MVector) param1,((Scaler) param2).getEle(0)); else if(res instanceof MVector && param1 instanceof Scaler && param2 instanceof MVector) return calcValue((MVector) res,((Scaler) param1).getEle(0),(MVector) param2); else if(res instanceof Matrix && param1 instanceof Matrix && param2 instanceof Scaler) return calcValue((Matrix) res,(Matrix) param1,((Scaler) param2).getEle(0)); else if(res instanceof Matrix && param1 instanceof Scaler && param2 instanceof Matrix) return calcValue((Matrix) res,((Scaler) param1).getEle(0),(Matrix) param2); else { Object val = super.mul(param1,param2); res.setEle(0,val); return res; } } |
|
if(param1 instanceof Matrix && param2 instanceof MVector) return mul((Matrix) param1,(MVector) param2); else if(param1 instanceof MVector && param2 instanceof Matrix) return mul((MVector) param1,(Matrix) param2); else if(param1 instanceof Matrix && param2 instanceof Matrix) return mul((Matrix) param1,(Matrix) param2); else if(param1 instanceof MVector && param2 instanceof MVector) return mul((MVector) param1,(MVector) param2); else if(param1 instanceof MVector) return mul((MVector) param1,param2); else if(param2 instanceof MVector) return mul(param1,(MVector) param2); else if(param1 instanceof Matrix) return mul((Matrix) param1,param2); else if(param2 instanceof Matrix) return mul(param1,(Matrix) param2); else return super.mul(param1,param2); | if(param1 instanceof MatrixValueI && param2 instanceof MatrixValueI) { return mul((MatrixValueI) param1,(MatrixValueI) param2); } else if(param1 instanceof MatrixValueI) { MatrixValueI l = (MatrixValueI) param1; MatrixValueI res = Tensor.getInstance(l.getDim()); for(int i=0;i<res.getNumEles();++i) res.setEle(i,super.mul(l.getEle(i),param2)); return res; } else if(param2 instanceof MatrixValueI) { MatrixValueI r = (MatrixValueI) param2; MatrixValueI res = Tensor.getInstance(r.getDim()); for(int i=0;i<res.getNumEles();++i) res.setEle(i,super.mul(param1,r.getEle(i))); return res; } return super.mul(param1,param2); | public Object mul(Object param1, Object param2) throws ParseException { // TODO tensor mult? if(param1 instanceof Matrix && param2 instanceof MVector) return mul((Matrix) param1,(MVector) param2); else if(param1 instanceof MVector && param2 instanceof Matrix) return mul((MVector) param1,(Matrix) param2); else if(param1 instanceof Matrix && param2 instanceof Matrix) return mul((Matrix) param1,(Matrix) param2); else if(param1 instanceof MVector && param2 instanceof MVector) return mul((MVector) param1,(MVector) param2); else if(param1 instanceof MVector) return mul((MVector) param1,param2); else if(param2 instanceof MVector) return mul(param1,(MVector) param2); else if(param1 instanceof Matrix) return mul((Matrix) param1,param2); else if(param2 instanceof Matrix) return mul(param1,(Matrix) param2); else return super.mul(param1,param2); } |
public void setEle(int i,int j,Object value) | public void setEle(int n,Object value) | public void setEle(int i,int j,Object value) { data[i][j] = value; } |
int i = n / cols; int j = n % cols; | public void setEle(int i,int j,Object value) { data[i][j] = value; } |
|
public Matrix(int rows,int cols) { this.rows = rows; this.cols = cols; data = new Object[rows][cols]; dims = Dimensions.valueOf(rows,cols); } | private Matrix() {} | public Matrix(int rows,int cols) { this.rows = rows; this.cols = cols; data = new Object[rows][cols]; dims = Dimensions.valueOf(rows,cols); } |
if (param instanceof Number) | if (param instanceof Complex) { return ((Complex)param).asinh(); } else if (param instanceof Number) | public Object asinh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.asinh(); } else if (param instanceof Complex) { return ((Complex)param).asinh(); } throw new ParseException("Invalid parameter type"); } |
else if (param instanceof Complex) { return ((Complex)param).asinh(); } | public Object asinh(Object param) throws ParseException { if (param instanceof Number) { Complex temp = new Complex(((Number)param).doubleValue(),0.0); return temp.asinh(); } else if (param instanceof Complex) { return ((Complex)param).asinh(); } throw new ParseException("Invalid parameter type"); } |
|
if (!child.delete()) throw new IOException("Unable to delete " + child.getPath()); | deleteFile(child); | public static void deleteContentsRecursive(File file) throws IOException { File[] files = file.listFiles(); if(files==null) return; // the directory didn't exist in the first place for (File child : files) { if (child.isDirectory()) deleteContentsRecursive(child); if (!child.delete()) throw new IOException("Unable to delete " + child.getPath()); } } |
if(!dir.delete()) throw new IOException("Unable to delete "+dir); | deleteFile(dir); | public static void deleteRecursive(File dir) throws IOException { deleteContentsRecursive(dir); if(!dir.delete()) throw new IOException("Unable to delete "+dir); } |
while(r!=null && r.getResult()!=Result.FAILURE) | while(r!=null && (r.isBuilding() || r.getResult()!=Result.FAILURE)) | public synchronized RunT getLastFailedBuild() { RunT r = getLastBuild(); while(r!=null && r.getResult()!=Result.FAILURE) r=r.getPreviousBuild(); return r; } |
while(r!=null && (r.getResult()==null || r.getResult().isWorseThan(Result.SUCCESS))) | while(r!=null && (r.isBuilding() || r.getResult().isWorseThan(Result.SUCCESS))) | public synchronized RunT getLastStableBuild() { RunT r = getLastBuild(); while(r!=null && (r.getResult()==null || r.getResult().isWorseThan(Result.SUCCESS))) r=r.getPreviousBuild(); return r; } |
while(r!=null && (r.getResult()==null || r.getResult().isWorseThan(Result.UNSTABLE))) | while(r!=null && (r.isBuilding() || r.getResult().isWorseThan(Result.UNSTABLE))) | public synchronized RunT getLastSuccessfulBuild() { RunT r = getLastBuild(); while(r!=null && (r.getResult()==null || r.getResult().isWorseThan(Result.UNSTABLE))) r=r.getPreviousBuild(); return r; } |
req.setAttribute("it",it); | static void forwardToRss( Object it, String title, StaplerRequest req, HttpServletResponse rsp, Collection<? extends Run> runs) throws IOException, ServletException { GregorianCalendar threshold = new GregorianCalendar(); threshold.add(Calendar.DAY_OF_YEAR,-7); int count=0; for (Iterator<? extends Run> i = runs.iterator(); i.hasNext();) { // at least put 10 items if(count<10) { i.next(); count++; continue; } // anything older than 7 days will be ignored if(i.next().getTimestamp().before(threshold)) i.remove(); } req.setAttribute("it",it); req.setAttribute("title",title); req.setAttribute("runs",runs); req.getServletContext().getRequestDispatcher("/WEB-INF/rss.jsp").forward(req,rsp); } |
|
req.getServletContext().getRequestDispatcher("/WEB-INF/rss.jsp").forward(req,rsp); | req.getView(it,"/hudson/rss.jelly").forward(req,rsp); | static void forwardToRss( Object it, String title, StaplerRequest req, HttpServletResponse rsp, Collection<? extends Run> runs) throws IOException, ServletException { GregorianCalendar threshold = new GregorianCalendar(); threshold.add(Calendar.DAY_OF_YEAR,-7); int count=0; for (Iterator<? extends Run> i = runs.iterator(); i.hasNext();) { // at least put 10 items if(count<10) { i.next(); count++; continue; } // anything older than 7 days will be ignored if(i.next().getTimestamp().before(threshold)) i.remove(); } req.setAttribute("it",it); req.setAttribute("title",title); req.setAttribute("runs",runs); req.getServletContext().getRequestDispatcher("/WEB-INF/rss.jsp").forward(req,rsp); } |
throw new NotFound("No sites in the database of code " + site_code + " for given station ids"); | throw new NotFound("No sites in the database of code '" + site_code + "' for given station ids"); | public int[] getDBIds(int[] possibleStaDbIds, String site_code) throws SQLException, NotFound { List ids = new ArrayList(); for(int i = 0; i < possibleStaDbIds.length; i++) { getDBIdsForStaAndCode.setInt(1, possibleStaDbIds[i]); getDBIdsForStaAndCode.setString(2, site_code); ResultSet rs = getDBIdsForStaAndCode.executeQuery(); while(rs.next()) { ids.add(new Integer(rs.getInt("site_id"))); } } if(ids.size() > 0) { int[] intIds = new int[ids.size()]; for(int i = 0; i < ids.size(); i++) { intIds[i] = ((Integer)ids.get(i)).intValue(); } return intIds; } throw new NotFound("No sites in the database of code " + site_code + " for given station ids"); } |
public JDBCStation(Connection conn) throws SQLException { this(conn, new JDBCLocation(conn), new JDBCNetwork(conn), new JDBCTime(conn)); | public JDBCStation() throws SQLException { this(ConnMgr.createConnection()); | public JDBCStation(Connection conn) throws SQLException { this(conn, new JDBCLocation(conn), new JDBCNetwork(conn), new JDBCTime(conn)); } |
public int put(Station sta) throws SQLException { int dbid; try { dbid = getDBId(sta.get_id()); getIfNameExists.setInt(1, dbid); ResultSet rs = getIfNameExists.executeQuery(); if(!rs.next()) { int index = insertOnlyStation(sta, updateSta, 1, netTable, locTable, time); updateSta.setInt(index, dbid); updateSta.executeUpdate(); } } catch(NotFound notFound) { dbid = seq.next(); putAll.setInt(1, dbid); insertAll(sta, putAll, 2, netTable, locTable, time); dbIdsToStations.put(new Integer(dbid), sta); putAll.executeUpdate(); } return dbid; | public int put(ChannelId id) throws SQLException { int netDbId = netTable.put(id.network_id); int dbId = seq.next(); putChanIdBits.setInt(1, dbId); putChanIdBits.setInt(2, netDbId); putChanIdBits.setString(3, id.station_code); putChanIdBits.executeUpdate(); return dbId; | public int put(Station sta) throws SQLException { int dbid; try { dbid = getDBId(sta.get_id()); // No NotFound exception, so already added the id // now check if the attrs are added getIfNameExists.setInt(1, dbid); ResultSet rs = getIfNameExists.executeQuery(); if(!rs.next()) {//No name, so we need to add the attr part int index = insertOnlyStation(sta, updateSta, 1, netTable, locTable, time); updateSta.setInt(index, dbid); updateSta.executeUpdate(); } } catch(NotFound notFound) { // no id found so ok to add the whole thing dbid = seq.next(); putAll.setInt(1, dbid); insertAll(sta, putAll, 2, netTable, locTable, time); dbIdsToStations.put(new Integer(dbid), sta); putAll.executeUpdate(); } return dbid; } |
rules[0] = localJep.differentiate((Node) fun.getTopNode(),"x"); | rules[0] = localJep.differentiate(fun.getTopNode(),"x"); | public MacroFunctionDiffRules(DJep djep,MacroFunction fun) throws ParseException { //super(dv); name = fun.getName(); pfmc = fun; XSymbolTable localSymTab = (XSymbolTable) ((XSymbolTable) djep.getSymbolTable()).newInstance(); //new SymbolTable(); localSymTab.copyConstants(djep.getSymbolTable()); DJep localJep = (DJep) djep.newInstance(localSymTab); int nargs = fun.getNumberOfParameters(); rules = new Node[nargs]; if(nargs == 1) rules[0] = localJep.differentiate((Node) fun.getTopNode(),"x"); else if(nargs == 2) { rules[0] = localJep.differentiate(fun.getTopNode(),"x"); rules[1] = localJep.differentiate(fun.getTopNode(),"y"); } else { for(int i=0;i<nargs;++i) rules[i] = localJep.differentiate(fun.getTopNode(),"x"+ String.valueOf(i)); } for(int i=0;i<nargs;++i) rules[i] = localJep.simplify(rules[i]); //fixVarNames(); } |
public XJep newInstance(SymbolTable st) | public XJep newInstance() | public XJep newInstance(SymbolTable st) { DJep newJep = new DJep(this); newJep.symTab = st; return newJep; } |
newJep.symTab = st; | public XJep newInstance(SymbolTable st) { DJep newJep = new DJep(this); newJep.symTab = st; return newJep; } |
|
try { SwarmingManager.getInstance().addMagmaToDownload( file ); } catch (IOException exp) { NLogger.error(NLoggerNames.MAGMA, exp.getMessage(), exp); GUIUtils.showErrorMessage( Localizer.getString( "NewDownload_FailedToParseMagmaMessage" ), Localizer.getString( "NewDownload_FailedToParseMagmaTitle" ) ); } | InternalFileHandler.magmaReadout( file ); | private void createNewMagmaDownload() { String magmaFileName = magmaTF.getText().trim(); if (magmaFileName.length() == 0) { return; } File file = new File(magmaFileName); if (!file.exists()) { return; } try { SwarmingManager.getInstance().addMagmaToDownload( file ); } catch (IOException exp) { NLogger.error(NLoggerNames.MAGMA, exp.getMessage(), exp); GUIUtils.showErrorMessage( Localizer.getString( "NewDownload_FailedToParseMagmaMessage" ), Localizer.getString( "NewDownload_FailedToParseMagmaTitle" ) ); } } |
try { Reader reader = new BufferedReader(new FileReader(file)); RSSParser parser = new RSSParser(reader); parser.start(); List magnetList = parser.getMagnets(); Iterator iter = magnetList.iterator(); while (iter.hasNext()) { String magnet = (String) iter.next(); URI uri = new URI( magnet, true ); SwarmingManager swarmingMgr = SwarmingManager.getInstance(); MagnetData magnetData = MagnetData.parseFromURI( uri ); URN urn = MagnetData.lookupSHA1URN(magnetData); if ( !swarmingMgr.isURNDownloaded( urn ) ) { swarmingMgr.addFileToDownload( uri ); } } } catch (IOException exp) { NLogger.error(NLoggerNames.RSS, exp.getMessage(), exp); } | InternalFileHandler.rssReadout( file ); | private void createNewRSSDownload() { String rssFileName = rssTF.getText().trim(); if (rssFileName.length() == 0) { return; } File file = new File(rssFileName); if (!file.exists()) { return; } try { Reader reader = new BufferedReader(new FileReader(file)); RSSParser parser = new RSSParser(reader); parser.start(); List magnetList = parser.getMagnets(); Iterator iter = magnetList.iterator(); while (iter.hasNext()) { String magnet = (String) iter.next(); URI uri = new URI( magnet, true ); SwarmingManager swarmingMgr = SwarmingManager.getInstance(); MagnetData magnetData = MagnetData.parseFromURI( uri ); URN urn = MagnetData.lookupSHA1URN(magnetData); if ( !swarmingMgr.isURNDownloaded( urn ) ) { swarmingMgr.addFileToDownload( uri ); } } } catch (IOException exp) { NLogger.error(NLoggerNames.RSS, exp.getMessage(), exp); } } |
MagnetData magnetData = MagnetData.parseFromURI(uri); URN urn = MagnetData.lookupSHA1URN(magnetData); SwarmingManager swarmingMgr = SwarmingManager.getInstance(); if ( !swarmingMgr.isURNDownloaded( urn ) ) { swarmingMgr.addFileToDownload( uri ); } | downloadUri( uri ); | public static void magmaReadout( File file ) { try { BufferedInputStream inStream = new BufferedInputStream( new FileInputStream( file ) ); MagmaParser parser = new MagmaParser( inStream ); parser.start(); List magnetList = parser.getMagnets(); Iterator iter = magnetList.iterator(); while (iter.hasNext()) { String magnet = (String) iter.next(); URI uri = new URI( magnet, true ); // dont add already downloading urns. MagnetData magnetData = MagnetData.parseFromURI(uri); URN urn = MagnetData.lookupSHA1URN(magnetData); SwarmingManager swarmingMgr = SwarmingManager.getInstance(); if ( !swarmingMgr.isURNDownloaded( urn ) ) { swarmingMgr.addFileToDownload( uri ); } }/* String uuri = parser.getUpdateURI(); if ( uuri != null) { URI uri = new URI( uuri, true ); sheduledReadout(uri, 60000); } */ } catch (IOException exp) { NLogger.warn(NLoggerNames.MAGMA, exp.getMessage(), exp); } } |
SwarmingManager swarmingMgr = SwarmingManager.getInstance(); MagnetData magnetData = MagnetData.parseFromURI( uri ); URN urn = MagnetData.lookupSHA1URN(magnetData); if ( !swarmingMgr.isURNDownloaded( urn ) ) { swarmingMgr.addFileToDownload( uri ); } | downloadUri( uri ); | public static void rssReadout( File file ) { if (!file.exists()) { return; } try { Reader reader = new BufferedReader(new FileReader(file)); RSSParser parser = new RSSParser(reader); parser.start(); List magnetList = parser.getMagnets(); Iterator iter = magnetList.iterator(); while (iter.hasNext()) { String magnet = (String) iter.next(); URI uri = new URI( magnet, true ); SwarmingManager swarmingMgr = SwarmingManager.getInstance(); MagnetData magnetData = MagnetData.parseFromURI( uri ); URN urn = MagnetData.lookupSHA1URN(magnetData); if ( !swarmingMgr.isURNDownloaded( urn ) ) { swarmingMgr.addFileToDownload( uri ); } } } catch (IOException exp) { NLogger.error(NLoggerNames.RSS, exp.getMessage(), exp); } } |
if(ch=='<') buf.append("<"); else if(ch=='&') buf.append("&"); else if(ch==' ') buf.append(" "); else | public String getMsgEscaped() { StringBuffer buf = new StringBuffer(); for( int i=0; i<msg.length(); i++ ) { char ch = msg.charAt(i); if(ch=='\n') buf.append("<br>"); else buf.append(ch); } return buf.toString(); } |
|
public ChangeLogSet parse(File changelogFile) throws IOException, SAXException { | public ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException { | public ChangeLogSet parse(File changelogFile) throws IOException, SAXException { return ChangeLogSet.EMPTY; } |
public abstract ChangeLogSet parse(File changelogFile) throws IOException, SAXException; | public abstract ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException; | public abstract ChangeLogSet parse(File changelogFile) throws IOException, SAXException; |
return sub(zeroPoly,(FreeGroupElement) a); | return sub(zeroPoly,a); | public Number getInverse(Number a) { return sub(zeroPoly,(FreeGroupElement) a); } |
PlasticTheme myCurrentTheme = PlasticLookAndFeel.getMyCurrentTheme(); | PlasticTheme myCurrentTheme = PlasticLookAndFeel.getPlasticTheme(); | public static ThemeInfo getCurrentTheme( String lafClassName ) { if ( Options.PLASTICXP_NAME.equals( lafClassName ) ) { PlasticTheme myCurrentTheme = PlasticLookAndFeel.getMyCurrentTheme(); if ( myCurrentTheme == null ) { return null; } Class clazz = myCurrentTheme.getClass(); String name = clazz.getName(); return new ThemeInfo( name, name ); } return null; } |
plasticThemes = new ThemeInfo[18]; plasticThemes[0] = new ThemeInfo( "BrownSugar", classPrefix + "BrownSugar" ); plasticThemes[1] = new ThemeInfo( "DarkStar", classPrefix + "DarkStar" ); plasticThemes[2] = new ThemeInfo( "DesertBlue", classPrefix + "DesertBlue" ); if ( !LookUtils.IS_LAF_WINDOWS_XP_ENABLED && LookUtils.IS_OS_WINDOWS_MODERN ) | plasticThemes = new ThemeInfo[ themeNames.length ]; String displayName; String name; for ( int i = 0; i < themeNames.length; i++ ) | private static void initPlasticThemes() { if ( plasticThemes == null ) { String classPrefix = "com.jgoodies.looks.plastic.theme."; plasticThemes = new ThemeInfo[18]; plasticThemes[0] = new ThemeInfo( "BrownSugar", classPrefix + "BrownSugar" ); plasticThemes[1] = new ThemeInfo( "DarkStar", classPrefix + "DarkStar" ); plasticThemes[2] = new ThemeInfo( "DesertBlue", classPrefix + "DesertBlue" ); if ( !LookUtils.IS_LAF_WINDOWS_XP_ENABLED && LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[3] = new ThemeInfo( "DesertBluer (default)", classPrefix + "DesertBluer" ); } else { plasticThemes[3] = new ThemeInfo( "DesertBluer", classPrefix + "DesertBluer" ); } plasticThemes[4] = new ThemeInfo( "DesertGreen", classPrefix + "DesertGreen" ); plasticThemes[5] = new ThemeInfo( "DesertRed", classPrefix + "DesertRed" ); plasticThemes[6] = new ThemeInfo( "DesertYellow", classPrefix + "DesertYellow" ); if ( LookUtils.IS_LAF_WINDOWS_XP_ENABLED ) { plasticThemes[7] = new ThemeInfo( "ExperienceBlue (default)", classPrefix + "ExperienceBlue" ); } else { plasticThemes[7] = new ThemeInfo( "ExperienceBlue", classPrefix + "ExperienceBlue" ); } plasticThemes[8] = new ThemeInfo( "ExperienceGreen", classPrefix + "ExperienceGreen" ); plasticThemes[9] = new ThemeInfo( "Silver", classPrefix + "Silver" ); if ( !LookUtils.IS_OS_WINDOWS_XP && !LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[10] = new ThemeInfo( "SkyBlue (default)", classPrefix + "SkyBlue" ); } else { plasticThemes[10] = new ThemeInfo( "SkyBlue", classPrefix + "SkyBlue" ); } plasticThemes[11] = new ThemeInfo( "SkyBluer", classPrefix + "SkyBluer" ); plasticThemes[13] = new ThemeInfo( "SkyGreen", classPrefix + "SkyGreen" ); plasticThemes[14] = new ThemeInfo( "SkyKrupp", classPrefix + "SkyKrupp" ); plasticThemes[15] = new ThemeInfo( "SkyPink", classPrefix + "SkyPink" ); plasticThemes[16] = new ThemeInfo( "SkyRed", classPrefix + "SkyRed" ); plasticThemes[17] = new ThemeInfo( "SkyYellow", classPrefix + "SkyYellow" ); } } |
plasticThemes[3] = new ThemeInfo( "DesertBluer (default)", classPrefix + "DesertBluer" ); | displayName = name = themeNames[i]; if ( defaultName.endsWith( name ) ) { displayName = name + " (default)"; } plasticThemes[i] = new ThemeInfo( displayName, classPrefix + name ); | private static void initPlasticThemes() { if ( plasticThemes == null ) { String classPrefix = "com.jgoodies.looks.plastic.theme."; plasticThemes = new ThemeInfo[18]; plasticThemes[0] = new ThemeInfo( "BrownSugar", classPrefix + "BrownSugar" ); plasticThemes[1] = new ThemeInfo( "DarkStar", classPrefix + "DarkStar" ); plasticThemes[2] = new ThemeInfo( "DesertBlue", classPrefix + "DesertBlue" ); if ( !LookUtils.IS_LAF_WINDOWS_XP_ENABLED && LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[3] = new ThemeInfo( "DesertBluer (default)", classPrefix + "DesertBluer" ); } else { plasticThemes[3] = new ThemeInfo( "DesertBluer", classPrefix + "DesertBluer" ); } plasticThemes[4] = new ThemeInfo( "DesertGreen", classPrefix + "DesertGreen" ); plasticThemes[5] = new ThemeInfo( "DesertRed", classPrefix + "DesertRed" ); plasticThemes[6] = new ThemeInfo( "DesertYellow", classPrefix + "DesertYellow" ); if ( LookUtils.IS_LAF_WINDOWS_XP_ENABLED ) { plasticThemes[7] = new ThemeInfo( "ExperienceBlue (default)", classPrefix + "ExperienceBlue" ); } else { plasticThemes[7] = new ThemeInfo( "ExperienceBlue", classPrefix + "ExperienceBlue" ); } plasticThemes[8] = new ThemeInfo( "ExperienceGreen", classPrefix + "ExperienceGreen" ); plasticThemes[9] = new ThemeInfo( "Silver", classPrefix + "Silver" ); if ( !LookUtils.IS_OS_WINDOWS_XP && !LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[10] = new ThemeInfo( "SkyBlue (default)", classPrefix + "SkyBlue" ); } else { plasticThemes[10] = new ThemeInfo( "SkyBlue", classPrefix + "SkyBlue" ); } plasticThemes[11] = new ThemeInfo( "SkyBluer", classPrefix + "SkyBluer" ); plasticThemes[13] = new ThemeInfo( "SkyGreen", classPrefix + "SkyGreen" ); plasticThemes[14] = new ThemeInfo( "SkyKrupp", classPrefix + "SkyKrupp" ); plasticThemes[15] = new ThemeInfo( "SkyPink", classPrefix + "SkyPink" ); plasticThemes[16] = new ThemeInfo( "SkyRed", classPrefix + "SkyRed" ); plasticThemes[17] = new ThemeInfo( "SkyYellow", classPrefix + "SkyYellow" ); } } |
else { plasticThemes[3] = new ThemeInfo( "DesertBluer", classPrefix + "DesertBluer" ); } plasticThemes[4] = new ThemeInfo( "DesertGreen", classPrefix + "DesertGreen" ); plasticThemes[5] = new ThemeInfo( "DesertRed", classPrefix + "DesertRed" ); plasticThemes[6] = new ThemeInfo( "DesertYellow", classPrefix + "DesertYellow" ); if ( LookUtils.IS_LAF_WINDOWS_XP_ENABLED ) { plasticThemes[7] = new ThemeInfo( "ExperienceBlue (default)", classPrefix + "ExperienceBlue" ); } else { plasticThemes[7] = new ThemeInfo( "ExperienceBlue", classPrefix + "ExperienceBlue" ); } plasticThemes[8] = new ThemeInfo( "ExperienceGreen", classPrefix + "ExperienceGreen" ); plasticThemes[9] = new ThemeInfo( "Silver", classPrefix + "Silver" ); if ( !LookUtils.IS_OS_WINDOWS_XP && !LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[10] = new ThemeInfo( "SkyBlue (default)", classPrefix + "SkyBlue" ); } else { plasticThemes[10] = new ThemeInfo( "SkyBlue", classPrefix + "SkyBlue" ); } plasticThemes[11] = new ThemeInfo( "SkyBluer", classPrefix + "SkyBluer" ); plasticThemes[13] = new ThemeInfo( "SkyGreen", classPrefix + "SkyGreen" ); plasticThemes[14] = new ThemeInfo( "SkyKrupp", classPrefix + "SkyKrupp" ); plasticThemes[15] = new ThemeInfo( "SkyPink", classPrefix + "SkyPink" ); plasticThemes[16] = new ThemeInfo( "SkyRed", classPrefix + "SkyRed" ); plasticThemes[17] = new ThemeInfo( "SkyYellow", classPrefix + "SkyYellow" ); | private static void initPlasticThemes() { if ( plasticThemes == null ) { String classPrefix = "com.jgoodies.looks.plastic.theme."; plasticThemes = new ThemeInfo[18]; plasticThemes[0] = new ThemeInfo( "BrownSugar", classPrefix + "BrownSugar" ); plasticThemes[1] = new ThemeInfo( "DarkStar", classPrefix + "DarkStar" ); plasticThemes[2] = new ThemeInfo( "DesertBlue", classPrefix + "DesertBlue" ); if ( !LookUtils.IS_LAF_WINDOWS_XP_ENABLED && LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[3] = new ThemeInfo( "DesertBluer (default)", classPrefix + "DesertBluer" ); } else { plasticThemes[3] = new ThemeInfo( "DesertBluer", classPrefix + "DesertBluer" ); } plasticThemes[4] = new ThemeInfo( "DesertGreen", classPrefix + "DesertGreen" ); plasticThemes[5] = new ThemeInfo( "DesertRed", classPrefix + "DesertRed" ); plasticThemes[6] = new ThemeInfo( "DesertYellow", classPrefix + "DesertYellow" ); if ( LookUtils.IS_LAF_WINDOWS_XP_ENABLED ) { plasticThemes[7] = new ThemeInfo( "ExperienceBlue (default)", classPrefix + "ExperienceBlue" ); } else { plasticThemes[7] = new ThemeInfo( "ExperienceBlue", classPrefix + "ExperienceBlue" ); } plasticThemes[8] = new ThemeInfo( "ExperienceGreen", classPrefix + "ExperienceGreen" ); plasticThemes[9] = new ThemeInfo( "Silver", classPrefix + "Silver" ); if ( !LookUtils.IS_OS_WINDOWS_XP && !LookUtils.IS_OS_WINDOWS_MODERN ) { plasticThemes[10] = new ThemeInfo( "SkyBlue (default)", classPrefix + "SkyBlue" ); } else { plasticThemes[10] = new ThemeInfo( "SkyBlue", classPrefix + "SkyBlue" ); } plasticThemes[11] = new ThemeInfo( "SkyBluer", classPrefix + "SkyBluer" ); plasticThemes[13] = new ThemeInfo( "SkyGreen", classPrefix + "SkyGreen" ); plasticThemes[14] = new ThemeInfo( "SkyKrupp", classPrefix + "SkyKrupp" ); plasticThemes[15] = new ThemeInfo( "SkyPink", classPrefix + "SkyPink" ); plasticThemes[16] = new ThemeInfo( "SkyRed", classPrefix + "SkyRed" ); plasticThemes[17] = new ThemeInfo( "SkyYellow", classPrefix + "SkyYellow" ); } } |
|
PlasticLookAndFeel.setMyCurrentTheme( (PlasticTheme)theme ); | PlasticLookAndFeel.setPlasticTheme( (PlasticTheme)theme ); | public static void setCurrentTheme( String lafClassName, Object theme ) { if ( lafClassName.equals( Options.PLASTICXP_NAME ) ) { PlasticLookAndFeel.setMyCurrentTheme( (PlasticTheme)theme ); try { // after setting the theme we must reset the PlasticLAF UIManager.setLookAndFeel( UIManager.getLookAndFeel() ); } catch ( UnsupportedLookAndFeelException exp ) {// this is not expected to happen since we reset a existing LAF NLogger.error( NLoggerNames.USER_INTERFACE, exp, exp ); } } GUIUtils.updateComponentsUI(); } |
if (param instanceof Number) { return new Double(Math.sin(((Number)param).doubleValue())); } else if (param instanceof Complex) { | if (param instanceof Complex) { | public Object sin(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.sin(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).sin(); } throw new ParseException("Invalid parameter type"); } |
else if (param instanceof Number) { return new Double(Math.sin(((Number)param).doubleValue())); } | public Object sin(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.sin(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).sin(); } throw new ParseException("Invalid parameter type"); } |
|
invokeEventMethod(iter.next(), bindMethodName, ref); | Object instance = iter.next(); invokeEventMethod(instance, bindMethodName, ref); | public void addedService(ServiceReference ref, Object service) { if (doneBound && multiple) { for (Iterator iter = instances.iterator(); iter.hasNext();) { invokeEventMethod(iter.next(), bindMethodName, ref); } } else if (bound != null && !multiple) { ServiceReference newBound = getServiceReference(); if (!bound.equals(newBound)) { if (dynamic) { // Bind new and unbind old for (Iterator iter = instances.iterator(); iter.hasNext();) { Object instance = iter.next(); invokeEventMethod(instance, unbindMethodName, bound); invokeEventMethod(instance, bindMethodName, newBound); ungetService(bound); // this is new. } bound = newBound; } else { // Static: deactivate and reactivate overrideUnsatisfied = true; config.referenceUnsatisfied(); overrideUnsatisfied = false; config.referenceSatisfied(); } } } if (!isSatisfied(1) && isSatisfied() && config != null) { config.referenceSatisfied(); } } |
ungetService(bound); | ungetService(instance, bound); | public void addedService(ServiceReference ref, Object service) { if (doneBound && multiple) { for (Iterator iter = instances.iterator(); iter.hasNext();) { invokeEventMethod(iter.next(), bindMethodName, ref); } } else if (bound != null && !multiple) { ServiceReference newBound = getServiceReference(); if (!bound.equals(newBound)) { if (dynamic) { // Bind new and unbind old for (Iterator iter = instances.iterator(); iter.hasNext();) { Object instance = iter.next(); invokeEventMethod(instance, unbindMethodName, bound); invokeEventMethod(instance, bindMethodName, newBound); ungetService(bound); // this is new. } bound = newBound; } else { // Static: deactivate and reactivate overrideUnsatisfied = true; config.referenceUnsatisfied(); overrideUnsatisfied = false; config.referenceSatisfied(); } } } if (!isSatisfied(1) && isSatisfied() && config != null) { config.referenceSatisfied(); } } |
registerDuplexRef(bound, instance); | public void bind(Object instance) { instances.add(instance); doneBound = true; if (multiple) { ServiceReference[] serviceReferences = getServiceReferences(); if (serviceReferences != null) { for (int i = 0; i < serviceReferences.length; i++) { bound = serviceReferences[i]; registerDuplexRef(bound, instance); invokeEventMethod(instance, bindMethodName, bound); } } } else { // unary bound = getServiceReference(); if (bound != null) { registerDuplexRef(bound, instance); invokeEventMethod(instance, bindMethodName, bound); } } } |
|
Bundle bundle = ref.getBundle(); Class serviceClass = null; try { serviceClass = bundle.loadClass(getInterfaceName()); } catch (ClassNotFoundException e) { Activator.log.error("Declarative Services could not load class", e); return; } | private void invokeEventMethod(Object instance, String methodName, ServiceReference ref) { if (methodName == null) { return; } Class instanceClass = instance.getClass(); Method method = null; Bundle bundle = ref.getBundle(); // the bundle where the service is // located Class serviceClass = null; try { serviceClass = bundle.loadClass(getInterfaceName()); } catch (ClassNotFoundException e) { Activator.log.error("Declarative Services could not load class", e); return; } while (instanceClass != null && method == null) { Method[] ms = instanceClass.getDeclaredMethods(); // searches this class for a suitable method. for (int i = 0; i < ms.length; i++) { if (methodName.equals(ms[i].getName()) && (Modifier.isProtected(ms[i].getModifiers()) || Modifier .isPublic(ms[i].getModifiers()))) { Class[] parms = ms[i].getParameterTypes(); if (parms.length == 1) { try { if (ServiceReference.class.equals(parms[0])) { ms[i].setAccessible(true); ms[i].invoke(instance, new Object[] { ref }); return; } else if (parms[0].isAssignableFrom(serviceClass)) { Object service = getService(ref); ms[i].setAccessible(true); ms[i] .invoke(instance, new Object[] { service }); return; } } catch (IllegalAccessException e) { Activator.log.error( "Declarative Services could not access the method \"" + methodName + "\" used by component \"" + config.getName() + "\". Got exception.", e); } catch (InvocationTargetException e) { Activator.log.error( "Declarative Services got exception while invoking \"" + methodName + "\" used by component \"" + config.getName() + "\". Got exception.", e); } } } } instanceClass = instanceClass.getSuperclass(); } // did not find any such method. Activator.log .error("Declarative Services could not find bind/unbind method \"" + methodName + "\" in class \"" + config.getImplementation() + "\" used by component " + config.getName() + "\"."); } |
|
} else if (parms[0].isAssignableFrom(serviceClass)) { Object service = getService(ref); | } else if (parms[0].getName().equals(getInterfaceName())) { Object service = getService(instance, ref); | private void invokeEventMethod(Object instance, String methodName, ServiceReference ref) { if (methodName == null) { return; } Class instanceClass = instance.getClass(); Method method = null; Bundle bundle = ref.getBundle(); // the bundle where the service is // located Class serviceClass = null; try { serviceClass = bundle.loadClass(getInterfaceName()); } catch (ClassNotFoundException e) { Activator.log.error("Declarative Services could not load class", e); return; } while (instanceClass != null && method == null) { Method[] ms = instanceClass.getDeclaredMethods(); // searches this class for a suitable method. for (int i = 0; i < ms.length; i++) { if (methodName.equals(ms[i].getName()) && (Modifier.isProtected(ms[i].getModifiers()) || Modifier .isPublic(ms[i].getModifiers()))) { Class[] parms = ms[i].getParameterTypes(); if (parms.length == 1) { try { if (ServiceReference.class.equals(parms[0])) { ms[i].setAccessible(true); ms[i].invoke(instance, new Object[] { ref }); return; } else if (parms[0].isAssignableFrom(serviceClass)) { Object service = getService(ref); ms[i].setAccessible(true); ms[i] .invoke(instance, new Object[] { service }); return; } } catch (IllegalAccessException e) { Activator.log.error( "Declarative Services could not access the method \"" + methodName + "\" used by component \"" + config.getName() + "\". Got exception.", e); } catch (InvocationTargetException e) { Activator.log.error( "Declarative Services got exception while invoking \"" + methodName + "\" used by component \"" + config.getName() + "\". Got exception.", e); } } } } instanceClass = instanceClass.getSuperclass(); } // did not find any such method. Activator.log .error("Declarative Services could not find bind/unbind method \"" + methodName + "\" in class \"" + config.getImplementation() + "\" used by component " + config.getName() + "\"."); } |
invokeEventMethod(iter.next(), unbindMethodName, ref); | Object instance = iter.next(); invokeEventMethod(instance, unbindMethodName, ref); ungetService(instance, ref); | public void removingService(ServiceReference ref, Object service) { if (!isSatisfied(1)) { // Will be unsatisfied by this remove. overrideUnsatisfied = true; config.referenceUnsatisfied(); overrideUnsatisfied = false; } else { // Will continue to be satisfied. if (doneBound && multiple) { for (Iterator iter = instances.iterator(); iter.hasNext();) { invokeEventMethod(iter.next(), unbindMethodName, ref); } ungetService(ref); } else if (ref.equals(bound)) { // The bound one is removed. if (dynamic) { // Unbind and let removedService bind the new // one. for (Iterator iter = instances.iterator(); iter.hasNext();) { invokeEventMethod(iter.next(), unbindMethodName, ref); } ungetService(ref); bound = null; } else { // Static. Deactivate and let removedService // re-activate. overrideUnsatisfied = true; config.referenceUnsatisfied(); overrideUnsatisfied = false; } } } } |
ungetService(ref); | public void removingService(ServiceReference ref, Object service) { if (!isSatisfied(1)) { // Will be unsatisfied by this remove. overrideUnsatisfied = true; config.referenceUnsatisfied(); overrideUnsatisfied = false; } else { // Will continue to be satisfied. if (doneBound && multiple) { for (Iterator iter = instances.iterator(); iter.hasNext();) { invokeEventMethod(iter.next(), unbindMethodName, ref); } ungetService(ref); } else if (ref.equals(bound)) { // The bound one is removed. if (dynamic) { // Unbind and let removedService bind the new // one. for (Iterator iter = instances.iterator(); iter.hasNext();) { invokeEventMethod(iter.next(), unbindMethodName, ref); } ungetService(ref); bound = null; } else { // Static. Deactivate and let removedService // re-activate. overrideUnsatisfied = true; config.referenceUnsatisfied(); overrideUnsatisfied = false; } } } } |
|
ungetService(serviceReferences[i]); unregisterDuplexRef(serviceReferences[i]); | ungetService(instance, serviceReferences[i]); | public void unbind(Object instance) { instances.remove(instance); if (!doneBound) return; doneBound = false; if (multiple) { ServiceReference[] serviceReferences = getServiceReferences(); if (serviceReferences != null) { for (int i = serviceReferences.length - 1; i >= 0; i--) { invokeEventMethod(instance, unbindMethodName, serviceReferences[i]); ungetService(serviceReferences[i]); unregisterDuplexRef(serviceReferences[i]); } } } else { // unary invokeEventMethod(instance, unbindMethodName, bound); ungetService(bound); unregisterDuplexRef(bound); } bound = null; } |
ungetService(bound); unregisterDuplexRef(bound); | ungetService(instance, bound); | public void unbind(Object instance) { instances.remove(instance); if (!doneBound) return; doneBound = false; if (multiple) { ServiceReference[] serviceReferences = getServiceReferences(); if (serviceReferences != null) { for (int i = serviceReferences.length - 1; i >= 0; i--) { invokeEventMethod(instance, unbindMethodName, serviceReferences[i]); ungetService(serviceReferences[i]); unregisterDuplexRef(serviceReferences[i]); } } } else { // unary invokeEventMethod(instance, unbindMethodName, bound); ungetService(bound); unregisterDuplexRef(bound); } bound = null; } |
void ungetService(ServiceReference ref) { | void ungetService(Object bindObject, ServiceReference ref) { | void ungetService(ServiceReference ref) { synchronized (tracking) { objects.remove(ref); context.ungetService(ref); } } |
objects.remove(ref); | Object removeObject = objects.remove(ref); | void ungetService(ServiceReference ref) { synchronized (tracking) { objects.remove(ref); context.ungetService(ref); } } |
ArrayList<DuplexReference> duplexRefList = (ArrayList) ref .getProperty(org.bamja.core.impl.Constants.DUPLEX_REFERENCES); if (removeObject != null && duplexRefList != null && removeObject instanceof DuplexFactoryComponent) { ((DuplexFactoryComponent) removeObject) .ungetInstance(bindObject); } | void ungetService(ServiceReference ref) { synchronized (tracking) { objects.remove(ref); context.ungetService(ref); } } |
|
Options opts = new Options("mash"); | Options opts = r.opts; | public Mash(Recipe r){ Options opts = new Options("mash"); mashRatio = opts.getDProperty("optMashRatio"); mashRatioU = opts.getProperty("optMashRatioU");; tempUnits = opts.getProperty("optMashTempU"); volUnits = opts.getProperty("optMashVolU"); grainTempF = opts.getDProperty("optGrainTemp"); boilTempF = opts.getDProperty("optBoilTempF"); ACIDTMPF = opts.getFProperty("optAcidTmpF"); GLUCANTMPF = opts.getFProperty("optGlucanTmpF"); PROTEINTMPF = opts.getFProperty("optProteinTmpF"); BETATMPF = opts.getFProperty("optBetaTmpF"); ALPHATMPF = opts.getFProperty("optAlphaTmpF"); MASHOUTTMPF = opts.getFProperty("optMashoutTmpF"); SPARGETMPF = opts.getFProperty("optSpargeTmpF"); thickDecoctRatio = opts.getDProperty("optThickDecoctRatio"); thinDecoctRatio = opts.getDProperty("optThinDecoctRatio"); cerealMashTemp = opts.getDProperty("optCerealMashTmpF"); myRecipe = r; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.