rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
meta
stringlengths
141
403
_providers.clear();
synchronized public void shutdown() { _log.notice("shutting down"); Enumeration e = _providers.elements(); _providers.clear(); while (e.hasMoreElements()) { Provider pr = (Provider) e.nextElement(); _log.info("stopping: " + pr); pr.destroy(); } _ls.flush(); }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/db912c29be83f4d17978d31cdc9f31860bedd866/Broker.java/buggy/webmacro/src/org/webmacro/Broker.java
_providers.clear();
synchronized public void shutdown() { _log.notice("shutting down"); Enumeration e = _providers.elements(); _providers.clear(); while (e.hasMoreElements()) { Provider pr = (Provider) e.nextElement(); _log.info("stopping: " + pr); pr.destroy(); } _ls.flush(); }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/db912c29be83f4d17978d31cdc9f31860bedd866/Broker.java/buggy/webmacro/src/org/webmacro/Broker.java
public static LogSystem getInstance(String category) { synchronized (_instances) { if (category == null) return _singleton; LogSystem ls = (LogSystem) _instances.get(category); if (ls == null) { ls = new LogSystem(category); _instances.put(category, ls); } return ls; }
public static LogSystem getInstance() { return getInstance(null);
public static LogSystem getInstance(String category) { synchronized (_instances) { if (category == null) return _singleton; LogSystem ls = (LogSystem) _instances.get(category); if (ls == null) { ls = new LogSystem(category); _instances.put(category, ls); } return ls; } }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/eaf4eda3d1dc696e065fa02b661b072950526e26/LogSystem.java/buggy/webmacro/src/org/webmacro/util/LogSystem.java
synchronized public Log getLog(String type, String description) { LogSource l = (LogSource) _logs.get(type); if (l != null) return l; l = new LogSource(_category, type, description); _logs.put(type, l); Iterator i = _targets.iterator(); while (i.hasNext()) { LogTarget lt = (LogTarget) i.next(); for (int level = LogSystem.ALL; level < LogSystem.NONE; level++) { if (lt.subscribe(_category, type, level)) { l.addTarget(lt, level); } } } if (_log != null) { _log.info("Started log " + l.getType() + ": " + l.getDescription()); } return l;
public Log getLog(String type) { return getLog(type, type);
synchronized public Log getLog(String type, String description) { LogSource l = (LogSource) _logs.get(type); if (l != null) return l; l = new LogSource(_category, type, description); _logs.put(type, l); Iterator i = _targets.iterator(); while (i.hasNext()) { LogTarget lt = (LogTarget) i.next(); for (int level = LogSystem.ALL; level < LogSystem.NONE; level++) { if (lt.subscribe(_category, type, level)) { l.addTarget(lt, level); } } } if (_log != null) { _log.info("Started log " + l.getType() + ": " + l.getDescription()); } return l; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/eaf4eda3d1dc696e065fa02b661b072950526e26/LogSystem.java/buggy/webmacro/src/org/webmacro/util/LogSystem.java
public void load(URL u) throws IOException { InputStream in = u.openStream(); _props.load(in); in.close();
public void load(String fileName) throws InitException, IOException { ClassLoader cl = this.getClass().getClassLoader(); URL u = cl.getResource(fileName); if (u == null) u = ClassLoader.getSystemResource(fileName); if (u == null) try { u = new URL("file:" + fileName); } catch (MalformedURLException e) { }; if (u == null) { StringBuffer error = new StringBuffer(); error.append("Unable to locate the configuration file: "); error.append(fileName); error.append("\n"); error.append("This may mean the system could not be started. The \n"); error.append("following list should be where I looked for it:\n"); error.append("\n"); error.append(" my classpath:\n"); try { buildPath(error, fileName, cl.getResources(".")); } catch (Exception e) { } error.append("\n"); error.append(" system classpath:\n"); try { buildPath(error, fileName, ClassLoader.getSystemResources(".")); } catch (Exception e) { } error.append("\n\n"); error.append("Please create an appropriate " + fileName + " at one of the above\n"); error.append("locations. Alternately this Settings class can be configured from\n"); error.append("a Properties object, if you want to modify the init code.\n"); throw new InitException(error.toString()); } load(u);
public void load(URL u) throws IOException { InputStream in = u.openStream(); _props.load(in); in.close(); }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/3a5b935d0fecd6ca6762a4f8eb9163a9970c170b/Settings.java/buggy/webmacro/src/org/webmacro/util/Settings.java
private byte[] bufferAsByteArrayWithExceptionIfNull( MappedByteBuffer buffer ) { return null; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public byte[] calculateMessageDigest() { try { return buffer.calculateMessageDigest(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
if ( id >= 0 )
if ( id != null )
public void create() { super.create(); if ( id >= 0 ) { load(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
load();
long reset = id.longValue(); id = null; setPixelsId( reset );
public void create() { super.create(); if ( id >= 0 ) { load(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
super.destroy();
pixelsInstance = null; buffer = null;
public void destroy() { // id is the only thing passivated. super.destroy(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public byte[] getPlane(Integer arg0, Integer arg1, Integer arg2) { MappedByteBuffer plane; try { plane = buffer.getPlane(arg0, arg1, arg2); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } return bufferAsByteArrayWithExceptionIfNull( plane ); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Long getPlaneOffset(Integer arg0, Integer arg1, Integer arg2) { try { return buffer.getPlaneOffset(arg0, arg1, arg2); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Integer getPlaneSize() { return buffer.getPlaneSize(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public byte[] getRegion(Integer arg0, Long arg1) { MappedByteBuffer region; try { region = buffer.getRegion(arg0, arg1); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } return bufferAsByteArrayWithExceptionIfNull( region ); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public byte[] getRow(Integer arg0, Integer arg1, Integer arg2, Integer arg3) { MappedByteBuffer row; try { row = buffer.getRow(arg0, arg1, arg2, arg3); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } return bufferAsByteArrayWithExceptionIfNull( row ); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Long getRowOffset(Integer arg0, Integer arg1, Integer arg2, Integer arg3) { try { return buffer.getRowOffset(arg0, arg1, arg2, arg3); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Integer getRowSize() { return buffer.getRowSize(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public byte[] getStack(Integer arg0, Integer arg1) { MappedByteBuffer stack; try { stack = buffer.getStack(arg0, arg1); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } return bufferAsByteArrayWithExceptionIfNull( stack ); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Long getStackOffset(Integer arg0, Integer arg1) { try { return buffer.getStackOffset(arg0, arg1); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Integer getStackSize() { return buffer.getStackSize(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public byte[] getTimepoint(Integer arg0) { MappedByteBuffer timepoint; try { timepoint = buffer.getTimepoint(arg0); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } return bufferAsByteArrayWithExceptionIfNull( timepoint ); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Long getTimepointOffset(Integer arg0) { try { return buffer.getTimepointOffset(arg0); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Integer getTimepointSize() { return buffer.getTimepointSize(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public Integer getTotalSize() { return buffer.getTotalSize(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
public void setPixelsId(long pixelsId)
public void setPixelsId( long pixelsId )
public void setPixelsId(long pixelsId) { id = pixelsId; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
id = pixelsId;
if ( id == null || id.longValue() != pixelsId ) { id = new Long( pixelsId ); pixelsInstance = null; buffer = null; IPixels metadataService = serviceFactory.getPixelsService(); PixelsService dataService = (PixelsService) applicationContext.getBean("/OME/OMEIS/Pixels"); pixelsInstance = metadataService.retrievePixDescription( id ); try { buffer = dataService.createPixelBuffer( pixelsInstance ); } catch (IOException e) { e.printStackTrace(); throw new ResourceError( "Failed to create PixelBuffer:\n" +e.getMessage()); } }
public void setPixelsId(long pixelsId) { id = pixelsId; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public void setPlane(byte[] arg0, Integer arg1, Integer arg2, Integer arg3) { try { buffer.setPlane(arg0, arg1, arg2, arg3); } catch (BufferOverflowException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public void setRegion(Integer arg0, Long arg1, byte[] arg2) { try { buffer.setRegion(arg0, arg1, arg2); } catch (BufferOverflowException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public void setRow(byte[] arg0, Integer arg1, Integer arg2, Integer arg3, Integer arg4) { // FIXME buffer.setRow(arg0, arg1, arg2, arg3, arg4); throw new RuntimeException("Not implemented yet."); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public void setStack(byte[] arg0, Integer arg1, Integer arg2, Integer arg3) { try { buffer.setStack(arg0, arg1, arg2, arg3); } catch (BufferOverflowException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
errorIfNotLoaded();
public void setTimepoint(byte[] arg0, Integer arg1) { try { buffer.setTimepoint(arg0, arg1); } catch (BufferOverflowException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } catch (DimensionsOutOfBoundsException e) { e.printStackTrace(); throw new RuntimeException("Unimplemented exception."); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/f7d8facc0df80871004c721c1920ba34361d4e05/RawPixelsBean.java/clean/components/ejb/src/ome/ro/ejb/RawPixelsBean.java
esServer.join();
public static void main(String[] args) throws Exception { int iIterations = 1; try { iIterations = Integer.parseInt(args[0]); } catch(Exception e) { } EchoServer esServer = new EchoServer(0); new EchoClient(InetAddress.getLocalHost(), esServer.getPort(), iIterations); }
53330 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/53330/eb6c850277407b38bcaefb81155941da0f27b849/echo.java/buggy/tests/shootout/java-start/echo.java
if ( nodes == null) {
if (nodes == null) {
public void onDataObjectSave(List nodes) { switch (model.getState()) { case DISCARDED: case NEW: case LOADING_THUMBNAILS: return; default: break; } if ( nodes == null) { model.onDataObjectSave(); fireStateChange(); return; } view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); DataSaveVisitor visitor = new DataSaveVisitor(this, nodes); Browser browser = model.getBrowser(); browser.accept(visitor); browser.getUI().repaint(); browser.setSelectedDisplay(browser.getLastSelectedDisplay()); if (model.getTreeView() != null) model.getTreeView().repaint(); model.onDataObjectSave(); view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fireStateChange(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/3b273af3a5320ab0a054540f14a3c299ff01de69/HiViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerComponent.java
browser.getUI().repaint();
JComponent c = browser.getUI(); c.validate(); c.repaint();
public void onDataObjectSave(List nodes) { switch (model.getState()) { case DISCARDED: case NEW: case LOADING_THUMBNAILS: return; default: break; } if ( nodes == null) { model.onDataObjectSave(); fireStateChange(); return; } view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); DataSaveVisitor visitor = new DataSaveVisitor(this, nodes); Browser browser = model.getBrowser(); browser.accept(visitor); browser.getUI().repaint(); browser.setSelectedDisplay(browser.getLastSelectedDisplay()); if (model.getTreeView() != null) model.getTreeView().repaint(); model.onDataObjectSave(); view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fireStateChange(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/3b273af3a5320ab0a054540f14a3c299ff01de69/HiViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerComponent.java
if (model.getTreeView() != null) model.getTreeView().repaint();
TreeView tv = model.getTreeView(); if (tv != null) tv.repaint();
public void onDataObjectSave(List nodes) { switch (model.getState()) { case DISCARDED: case NEW: case LOADING_THUMBNAILS: return; default: break; } if ( nodes == null) { model.onDataObjectSave(); fireStateChange(); return; } view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); DataSaveVisitor visitor = new DataSaveVisitor(this, nodes); Browser browser = model.getBrowser(); browser.accept(visitor); browser.getUI().repaint(); browser.setSelectedDisplay(browser.getLastSelectedDisplay()); if (model.getTreeView() != null) model.getTreeView().repaint(); model.onDataObjectSave(); view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); fireStateChange(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/3b273af3a5320ab0a054540f14a3c299ff01de69/HiViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerComponent.java
if (model.getTreeView() != null) {
TreeView tv = model.getTreeView(); if (tv != null) {
public void setHierarchyRoots(Set roots, boolean flat, boolean refresh) { if (model.getState() != LOADING_HIERARCHY) throw new IllegalStateException( "This method can only be invoked in the LOADING_HIERARCHY "+ "state."); if (!refresh) { model.createBrowser(roots, flat); model.createClipBoard(); model.getClipBoard().addPropertyChangeListener(controller); model.fireThumbnailLoading(); //b/c fireThumbnailLoading() sets the state to READY if there is no //image. if (model.getBrowser().getImages().size() == 0) setStatus("Done", -1); else setStatus(HiViewer.PAINTING_TEXT, -1); fireStateChange(); } else { Browser browser = model.getBrowser(); boolean isClipBoardDisplay = model.getClipBoard().isDisplay(); if (browser == null) throw new NullPointerException("The browser cannot be NULL."); view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); model.refreshBrowser(roots, flat); model.createClipBoard(); model.getClipBoard().addPropertyChangeListener(controller); model.fireThumbnailLoading(); //b/c fireThumbnailLoading() sets the state to READY if there is no //image. if (model.getBrowser().getImages().size() == 0) setStatus("Done", -1); else setStatus(HiViewer.PAINTING_TEXT, -1); fireStateChange(); if (model.getTreeView() != null) { model.createTreeView(); view.showTreeView(true); } view.showClipBoard(isClipBoardDisplay); view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/3b273af3a5320ab0a054540f14a3c299ff01de69/HiViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerComponent.java
view.showTreeView(true);
view.showTreeView(tv.isDisplay());
public void setHierarchyRoots(Set roots, boolean flat, boolean refresh) { if (model.getState() != LOADING_HIERARCHY) throw new IllegalStateException( "This method can only be invoked in the LOADING_HIERARCHY "+ "state."); if (!refresh) { model.createBrowser(roots, flat); model.createClipBoard(); model.getClipBoard().addPropertyChangeListener(controller); model.fireThumbnailLoading(); //b/c fireThumbnailLoading() sets the state to READY if there is no //image. if (model.getBrowser().getImages().size() == 0) setStatus("Done", -1); else setStatus(HiViewer.PAINTING_TEXT, -1); fireStateChange(); } else { Browser browser = model.getBrowser(); boolean isClipBoardDisplay = model.getClipBoard().isDisplay(); if (browser == null) throw new NullPointerException("The browser cannot be NULL."); view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); model.refreshBrowser(roots, flat); model.createClipBoard(); model.getClipBoard().addPropertyChangeListener(controller); model.fireThumbnailLoading(); //b/c fireThumbnailLoading() sets the state to READY if there is no //image. if (model.getBrowser().getImages().size() == 0) setStatus("Done", -1); else setStatus(HiViewer.PAINTING_TEXT, -1); fireStateChange(); if (model.getTreeView() != null) { model.createTreeView(); view.showTreeView(true); } view.showClipBoard(isClipBoardDisplay); view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/3b273af3a5320ab0a054540f14a3c299ff01de69/HiViewerComponent.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerComponent.java
controllers.invokeControllerMethod(methodDescriptor, e);
dispatcher.invokeControllerMethod(methodDescriptor, e);
public void handleEvent(Event e) { String methodDescriptor = srcToEvtToMethod.get(e.widget).get(e.type); controllers.invokeControllerMethod(methodDescriptor, e); }
57508 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57508/18ce9cf33f3e06fda4addd57f5ae5c9423a990fb/Listener.java/clean/trunk/src/de/berlios/koalanotes/controllers/Listener.java
popupMenu = new TreePopupMenu(this);
popupMenu = new TreePopupMenu(this, model);
private void initComponents() { popupMenu = new TreePopupMenu(this); searchView = new CBSearchTabView(model, this, controller); annotationView = new CBAnnotationTabView(model, this, controller); tabPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); tabPane.setAlignmentX(LEFT_ALIGNMENT); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/b4992016524102ee0a5c7465d4cc7a94e9ffce2d/ClipBoardUI.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/clipboard/ClipBoardUI.java
try { if (customList.contains(StringUtils.parseBareAddress(message.getFrom()))) { cancelledNotification(message.getFrom(), ""); } } catch (Exception e) { Log.error(e); }
public void filterIncomingMessage(ChatRoom room, Message message) { // Fire Message Filters final ChatManager chatManager = SparkManager.getChatManager(); Iterator filters = chatManager.getMessageFilters().iterator(); while (filters.hasNext()) { ((MessageFilter)filters.next()).filterIncoming(room, message); } }
52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/24dc09d27297f55d2ff835c60b42b5f418a75e70/ChatManager.java/buggy/src/java/org/jivesoftware/spark/ChatManager.java
c = (Context) _context.clone();
c = (Context) _context.clone(); c.setPool(cpool);
final public Context getContext() { Pool cpool = (Pool) _contextCache.get(); Context c = (Context) cpool.get(); if (c == null) { c = (Context) _context.clone(); } c.setPool(cpool); return c; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7ffcb0a1dccbd0a8cb2d3e1b596015808bd39549/WM.java/buggy/webmacro/src/org/webmacro/WM.java
c.setPool(cpool);
else c.clear();
final public Context getContext() { Pool cpool = (Pool) _contextCache.get(); Context c = (Context) cpool.get(); if (c == null) { c = (Context) _context.clone(); } c.setPool(cpool); return c; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7ffcb0a1dccbd0a8cb2d3e1b596015808bd39549/WM.java/buggy/webmacro/src/org/webmacro/WM.java
c = _webContext.newInstance(req,resp);
c = _webContext.newInstance(req,resp); c.setPool(cpool);
final public WebContext getWebContext(HttpServletRequest req, HttpServletResponse resp) { Pool cpool = (Pool) _webContextCache.get(); WebContext c = (WebContext) cpool.get(); if (c == null) { c = _webContext.newInstance(req,resp); } Context ctx = c; ctx.setPool(cpool); return c; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7ffcb0a1dccbd0a8cb2d3e1b596015808bd39549/WM.java/buggy/webmacro/src/org/webmacro/WM.java
Context ctx = c; ctx.setPool(cpool);
else c.reinitialize(req, resp);
final public WebContext getWebContext(HttpServletRequest req, HttpServletResponse resp) { Pool cpool = (Pool) _webContextCache.get(); WebContext c = (WebContext) cpool.get(); if (c == null) { c = _webContext.newInstance(req,resp); } Context ctx = c; ctx.setPool(cpool); return c; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7ffcb0a1dccbd0a8cb2d3e1b596015808bd39549/WM.java/buggy/webmacro/src/org/webmacro/WM.java
l.mapEvent(menu, SWT.Show, TreeContextMenuController.INITIALISE_MENU);
l.mapEvent(menu, SWT.Show, TreeController.INITIALISE_CONTEXT_MENU); l.mapEvent(menu, SWT.Dispose, TreeController.DISPOSE_CONTEXT_MENU);
public TreeContextMenu(Control parent, Listener l) { // menu menu = new Menu(parent); l.mapEvent(menu, SWT.Show, TreeContextMenuController.INITIALISE_MENU); parent.setMenu(menu); // menu items addNote = createMenuItem(menu, "Add Note", l, TreeContextMenuController.ADD_NOTE); removeNotes = createMenuItem(menu, "Remove Notes", l, TreeContextMenuController.REMOVE_NOTES); renameNote = createMenuItem(menu, "Rename Note", l, TreeContextMenuController.RENAME_NOTE); }
57508 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57508/57d4036eb7167d2d27117abe1f0280376377dbaa/TreeContextMenu.java/buggy/trunk/src/de/berlios/koalanotes/display/TreeContextMenu.java
mockSession.expects( atLeastOnce() ).method( "setFlushMode" ) .with( eq( FlushMode.AUTO ));
protected void getsFactoryFromSession() { mockSession.expects( atLeastOnce() ).method( "getSessionFactory" ) .will( returnValue( factory )); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
.with( eq( FlushMode.COMMIT ));
.with( eq( FlushMode.MANUAL ));
protected void setsFlushMode() { mockSession.expects( atLeastOnce() ).method( "setFlushMode" ) .with( eq( FlushMode.COMMIT )); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
getsAutoFlushMode();
getsFlushMode();
public void testClosedOnException() throws Throwable { prepareThreadWithSession(); try { newStatefulReadInvocationThrows(); checksSessionIsOpen(); checksSessionIsConnected(); getsFactoryFromSession(); getsAutoFlushMode(); // here it throws disconnectsSession(); closesSession(); handler.invoke( invocation ); fail("Should have thrown."); } catch (Exception e) {} }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
getsAutoFlushMode();
getsFlushMode();
public void testSecondStatefulInvocationsReusesSession() throws Throwable { newStatefulReadInvocation(); opensSession(); setsFlushMode(); beginsTransaction(2); checksSessionIsOpen(); getsFactoryFromSession(); getsAutoFlushMode(); // invocation here checksSessionIsConnected(); disconnectsSession(); handler.invoke( invocation ); // And a second call should just work. newStatefulReadInvocation(); // invocation here checksSessionIsConnected(); disconnectsSession(); handler.invoke( invocation ); super.verify(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
getsAutoFlushMode();
getsFlushMode();
public void testStatefulInvocationGetsNewSession() throws Throwable { newStatefulReadInvocation(); opensSession(); setsFlushMode(); beginsTransaction(1); checksSessionIsOpen(); getsFactoryFromSession(); getsAutoFlushMode(); // invocation here checksSessionIsConnected(); disconnectsSession(); handler.invoke( invocation ); super.verify(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
getsAutoFlushMode();
getsFlushMode();
public void testStatefulInvocationWithExistingSession() throws Throwable { prepareThreadWithSession(); newStatefulReadInvocation(); checksSessionIsOpen(); checksSessionIsConnected(); getsFactoryFromSession(); getsAutoFlushMode(); disconnectsSession(); closesSession(); handler.invoke( invocation ); super.verify(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
getsAutoFlushMode();
getsFlushMode();
public void testStatefulInvocationWithSessionThenClosed() throws Throwable { newStatefulDestroyInvocation(); checksSessionIsOpen(); getsFactoryFromSession(); getsAutoFlushMode(); setsFlushMode(); opensSession();// setsFlushMode(); TODO huh? beginsTransaction(1); getsSessionsConnection(); commitsConnection(); closesSession(); handler.invoke( invocation ); super.verify(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
getsAutoFlushMode();
getsFlushMode();
public void testStatefulReentrantCallThrows() throws Throwable { Method method = RenderingEngine.class.getMethod("getDefaultZ"); newStatefulInvocation( method, new Stub() { public Object invoke(Invocation dummy) throws Throwable { handler.invoke( invocation ); return null; } public StringBuffer describeTo(StringBuffer buffer) { return buffer.append(" reentrant call "); } }); opensSession(); setsFlushMode(); beginsTransaction(2); checksSessionIsOpen(); getsFactoryFromSession(); getsAutoFlushMode(); // invocation here checksSessionIsConnected(); disconnectsSession(); closesSession(); handler.invoke( invocation ); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/abb75611ecbe8038586bfc5b8903fe7fb0b36a3e/SessionHandlerMockHibernateTest.java/clean/components/server/test/ome/server/utests/handlers/SessionHandlerMockHibernateTest.java
} else { getRuntime().getRuntime().printBug("attachSingletonClass called on a non singleton class.");
public void attachSingletonClass(IRubyObject object) { if (isSingleton()) { setInstanceVariable("__atached__", object); } else { getRuntime().getRuntime().printBug("attachSingletonClass called on a non singleton class."); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/5d81c9b241cfde36fd62602eb41786ab5a0cd134/RubyClass.java/clean/org/jruby/RubyClass.java
return (int) RubyNumeric.fix2int(callMethod("hash"));
return (int) RubyNumeric.fix2long(callMethod("hash"));
public final int hashCode() { return (int) RubyNumeric.fix2int(callMethod("hash")); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/af51f14db0489531b1223e4034f3691e70b94df1/RubyObject.java/clean/src/org/jruby/RubyObject.java
int s = o == runtime.getNil() ? 0 : (int) (RubyNumeric.num2long(o) & 0xffff); encodeShortLittleEndian(result, s); }});
int s = o == runtime.getNil() ? 0 : (int) (RubyNumeric.num2long(o) & 0xffff); encodeShortLittleEndian(result, s); }});
public void encode(IRuby runtime, IRubyObject o, StringBuffer result){ int s = o == runtime.getNil() ? 0 : (int) (RubyNumeric.num2long(o) & 0xffff); encodeShortLittleEndian(result, s); }});
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
this.size = size; }
this.size = size; }
public Converter(int size) { this.size = size; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
StringBuffer result);
StringBuffer result);
public abstract void encode(IRuby runtime, IRubyObject from, StringBuffer result);
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
index -= occurrences;
index -= occurrences;
public void backup(int occurrences) { index -= occurrences; if (index < 0) { throw new IllegalArgumentException(); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
if (index < 0) { throw new IllegalArgumentException(); } }
if (index < 0) { throw new IllegalArgumentException(); } }
public void backup(int occurrences) { index -= occurrences; if (index < 0) { throw new IllegalArgumentException(); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return index; }
return index; }
public int getIndex() { return index; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return buffer.length; }
return buffer.length; }
public int getLength() { return buffer.length; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return index > buffer.length;
return index > buffer.length;
public boolean isAtEnd() { return index > buffer.length; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
if (!Character.isDigit(buffer[i])) {
if (!Character.isDigit(buffer[i])) {
public int nextAsciiNumber() { int i = index; for (; i < buffer.length; i++) { if (!Character.isDigit(buffer[i])) { break; } } // An exception will occur if no number is at ptr.... int number = Integer.parseInt(new String(buffer, index, i - index)); // An exception may occur here if an int can't hold this but ... index = i; return number; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
} }
} }
public int nextAsciiNumber() { int i = index; for (; i < buffer.length; i++) { if (!Character.isDigit(buffer[i])) { break; } } // An exception will occur if no number is at ptr.... int number = Integer.parseInt(new String(buffer, index, i - index)); // An exception may occur here if an int can't hold this but ... index = i; return number; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return number;
return number;
public int nextAsciiNumber() { int i = index; for (; i < buffer.length; i++) { if (!Character.isDigit(buffer[i])) { break; } } // An exception will occur if no number is at ptr.... int number = Integer.parseInt(new String(buffer, index, i - index)); // An exception may occur here if an int can't hold this but ... index = i; return number; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return nextChar() & 0xff; }
return nextChar() & 0xff; }
public int nextByte() { return nextChar() & 0xff; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
char next = '\0'; if (index < buffer.length) { next = buffer[index++]; } else if (index == buffer.length) { index++; } return next; }
char next = '\0'; if (index < buffer.length) { next = buffer[index++]; } else if (index == buffer.length) { index++; } return next; }
public char nextChar() { char next = '\0'; if (index < buffer.length) { next = buffer[index++]; } else if (index == buffer.length) { index++; } return next; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
if (index + length > buffer.length) { throw new IllegalArgumentException(); } String substring = new String(buffer, index, length); index += length; return substring; }
if (index + length > buffer.length) { throw new IllegalArgumentException(); } String substring = new String(buffer, index, length); index += length; return substring; }
public String nextSubstring(int length) { // Cannot get substring off end of buffer if (index + length > buffer.length) { throw new IllegalArgumentException(); } String substring = new String(buffer, index, length); index += length; return substring; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
if (position < buffer.length) { index = position; } }
if (position < buffer.length) { index = position; } }
public void setPosition(int position) { if (position < buffer.length) { index = position; } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
public static void decode(IRuby runtime, PtrList encode, int occurrences, RubyArray result, Converter converter) { int lPadLength = 0; if (occurrences == IS_STAR) { occurrences = encode.remaining() / converter.size; } else if (occurrences > encode.remaining() / converter.size) { lPadLength = occurrences - encode.remaining() / converter.size; occurrences = encode.remaining() / converter.size; } for (; occurrences-- > 0;) { result.append(converter.decode(runtime, encode)); } for (; lPadLength-- > 0;) result.append(runtime.getNil()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return Double.longBitsToDouble(decodeLongBigEndian(encode)); }
return Double.longBitsToDouble(decodeLongBigEndian(encode)); }
private static double decodeDoubleBigEndian(PtrList encode) { return Double.longBitsToDouble(decodeLongBigEndian(encode)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return Double.longBitsToDouble(decodeLongLittleEndian(encode)); }
return Double.longBitsToDouble(decodeLongLittleEndian(encode)); }
private static double decodeDoubleLittleEndian(PtrList encode) { return Double.longBitsToDouble(decodeLongLittleEndian(encode)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return Float.intBitsToFloat(decodeIntBigEndian(encode)); }
return Float.intBitsToFloat(decodeIntBigEndian(encode)); }
private static float decodeFloatBigEndian(PtrList encode) { return Float.intBitsToFloat(decodeIntBigEndian(encode)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return Float.intBitsToFloat(decodeIntLittleEndian(encode)); }
return Float.intBitsToFloat(decodeIntLittleEndian(encode)); }
private static float decodeFloatLittleEndian(PtrList encode) { return Float.intBitsToFloat(decodeIntLittleEndian(encode)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
int c1 = decodeIntBigEndian(encode); int c2 = decodeIntBigEndian(encode); return ((long) c1 << 32) + (c2 & 0xffffffffL); }
int c1 = decodeIntBigEndian(encode); int c2 = decodeIntBigEndian(encode); return ((long) c1 << 32) + (c2 & 0xffffffffL); }
private static long decodeLongBigEndian(PtrList encode) { int c1 = decodeIntBigEndian(encode); int c2 = decodeIntBigEndian(encode); return ((long) c1 << 32) + (c2 & 0xffffffffL); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
int c1 = decodeIntLittleEndian(encode); int c2 = decodeIntLittleEndian(encode);
int c1 = decodeIntLittleEndian(encode); int c2 = decodeIntLittleEndian(encode);
private static long decodeLongLittleEndian(PtrList encode) { int c1 = decodeIntLittleEndian(encode); int c2 = decodeIntLittleEndian(encode); return ((long) c2 << 32) + (c1 & 0xffffffffL); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return ((long) c2 << 32) + (c1 & 0xffffffffL); }
return ((long) c2 << 32) + (c1 & 0xffffffffL); }
private static long decodeLongLittleEndian(PtrList encode) { int c1 = decodeIntLittleEndian(encode); int c2 = decodeIntLittleEndian(encode); return ((long) c2 << 32) + (c1 & 0xffffffffL); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return (short) ((short) (encode.nextByte() << 8) + encode.nextByte()); }
return (short) ((short) (encode.nextByte() << 8) + encode.nextByte()); }
private static short decodeShortBigEndian(PtrList encode) { return (short) ((short) (encode.nextByte() << 8) + encode.nextByte()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return (encode.nextByte() << 8) + encode.nextByte(); }
return (encode.nextByte() << 8) + encode.nextByte(); }
private static int decodeShortUnsignedBigEndian(PtrList encode) { return (encode.nextByte() << 8) + encode.nextByte(); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
return encode.nextByte() + (encode.nextByte() << 8); }
return encode.nextByte() + (encode.nextByte() << 8); }
private static int decodeShortUnsignedLittleEndian(PtrList encode) { return encode.nextByte() + (encode.nextByte() << 8); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
encodeLongBigEndian(result, Double.doubleToLongBits(d)); }
encodeLongBigEndian(result, Double.doubleToLongBits(d)); }
private static void encodeDoubleBigEndian(StringBuffer result, double d) { encodeLongBigEndian(result, Double.doubleToLongBits(d)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
encodeLongLittleEndian(result, Double.doubleToLongBits(d)); }
encodeLongLittleEndian(result, Double.doubleToLongBits(d)); }
private static void encodeDoubleLittleEndian(StringBuffer result, double d) { encodeLongLittleEndian(result, Double.doubleToLongBits(d)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
encodeIntBigEndian(result, Float.floatToIntBits(f)); }
encodeIntBigEndian(result, Float.floatToIntBits(f)); }
private static void encodeFloatBigEndian(StringBuffer result, float f) { encodeIntBigEndian(result, Float.floatToIntBits(f)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
encodeIntLittleEndian(result, Float.floatToIntBits(f)); }
encodeIntLittleEndian(result, Float.floatToIntBits(f)); }
private static void encodeFloatLittleEndian(StringBuffer result, float f) { encodeIntLittleEndian(result, Float.floatToIntBits(f)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
encodeIntBigEndian(result, (int) (l >>> 32)); encodeIntBigEndian(result, (int) (l & 0xffffffff)); }
encodeIntBigEndian(result, (int) (l >>> 32)); encodeIntBigEndian(result, (int) (l & 0xffffffff)); }
private static void encodeLongBigEndian(StringBuffer result, long l) { encodeIntBigEndian(result, (int) (l >>> 32)); encodeIntBigEndian(result, (int) (l & 0xffffffff)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
encodeIntLittleEndian(result, (int) (l & 0xffffffff)); encodeIntLittleEndian(result, (int) (l >>> 32)); }
encodeIntLittleEndian(result, (int) (l & 0xffffffff)); encodeIntLittleEndian(result, (int) (l >>> 32)); }
private static void encodeLongLittleEndian(StringBuffer result, long l) { encodeIntLittleEndian(result, (int) (l & 0xffffffff)); encodeIntLittleEndian(result, (int) (l >>> 32)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
result.append((char) ((s & 0xff00) >> 8)).append((char) (s & 0xff)); }
result.append((char) ((s & 0xff00) >> 8)).append((char) (s & 0xff)); }
private static void encodeShortBigEndian(StringBuffer result, int s) { result.append((char) ((s & 0xff00) >> 8)).append((char) (s & 0xff)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
result.append((char) (s & 0xff)).append((char) ((s & 0xff00) >> 8)); }
result.append((char) (s & 0xff)).append((char) ((s & 0xff00) >> 8)); }
private static void encodeShortLittleEndian(StringBuffer result, int s) { result.append((char) (s & 0xff)).append((char) ((s & 0xff00) >> 8)); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
char next = format.nextChar();
char next = format.nextChar();
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES);
throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES);
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
{ if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); }
{ if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else { result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); }
switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else { result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); }
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) { currentByte |= 128; } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } currentByte >>= 1; }
for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) { currentByte |= 128; } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } currentByte >>= 1; }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
if ((occurrences & 7) != 0) { currentByte >>= 7 - (occurrences & 7); result.append((char) (currentByte & 0xff)); }
if ((occurrences & 7) != 0) { currentByte >>= 7 - (occurrences & 7); result.append((char) (currentByte & 0xff)); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
result.setLength(result.length() + padLength); }
result.setLength(result.length() + padLength); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } currentByte <<= 1; } if ((occurrences & 7) != 0) { currentByte <<= 7 - (occurrences & 7); result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); }
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } currentByte <<= 1; } if ((occurrences & 7) != 0) { currentByte <<= 7 - (occurrences & 7); result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); }
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; }
{ int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; }
public static RubyString pack(List list, RubyString formatString) { IRuby runtime = formatString.getRuntime(); PtrList format = new PtrList(formatString.getValue()); StringBuffer result = new StringBuffer(); int listSize = list.size(); char type = format.nextChar(); int idx = 0; String lCurElemString; while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); if (Character.isWhitespace(type)) { // skip all spaces type = next; continue; } if (next == '!' || next == '_') { if (NATIVE_CODES.indexOf(type) == -1) { throw runtime.newArgumentError("'" + next + "' allowed only after types " + NATIVE_CODES); } next = format.nextChar(); } // Determine how many of type are needed (default: 1) boolean isStar = false; int occurrences = 1; if (next == '*') { if ("@Xxu".indexOf(type) != -1) { occurrences = 0; } else { occurrences = listSize; isStar = true; } next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); // an exception may occur here if an int can't hold this but ... occurrences = format.nextAsciiNumber(); next = format.nextChar(); } Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { idx = encode(runtime, occurrences, result, list, idx, converter); type = next; continue; } switch (type) { case '%' : throw runtime.newArgumentError("% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (isStar) { occurrences = lCurElemString.length(); } switch (type) { case 'a' : case 'A' : case 'Z' : if (lCurElemString.length() >= occurrences) { result.append(lCurElemString.toCharArray(), 0, occurrences); } else {//need padding //I'm fairly sure there is a library call to create a //string filled with a given char with a given length but I couldn't find it result.append(lCurElemString); occurrences -= lCurElemString.length(); grow(result, (type == 'a') ? sNil10 : sSp10, occurrences); } break; //I believe there is a bug in the b and B case we skip a char too easily case 'b' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set currentByte |= 128; //set the high bit of the result } if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte >>= 1; //shift the byte } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } //do some padding, I don't understand the padding strategy result.setLength(result.length() + padLength); } break; case 'B' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { currentByte |= lCurElemString.charAt(i++) & 1; // we filled up current byte; append it and create next one if ((i & 7) == 0) { result.append((char) (currentByte & 0xff)); currentByte = 0; continue; } //if the index is not a multiple of 8, we are not on a byte boundary currentByte <<= 1; } if ((occurrences & 7) != 0) { //if the length is not a multiple of 8 currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'h' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= (((currentChar & 15) + 9) & 15) << 4; } else { currentByte |= (currentChar & 15) << 4; } if ((i & 1) != 0) { currentByte >>= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; case 'H' : { int currentByte = 0; int padLength = 0; if (occurrences > lCurElemString.length()) { padLength = occurrences - lCurElemString.length(); occurrences = lCurElemString.length(); } for (int i = 0; i < occurrences;) { char currentChar = lCurElemString.charAt(i++); if (Character.isJavaIdentifierStart(currentChar)) { //this test may be too lax but it is the same as in MRI currentByte |= ((currentChar & 15) + 9) & 15; } else { currentByte |= currentChar & 15; } if ((i & 1) != 0) { currentByte <<= 4; } else { result.append((char) (currentByte & 0xff)); currentByte = 0; } } if ((occurrences & 1) != 0) { result.append((char) (currentByte & 0xff)); } result.setLength(result.length() + padLength); } break; } break; } case 'x' : grow(result, sNil10, occurrences); break; case 'X' : try { shrink(result, occurrences); } catch (IllegalArgumentException e) { throw runtime.newArgumentError("in `pack': X outside of string"); } break; case '@' : occurrences -= result.length(); if (occurrences > 0) { grow(result, sNil10, occurrences); } occurrences = -occurrences; if (occurrences > 0) { shrink(result, occurrences); } break; case 'u' : case 'm' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); occurrences = occurrences <= 2 ? 45 : occurrences / 3 * 3; for (;;) { encodes(runtime, result, lCurElemString, occurrences, type); if (occurrences >= lCurElemString.length()) { break; } lCurElemString = lCurElemString.substring(occurrences); } } break; case 'M' : { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); lCurElemString = from == runtime.getNil() ? "" : convert2String(from); if (occurrences <= 1) { occurrences = 72; } qpencode(result, lCurElemString, occurrences); } break; case 'U' : char[] c = new char[occurrences]; for (int cIndex = 0; occurrences-- > 0; cIndex++) { if (listSize-- <= 0) { throw runtime.newArgumentError(sTooFew); } IRubyObject from = (IRubyObject) list.get(idx++); long l = from == runtime.getNil() ? 0 : RubyNumeric.num2long(from); c[cIndex] = (char) l; } try { byte[] bytes = new String(c).getBytes("UTF-8"); result.append(RubyString.bytesToString(bytes)); } catch (java.io.UnsupportedEncodingException e) { assert false : "can't convert to UTF8"; } break; } type = next; } return runtime.newString(result.toString()); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/415b1e0db282c02d672a7e34a34a2bea0f69ccb2/Pack.java/clean/src/org/jruby/util/Pack.java