rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
| meta
stringlengths 141
403
|
---|---|---|---|
Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } }; } | Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } }; } | private IProgressMonitor getEventLoopMonitor() { return new EventLoopProgressMonitor(new NullProgressMonitor()) { /* * (non-Javadoc) * * @see org.eclipse.ui.internal.dialogs.EventLoopProgressMonitor#setBlocked(org.eclipse.core.runtime.IStatus) */ public void setBlocked(IStatus reason) { //Set a shell to open with as we want to create this //even if there is a modal shell. Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } }; } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } | Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } | public void setBlocked(IStatus reason) { //Set a shell to open with as we want to create this //even if there is a modal shell. Dialog.getBlockedHandler().showBlocked( ProgressManagerUtil.getDefaultParent(), this, reason, getTaskName()); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
try { manager.beginRule(rule, ((Workbench)PlatformUI.getWorkbench()).isStarting() ? new NullProgressMonitor() : getEventLoopMonitor()); context.run(false, false, runnable); } catch (InvocationTargetException e) { exception[0] = e; } catch (InterruptedException e) { canceled[0] = e; } catch (OperationCanceledException e) { canceled[0] = new InterruptedException(e.getMessage()); } finally { manager.endRule(rule); } } | try { manager.beginRule(rule, ((Workbench) PlatformUI.getWorkbench()) .isStarting() ? new NullProgressMonitor() : getEventLoopMonitor()); context.run(false, false, runnable); } catch (InvocationTargetException e) { exception[0] = e; } catch (InterruptedException e) { canceled[0] = e; } catch (OperationCanceledException e) { canceled[0] = new InterruptedException(e.getMessage()); } finally { manager.endRule(rule); } } | public void run() { try { manager.beginRule(rule, ((Workbench)PlatformUI.getWorkbench()).isStarting() ? new NullProgressMonitor() : getEventLoopMonitor()); context.run(false, false, runnable); } catch (InvocationTargetException e) { exception[0] = e; } catch (InterruptedException e) { canceled[0] = e; } catch (OperationCanceledException e) { canceled[0] = new InterruptedException(e.getMessage()); } finally { manager.endRule(rule); } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
final ProgressMonitorJobsDialog dialog) { | final ProgressMonitorJobsDialog dialog) { | private void scheduleProgressMonitorJob( final ProgressMonitorJobsDialog dialog) { final WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.ProgressManager_openJobName) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { dialog.open(); } return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(getLongOperationTime()); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
final WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.ProgressManager_openJobName) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { | final WorkbenchJob updateJob = new WorkbenchJob( ProgressMessages.ProgressManager_openJobName) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog, null)) { | private void scheduleProgressMonitorJob( final ProgressMonitorJobsDialog dialog) { final WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.ProgressManager_openJobName) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { dialog.open(); } return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(getLongOperationTime()); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(getLongOperationTime()); | return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(getLongOperationTime()); | private void scheduleProgressMonitorJob( final ProgressMonitorJobsDialog dialog) { final WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.ProgressManager_openJobName) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { dialog.open(); } return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(getLongOperationTime()); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
} | } | private void scheduleProgressMonitorJob( final ProgressMonitorJobsDialog dialog) { final WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.ProgressManager_openJobName) { /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { dialog.open(); } return Status.OK_STATUS; } }; updateJob.setSystem(true); updateJob.schedule(getLongOperationTime()); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { | setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog, null)) { | public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { dialog.open(); } return Status.OK_STATUS; } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
return Status.OK_STATUS; } | return Status.OK_STATUS; } | public IStatus runInUIThread(IProgressMonitor monitor) { setUserInterfaceActive(true); if (ProgressManagerUtil.safeToOpen(dialog,null)) { dialog.open(); } return Status.OK_STATUS; } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
public void setShowSystemJobs(boolean showSystem) { ProgressViewUpdater updater = ProgressViewUpdater.getSingleton(); updater.debug = showSystem; updater.refreshAll(); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
||
throws MalformedURLException { JFaceResources.getImageRegistry().put(key, ImageDescriptor.createFromURL(new URL(iconsRoot, fileName))); } | throws MalformedURLException { JFaceResources.getImageRegistry().put(key, ImageDescriptor.createFromURL(new URL(iconsRoot, fileName))); } | private void setUpImage(URL iconsRoot, String fileName, String key) throws MalformedURLException { JFaceResources.getImageRegistry().put(key, ImageDescriptor.createFromURL(new URL(iconsRoot, fileName))); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
IWorkbench workbench = PlatformUI.getWorkbench(); Shell[] shells = workbench.getDisplay().getShells(); if (active) { for (int i = 0; i < shells.length; i++) { shells[i].setEnabled(active); } } else { for (int i = shells.length-1; i >= 0; i--) { shells[i].setEnabled(active); } } } | IWorkbench workbench = PlatformUI.getWorkbench(); Shell[] shells = workbench.getDisplay().getShells(); if (active) { for (int i = 0; i < shells.length; i++) { shells[i].setEnabled(active); } } else { for (int i = shells.length - 1; i >= 0; i--) { shells[i].setEnabled(active); } } } | private void setUserInterfaceActive(boolean active) { IWorkbench workbench = PlatformUI.getWorkbench(); Shell[] shells = workbench.getDisplay().getShells(); if (active) { for (int i = 0; i < shells.length; i++) { shells[i].setEnabled(active); } } else { // Deactive shells in reverse order for (int i = shells.length-1; i >= 0; i--) { shells[i].setEnabled(active); } } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
return WorkbenchPlugin.getDefault().getPreferenceStore().getBoolean( IPreferenceConstants.RUN_IN_BACKGROUND); } | return WorkbenchPlugin.getDefault().getPreferenceStore().getBoolean( IPreferenceConstants.RUN_IN_BACKGROUND); } | private boolean shouldRunInBackground() { return WorkbenchPlugin.getDefault().getPreferenceStore().getBoolean( IPreferenceConstants.RUN_IN_BACKGROUND); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
if (shouldRunInBackground()) { | if (shouldRunInBackground()) { | public void showInDialog(Shell shell, Job job) { if (shouldRunInBackground()) { return; } final ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog( shell); dialog.show(job,shell); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
final ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog( shell); dialog.show(job,shell); } | final ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog( shell); dialog.show(job, shell); } | public void showInDialog(Shell shell, Job job) { if (shouldRunInBackground()) { return; } final ProgressMonitorFocusJobDialog dialog = new ProgressMonitorFocusJobDialog( shell); dialog.show(job,shell); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
synchronized (listenersKey) { this.listeners = new IJobProgressManagerListener[0]; } Platform.getJobManager().setProgressProvider(null); Platform.getJobManager().removeJobChangeListener(this.changeListener); } | synchronized (listenersKey) { this.listeners = new IJobProgressManagerListener[0]; } Platform.getJobManager().setProgressProvider(null); Platform.getJobManager().removeJobChangeListener(this.changeListener); } | private void shutdown() { synchronized (listenersKey) { this.listeners = new IJobProgressManagerListener[0]; } Platform.getJobManager().setProgressProvider(null); Platform.getJobManager().removeJobChangeListener(this.changeListener); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
if (singleton == null) { | if (singleton == null) { | public static void shutdownProgressManager() { if (singleton == null) { return; } singleton.shutdown(); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
singleton.shutdown(); } | singleton.shutdown(); } | public static void shutdownProgressManager() { if (singleton == null) { return; } singleton.shutdown(); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/9f68fc05c49b144eebae1957b15f8f3671c54cac/ProgressManager.java/buggy/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
setModified(true); | public void setCompanyId(String companyId) { if (((companyId == null) && (_companyId != null)) || ((companyId != null) && (_companyId == null)) || ((companyId != null) && (_companyId != null) && !companyId.equals(_companyId))) { if (!XSS_ALLOW_COMPANYID) { companyId = XSSUtil.strip(companyId); } _companyId = companyId; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
setModified(true); | public void setModifiedDate(Date modifiedDate) { if (((modifiedDate == null) && (_modifiedDate != null)) || ((modifiedDate != null) && (_modifiedDate == null)) || ((modifiedDate != null) && (_modifiedDate != null) && !modifiedDate.equals(_modifiedDate))) { _modifiedDate = modifiedDate; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
setModified(true); | public void setRemoteAddr(String remoteAddr) { if (((remoteAddr == null) && (_remoteAddr != null)) || ((remoteAddr != null) && (_remoteAddr == null)) || ((remoteAddr != null) && (_remoteAddr != null) && !remoteAddr.equals(_remoteAddr))) { if (!XSS_ALLOW_REMOTEADDR) { remoteAddr = XSSUtil.strip(remoteAddr); } _remoteAddr = remoteAddr; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
setModified(true); | public void setRemoteHost(String remoteHost) { if (((remoteHost == null) && (_remoteHost != null)) || ((remoteHost != null) && (_remoteHost == null)) || ((remoteHost != null) && (_remoteHost != null) && !remoteHost.equals(_remoteHost))) { if (!XSS_ALLOW_REMOTEHOST) { remoteHost = XSSUtil.strip(remoteHost); } _remoteHost = remoteHost; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
setModified(true); | public void setUserAgent(String userAgent) { if (((userAgent == null) && (_userAgent != null)) || ((userAgent != null) && (_userAgent == null)) || ((userAgent != null) && (_userAgent != null) && !userAgent.equals(_userAgent))) { if (!XSS_ALLOW_USERAGENT) { userAgent = XSSUtil.strip(userAgent); } _userAgent = userAgent; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
setModified(true); | public void setUserId(String userId) { if (((userId == null) && (_userId != null)) || ((userId != null) && (_userId == null)) || ((userId != null) && (_userId != null) && !userId.equals(_userId))) { if (!XSS_ALLOW_USERID) { userId = XSSUtil.strip(userId); } _userId = userId; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
setModified(true); | public void setUserTrackerId(String userTrackerId) { if (((userTrackerId == null) && (_userTrackerId != null)) || ((userTrackerId != null) && (_userTrackerId == null)) || ((userTrackerId != null) && (_userTrackerId != null) && !userTrackerId.equals(_userTrackerId))) { if (!XSS_ALLOW_USERTRACKERID) { userTrackerId = XSSUtil.strip(userTrackerId); } _userTrackerId = userTrackerId; setModified(true); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/UserTrackerModel.java/buggy/portal-ejb/src/com/liferay/portal/model/UserTrackerModel.java |
|
if (changeListeners == null) { boolean hadListeners = hasListeners(); changeListeners = listener; if (!hadListeners) { firstListenerAdded(); } return; } Collection listenerList; if (changeListeners instanceof IChangeListener) { IChangeListener l = (IChangeListener) changeListeners; listenerList = new ArrayList(); listenerList.add(l); changeListeners = listenerList; } else { listenerList = (Collection) changeListeners; } listenerList.add(listener); | changeSupport.addChangeListener(listener); | public synchronized void addChangeListener(IChangeListener listener) { if (changeListeners == null) { boolean hadListeners = hasListeners(); changeListeners = listener; if (!hadListeners) { firstListenerAdded(); } return; } Collection listenerList; if (changeListeners instanceof IChangeListener) { IChangeListener l = (IChangeListener) changeListeners; listenerList = new ArrayList(); listenerList.add(l); changeListeners = listenerList; } else { listenerList = (Collection) changeListeners; } listenerList.add(listener); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (listChangeListeners == null) { boolean hadListeners = hasListeners(); listChangeListeners = listener; if (!hadListeners) { firstListenerAdded(); } return; } Collection listenerList; if (listChangeListeners instanceof Collection) { listenerList = (Collection) listChangeListeners; } else { IListChangeListener l = (IListChangeListener) listChangeListeners; listenerList = new ArrayList(); listenerList.add(l); listChangeListeners = listenerList; } listenerList.add(listener); | changeSupport.addListener(ListChangeEvent.TYPE, listener); | public synchronized void addListChangeListener(IListChangeListener listener) { if (listChangeListeners == null) { boolean hadListeners = hasListeners(); listChangeListeners = listener; if (!hadListeners) { firstListenerAdded(); } return; } Collection listenerList; if (listChangeListeners instanceof Collection) { listenerList = (Collection) listChangeListeners; } else { IListChangeListener l = (IListChangeListener) listChangeListeners; listenerList = new ArrayList(); listenerList.add(l); listChangeListeners = listenerList; } listenerList.add(listener); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (staleListeners == null) { boolean hadListeners = hasListeners(); staleListeners = listener; if (!hadListeners) { firstListenerAdded(); } return; } Collection listenerList; if (staleListeners instanceof IStaleListener) { IStaleListener l = (IStaleListener) staleListeners; listenerList = new ArrayList(); listenerList.add(l); staleListeners = listenerList; } else { listenerList = (Collection) staleListeners; } listenerList.add(listener); | changeSupport.addStaleListener(listener); | public synchronized void addStaleListener(IStaleListener listener) { if (staleListeners == null) { boolean hadListeners = hasListeners(); staleListeners = listener; if (!hadListeners) { firstListenerAdded(); } return; } Collection listenerList; if (staleListeners instanceof IStaleListener) { IStaleListener l = (IStaleListener) staleListeners; listenerList = new ArrayList(); listenerList.add(l); staleListeners = listenerList; } else { listenerList = (Collection) staleListeners; } listenerList.add(listener); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
listChangeListeners = null; changeListeners = null; staleListeners = null; | changeSupport = null; | public synchronized void dispose() { listChangeListeners = null; changeListeners = null; staleListeners = null; lastListenerRemoved(); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (changeListeners == null) { return; } if (changeListeners instanceof IChangeListener) { ((IChangeListener) changeListeners).handleChange(this); return; } Collection changeListenerCollection = (Collection) changeListeners; IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection) .toArray(new IChangeListener[changeListenerCollection.size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleChange(this); } | changeSupport.fireEvent(new ChangeEvent(this)); | protected void fireChange() { checkRealm(); if (changeListeners == null) { return; } if (changeListeners instanceof IChangeListener) { ((IChangeListener) changeListeners).handleChange(this); return; } Collection changeListenerCollection = (Collection) changeListeners; IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection) .toArray(new IChangeListener[changeListenerCollection.size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleChange(this); } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (listChangeListeners == null) { return; } if (listChangeListeners instanceof IListChangeListener) { ((IListChangeListener) listChangeListeners).handleListChange(this, diff); return; } Collection changeListenerCollection = (Collection) listChangeListeners; IListChangeListener[] listeners = (IListChangeListener[]) (changeListenerCollection) .toArray(new IListChangeListener[changeListenerCollection .size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleListChange(this, diff); } | changeSupport.fireEvent(new ListChangeEvent(this, diff)); | protected void fireListChange(ListDiff diff) { // fire general change event first fireChange(); if (listChangeListeners == null) { return; } if (listChangeListeners instanceof IListChangeListener) { ((IListChangeListener) listChangeListeners).handleListChange(this, diff); return; } Collection changeListenerCollection = (Collection) listChangeListeners; IListChangeListener[] listeners = (IListChangeListener[]) (changeListenerCollection) .toArray(new IListChangeListener[changeListenerCollection .size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleListChange(this, diff); } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (staleListeners == null) { return; } if (staleListeners instanceof IChangeListener) { ((IChangeListener) staleListeners).handleChange(this); return; } Collection changeListenerCollection = (Collection) staleListeners; IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection) .toArray(new IChangeListener[changeListenerCollection.size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleChange(this); } | changeSupport.fireEvent(new StaleEvent(this)); | protected void fireStale() { checkRealm(); if (staleListeners == null) { return; } if (staleListeners instanceof IChangeListener) { ((IChangeListener) staleListeners).handleChange(this); return; } Collection changeListenerCollection = (Collection) staleListeners; IChangeListener[] listeners = (IChangeListener[]) (changeListenerCollection) .toArray(new IChangeListener[changeListenerCollection.size()]); for (int i = 0; i < listeners.length; i++) { listeners[i].handleChange(this); } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (changeListeners == listener) { changeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } return; } if (changeListeners instanceof Collection) { Collection listenerList = (Collection) changeListeners; listenerList.remove(listener); if (listenerList.isEmpty()) { changeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } } } | changeSupport.removeChangeListener(listener); | public synchronized void removeChangeListener(IChangeListener listener) { if (changeListeners == listener) { changeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } return; } if (changeListeners instanceof Collection) { Collection listenerList = (Collection) changeListeners; listenerList.remove(listener); if (listenerList.isEmpty()) { changeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } } } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (listChangeListeners == listener) { listChangeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } return; } if (listChangeListeners instanceof Collection) { Collection listenerList = (Collection) listChangeListeners; listenerList.remove(listener); if (listenerList.isEmpty()) { listChangeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } } } | changeSupport.removeListener(ListChangeEvent.TYPE, listener); | public synchronized void removeListChangeListener(IListChangeListener listener) { if (listChangeListeners == listener) { listChangeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } return; } if (listChangeListeners instanceof Collection) { Collection listenerList = (Collection) listChangeListeners; listenerList.remove(listener); if (listenerList.isEmpty()) { listChangeListeners = null; if (!hasListeners()) { lastListenerRemoved(); } } } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (staleListeners == listener) { staleListeners = null; if (!hasListeners()) { lastListenerRemoved(); } return; } if (staleListeners instanceof Collection) { Collection listenerList = (Collection) staleListeners; listenerList.remove(listener); if (listenerList.isEmpty()) { staleListeners = null; if (!hasListeners()) { lastListenerRemoved(); } } } | changeSupport.removeStaleListener(listener); | public synchronized void removeStaleListener(IStaleListener listener) { if (staleListeners == listener) { staleListeners = null; if (!hasListeners()) { lastListenerRemoved(); } return; } if (staleListeners instanceof Collection) { Collection listenerList = (Collection) staleListeners; listenerList.remove(listener); if (listenerList.isEmpty()) { staleListeners = null; if (!hasListeners()) { lastListenerRemoved(); } } } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/6aecdb31231a8602dbf72944625703c440949c78/AbstractObservableList.java/clean/bundles/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/AbstractObservableList.java |
if (passwordTracker.isNew() || passwordTracker.isModified()) { session = openSession(); if (passwordTracker.isNew()) { PasswordTracker passwordTrackerModel = new PasswordTracker(); passwordTrackerModel.setPasswordTrackerId(passwordTracker.getPasswordTrackerId()); passwordTrackerModel.setUserId(passwordTracker.getUserId()); passwordTrackerModel.setCreateDate(passwordTracker.getCreateDate()); passwordTrackerModel.setPassword(passwordTracker.getPassword()); session.save(passwordTrackerModel); session.flush(); } else { PasswordTracker passwordTrackerModel = (PasswordTracker)session.get(PasswordTracker.class, passwordTracker.getPrimaryKey()); if (passwordTrackerModel != null) { passwordTrackerModel.setUserId(passwordTracker.getUserId()); passwordTrackerModel.setCreateDate(passwordTracker.getCreateDate()); passwordTrackerModel.setPassword(passwordTracker.getPassword()); session.flush(); } else { passwordTrackerModel = new PasswordTracker(); passwordTrackerModel.setPasswordTrackerId(passwordTracker.getPasswordTrackerId()); passwordTrackerModel.setUserId(passwordTracker.getUserId()); passwordTrackerModel.setCreateDate(passwordTracker.getCreateDate()); passwordTrackerModel.setPassword(passwordTracker.getPassword()); session.save(passwordTrackerModel); session.flush(); } } passwordTracker.setNew(false); passwordTracker.setModified(false); } | session = openSession(); session.saveOrUpdate(passwordTracker); session.flush(); passwordTracker.setNew(false); | public com.liferay.portal.model.PasswordTracker update( com.liferay.portal.model.PasswordTracker passwordTracker) throws SystemException { Session session = null; try { if (passwordTracker.isNew() || passwordTracker.isModified()) { session = openSession(); if (passwordTracker.isNew()) { PasswordTracker passwordTrackerModel = new PasswordTracker(); passwordTrackerModel.setPasswordTrackerId(passwordTracker.getPasswordTrackerId()); passwordTrackerModel.setUserId(passwordTracker.getUserId()); passwordTrackerModel.setCreateDate(passwordTracker.getCreateDate()); passwordTrackerModel.setPassword(passwordTracker.getPassword()); session.save(passwordTrackerModel); session.flush(); } else { PasswordTracker passwordTrackerModel = (PasswordTracker)session.get(PasswordTracker.class, passwordTracker.getPrimaryKey()); if (passwordTrackerModel != null) { passwordTrackerModel.setUserId(passwordTracker.getUserId()); passwordTrackerModel.setCreateDate(passwordTracker.getCreateDate()); passwordTrackerModel.setPassword(passwordTracker.getPassword()); session.flush(); } else { passwordTrackerModel = new PasswordTracker(); passwordTrackerModel.setPasswordTrackerId(passwordTracker.getPasswordTrackerId()); passwordTrackerModel.setUserId(passwordTracker.getUserId()); passwordTrackerModel.setCreateDate(passwordTracker.getCreateDate()); passwordTrackerModel.setPassword(passwordTracker.getPassword()); session.save(passwordTrackerModel); session.flush(); } } passwordTracker.setNew(false); passwordTracker.setModified(false); } return passwordTracker; } catch (HibernateException he) { throw new SystemException(he); } finally { closeSession(session); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/PasswordTrackerPersistence.java/clean/portal-ejb/src/com/liferay/portal/service/persistence/PasswordTrackerPersistence.java |
return RubyFixnum.newFixnum(runtime, | return runtime.newFixnum( | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, decodeShortUnsignedLittleEndian(enc)); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, | return runtime.newFixnum( | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, decodeIntUnsignedLittleEndian(enc)); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, | return runtime.newFixnum( | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, decodeIntUnsignedBigEndian(enc)); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, decodeIntBigEndian(enc)); | return runtime.newFixnum(decodeIntBigEndian(enc)); | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, decodeIntBigEndian(enc)); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, decodeShortBigEndian(enc)); | return runtime.newFixnum(decodeShortBigEndian(enc)); | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, decodeShortBigEndian(enc)); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, | return runtime.newFixnum( | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, decodeShortUnsignedBigEndian(enc)); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, c > (char) 127 ? c-256 : c); | return runtime.newFixnum(c > (char) 127 ? c-256 : c); | public IRubyObject decode(Ruby runtime, PtrList enc) { int c = enc.nextChar(); return RubyFixnum.newFixnum(runtime, c > (char) 127 ? c-256 : c); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyFixnum.newFixnum(runtime, enc.nextChar()); | return runtime.newFixnum(enc.nextChar()); | public IRubyObject decode(Ruby runtime, PtrList enc) { return RubyFixnum.newFixnum(runtime, enc.nextChar()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, sTooFew); | throw runtime.newArgumentError(sTooFew); | public static int encode(Ruby runtime, int occurrences, StringBuffer result, List list, int index, Converter converter) { int listSize = list.size(); while (occurrences-- > 0) { if (listSize-- <= 0) { throw new ArgumentError(runtime, sTooFew); } IRubyObject from = (IRubyObject) list.get(index++); converter.encode(runtime, from, result); } return index; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError( runtime, | throw runtime.newArgumentError( | private static StringBuffer encodes(Ruby runtime, StringBuffer io2Append, String i2Encode, int iLength, char iType) { iLength = iLength < i2Encode.length() ? iLength : i2Encode.length(); io2Append.ensureCapacity(iLength * 4 / 3 + 6); int i = 0; char[] lTranslationTable = iType == 'u' ? uu_table : b64_table; char lPadding; char[] l2Encode = i2Encode.toCharArray(); if (iType == 'u') { if (iLength >= lTranslationTable.length) { throw new ArgumentError( runtime, "" + iLength + " is not a correct value for the number of bytes per line in a u directive. Correct values range from 0 to " + lTranslationTable.length); } io2Append.append(lTranslationTable[iLength]); lPadding = '`'; } else { lPadding = '='; } while (iLength >= 3) { char lCurChar = l2Encode[i++]; char lNextChar = l2Encode[i++]; char lNextNextChar = l2Encode[i++]; io2Append.append(lTranslationTable[077 & (lCurChar >>> 2)]); io2Append.append(lTranslationTable[077 & (((lCurChar << 4) & 060) | ((lNextChar >>> 4) & 017))]); io2Append.append(lTranslationTable[077 & (((lNextChar << 2) & 074) | ((lNextNextChar >>> 6) & 03))]); io2Append.append(lTranslationTable[077 & lNextNextChar]); iLength -= 3; } if (iLength == 2) { char lCurChar = l2Encode[i++]; char lNextChar = l2Encode[i++]; io2Append.append(lTranslationTable[077 & (lCurChar >>> 2)]); io2Append.append(lTranslationTable[077 & (((lCurChar << 4) & 060) | ((lNextChar >> 4) & 017))]); io2Append.append(lTranslationTable[077 & (((lNextChar << 2) & 074) | (('\0' >> 6) & 03))]); io2Append.append(lPadding); } else if (iLength == 1) { char lCurChar = l2Encode[i++]; io2Append.append(lTranslationTable[077 & (lCurChar >>> 2)]); io2Append.append(lTranslationTable[077 & (((lCurChar << 4) & 060) | (('\0' >>> 4) & 017))]); io2Append.append(lPadding); io2Append.append(lPadding); } io2Append.append('\n'); return io2Append; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "'" + next + | throw runtime.newArgumentError("'" + next + | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "% is not supported"); | throw runtime.newArgumentError("% is not supported"); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, sTooFew); | throw runtime.newArgumentError(sTooFew); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "in `pack': X outside of string"); | throw runtime.newArgumentError("in `pack': X outside of string"); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, sTooFew); | throw runtime.newArgumentError(sTooFew); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, sTooFew); | throw runtime.newArgumentError(sTooFew); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, sTooFew); | throw runtime.newArgumentError(sTooFew); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return RubyString.newString(runtime, result.toString()); | return runtime.newString(result.toString()); | public static RubyString pack(List list, RubyString formatString) { Ruby runtime = formatString.getRuntime(); PtrList format = new PtrList(runtime, 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 new ArgumentError(runtime, "'" + 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 new ArgumentError(runtime, "% is not supported"); case 'A' : case 'a' : case 'Z' : case 'B' : case 'b' : case 'H' : case 'h' : { if (listSize-- <= 0) { throw new ArgumentError(runtime, 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 new ArgumentError(runtime, "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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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 new ArgumentError(runtime, 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) { Asserts.notReached("can't convert to UTF8"); } break; } type = next; } return RubyString.newString(runtime, result.toString()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
RubyArray result = RubyArray.newArray(runtime); | RubyArray result = runtime.newArray(); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "'" + next + | throw runtime.newArgumentError("'" + next + | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "% is not supported"); | throw runtime.newArgumentError("% is not supported"); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, potential)); | result.append(runtime.newString(potential)); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, potential)); | result.append(runtime.newString(potential)); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); | result.append(runtime.newString(encode.nextSubstring(occurrences))); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, lElem.toString())); | result.append(runtime.newString(lElem.toString())); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, lElem.toString())); | result.append(runtime.newString(lElem.toString())); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, lElem.toString())); | result.append(runtime.newString(lElem.toString())); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyString.newString(runtime, lElem.toString())); | result.append(runtime.newString(lElem.toString())); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); | result.append(runtime.newFixnum(c[lCurCharIdx])); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "in `unpack': X outside of string"); | throw runtime.newArgumentError("in `unpack': X outside of string"); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
throw new ArgumentError(runtime, "in `unpack': x outside of string"); | throw runtime.newArgumentError("in `unpack': x outside of string"); | public static RubyArray unpack(String encodedString, RubyString formatString) { Ruby runtime = formatString.getRuntime(); RubyArray result = RubyArray.newArray(runtime); PtrList format = new PtrList(runtime, formatString.getValue()); PtrList encode = new PtrList(runtime, encodedString); char type = format.nextChar(); // Type to be unpacked while(!format.isAtEnd()) { // Possible next type, format of current type, occurrences of type char next = format.nextChar(); // Next indicates to decode using native encoding format if (next == '_' || next == '!') { if (NATIVE_CODES.indexOf(type) == -1) { throw new ArgumentError(runtime, "'" + next + "' allowed only after types " + NATIVE_CODES); } // We advance in case occurences follows next = format.nextChar(); } // How many occurrences of 'type' we want int occurrences = 0; if (format.isAtEnd()) { occurrences = 1; } else if (next == '*') { occurrences = IS_STAR; next = format.nextChar(); } else if (Character.isDigit(next)) { format.backup(1); occurrences = format.nextAsciiNumber(); next = format.nextChar(); } else { occurrences = type == '@' ? 0 : 1; } // See if we have a converter for the job... Converter converter = (Converter) converters.get(new Character(type)); if (converter != null) { decode(runtime, encode, occurrences, result, converter); type = next; continue; } // Otherwise the unpack should be here... switch (type) { case '@' : encode.setPosition(occurrences); break; case '%' : throw new ArgumentError(runtime, "% is not supported"); case 'A' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0' && c != ' ') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'Z' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } String potential = encode.nextSubstring(occurrences); for (int t = occurrences - 1; occurrences > 0; occurrences--, t--) { char c = potential.charAt(t); if (c != '\0') { break; } } potential = potential.substring(0, occurrences); result.append(RubyString.newString(runtime, potential)); } break; case 'a' : if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } result.append(RubyString.newString(runtime, encode.nextSubstring(occurrences))); break; case 'b' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) { bits >>>= 1; } else { bits = encode.nextChar(); } lElem.append((bits & 1) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'B' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 8) { occurrences = encode.remaining() * 8; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 7) != 0) bits <<= 1; else bits = encode.nextChar(); lElem.append((bits & 128) != 0 ? '1' : '0'); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'h' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) { bits >>>= 4; } else { bits = encode.nextChar(); } lElem.append(sHexDigits[bits & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'H' : { if (occurrences == IS_STAR || occurrences > encode.remaining() * 2) { occurrences = encode.remaining() * 2; } int bits = 0; StringBuffer lElem = new StringBuffer(occurrences); for (int lCurByte = 0; lCurByte < occurrences; lCurByte++) { if ((lCurByte & 1) != 0) bits <<= 4; else bits = encode.nextChar(); lElem.append(sHexDigits[(bits >>> 4) & 15]); } result.append(RubyString.newString(runtime, lElem.toString())); } break; case 'U' : { if (occurrences == IS_STAR || occurrences > encode.remaining()) { occurrences = encode.remaining(); } //get the correct substring String toUnpack = encode.nextSubstring(occurrences); String lUtf8 = null; try { lUtf8 = new String(toUnpack.getBytes("iso8859-1"), "UTF-8"); } catch (java.io.UnsupportedEncodingException e) { Asserts.notReached("can't convert from UTF8"); } char[] c = lUtf8.toCharArray(); for (int lCurCharIdx = 0; occurrences-- > 0 && lCurCharIdx < c.length; lCurCharIdx++) result.append(RubyFixnum.newFixnum(runtime, c[lCurCharIdx])); } break; case 'X': if (occurrences == IS_STAR) { occurrences = encode.getLength() - encode.remaining(); } try { encode.backup(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': X outside of string"); } break; case 'x': if (occurrences == IS_STAR) { occurrences = encode.remaining(); } try { encode.nextSubstring(occurrences); } catch (IllegalArgumentException e) { throw new ArgumentError(runtime, "in `unpack': x outside of string"); } break; } type = next; } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/870e1da9b41bfdbae259e1fc5f18fc8b76686998/Pack.java/buggy/src/org/jruby/util/Pack.java |
return lineHeight(context, style); | return lineHeight(context); | public static int fontXHeightForElement(Context context, CalculatedStyle style) { return lineHeight(context, style); } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/71b2cfce5b6554582e24848d6c3702480ac8ba6c/FontUtil.java/buggy/src/java/org/xhtmlrenderer/layout/FontUtil.java |
return getFont(c, style); | Font f = c.getGraphics().getFont(); if (quick) { return f; } float size = style.propertyByName(CSSName.FONT_SIZE).computedValue().asFloat(); String weight = style.propertyByName(CSSName.FONT_WEIGHT).computedValue().asString(); String[] families = style.propertyByName(CSSName.FONT_FAMILY).computedValue().asStringArray(); String fstyle = style.propertyByName(CSSName.FONT_STYLE).computedValue().asString(); String variant = style.propertyByName(CSSName.FONT_VARIANT).computedValue().asString(); f = c.getFontResolver().resolveFont(c, families, size, weight, fstyle, variant); return f; | public static Font getFont(Context c) { CalculatedStyle style = c.getCurrentStyle(); return getFont(c, style); } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/71b2cfce5b6554582e24848d6c3702480ac8ba6c/FontUtil.java/buggy/src/java/org/xhtmlrenderer/layout/FontUtil.java |
CalculatedStyle style = c.getCurrentStyle(); | public static Rectangle2D getTextBounds(Context c, InlineTextBox box) { CalculatedStyle style = c.getCurrentStyle(); return c.getTextRenderer().getLogicalBounds(c.getGraphics(), getFont(c, style), box.getSubstring()); } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/71b2cfce5b6554582e24848d6c3702480ac8ba6c/FontUtil.java/buggy/src/java/org/xhtmlrenderer/layout/FontUtil.java |
|
getFont(c, style), box.getSubstring()); | getFont(c), box.getSubstring()); | public static Rectangle2D getTextBounds(Context c, InlineTextBox box) { CalculatedStyle style = c.getCurrentStyle(); return c.getTextRenderer().getLogicalBounds(c.getGraphics(), getFont(c, style), box.getSubstring()); } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/71b2cfce5b6554582e24848d6c3702480ac8ba6c/FontUtil.java/buggy/src/java/org/xhtmlrenderer/layout/FontUtil.java |
public static int lineHeight(Context c, CalculatedStyle style) { int val = (int) Math.ceil(c.getTextRenderer().getLogicalBounds(c.getGraphics(), getFont(c, style), "Test").getHeight()); if (style.hasProperty(CSSName.LINE_HEIGHT)) { | public static int lineHeight(Context c) { CalculatedStyle style = c.getCurrentStyle(); int val = (int) Math.ceil(c.getTextRenderer().getLogicalBounds(c.getGraphics(), getFont(c), "Test").getHeight()); if (!style.propertyByName(CSSName.LINE_HEIGHT).computedValue().cssValue().getCssText().equals("normal")) { | public static int lineHeight(Context c, CalculatedStyle style) { int val = (int) Math.ceil(c.getTextRenderer().getLogicalBounds(c.getGraphics(), getFont(c, style), "Test").getHeight()); if (style.hasProperty(CSSName.LINE_HEIGHT)) { val = (int) style.getFloatPropertyRelative(CSSName.LINE_HEIGHT, val); } return val; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/71b2cfce5b6554582e24848d6c3702480ac8ba6c/FontUtil.java/buggy/src/java/org/xhtmlrenderer/layout/FontUtil.java |
Iterator startListeners = busyListenersForJob(event.getJob()).iterator(); while(startListeners.hasNext()){ IJobBusyListener next = (IJobBusyListener) startListeners.next(); next.decrementBusy(event.getJob()); } | private void createChangeListener() { changeListener = new JobChangeAdapter() { /* * (non-Javadoc) * * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent) */ public void aboutToRun(IJobChangeEvent event) { JobInfo info = getJobInfo(event.getJob()); refreshJobInfo(info); if (event.getJob().isUser()) { boolean inDialog = WorkbenchPlugin .getDefault() .getPreferenceStore() .getBoolean( IPreferenceConstants.SHOW_USER_JOBS_IN_DIALOG); if (inDialog) new ProgressMonitorFocusJobDialog(null, event .getJob()).scheduleOpen(); } } /* * (non-Javadoc) * * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#done(org.eclipse.core.runtime.jobs.IJobChangeEvent) */ public void done(IJobChangeEvent event) { if (!PlatformUI.isWorkbenchRunning()) return; JobInfo info = getJobInfo(event.getJob()); if (event.getResult().getSeverity() == IStatus.ERROR) { errorManager.addError(event.getResult(), event.getJob() .getName()); } jobs.remove(event.getJob()); //Only refresh if we are showing it removeJobInfo(info); //If there are no more left then refresh all on the last // displayed one if (hasNoRegularJobInfos() && !isNonDisplayableJob(event.getJob(), false)) refreshAll(); } /* * (non-Javadoc) * * @see org.eclipse.core.runtime.jobs.JobChangeAdapter#scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent) */ public void scheduled(IJobChangeEvent event) { if (isNeverDisplayedJob(event.getJob())) return; if (jobs.containsKey(event.getJob())) refreshJobInfo(getJobInfo(event.getJob())); else { addJobInfo(new JobInfo(event.getJob())); } } }; } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/cd7c319063c31bff9b7288c8ad799363b2c3f2b1/ProgressManager.java/clean/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
|
Iterator startListeners = busyListenersForJob(event.getJob()).iterator(); while(startListeners.hasNext()){ IJobBusyListener next = (IJobBusyListener) startListeners.next(); next.incrementBusy(event.getJob()); } | public void aboutToRun(IJobChangeEvent event) { JobInfo info = getJobInfo(event.getJob()); refreshJobInfo(info); if (event.getJob().isUser()) { boolean inDialog = WorkbenchPlugin .getDefault() .getPreferenceStore() .getBoolean( IPreferenceConstants.SHOW_USER_JOBS_IN_DIALOG); if (inDialog) new ProgressMonitorFocusJobDialog(null, event .getJob()).scheduleOpen(); } } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/cd7c319063c31bff9b7288c8ad799363b2c3f2b1/ProgressManager.java/clean/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
|
Iterator startListeners = busyListenersForJob(event.getJob()).iterator(); while(startListeners.hasNext()){ IJobBusyListener next = (IJobBusyListener) startListeners.next(); next.decrementBusy(event.getJob()); } | public void done(IJobChangeEvent event) { if (!PlatformUI.isWorkbenchRunning()) return; JobInfo info = getJobInfo(event.getJob()); if (event.getResult().getSeverity() == IStatus.ERROR) { errorManager.addError(event.getResult(), event.getJob() .getName()); } jobs.remove(event.getJob()); //Only refresh if we are showing it removeJobInfo(info); //If there are no more left then refresh all on the last // displayed one if (hasNoRegularJobInfos() && !isNonDisplayableJob(event.getJob(), false)) refreshAll(); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/cd7c319063c31bff9b7288c8ad799363b2c3f2b1/ProgressManager.java/clean/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java |
|
allWhitespace = false; | public static List stripInlineContent(Context c, List inlineContent) { List stripped = new LinkedList(); List pendingStylePushes = new LinkedList(); boolean collapse = false; boolean allWhitespace = true; for (Iterator i = inlineContent.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof StylePush) { pendingStylePushes.add(o); c.pushStyle(((StylePush) o).getStyle()); continue; } if (o instanceof TextContent) { TextContent tc = (TextContent) o; CalculatedStyle style = c.getCurrentStyle(); boolean collapseNext = stripWhitespace(style, collapse, tc); if (!tc.isRemovableWhitespace()) { allWhitespace = false; } stripped.addAll(pendingStylePushes); pendingStylePushes.clear(); stripped.add(tc); collapse = collapseNext; continue; } if (o instanceof StylePop) { c.popStyle(); if (pendingStylePushes.size() != 0) { //redundant style-change pendingStylePushes.remove(pendingStylePushes.size() - 1); } else { stripped.add(o); } continue; } //Here we have some other object, just add it with preceding styles allWhitespace = false; stripped.addAll(pendingStylePushes); pendingStylePushes.clear(); stripped.add(o); collapse = false;//no collapsing of the next one } //there may be relevant StylePushes pending, e.g. if this is content of AnonymousBlock stripped.addAll(pendingStylePushes); // Uu.p("final stripped = " + stripped); // Uu.p("all whitespace = " + allWhitespace); if (allWhitespace) { stripWhitespaceContent(stripped); } return stripped; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/3f42b421383cc638581563923e0f4301d1a776e8/WhitespaceStripper.java/clean/src/java/org/xhtmlrenderer/layout/inline/WhitespaceStripper.java |
|
List remove_list = new ArrayList(); for (int i = 0; i < list.size(); i++) { if (list.get(i) instanceof TextContent) { remove_list.add(list.get(i)); | for (Iterator i = list.iterator(); i.hasNext();) { if (i.next() instanceof TextContent) { i.remove(); | private static void stripWhitespaceContent(List list) { List remove_list = new ArrayList(); for (int i = 0; i < list.size(); i++) { if (list.get(i) instanceof TextContent) { remove_list.add(list.get(i)); } } for (int i = 0; i < remove_list.size(); i++) { list.remove(remove_list.get(i)); } } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/3f42b421383cc638581563923e0f4301d1a776e8/WhitespaceStripper.java/clean/src/java/org/xhtmlrenderer/layout/inline/WhitespaceStripper.java |
for (int i = 0; i < remove_list.size(); i++) { list.remove(remove_list.get(i)); } | private static void stripWhitespaceContent(List list) { List remove_list = new ArrayList(); for (int i = 0; i < list.size(); i++) { if (list.get(i) instanceof TextContent) { remove_list.add(list.get(i)); } } for (int i = 0; i < remove_list.size(); i++) { list.remove(remove_list.get(i)); } } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/3f42b421383cc638581563923e0f4301d1a776e8/WhitespaceStripper.java/clean/src/java/org/xhtmlrenderer/layout/inline/WhitespaceStripper.java |
|
ruby.defineReadonlyVariable("$!", ruby.getNil()); | public RubyObject eval(Ruby ruby, RubyObject self) { RescuedBlock: while (true) { try { // Execute recued Block RubyObject result = getHeadNode().eval(ruby, self); // If no exception is thrown execute else Block if (getElseNode() != null) { return getElseNode().eval(ruby, self); } return result; } catch (RaiseException raExcptn) { ruby.setSourceLine(getLine()); Node body = getResqNode(); while (body != null) { if (isRescueHandled(ruby, raExcptn.getActException(), self, body)) { try { return body.eval(ruby, self); } catch (RetryException rExcptn) { continue RescuedBlock; } } body = body.getHeadNode(); } throw raExcptn; } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0240686adf37f131cfc2bf0b05872198ea588dd4/RescueNode.java/buggy/org/jruby/nodes/RescueNode.java |
|
super(runtime, (RubyClass) runtime.getClasses().getClassFromPath("Java::JavaConstructor")); | super(runtime, runtime.getModule("Java").getClass("JavaConstructor")); | public JavaConstructor(Ruby runtime, Constructor constructor) { super(runtime, (RubyClass) runtime.getClasses().getClassFromPath("Java::JavaConstructor")); this.constructor = constructor; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/JavaConstructor.java/clean/src/org/jruby/javasupport/JavaConstructor.java |
javaModule.defineClassUnder("JavaConstructor", runtime.getClasses().getObjectClass()); | javaModule.defineClassUnder("JavaConstructor", runtime.getObject()); | public static RubyClass createJavaConstructorClass(Ruby runtime, RubyModule javaModule) { RubyClass result = javaModule.defineClassUnder("JavaConstructor", runtime.getClasses().getObjectClass()); CallbackFactory callbackFactory = runtime.callbackFactory(JavaConstructor.class); JavaCallable.registerRubyMethods(runtime, result, JavaConstructor.class); result.defineMethod("arity", callbackFactory.getMethod("arity")); result.defineMethod("inspect", callbackFactory.getMethod("inspect")); result.defineMethod("argument_types", callbackFactory.getMethod("argument_types")); result.defineMethod("new_instance", callbackFactory.getOptMethod("new_instance")); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ca6b16e996ea9af83ce593594b9c69b9364a9924/JavaConstructor.java/clean/src/org/jruby/javasupport/JavaConstructor.java |
outerBox.setMarginWidth(new Border(0, 0, 0, 0)); | c.pushStyle(CascadedStyle.emptyCascadedStyle); outerBox.setStyle(new Style(c.getCurrentStyle(), 0, c.getCtx())); c.popStyle(); | public static Box layout(Context c, BlockBox outerBox, Content content) { boolean set_bfc = false; if (content instanceof TableContent) { // install a block formatting context for the body, // ie. if it's null. // set up the outtermost bfc if (c.getBlockFormattingContext() == null) { outerBox.setParent(c.getCtx().getRootBox()); BlockFormattingContext bfc = new BlockFormattingContext(outerBox, c); c.pushBFC(bfc); set_bfc = true; bfc.setWidth((int) c.getExtents().getWidth()); } } else { XRLog.layout(Level.WARNING, "Unsupported table type " + content.getClass().getName()); return null; } // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); //outerBox.x = c.getExtents().x; //outerBox.y = c.getExtents().y; //HACK: for now outerBox.contentWidth = c.getExtents().width; outerBox.height = c.getExtents().height; outerBox.setMarginWidth(new Border(0, 0, 0, 0)); TableBox tableBox = new TableBox(); outerBox.addChild(tableBox); tableBox.element = content.getElement(); //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } else { c.pushStyle(CascadedStyle.emptyCascadedStyle); } VerticalMarginCollapser.collapseVerticalMargins(c, tableBox, content, (float) oe.getWidth()); TableContent tableContent = (TableContent) content; if (tableContent.isTopMarginCollapsed()) { tableBox.setMarginTopOverride(0f); } if (tableContent.isBottomMarginCollapsed()) { tableBox.setMarginBottomOverride(0f); } Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); //note: percentages here refer to width of containing block tableBox.setMarginWidth(c, (float) oe.getWidth()); Border margin = tableBox.getMarginWidth(); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); int tx = margin.left + border.left + padding.left; int ty = margin.top + border.top + padding.top; tableBox.tx = tx; tableBox.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + margin.right + border.right + padding.right, ty + margin.bottom + border.bottom + padding.bottom); IdentValue borderStyle = c.getCurrentStyle().getIdent(CSSName.BORDER_COLLAPSE); int borderSpacingHorizontal = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_HORIZONTAL, 0, c.getCtx()); int borderSpacingVertical = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_VERTICAL, 0, c.getCtx()); layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.unshrinkExtents(); c.translate(-tx, -ty); //OK, now we basically have the maximum cell widths, is that a smart order? //TODO: percentages? if (c.getCurrentStyle().isIdent(CSSName.WIDTH, IdentValue.AUTO)) { //we're normally fine, unless the maximum width is greater than the extents fixWidths(tableBox, borderSpacingHorizontal); } else {//if the algorithm is fixed, we need to do something else from the start int givenWidth = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); //also fine, if the total calculated is less than the extents and the width if (tableBox.contentWidth < givenWidth) { tableBox.contentWidth = givenWidth; fixWidths(tableBox, borderSpacingHorizontal); } else { c.getExtents().width = 1; c.translate(tx, ty); int[] preferredColumns = tableBox.columns; tableBox.columns = null; tableBox.removeAllChildren(); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); //here the table is layed out with minimum column widths if (tableBox.contentWidth < givenWidth) { //do it right tableBox.contentWidth = givenWidth; tableBox.removeAllChildren(); fixWidths(tableBox, borderSpacingHorizontal, preferredColumns); c.translate(tx, ty); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, true, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); } } } //now the width is settled, fix vertical alignment for (Iterator i = tableBox.getChildIterator(); i.hasNext();) { Object o = i.next(); if (o instanceof RowBox) { fixVerticalAlign(c, (RowBox) o); } } //TODO: margins go on the outer box tableBox.leftPadding = border.left + padding.left; tableBox.leftPadding += margin.left; tableBox.rightPadding = border.right + margin.right; tableBox.rightPadding += margin.right; tableBox.height = margin.top + border.top + padding.top + tableBox.height + padding.bottom + border.bottom + margin.bottom; c.popStyle(); //restore the extents c.setExtents(oe); // remove the outtermost bfc if (set_bfc) { c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); } outerBox.height = 0; for (Iterator i = outerBox.getChildIterator(); i.hasNext();) { Box child = (Box) i.next(); outerBox.height += child.height; outerBox.adjustWidthForChild(child.getWidth()); } tableBox.setState(Box.DONE); outerBox.propagateChildProperties(tableBox); outerBox.setState(Box.DONE); return outerBox; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
tableBox.setMarginTopOverride(0f); | tableBox.getStyle().setMarginTopOverride(0f); | public static Box layout(Context c, BlockBox outerBox, Content content) { boolean set_bfc = false; if (content instanceof TableContent) { // install a block formatting context for the body, // ie. if it's null. // set up the outtermost bfc if (c.getBlockFormattingContext() == null) { outerBox.setParent(c.getCtx().getRootBox()); BlockFormattingContext bfc = new BlockFormattingContext(outerBox, c); c.pushBFC(bfc); set_bfc = true; bfc.setWidth((int) c.getExtents().getWidth()); } } else { XRLog.layout(Level.WARNING, "Unsupported table type " + content.getClass().getName()); return null; } // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); //outerBox.x = c.getExtents().x; //outerBox.y = c.getExtents().y; //HACK: for now outerBox.contentWidth = c.getExtents().width; outerBox.height = c.getExtents().height; outerBox.setMarginWidth(new Border(0, 0, 0, 0)); TableBox tableBox = new TableBox(); outerBox.addChild(tableBox); tableBox.element = content.getElement(); //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } else { c.pushStyle(CascadedStyle.emptyCascadedStyle); } VerticalMarginCollapser.collapseVerticalMargins(c, tableBox, content, (float) oe.getWidth()); TableContent tableContent = (TableContent) content; if (tableContent.isTopMarginCollapsed()) { tableBox.setMarginTopOverride(0f); } if (tableContent.isBottomMarginCollapsed()) { tableBox.setMarginBottomOverride(0f); } Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); //note: percentages here refer to width of containing block tableBox.setMarginWidth(c, (float) oe.getWidth()); Border margin = tableBox.getMarginWidth(); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); int tx = margin.left + border.left + padding.left; int ty = margin.top + border.top + padding.top; tableBox.tx = tx; tableBox.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + margin.right + border.right + padding.right, ty + margin.bottom + border.bottom + padding.bottom); IdentValue borderStyle = c.getCurrentStyle().getIdent(CSSName.BORDER_COLLAPSE); int borderSpacingHorizontal = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_HORIZONTAL, 0, c.getCtx()); int borderSpacingVertical = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_VERTICAL, 0, c.getCtx()); layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.unshrinkExtents(); c.translate(-tx, -ty); //OK, now we basically have the maximum cell widths, is that a smart order? //TODO: percentages? if (c.getCurrentStyle().isIdent(CSSName.WIDTH, IdentValue.AUTO)) { //we're normally fine, unless the maximum width is greater than the extents fixWidths(tableBox, borderSpacingHorizontal); } else {//if the algorithm is fixed, we need to do something else from the start int givenWidth = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); //also fine, if the total calculated is less than the extents and the width if (tableBox.contentWidth < givenWidth) { tableBox.contentWidth = givenWidth; fixWidths(tableBox, borderSpacingHorizontal); } else { c.getExtents().width = 1; c.translate(tx, ty); int[] preferredColumns = tableBox.columns; tableBox.columns = null; tableBox.removeAllChildren(); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); //here the table is layed out with minimum column widths if (tableBox.contentWidth < givenWidth) { //do it right tableBox.contentWidth = givenWidth; tableBox.removeAllChildren(); fixWidths(tableBox, borderSpacingHorizontal, preferredColumns); c.translate(tx, ty); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, true, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); } } } //now the width is settled, fix vertical alignment for (Iterator i = tableBox.getChildIterator(); i.hasNext();) { Object o = i.next(); if (o instanceof RowBox) { fixVerticalAlign(c, (RowBox) o); } } //TODO: margins go on the outer box tableBox.leftPadding = border.left + padding.left; tableBox.leftPadding += margin.left; tableBox.rightPadding = border.right + margin.right; tableBox.rightPadding += margin.right; tableBox.height = margin.top + border.top + padding.top + tableBox.height + padding.bottom + border.bottom + margin.bottom; c.popStyle(); //restore the extents c.setExtents(oe); // remove the outtermost bfc if (set_bfc) { c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); } outerBox.height = 0; for (Iterator i = outerBox.getChildIterator(); i.hasNext();) { Box child = (Box) i.next(); outerBox.height += child.height; outerBox.adjustWidthForChild(child.getWidth()); } tableBox.setState(Box.DONE); outerBox.propagateChildProperties(tableBox); outerBox.setState(Box.DONE); return outerBox; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
tableBox.setMarginBottomOverride(0f); | tableBox.getStyle().setMarginBottomOverride(0f); | public static Box layout(Context c, BlockBox outerBox, Content content) { boolean set_bfc = false; if (content instanceof TableContent) { // install a block formatting context for the body, // ie. if it's null. // set up the outtermost bfc if (c.getBlockFormattingContext() == null) { outerBox.setParent(c.getCtx().getRootBox()); BlockFormattingContext bfc = new BlockFormattingContext(outerBox, c); c.pushBFC(bfc); set_bfc = true; bfc.setWidth((int) c.getExtents().getWidth()); } } else { XRLog.layout(Level.WARNING, "Unsupported table type " + content.getClass().getName()); return null; } // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); //outerBox.x = c.getExtents().x; //outerBox.y = c.getExtents().y; //HACK: for now outerBox.contentWidth = c.getExtents().width; outerBox.height = c.getExtents().height; outerBox.setMarginWidth(new Border(0, 0, 0, 0)); TableBox tableBox = new TableBox(); outerBox.addChild(tableBox); tableBox.element = content.getElement(); //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } else { c.pushStyle(CascadedStyle.emptyCascadedStyle); } VerticalMarginCollapser.collapseVerticalMargins(c, tableBox, content, (float) oe.getWidth()); TableContent tableContent = (TableContent) content; if (tableContent.isTopMarginCollapsed()) { tableBox.setMarginTopOverride(0f); } if (tableContent.isBottomMarginCollapsed()) { tableBox.setMarginBottomOverride(0f); } Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); //note: percentages here refer to width of containing block tableBox.setMarginWidth(c, (float) oe.getWidth()); Border margin = tableBox.getMarginWidth(); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); int tx = margin.left + border.left + padding.left; int ty = margin.top + border.top + padding.top; tableBox.tx = tx; tableBox.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + margin.right + border.right + padding.right, ty + margin.bottom + border.bottom + padding.bottom); IdentValue borderStyle = c.getCurrentStyle().getIdent(CSSName.BORDER_COLLAPSE); int borderSpacingHorizontal = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_HORIZONTAL, 0, c.getCtx()); int borderSpacingVertical = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_VERTICAL, 0, c.getCtx()); layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.unshrinkExtents(); c.translate(-tx, -ty); //OK, now we basically have the maximum cell widths, is that a smart order? //TODO: percentages? if (c.getCurrentStyle().isIdent(CSSName.WIDTH, IdentValue.AUTO)) { //we're normally fine, unless the maximum width is greater than the extents fixWidths(tableBox, borderSpacingHorizontal); } else {//if the algorithm is fixed, we need to do something else from the start int givenWidth = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); //also fine, if the total calculated is less than the extents and the width if (tableBox.contentWidth < givenWidth) { tableBox.contentWidth = givenWidth; fixWidths(tableBox, borderSpacingHorizontal); } else { c.getExtents().width = 1; c.translate(tx, ty); int[] preferredColumns = tableBox.columns; tableBox.columns = null; tableBox.removeAllChildren(); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); //here the table is layed out with minimum column widths if (tableBox.contentWidth < givenWidth) { //do it right tableBox.contentWidth = givenWidth; tableBox.removeAllChildren(); fixWidths(tableBox, borderSpacingHorizontal, preferredColumns); c.translate(tx, ty); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, true, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); } } } //now the width is settled, fix vertical alignment for (Iterator i = tableBox.getChildIterator(); i.hasNext();) { Object o = i.next(); if (o instanceof RowBox) { fixVerticalAlign(c, (RowBox) o); } } //TODO: margins go on the outer box tableBox.leftPadding = border.left + padding.left; tableBox.leftPadding += margin.left; tableBox.rightPadding = border.right + margin.right; tableBox.rightPadding += margin.right; tableBox.height = margin.top + border.top + padding.top + tableBox.height + padding.bottom + border.bottom + margin.bottom; c.popStyle(); //restore the extents c.setExtents(oe); // remove the outtermost bfc if (set_bfc) { c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); } outerBox.height = 0; for (Iterator i = outerBox.getChildIterator(); i.hasNext();) { Box child = (Box) i.next(); outerBox.height += child.height; outerBox.adjustWidthForChild(child.getWidth()); } tableBox.setState(Box.DONE); outerBox.propagateChildProperties(tableBox); outerBox.setState(Box.DONE); return outerBox; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
tableBox.setMarginWidth(c, (float) oe.getWidth()); Border margin = tableBox.getMarginWidth(); | Border margin = tableBox.getStyle().getMarginWidth(); | public static Box layout(Context c, BlockBox outerBox, Content content) { boolean set_bfc = false; if (content instanceof TableContent) { // install a block formatting context for the body, // ie. if it's null. // set up the outtermost bfc if (c.getBlockFormattingContext() == null) { outerBox.setParent(c.getCtx().getRootBox()); BlockFormattingContext bfc = new BlockFormattingContext(outerBox, c); c.pushBFC(bfc); set_bfc = true; bfc.setWidth((int) c.getExtents().getWidth()); } } else { XRLog.layout(Level.WARNING, "Unsupported table type " + content.getClass().getName()); return null; } // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); //outerBox.x = c.getExtents().x; //outerBox.y = c.getExtents().y; //HACK: for now outerBox.contentWidth = c.getExtents().width; outerBox.height = c.getExtents().height; outerBox.setMarginWidth(new Border(0, 0, 0, 0)); TableBox tableBox = new TableBox(); outerBox.addChild(tableBox); tableBox.element = content.getElement(); //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } else { c.pushStyle(CascadedStyle.emptyCascadedStyle); } VerticalMarginCollapser.collapseVerticalMargins(c, tableBox, content, (float) oe.getWidth()); TableContent tableContent = (TableContent) content; if (tableContent.isTopMarginCollapsed()) { tableBox.setMarginTopOverride(0f); } if (tableContent.isBottomMarginCollapsed()) { tableBox.setMarginBottomOverride(0f); } Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); //note: percentages here refer to width of containing block tableBox.setMarginWidth(c, (float) oe.getWidth()); Border margin = tableBox.getMarginWidth(); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); int tx = margin.left + border.left + padding.left; int ty = margin.top + border.top + padding.top; tableBox.tx = tx; tableBox.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + margin.right + border.right + padding.right, ty + margin.bottom + border.bottom + padding.bottom); IdentValue borderStyle = c.getCurrentStyle().getIdent(CSSName.BORDER_COLLAPSE); int borderSpacingHorizontal = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_HORIZONTAL, 0, c.getCtx()); int borderSpacingVertical = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.FS_BORDER_SPACING_VERTICAL, 0, c.getCtx()); layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.unshrinkExtents(); c.translate(-tx, -ty); //OK, now we basically have the maximum cell widths, is that a smart order? //TODO: percentages? if (c.getCurrentStyle().isIdent(CSSName.WIDTH, IdentValue.AUTO)) { //we're normally fine, unless the maximum width is greater than the extents fixWidths(tableBox, borderSpacingHorizontal); } else {//if the algorithm is fixed, we need to do something else from the start int givenWidth = (int) c.getCurrentStyle().getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); //also fine, if the total calculated is less than the extents and the width if (tableBox.contentWidth < givenWidth) { tableBox.contentWidth = givenWidth; fixWidths(tableBox, borderSpacingHorizontal); } else { c.getExtents().width = 1; c.translate(tx, ty); int[] preferredColumns = tableBox.columns; tableBox.columns = null; tableBox.removeAllChildren(); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, false, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); //here the table is layed out with minimum column widths if (tableBox.contentWidth < givenWidth) { //do it right tableBox.contentWidth = givenWidth; tableBox.removeAllChildren(); fixWidths(tableBox, borderSpacingHorizontal, preferredColumns); c.translate(tx, ty); tableBox.contentWidth = 0; tableBox.height = 0; layoutChildren(c, tableBox, content, true, borderSpacingHorizontal, borderSpacingVertical); c.translate(-tx, -ty); } } } //now the width is settled, fix vertical alignment for (Iterator i = tableBox.getChildIterator(); i.hasNext();) { Object o = i.next(); if (o instanceof RowBox) { fixVerticalAlign(c, (RowBox) o); } } //TODO: margins go on the outer box tableBox.leftPadding = border.left + padding.left; tableBox.leftPadding += margin.left; tableBox.rightPadding = border.right + margin.right; tableBox.rightPadding += margin.right; tableBox.height = margin.top + border.top + padding.top + tableBox.height + padding.bottom + border.bottom + margin.bottom; c.popStyle(); //restore the extents c.setExtents(oe); // remove the outtermost bfc if (set_bfc) { c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); } outerBox.height = 0; for (Iterator i = outerBox.getChildIterator(); i.hasNext();) { Box child = (Box) i.next(); outerBox.height += child.height; outerBox.adjustWidthForChild(child.getWidth()); } tableBox.setState(Box.DONE); outerBox.propagateChildProperties(tableBox); outerBox.setState(Box.DONE); return outerBox; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
cell.setMarginWidth(c, c.getExtents().width); | cell.setStyle(new Style(c.getCurrentStyle(), (float) c.getExtents().width, c.getCtx())); | private static CellBox layoutCell(Context c, CellBox cell, Content content, boolean fixed, TableBox table, int col) { //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) { cell.setChildrenExceedBounds(true); } // a cell defines a new bfc cell.setMarginWidth(c, c.getExtents().width); BlockFormattingContext bfc = new BlockFormattingContext(cell, c); c.pushBFC(bfc); bfc.setWidth((int) c.getExtents().getWidth()); // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); cell.colspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_COLSPAN); cell.rowspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_ROWSPAN); if (fixed) { int width = 0; for (int i = 0; i < cell.colspan; i++) width += table.columns[col + i]; c.getExtents().width = width; } CalculatedStyle style = c.getCurrentStyle(); boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); //TODO: handle relative heights, but only if containing cell height is not defined by content height boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); //HACK: assume containing cell height is auto, so percentages become auto hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); // calculate the width and height as much as possible int setHeight = -1;//means height is not set by css int setWidth = -1;//means width is not set by css if (hasSpecifiedWidth) { setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); c.getExtents().width = setWidth; } if (hasSpecifiedHeight) { setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c.getCtx()); c.getExtents().height = setHeight; cell.height = setHeight; cell.auto_height = false; } //check if replaced JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c, setWidth, setHeight); if (cc != null) { Rectangle bounds = cc.getBounds(); //cell.x = bounds.x; //cell.y = bounds.y; cell.contentWidth = bounds.width; cell.height = bounds.height; cell.component = cc; } // save height incase fixed height int original_height = cell.height; // do children's layout boolean old_sub = c.isSubBlock(); c.setSubBlock(false); Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); cell.leftPadding = border.left + padding.left; cell.rightPadding = padding.right + border.right; int tx = border.left + padding.left; int ty = border.top + padding.top; cell.tx = tx; cell.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right + padding.right, ty + border.bottom + padding.bottom); if (cell.component == null) Boxing.layoutChildren(c, cell, content); else { Point origin = c.getOriginOffset(); cell.component.setLocation((int) origin.getX(), (int) origin.getY()); if (c.isInteractive()) { c.getCanvas().add(cell.component); } } c.unshrinkExtents(); c.translate(-tx, -ty); c.setSubBlock(old_sub); // restore height incase fixed height if (cell.auto_height == false) { Uu.p("restoring original height"); cell.height = original_height; } cell.height = border.top + padding.top + cell.height + padding.bottom + border.bottom; //restore the extents c.setExtents(oe); // remove the bfc c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); //and now, back to previous style if (pushed != null) { c.popStyle(); } // Uu.p("BoxLayout: finished with cell: " + cell); cell.setState(Box.DONE); return cell; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); | private static CellBox layoutCell(Context c, CellBox cell, Content content, boolean fixed, TableBox table, int col) { //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) { cell.setChildrenExceedBounds(true); } // a cell defines a new bfc cell.setMarginWidth(c, c.getExtents().width); BlockFormattingContext bfc = new BlockFormattingContext(cell, c); c.pushBFC(bfc); bfc.setWidth((int) c.getExtents().getWidth()); // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); cell.colspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_COLSPAN); cell.rowspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_ROWSPAN); if (fixed) { int width = 0; for (int i = 0; i < cell.colspan; i++) width += table.columns[col + i]; c.getExtents().width = width; } CalculatedStyle style = c.getCurrentStyle(); boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); //TODO: handle relative heights, but only if containing cell height is not defined by content height boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); //HACK: assume containing cell height is auto, so percentages become auto hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); // calculate the width and height as much as possible int setHeight = -1;//means height is not set by css int setWidth = -1;//means width is not set by css if (hasSpecifiedWidth) { setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); c.getExtents().width = setWidth; } if (hasSpecifiedHeight) { setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c.getCtx()); c.getExtents().height = setHeight; cell.height = setHeight; cell.auto_height = false; } //check if replaced JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c, setWidth, setHeight); if (cc != null) { Rectangle bounds = cc.getBounds(); //cell.x = bounds.x; //cell.y = bounds.y; cell.contentWidth = bounds.width; cell.height = bounds.height; cell.component = cc; } // save height incase fixed height int original_height = cell.height; // do children's layout boolean old_sub = c.isSubBlock(); c.setSubBlock(false); Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); cell.leftPadding = border.left + padding.left; cell.rightPadding = padding.right + border.right; int tx = border.left + padding.left; int ty = border.top + padding.top; cell.tx = tx; cell.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right + padding.right, ty + border.bottom + padding.bottom); if (cell.component == null) Boxing.layoutChildren(c, cell, content); else { Point origin = c.getOriginOffset(); cell.component.setLocation((int) origin.getX(), (int) origin.getY()); if (c.isInteractive()) { c.getCanvas().add(cell.component); } } c.unshrinkExtents(); c.translate(-tx, -ty); c.setSubBlock(old_sub); // restore height incase fixed height if (cell.auto_height == false) { Uu.p("restoring original height"); cell.height = original_height; } cell.height = border.top + padding.top + cell.height + padding.bottom + border.bottom; //restore the extents c.setExtents(oe); // remove the bfc c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); //and now, back to previous style if (pushed != null) { c.popStyle(); } // Uu.p("BoxLayout: finished with cell: " + cell); cell.setState(Box.DONE); return cell; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
|
if (hasSpecifiedWidth) { | if (!cell.getStyle().isAutoWidth()) { | private static CellBox layoutCell(Context c, CellBox cell, Content content, boolean fixed, TableBox table, int col) { //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) { cell.setChildrenExceedBounds(true); } // a cell defines a new bfc cell.setMarginWidth(c, c.getExtents().width); BlockFormattingContext bfc = new BlockFormattingContext(cell, c); c.pushBFC(bfc); bfc.setWidth((int) c.getExtents().getWidth()); // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); cell.colspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_COLSPAN); cell.rowspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_ROWSPAN); if (fixed) { int width = 0; for (int i = 0; i < cell.colspan; i++) width += table.columns[col + i]; c.getExtents().width = width; } CalculatedStyle style = c.getCurrentStyle(); boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); //TODO: handle relative heights, but only if containing cell height is not defined by content height boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); //HACK: assume containing cell height is auto, so percentages become auto hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); // calculate the width and height as much as possible int setHeight = -1;//means height is not set by css int setWidth = -1;//means width is not set by css if (hasSpecifiedWidth) { setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); c.getExtents().width = setWidth; } if (hasSpecifiedHeight) { setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c.getCtx()); c.getExtents().height = setHeight; cell.height = setHeight; cell.auto_height = false; } //check if replaced JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c, setWidth, setHeight); if (cc != null) { Rectangle bounds = cc.getBounds(); //cell.x = bounds.x; //cell.y = bounds.y; cell.contentWidth = bounds.width; cell.height = bounds.height; cell.component = cc; } // save height incase fixed height int original_height = cell.height; // do children's layout boolean old_sub = c.isSubBlock(); c.setSubBlock(false); Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); cell.leftPadding = border.left + padding.left; cell.rightPadding = padding.right + border.right; int tx = border.left + padding.left; int ty = border.top + padding.top; cell.tx = tx; cell.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right + padding.right, ty + border.bottom + padding.bottom); if (cell.component == null) Boxing.layoutChildren(c, cell, content); else { Point origin = c.getOriginOffset(); cell.component.setLocation((int) origin.getX(), (int) origin.getY()); if (c.isInteractive()) { c.getCanvas().add(cell.component); } } c.unshrinkExtents(); c.translate(-tx, -ty); c.setSubBlock(old_sub); // restore height incase fixed height if (cell.auto_height == false) { Uu.p("restoring original height"); cell.height = original_height; } cell.height = border.top + padding.top + cell.height + padding.bottom + border.bottom; //restore the extents c.setExtents(oe); // remove the bfc c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); //and now, back to previous style if (pushed != null) { c.popStyle(); } // Uu.p("BoxLayout: finished with cell: " + cell); cell.setState(Box.DONE); return cell; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
if (hasSpecifiedHeight) { | if (!cell.getStyle().isAutoHeight()) { | private static CellBox layoutCell(Context c, CellBox cell, Content content, boolean fixed, TableBox table, int col) { //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) { cell.setChildrenExceedBounds(true); } // a cell defines a new bfc cell.setMarginWidth(c, c.getExtents().width); BlockFormattingContext bfc = new BlockFormattingContext(cell, c); c.pushBFC(bfc); bfc.setWidth((int) c.getExtents().getWidth()); // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); cell.colspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_COLSPAN); cell.rowspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_ROWSPAN); if (fixed) { int width = 0; for (int i = 0; i < cell.colspan; i++) width += table.columns[col + i]; c.getExtents().width = width; } CalculatedStyle style = c.getCurrentStyle(); boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); //TODO: handle relative heights, but only if containing cell height is not defined by content height boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); //HACK: assume containing cell height is auto, so percentages become auto hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); // calculate the width and height as much as possible int setHeight = -1;//means height is not set by css int setWidth = -1;//means width is not set by css if (hasSpecifiedWidth) { setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); c.getExtents().width = setWidth; } if (hasSpecifiedHeight) { setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c.getCtx()); c.getExtents().height = setHeight; cell.height = setHeight; cell.auto_height = false; } //check if replaced JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c, setWidth, setHeight); if (cc != null) { Rectangle bounds = cc.getBounds(); //cell.x = bounds.x; //cell.y = bounds.y; cell.contentWidth = bounds.width; cell.height = bounds.height; cell.component = cc; } // save height incase fixed height int original_height = cell.height; // do children's layout boolean old_sub = c.isSubBlock(); c.setSubBlock(false); Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); cell.leftPadding = border.left + padding.left; cell.rightPadding = padding.right + border.right; int tx = border.left + padding.left; int ty = border.top + padding.top; cell.tx = tx; cell.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right + padding.right, ty + border.bottom + padding.bottom); if (cell.component == null) Boxing.layoutChildren(c, cell, content); else { Point origin = c.getOriginOffset(); cell.component.setLocation((int) origin.getX(), (int) origin.getY()); if (c.isInteractive()) { c.getCanvas().add(cell.component); } } c.unshrinkExtents(); c.translate(-tx, -ty); c.setSubBlock(old_sub); // restore height incase fixed height if (cell.auto_height == false) { Uu.p("restoring original height"); cell.height = original_height; } cell.height = border.top + padding.top + cell.height + padding.bottom + border.bottom; //restore the extents c.setExtents(oe); // remove the bfc c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); //and now, back to previous style if (pushed != null) { c.popStyle(); } // Uu.p("BoxLayout: finished with cell: " + cell); cell.setState(Box.DONE); return cell; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
cell.auto_height = false; | private static CellBox layoutCell(Context c, CellBox cell, Content content, boolean fixed, TableBox table, int col) { //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) { cell.setChildrenExceedBounds(true); } // a cell defines a new bfc cell.setMarginWidth(c, c.getExtents().width); BlockFormattingContext bfc = new BlockFormattingContext(cell, c); c.pushBFC(bfc); bfc.setWidth((int) c.getExtents().getWidth()); // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); cell.colspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_COLSPAN); cell.rowspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_ROWSPAN); if (fixed) { int width = 0; for (int i = 0; i < cell.colspan; i++) width += table.columns[col + i]; c.getExtents().width = width; } CalculatedStyle style = c.getCurrentStyle(); boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); //TODO: handle relative heights, but only if containing cell height is not defined by content height boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); //HACK: assume containing cell height is auto, so percentages become auto hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); // calculate the width and height as much as possible int setHeight = -1;//means height is not set by css int setWidth = -1;//means width is not set by css if (hasSpecifiedWidth) { setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); c.getExtents().width = setWidth; } if (hasSpecifiedHeight) { setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c.getCtx()); c.getExtents().height = setHeight; cell.height = setHeight; cell.auto_height = false; } //check if replaced JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c, setWidth, setHeight); if (cc != null) { Rectangle bounds = cc.getBounds(); //cell.x = bounds.x; //cell.y = bounds.y; cell.contentWidth = bounds.width; cell.height = bounds.height; cell.component = cc; } // save height incase fixed height int original_height = cell.height; // do children's layout boolean old_sub = c.isSubBlock(); c.setSubBlock(false); Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); cell.leftPadding = border.left + padding.left; cell.rightPadding = padding.right + border.right; int tx = border.left + padding.left; int ty = border.top + padding.top; cell.tx = tx; cell.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right + padding.right, ty + border.bottom + padding.bottom); if (cell.component == null) Boxing.layoutChildren(c, cell, content); else { Point origin = c.getOriginOffset(); cell.component.setLocation((int) origin.getX(), (int) origin.getY()); if (c.isInteractive()) { c.getCanvas().add(cell.component); } } c.unshrinkExtents(); c.translate(-tx, -ty); c.setSubBlock(old_sub); // restore height incase fixed height if (cell.auto_height == false) { Uu.p("restoring original height"); cell.height = original_height; } cell.height = border.top + padding.top + cell.height + padding.bottom + border.bottom; //restore the extents c.setExtents(oe); // remove the bfc c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); //and now, back to previous style if (pushed != null) { c.popStyle(); } // Uu.p("BoxLayout: finished with cell: " + cell); cell.setState(Box.DONE); return cell; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
|
if (cell.auto_height == false) { | if (!cell.getStyle().isAutoHeight()) { | private static CellBox layoutCell(Context c, CellBox cell, Content content, boolean fixed, TableBox table, int col) { //OK, first set up the current style. All depends on this... CascadedStyle pushed = content.getStyle(); if (pushed != null) { c.pushStyle(pushed); } if (c.getCurrentStyle().isIdent(CSSName.BACKGROUND_ATTACHMENT, IdentValue.FIXED)) { cell.setChildrenExceedBounds(true); } // a cell defines a new bfc cell.setMarginWidth(c, c.getExtents().width); BlockFormattingContext bfc = new BlockFormattingContext(cell, c); c.pushBFC(bfc); bfc.setWidth((int) c.getExtents().getWidth()); // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); cell.colspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_COLSPAN); cell.rowspan = (int) c.getCurrentStyle().getNumberProperty(CSSName.FS_ROWSPAN); if (fixed) { int width = 0; for (int i = 0; i < cell.colspan; i++) width += table.columns[col + i]; c.getExtents().width = width; } CalculatedStyle style = c.getCurrentStyle(); boolean hasSpecifiedWidth = !style.isIdent(CSSName.WIDTH, IdentValue.AUTO); //TODO: handle relative heights, but only if containing cell height is not defined by content height boolean hasSpecifiedHeight = !style.isIdent(CSSName.HEIGHT, IdentValue.AUTO); //HACK: assume containing cell height is auto, so percentages become auto hasSpecifiedHeight = hasSpecifiedHeight && style.propertyByName(CSSName.HEIGHT).computedValue().hasAbsoluteUnit(); // calculate the width and height as much as possible int setHeight = -1;//means height is not set by css int setWidth = -1;//means width is not set by css if (hasSpecifiedWidth) { setWidth = (int) style.getFloatPropertyProportionalWidth(CSSName.WIDTH, c.getExtents().width, c.getCtx()); c.getExtents().width = setWidth; } if (hasSpecifiedHeight) { setHeight = (int) style.getFloatPropertyProportionalHeight(CSSName.HEIGHT, c.getExtents().height, c.getCtx()); c.getExtents().height = setHeight; cell.height = setHeight; cell.auto_height = false; } //check if replaced JComponent cc = c.getNamespaceHandler().getCustomComponent(content.getElement(), c, setWidth, setHeight); if (cc != null) { Rectangle bounds = cc.getBounds(); //cell.x = bounds.x; //cell.y = bounds.y; cell.contentWidth = bounds.width; cell.height = bounds.height; cell.component = cc; } // save height incase fixed height int original_height = cell.height; // do children's layout boolean old_sub = c.isSubBlock(); c.setSubBlock(false); Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); Border padding = c.getCurrentStyle().getPaddingWidth((float) oe.getWidth(), (float) oe.getWidth(), c.getCtx()); cell.leftPadding = border.left + padding.left; cell.rightPadding = padding.right + border.right; int tx = border.left + padding.left; int ty = border.top + padding.top; cell.tx = tx; cell.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right + padding.right, ty + border.bottom + padding.bottom); if (cell.component == null) Boxing.layoutChildren(c, cell, content); else { Point origin = c.getOriginOffset(); cell.component.setLocation((int) origin.getX(), (int) origin.getY()); if (c.isInteractive()) { c.getCanvas().add(cell.component); } } c.unshrinkExtents(); c.translate(-tx, -ty); c.setSubBlock(old_sub); // restore height incase fixed height if (cell.auto_height == false) { Uu.p("restoring original height"); cell.height = original_height; } cell.height = border.top + padding.top + cell.height + padding.bottom + border.bottom; //restore the extents c.setExtents(oe); // remove the bfc c.getBlockFormattingContext().doFinalAdjustments(); c.popBFC(); //and now, back to previous style if (pushed != null) { c.popStyle(); } // Uu.p("BoxLayout: finished with cell: " + cell); cell.setState(Box.DONE); return cell; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
row.setMarginWidth(c, (float) oe.getWidth()); | private static RowBox layoutRow(Context c, TableRowContent tableRowContent, TableBox table, boolean fixed, int borderSpacingHorizontal, int borderSpacingVertical) { // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); RowBox row = new RowBox(); row.setMarginWidth(c, (float) oe.getWidth()); CascadedStyle pushed = tableRowContent.getStyle(); if (pushed != null) { c.pushStyle(pushed); } else { c.pushStyle(CascadedStyle.emptyCascadedStyle); } Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); //rows have no margin or padding row.leftPadding = border.left; row.rightPadding = border.right; //TODO: check how borders should interact with cell borders int tx = border.left; int ty = border.top; row.tx = tx; row.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right, ty + border.bottom); List cells = tableRowContent.getChildContent(c); checkColumns(table, cells.size()); layoutCells(cells, c, row, table, fixed, borderSpacingHorizontal, borderSpacingVertical); c.unshrinkExtents(); c.translate(-tx, -ty); // calculate the total outer width row.contentWidth += borderSpacingHorizontal; row.height = border.top + row.height + border.bottom; c.popStyle(); //restore the extents c.setExtents(oe); row.setState(Box.DONE); return row; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
|
row.setStyle(new Style(c.getCurrentStyle(), (float) oe.getWidth(), c.getCtx())); | private static RowBox layoutRow(Context c, TableRowContent tableRowContent, TableBox table, boolean fixed, int borderSpacingHorizontal, int borderSpacingVertical) { // copy the extents Rectangle oe = c.getExtents(); c.setExtents(new Rectangle(oe)); RowBox row = new RowBox(); row.setMarginWidth(c, (float) oe.getWidth()); CascadedStyle pushed = tableRowContent.getStyle(); if (pushed != null) { c.pushStyle(pushed); } else { c.pushStyle(CascadedStyle.emptyCascadedStyle); } Border border = c.getCurrentStyle().getBorderWidth(c.getCtx()); //rows have no margin or padding row.leftPadding = border.left; row.rightPadding = border.right; //TODO: check how borders should interact with cell borders int tx = border.left; int ty = border.top; row.tx = tx; row.ty = ty; c.translate(tx, ty); c.shrinkExtents(tx + border.right, ty + border.bottom); List cells = tableRowContent.getChildContent(c); checkColumns(table, cells.size()); layoutCells(cells, c, row, table, fixed, borderSpacingHorizontal, borderSpacingVertical); c.unshrinkExtents(); c.translate(-tx, -ty); // calculate the total outer width row.contentWidth += borderSpacingHorizontal; row.height = border.top + row.height + border.bottom; c.popStyle(); //restore the extents c.setExtents(oe); row.setState(Box.DONE); return row; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/d78edbe00854320b48eb4ef97095b253df533dd8/TableBoxing.java/clean/src/java/org/xhtmlrenderer/table/TableBoxing.java |
|
public static Border getBorder(Context c, Box box) { //TODO: can I skip this? //Uu.p("box on: " + box); //Uu.p("is inline element = " + box.isInlineElement()); //Uu.p("text content = " + (box.content instanceof TextContent)); if (isBlockOrInlineElementBox(box)) { // if (box.isInlineElement() || !(box.content instanceof TextContent)) { // Uu.p("setting border for: " + box); if (box.border == null) { box.border = c.getCurrentStyle().getBorderWidth(); } //} else { // Uu.p("skipping border for: " + box); } return box.border; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/13c62f942cf10401fce3541f4f6970cf6d291755/LayoutUtil.java/buggy/src/java/org/xhtmlrenderer/layout/LayoutUtil.java |
||
public static Border getBorder(Context c, Box box) { //TODO: can I skip this? //Uu.p("box on: " + box); //Uu.p("is inline element = " + box.isInlineElement()); //Uu.p("text content = " + (box.content instanceof TextContent)); if (isBlockOrInlineElementBox(box)) { // if (box.isInlineElement() || !(box.content instanceof TextContent)) { // Uu.p("setting border for: " + box); if (box.border == null) { box.border = c.getCurrentStyle().getBorderWidth(); } //} else { // Uu.p("skipping border for: " + box); } return box.border; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/13c62f942cf10401fce3541f4f6970cf6d291755/LayoutUtil.java/buggy/src/java/org/xhtmlrenderer/layout/LayoutUtil.java |
||
public static Border getBorder(Context c, Box box) { //TODO: can I skip this? //Uu.p("box on: " + box); //Uu.p("is inline element = " + box.isInlineElement()); //Uu.p("text content = " + (box.content instanceof TextContent)); if (isBlockOrInlineElementBox(box)) { // if (box.isInlineElement() || !(box.content instanceof TextContent)) { // Uu.p("setting border for: " + box); if (box.border == null) { box.border = c.getCurrentStyle().getBorderWidth(); } //} else { // Uu.p("skipping border for: " + box); } return box.border; } | 57883 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57883/13c62f942cf10401fce3541f4f6970cf6d291755/LayoutUtil.java/buggy/src/java/org/xhtmlrenderer/layout/LayoutUtil.java |
||
fScanner.setPartialRange(d, reparseStart, d.getLength(), contentType, partitionStart); | fScanner.setPartialRange(d, reparseStart, d.getLength() - reparseStart, contentType, partitionStart); | public IRegion documentChanged2(DocumentEvent e) { try { IDocument d= e.getDocument(); Position[] category= d.getPositions(CONTENT_TYPES_CATEGORY); IRegion line= d.getLineInformationOfOffset(e.getOffset()); int reparseStart= line.getOffset(); int partitionStart= 0; String contentType= null; int first= d.computeIndexInCategory(CONTENT_TYPES_CATEGORY, reparseStart); if (first > 0) { TypedPosition partition= (TypedPosition) category[first - 1]; if (partition.includes(reparseStart)) { partitionStart= partition.getOffset(); contentType= partition.getType(); if (e.getOffset() == partition.getOffset() + partition.getLength()) reparseStart= partitionStart; -- first; } else if (reparseStart == e.getOffset() && reparseStart == partition.getOffset() + partition.getLength()) { partitionStart= partition.getOffset(); contentType= partition.getType(); reparseStart= partitionStart; -- first; } else { partitionStart= partition.getOffset() + partition.getLength(); contentType= IDocument.DEFAULT_CONTENT_TYPE; } } fPositionUpdater.update(e); for (int i= first; i < category.length; i++) { Position p= category[i]; if (p.isDeleted) { rememberDeletedOffset(e.getOffset()); break; } } category= d.getPositions(CONTENT_TYPES_CATEGORY); fScanner.setPartialRange(d, reparseStart, d.getLength(), contentType, partitionStart); int lastScannedPosition= reparseStart; IToken token= fScanner.nextToken(); while (!token.isEOF()) { contentType= getTokenContentType(token); if (!isSupportedContentType(contentType)) { token= fScanner.nextToken(); continue; } int start= fScanner.getTokenOffset(); int length= fScanner.getTokenLength(); lastScannedPosition= start + length - 1; // remove all affected positions while (first < category.length) { TypedPosition p= (TypedPosition) category[first]; if (lastScannedPosition >= p.offset + p.length || (p.overlapsWith(start, length) && (!d.containsPosition(CONTENT_TYPES_CATEGORY, start, length) || !contentType.equals(p.getType())))) { rememberRegion(p.offset, p.length); d.removePosition(CONTENT_TYPES_CATEGORY, p); ++ first; } else break; } // if position already exists we are done if (d.containsPosition(CONTENT_TYPES_CATEGORY, start, length)) { if (lastScannedPosition > e.getOffset()) return createRegion(); ++ first; } else { // insert the new type position try { d.addPosition(CONTENT_TYPES_CATEGORY, new TypedPosition(start, length, contentType)); rememberRegion(start, length); } catch (BadPositionCategoryException x) { } catch (BadLocationException x) { } } token= fScanner.nextToken(); } // remove all positions behind lastScannedPosition since there aren't any further types TypedPosition p; first= d.computeIndexInCategory(CONTENT_TYPES_CATEGORY, lastScannedPosition); while (first < category.length) { p= (TypedPosition) category[first++]; d.removePosition(CONTENT_TYPES_CATEGORY, p); rememberRegion(p.offset, p.length); } } catch (BadPositionCategoryException x) { // should never happen on connected documents } catch (BadLocationException x) { } return createRegion(); } | 57470 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57470/1e89ed4f435a1d935b1b83c322ba5c469d0667c7/DefaultPartitioner.java/buggy/bundles/org.eclipse.ui/Eclipse JFace Text/org/eclipse/jface/text/rules/DefaultPartitioner.java |
if (orgLabor.isNew() || orgLabor.isModified()) { session = openSession(); if (orgLabor.isNew()) { OrgLabor orgLaborModel = new OrgLabor(); orgLaborModel.setOrgLaborId(orgLabor.getOrgLaborId()); orgLaborModel.setOrganizationId(orgLabor.getOrganizationId()); orgLaborModel.setTypeId(orgLabor.getTypeId()); orgLaborModel.setSunOpen(orgLabor.getSunOpen()); orgLaborModel.setSunClose(orgLabor.getSunClose()); orgLaborModel.setMonOpen(orgLabor.getMonOpen()); orgLaborModel.setMonClose(orgLabor.getMonClose()); orgLaborModel.setTueOpen(orgLabor.getTueOpen()); orgLaborModel.setTueClose(orgLabor.getTueClose()); orgLaborModel.setWedOpen(orgLabor.getWedOpen()); orgLaborModel.setWedClose(orgLabor.getWedClose()); orgLaborModel.setThuOpen(orgLabor.getThuOpen()); orgLaborModel.setThuClose(orgLabor.getThuClose()); orgLaborModel.setFriOpen(orgLabor.getFriOpen()); orgLaborModel.setFriClose(orgLabor.getFriClose()); orgLaborModel.setSatOpen(orgLabor.getSatOpen()); orgLaborModel.setSatClose(orgLabor.getSatClose()); session.save(orgLaborModel); session.flush(); } else { OrgLabor orgLaborModel = (OrgLabor)session.get(OrgLabor.class, orgLabor.getPrimaryKey()); if (orgLaborModel != null) { orgLaborModel.setOrganizationId(orgLabor.getOrganizationId()); orgLaborModel.setTypeId(orgLabor.getTypeId()); orgLaborModel.setSunOpen(orgLabor.getSunOpen()); orgLaborModel.setSunClose(orgLabor.getSunClose()); orgLaborModel.setMonOpen(orgLabor.getMonOpen()); orgLaborModel.setMonClose(orgLabor.getMonClose()); orgLaborModel.setTueOpen(orgLabor.getTueOpen()); orgLaborModel.setTueClose(orgLabor.getTueClose()); orgLaborModel.setWedOpen(orgLabor.getWedOpen()); orgLaborModel.setWedClose(orgLabor.getWedClose()); orgLaborModel.setThuOpen(orgLabor.getThuOpen()); orgLaborModel.setThuClose(orgLabor.getThuClose()); orgLaborModel.setFriOpen(orgLabor.getFriOpen()); orgLaborModel.setFriClose(orgLabor.getFriClose()); orgLaborModel.setSatOpen(orgLabor.getSatOpen()); orgLaborModel.setSatClose(orgLabor.getSatClose()); session.flush(); } else { orgLaborModel = new OrgLabor(); orgLaborModel.setOrgLaborId(orgLabor.getOrgLaborId()); orgLaborModel.setOrganizationId(orgLabor.getOrganizationId()); orgLaborModel.setTypeId(orgLabor.getTypeId()); orgLaborModel.setSunOpen(orgLabor.getSunOpen()); orgLaborModel.setSunClose(orgLabor.getSunClose()); orgLaborModel.setMonOpen(orgLabor.getMonOpen()); orgLaborModel.setMonClose(orgLabor.getMonClose()); orgLaborModel.setTueOpen(orgLabor.getTueOpen()); orgLaborModel.setTueClose(orgLabor.getTueClose()); orgLaborModel.setWedOpen(orgLabor.getWedOpen()); orgLaborModel.setWedClose(orgLabor.getWedClose()); orgLaborModel.setThuOpen(orgLabor.getThuOpen()); orgLaborModel.setThuClose(orgLabor.getThuClose()); orgLaborModel.setFriOpen(orgLabor.getFriOpen()); orgLaborModel.setFriClose(orgLabor.getFriClose()); orgLaborModel.setSatOpen(orgLabor.getSatOpen()); orgLaborModel.setSatClose(orgLabor.getSatClose()); session.save(orgLaborModel); session.flush(); } } orgLabor.setNew(false); orgLabor.setModified(false); } | session = openSession(); session.saveOrUpdate(orgLabor); session.flush(); orgLabor.setNew(false); | public com.liferay.portal.model.OrgLabor update( com.liferay.portal.model.OrgLabor orgLabor) throws SystemException { Session session = null; try { if (orgLabor.isNew() || orgLabor.isModified()) { session = openSession(); if (orgLabor.isNew()) { OrgLabor orgLaborModel = new OrgLabor(); orgLaborModel.setOrgLaborId(orgLabor.getOrgLaborId()); orgLaborModel.setOrganizationId(orgLabor.getOrganizationId()); orgLaborModel.setTypeId(orgLabor.getTypeId()); orgLaborModel.setSunOpen(orgLabor.getSunOpen()); orgLaborModel.setSunClose(orgLabor.getSunClose()); orgLaborModel.setMonOpen(orgLabor.getMonOpen()); orgLaborModel.setMonClose(orgLabor.getMonClose()); orgLaborModel.setTueOpen(orgLabor.getTueOpen()); orgLaborModel.setTueClose(orgLabor.getTueClose()); orgLaborModel.setWedOpen(orgLabor.getWedOpen()); orgLaborModel.setWedClose(orgLabor.getWedClose()); orgLaborModel.setThuOpen(orgLabor.getThuOpen()); orgLaborModel.setThuClose(orgLabor.getThuClose()); orgLaborModel.setFriOpen(orgLabor.getFriOpen()); orgLaborModel.setFriClose(orgLabor.getFriClose()); orgLaborModel.setSatOpen(orgLabor.getSatOpen()); orgLaborModel.setSatClose(orgLabor.getSatClose()); session.save(orgLaborModel); session.flush(); } else { OrgLabor orgLaborModel = (OrgLabor)session.get(OrgLabor.class, orgLabor.getPrimaryKey()); if (orgLaborModel != null) { orgLaborModel.setOrganizationId(orgLabor.getOrganizationId()); orgLaborModel.setTypeId(orgLabor.getTypeId()); orgLaborModel.setSunOpen(orgLabor.getSunOpen()); orgLaborModel.setSunClose(orgLabor.getSunClose()); orgLaborModel.setMonOpen(orgLabor.getMonOpen()); orgLaborModel.setMonClose(orgLabor.getMonClose()); orgLaborModel.setTueOpen(orgLabor.getTueOpen()); orgLaborModel.setTueClose(orgLabor.getTueClose()); orgLaborModel.setWedOpen(orgLabor.getWedOpen()); orgLaborModel.setWedClose(orgLabor.getWedClose()); orgLaborModel.setThuOpen(orgLabor.getThuOpen()); orgLaborModel.setThuClose(orgLabor.getThuClose()); orgLaborModel.setFriOpen(orgLabor.getFriOpen()); orgLaborModel.setFriClose(orgLabor.getFriClose()); orgLaborModel.setSatOpen(orgLabor.getSatOpen()); orgLaborModel.setSatClose(orgLabor.getSatClose()); session.flush(); } else { orgLaborModel = new OrgLabor(); orgLaborModel.setOrgLaborId(orgLabor.getOrgLaborId()); orgLaborModel.setOrganizationId(orgLabor.getOrganizationId()); orgLaborModel.setTypeId(orgLabor.getTypeId()); orgLaborModel.setSunOpen(orgLabor.getSunOpen()); orgLaborModel.setSunClose(orgLabor.getSunClose()); orgLaborModel.setMonOpen(orgLabor.getMonOpen()); orgLaborModel.setMonClose(orgLabor.getMonClose()); orgLaborModel.setTueOpen(orgLabor.getTueOpen()); orgLaborModel.setTueClose(orgLabor.getTueClose()); orgLaborModel.setWedOpen(orgLabor.getWedOpen()); orgLaborModel.setWedClose(orgLabor.getWedClose()); orgLaborModel.setThuOpen(orgLabor.getThuOpen()); orgLaborModel.setThuClose(orgLabor.getThuClose()); orgLaborModel.setFriOpen(orgLabor.getFriOpen()); orgLaborModel.setFriClose(orgLabor.getFriClose()); orgLaborModel.setSatOpen(orgLabor.getSatOpen()); orgLaborModel.setSatClose(orgLabor.getSatClose()); session.save(orgLaborModel); session.flush(); } } orgLabor.setNew(false); orgLabor.setModified(false); } return orgLabor; } catch (HibernateException he) { throw new SystemException(he); } finally { closeSession(session); } } | 57692 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/57692/f4d6afc6707f57fd84bf6b624f0c119657b0a766/OrgLaborPersistence.java/buggy/portal-ejb/src/com/liferay/portal/service/persistence/OrgLaborPersistence.java |
modules[i].callMethod("included", this); | public RubyModule include(IRubyObject[] modules) { for (int i = modules.length - 1; i >= 0; i--) { modules[i].callMethod("append_features", this); } return this; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f7fd42a4ed234e7ec538d58da2024183eee3d0f4/RubyModule.java/clean/src/org/jruby/RubyModule.java |
|
throw getRuntime().newTypeError("Wrong argument type " + arg.getMetaClass().getName() + " (expected Module)."); | throw getRuntime().newTypeError("Wrong argument type " + arg.getMetaClass().getName() + " (expected Module)."); | public synchronized void includeModule(IRubyObject arg) { testFrozen("module"); if (!isTaint()) { getRuntime().secure(4); } if (!(arg instanceof RubyModule)) { throw getRuntime().newTypeError("Wrong argument type " + arg.getMetaClass().getName() + " (expected Module)."); } RubyModule module = (RubyModule) arg; Map moduleMethods = module.getMethods(); // Make sure the module we include does not already exist if (isSame(module)) { return; } // Invalidate cache for all methods in the new included module in case a base class method // of the same name has already been cached. for (Iterator iter = moduleMethods.keySet().iterator(); iter.hasNext();) { String methodName = (String) iter.next(); getRuntime().getCacheMap().remove(methodName, searchMethod(methodName)); } // Include new module setSuperClass(module.newIncludeClass(getSuperClass())); // cnutter: removed iterative inclusion of module's superclasses, because it included them in reverse order // see RubyModule.newIncludeClass for replacement module.callMethod("included", this); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f7fd42a4ed234e7ec538d58da2024183eee3d0f4/RubyModule.java/clean/src/org/jruby/RubyModule.java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.