repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
primefaces-extensions/core
src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java
SheetColumn.getColWidth
public Integer getColWidth() { final Object result = getStateHelper().eval(PropertyKeys.colWidth, null); if (result == null) { return null; } return Integer.valueOf(result.toString()); }
java
public Integer getColWidth() { final Object result = getStateHelper().eval(PropertyKeys.colWidth, null); if (result == null) { return null; } return Integer.valueOf(result.toString()); }
[ "public", "Integer", "getColWidth", "(", ")", "{", "final", "Object", "result", "=", "getStateHelper", "(", ")", ".", "eval", "(", "PropertyKeys", ".", "colWidth", ",", "null", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "null", ";...
The column width @return
[ "The", "column", "width" ]
afdbca591f60f47898e3517e1e939bc2f63d5355
https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java#L267-L273
train
primefaces-extensions/core
src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java
SheetColumn.getFilterOptions
public Collection<SelectItem> getFilterOptions() { return (Collection<SelectItem>) getStateHelper().eval(PropertyKeys.filterOptions, null); }
java
public Collection<SelectItem> getFilterOptions() { return (Collection<SelectItem>) getStateHelper().eval(PropertyKeys.filterOptions, null); }
[ "public", "Collection", "<", "SelectItem", ">", "getFilterOptions", "(", ")", "{", "return", "(", "Collection", "<", "SelectItem", ">", ")", "getStateHelper", "(", ")", ".", "eval", "(", "PropertyKeys", ".", "filterOptions", ",", "null", ")", ";", "}" ]
The filterOptions expression @return
[ "The", "filterOptions", "expression" ]
afdbca591f60f47898e3517e1e939bc2f63d5355
https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java#L492-L494
train
primefaces-extensions/core
src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java
SheetColumn.getSheet
public Sheet getSheet() { if (sheet != null) { return sheet; } UIComponent parent = getParent(); while (parent != null && !(parent instanceof Sheet)) { parent = parent.getParent(); } return (Sheet) parent; }
java
public Sheet getSheet() { if (sheet != null) { return sheet; } UIComponent parent = getParent(); while (parent != null && !(parent instanceof Sheet)) { parent = parent.getParent(); } return (Sheet) parent; }
[ "public", "Sheet", "getSheet", "(", ")", "{", "if", "(", "sheet", "!=", "null", ")", "{", "return", "sheet", ";", "}", "UIComponent", "parent", "=", "getParent", "(", ")", ";", "while", "(", "parent", "!=", "null", "&&", "!", "(", "parent", "instance...
Get the parent sheet @return
[ "Get", "the", "parent", "sheet" ]
afdbca591f60f47898e3517e1e939bc2f63d5355
https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java#L508-L518
train
primefaces-extensions/core
src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java
SheetColumn.validateRequired
protected boolean validateRequired(final FacesContext context, final Object newValue) { // If our value is valid, enforce the required property if present if (isValid() && isRequired() && isEmpty(newValue)) { final String requiredMessageStr = getRequiredMessage(); FacesMessage message; if (null != requiredMessageStr) { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessageStr, requiredMessageStr); } else { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, MESSAGE_REQUIRED, MESSAGE_REQUIRED); } context.addMessage(getClientId(context), message); final Sheet sheet = getSheet(); if (sheet != null) { sheet.getInvalidUpdates().add( new SheetInvalidUpdate(sheet.getRowKeyValue(context), sheet.getColumns().indexOf(this), this, newValue, message.getDetail())); } setValid(false); return false; } return true; }
java
protected boolean validateRequired(final FacesContext context, final Object newValue) { // If our value is valid, enforce the required property if present if (isValid() && isRequired() && isEmpty(newValue)) { final String requiredMessageStr = getRequiredMessage(); FacesMessage message; if (null != requiredMessageStr) { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessageStr, requiredMessageStr); } else { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, MESSAGE_REQUIRED, MESSAGE_REQUIRED); } context.addMessage(getClientId(context), message); final Sheet sheet = getSheet(); if (sheet != null) { sheet.getInvalidUpdates().add( new SheetInvalidUpdate(sheet.getRowKeyValue(context), sheet.getColumns().indexOf(this), this, newValue, message.getDetail())); } setValid(false); return false; } return true; }
[ "protected", "boolean", "validateRequired", "(", "final", "FacesContext", "context", ",", "final", "Object", "newValue", ")", "{", "// If our value is valid, enforce the required property if present", "if", "(", "isValid", "(", ")", "&&", "isRequired", "(", ")", "&&", ...
Validates the value against the required flags on this column. @param context the FacesContext @param newValue the new value for this column @return true if passes validation, otherwise valse
[ "Validates", "the", "value", "against", "the", "required", "flags", "on", "this", "column", "." ]
afdbca591f60f47898e3517e1e939bc2f63d5355
https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetColumn.java#L674-L700
train
Credntia/MVBarcodeReader
mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeCaptureFragment.java
BarcodeCaptureFragment.requestCameraPermission
private void requestCameraPermission() { Log.w("BARCODE-SCANNER", "Camera permission is not granted. Requesting permission"); final String[] permissions = new String[]{Manifest.permission.CAMERA}; if (!shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { requestPermissions(permissions, RC_HANDLE_CAMERA_PERM); return; } Snackbar.make(mGraphicOverlay, R.string.permission_camera_rationale, Snackbar.LENGTH_INDEFINITE) .setAction(R.string.ok, new View.OnClickListener() { @Override public void onClick(View view) { requestPermissions(permissions, RC_HANDLE_CAMERA_PERM); } }) .show(); /* new AlertDialog.Builder(getContext()) .setTitle(R.string.perm_required) .setMessage(R.string.permission_camera_rationale) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //dialogInterface.dismiss(); requestPermissions(permissions, RC_HANDLE_CAMERA_PERM); } }) .setCancelable(false) .show();*/ }
java
private void requestCameraPermission() { Log.w("BARCODE-SCANNER", "Camera permission is not granted. Requesting permission"); final String[] permissions = new String[]{Manifest.permission.CAMERA}; if (!shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) { requestPermissions(permissions, RC_HANDLE_CAMERA_PERM); return; } Snackbar.make(mGraphicOverlay, R.string.permission_camera_rationale, Snackbar.LENGTH_INDEFINITE) .setAction(R.string.ok, new View.OnClickListener() { @Override public void onClick(View view) { requestPermissions(permissions, RC_HANDLE_CAMERA_PERM); } }) .show(); /* new AlertDialog.Builder(getContext()) .setTitle(R.string.perm_required) .setMessage(R.string.permission_camera_rationale) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //dialogInterface.dismiss(); requestPermissions(permissions, RC_HANDLE_CAMERA_PERM); } }) .setCancelable(false) .show();*/ }
[ "private", "void", "requestCameraPermission", "(", ")", "{", "Log", ".", "w", "(", "\"BARCODE-SCANNER\"", ",", "\"Camera permission is not granted. Requesting permission\"", ")", ";", "final", "String", "[", "]", "permissions", "=", "new", "String", "[", "]", "{", ...
Handles the requesting of the camera permission. This includes showing a "Snackbar" message of why the permission is needed then sending the request.
[ "Handles", "the", "requesting", "of", "the", "camera", "permission", ".", "This", "includes", "showing", "a", "Snackbar", "message", "of", "why", "the", "permission", "is", "needed", "then", "sending", "the", "request", "." ]
2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d
https://github.com/Credntia/MVBarcodeReader/blob/2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d/mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeCaptureFragment.java#L274-L307
train
Credntia/MVBarcodeReader
mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeCaptureFragment.java
BarcodeCaptureFragment.onTouch
@Override public boolean onTouch(View v, MotionEvent event) { boolean b = scaleGestureDetector.onTouchEvent(event); boolean c = gestureDetector.onTouchEvent(event); return b || c || v.onTouchEvent(event); }
java
@Override public boolean onTouch(View v, MotionEvent event) { boolean b = scaleGestureDetector.onTouchEvent(event); boolean c = gestureDetector.onTouchEvent(event); return b || c || v.onTouchEvent(event); }
[ "@", "Override", "public", "boolean", "onTouch", "(", "View", "v", ",", "MotionEvent", "event", ")", "{", "boolean", "b", "=", "scaleGestureDetector", ".", "onTouchEvent", "(", "event", ")", ";", "boolean", "c", "=", "gestureDetector", ".", "onTouchEvent", "...
Called when a touch event is dispatched to a view. This allows listeners to get a chance to respond before the target view. @param v The view the touch event has been dispatched to. @param event The MotionEvent object containing full information about the event. @return True if the listener has consumed the event, false otherwise.
[ "Called", "when", "a", "touch", "event", "is", "dispatched", "to", "a", "view", ".", "This", "allows", "listeners", "to", "get", "a", "chance", "to", "respond", "before", "the", "target", "view", "." ]
2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d
https://github.com/Credntia/MVBarcodeReader/blob/2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d/mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeCaptureFragment.java#L423-L430
train
Credntia/MVBarcodeReader
mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeCaptureFragment.java
BarcodeCaptureFragment.onTap
protected boolean onTap(float rawX, float rawY) { Log.d("CAPTURE-FRAGMENT", "got tap at: (" + rawX + ", " + rawY + ")"); Barcode barcode = null; if (mMode == MVBarcodeScanner.ScanningMode.SINGLE_AUTO) { BarcodeGraphic graphic = mGraphicOverlay.getFirstGraphic(); if (graphic != null) { barcode = graphic.getBarcode(); if (barcode != null && mListener != null) { mListener.onBarcodeScanned(barcode); } } } else if (mMode == MVBarcodeScanner.ScanningMode.SINGLE_MANUAL) { Set<BarcodeGraphic> graphicSet = mGraphicOverlay.getAllGraphics(); if (graphicSet != null && !graphicSet.isEmpty()) { for (BarcodeGraphic graphic : graphicSet) { if (graphic != null && graphic.isPointInsideBarcode(rawX, rawY)) { Log.d("CAPTURE-FRAGMENT", "got tap inside barcode"); barcode = graphic.getBarcode(); break; } } if (mListener != null && barcode != null) { mListener.onBarcodeScanned(barcode); } } } else { Set<BarcodeGraphic> graphicSet = mGraphicOverlay.getAllGraphics(); if (graphicSet != null && !graphicSet.isEmpty()) { List<Barcode> barcodes = new ArrayList<>(); for (BarcodeGraphic graphic : graphicSet) { if (graphic != null && graphic.getBarcode() != null) { barcode = graphic.getBarcode(); barcodes.add(barcode); } } if (mListener != null && !barcodes.isEmpty()) { mListener.onBarcodesScanned(barcodes); } } } return barcode != null; }
java
protected boolean onTap(float rawX, float rawY) { Log.d("CAPTURE-FRAGMENT", "got tap at: (" + rawX + ", " + rawY + ")"); Barcode barcode = null; if (mMode == MVBarcodeScanner.ScanningMode.SINGLE_AUTO) { BarcodeGraphic graphic = mGraphicOverlay.getFirstGraphic(); if (graphic != null) { barcode = graphic.getBarcode(); if (barcode != null && mListener != null) { mListener.onBarcodeScanned(barcode); } } } else if (mMode == MVBarcodeScanner.ScanningMode.SINGLE_MANUAL) { Set<BarcodeGraphic> graphicSet = mGraphicOverlay.getAllGraphics(); if (graphicSet != null && !graphicSet.isEmpty()) { for (BarcodeGraphic graphic : graphicSet) { if (graphic != null && graphic.isPointInsideBarcode(rawX, rawY)) { Log.d("CAPTURE-FRAGMENT", "got tap inside barcode"); barcode = graphic.getBarcode(); break; } } if (mListener != null && barcode != null) { mListener.onBarcodeScanned(barcode); } } } else { Set<BarcodeGraphic> graphicSet = mGraphicOverlay.getAllGraphics(); if (graphicSet != null && !graphicSet.isEmpty()) { List<Barcode> barcodes = new ArrayList<>(); for (BarcodeGraphic graphic : graphicSet) { if (graphic != null && graphic.getBarcode() != null) { barcode = graphic.getBarcode(); barcodes.add(barcode); } } if (mListener != null && !barcodes.isEmpty()) { mListener.onBarcodesScanned(barcodes); } } } return barcode != null; }
[ "protected", "boolean", "onTap", "(", "float", "rawX", ",", "float", "rawY", ")", "{", "Log", ".", "d", "(", "\"CAPTURE-FRAGMENT\"", ",", "\"got tap at: (\"", "+", "rawX", "+", "\", \"", "+", "rawY", "+", "\")\"", ")", ";", "Barcode", "barcode", "=", "nu...
onTap is called to capture the oldest barcode currently detected and return it to the caller. @param rawX - the raw position of the tap @param rawY - the raw position of the tap. @return true if the activity is ending.
[ "onTap", "is", "called", "to", "capture", "the", "oldest", "barcode", "currently", "detected", "and", "return", "it", "to", "the", "caller", "." ]
2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d
https://github.com/Credntia/MVBarcodeReader/blob/2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d/mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeCaptureFragment.java#L440-L487
train
Credntia/MVBarcodeReader
mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeGraphicTracker.java
BarcodeGraphicTracker.onNewItem
@Override public void onNewItem(int id, Barcode item) { mGraphic.setId(id); if (mListener != null) mListener.onNewBarcodeDetected(id, item); }
java
@Override public void onNewItem(int id, Barcode item) { mGraphic.setId(id); if (mListener != null) mListener.onNewBarcodeDetected(id, item); }
[ "@", "Override", "public", "void", "onNewItem", "(", "int", "id", ",", "Barcode", "item", ")", "{", "mGraphic", ".", "setId", "(", "id", ")", ";", "if", "(", "mListener", "!=", "null", ")", "mListener", ".", "onNewBarcodeDetected", "(", "id", ",", "ite...
Start tracking the detected item instance within the item overlay.
[ "Start", "tracking", "the", "detected", "item", "instance", "within", "the", "item", "overlay", "." ]
2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d
https://github.com/Credntia/MVBarcodeReader/blob/2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d/mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeGraphicTracker.java#L50-L54
train
Credntia/MVBarcodeReader
mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeGraphic.java
BarcodeGraphic.draw
@Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = getViewBoundingBox(barcode); canvas.drawRect(rect, mOverlayPaint); /** * Draw the top left corner */ canvas.drawLine(rect.left, rect.top, rect.left + CORNER_WIDTH, rect.top, mRectPaint); canvas.drawLine(rect.left, rect.top, rect.left, rect.top + CORNER_WIDTH, mRectPaint); /** * Draw the bottom left corner */ canvas.drawLine(rect.left, rect.bottom, rect.left, rect.bottom - CORNER_WIDTH, mRectPaint); canvas.drawLine(rect.left, rect.bottom, rect.left + CORNER_WIDTH, rect.bottom, mRectPaint); /** * Draw the top right corner */ canvas.drawLine(rect.right, rect.top, rect.right - CORNER_WIDTH, rect.top, mRectPaint); canvas.drawLine(rect.right, rect.top, rect.right, rect.top + CORNER_WIDTH, mRectPaint); /** * Draw the bottom right corner */ canvas.drawLine(rect.right, rect.bottom, rect.right - CORNER_WIDTH, rect.bottom, mRectPaint); canvas.drawLine(rect.right, rect.bottom, rect.right, rect.bottom - CORNER_WIDTH, mRectPaint); }
java
@Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = getViewBoundingBox(barcode); canvas.drawRect(rect, mOverlayPaint); /** * Draw the top left corner */ canvas.drawLine(rect.left, rect.top, rect.left + CORNER_WIDTH, rect.top, mRectPaint); canvas.drawLine(rect.left, rect.top, rect.left, rect.top + CORNER_WIDTH, mRectPaint); /** * Draw the bottom left corner */ canvas.drawLine(rect.left, rect.bottom, rect.left, rect.bottom - CORNER_WIDTH, mRectPaint); canvas.drawLine(rect.left, rect.bottom, rect.left + CORNER_WIDTH, rect.bottom, mRectPaint); /** * Draw the top right corner */ canvas.drawLine(rect.right, rect.top, rect.right - CORNER_WIDTH, rect.top, mRectPaint); canvas.drawLine(rect.right, rect.top, rect.right, rect.top + CORNER_WIDTH, mRectPaint); /** * Draw the bottom right corner */ canvas.drawLine(rect.right, rect.bottom, rect.right - CORNER_WIDTH, rect.bottom, mRectPaint); canvas.drawLine(rect.right, rect.bottom, rect.right, rect.bottom - CORNER_WIDTH, mRectPaint); }
[ "@", "Override", "public", "void", "draw", "(", "Canvas", "canvas", ")", "{", "Barcode", "barcode", "=", "mBarcode", ";", "if", "(", "barcode", "==", "null", ")", "{", "return", ";", "}", "// Draws the bounding box around the barcode.", "RectF", "rect", "=", ...
Draws the barcode annotations for position, size, and raw value on the supplied canvas.
[ "Draws", "the", "barcode", "annotations", "for", "position", "size", "and", "raw", "value", "on", "the", "supplied", "canvas", "." ]
2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d
https://github.com/Credntia/MVBarcodeReader/blob/2a2561f1c3b4d4e3c046a341fbf23a31eabfda8d/mvbarcodereader/src/main/java/devliving/online/mvbarcodereader/BarcodeGraphic.java#L123-L158
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/AbstractGwtMojo.java
AbstractGwtMojo.addClasspathElements
protected int addClasspathElements( Collection<?> elements, URL[] urls, int startPosition ) throws MojoExecutionException { for ( Object object : elements ) { try { if ( object instanceof Artifact ) { urls[startPosition] = ( (Artifact) object ).getFile().toURI().toURL(); } else if ( object instanceof Resource ) { urls[startPosition] = new File( ( (Resource) object ).getDirectory() ).toURI().toURL(); } else { urls[startPosition] = new File( (String) object ).toURI().toURL(); } } catch ( MalformedURLException e ) { throw new MojoExecutionException( "Failed to convert original classpath element " + object + " to URL.", e ); } startPosition++; } return startPosition; }
java
protected int addClasspathElements( Collection<?> elements, URL[] urls, int startPosition ) throws MojoExecutionException { for ( Object object : elements ) { try { if ( object instanceof Artifact ) { urls[startPosition] = ( (Artifact) object ).getFile().toURI().toURL(); } else if ( object instanceof Resource ) { urls[startPosition] = new File( ( (Resource) object ).getDirectory() ).toURI().toURL(); } else { urls[startPosition] = new File( (String) object ).toURI().toURL(); } } catch ( MalformedURLException e ) { throw new MojoExecutionException( "Failed to convert original classpath element " + object + " to URL.", e ); } startPosition++; } return startPosition; }
[ "protected", "int", "addClasspathElements", "(", "Collection", "<", "?", ">", "elements", ",", "URL", "[", "]", "urls", ",", "int", "startPosition", ")", "throws", "MojoExecutionException", "{", "for", "(", "Object", "object", ":", "elements", ")", "{", "try...
Add classpath elements to a classpath URL set @param elements the initial URL set @param urls the urls to add @param startPosition the position to insert URLS @return full classpath URL set @throws MojoExecutionException some error occured
[ "Add", "classpath", "elements", "to", "a", "classpath", "URL", "set" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/AbstractGwtMojo.java#L184-L213
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/AbstractGwtMojo.java
AbstractGwtMojo.getClasspath
public Collection<File> getClasspath( String scope ) throws MojoExecutionException { try { Collection<File> files = classpathBuilder.buildClasspathList( getProject(), scope, getProjectArtifacts(), isGenerator() ); if ( getLog().isDebugEnabled() ) { getLog().debug( "GWT SDK execution classpath :" ); for ( File f : files ) { getLog().debug( " " + f.getAbsolutePath() ); } } return files; } catch ( ClasspathBuilderException e ) { throw new MojoExecutionException( e.getMessage(), e ); } }
java
public Collection<File> getClasspath( String scope ) throws MojoExecutionException { try { Collection<File> files = classpathBuilder.buildClasspathList( getProject(), scope, getProjectArtifacts(), isGenerator() ); if ( getLog().isDebugEnabled() ) { getLog().debug( "GWT SDK execution classpath :" ); for ( File f : files ) { getLog().debug( " " + f.getAbsolutePath() ); } } return files; } catch ( ClasspathBuilderException e ) { throw new MojoExecutionException( e.getMessage(), e ); } }
[ "public", "Collection", "<", "File", ">", "getClasspath", "(", "String", "scope", ")", "throws", "MojoExecutionException", "{", "try", "{", "Collection", "<", "File", ">", "files", "=", "classpathBuilder", ".", "buildClasspathList", "(", "getProject", "(", ")", ...
Build the GWT classpath for the specified scope @param scope Artifact.SCOPE_COMPILE or Artifact.SCOPE_TEST @return a collection of dependencies as Files for the specified scope. @throws MojoExecutionException if classPath building failed
[ "Build", "the", "GWT", "classpath", "for", "the", "specified", "scope" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/AbstractGwtMojo.java#L223-L244
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/AbstractGwtMojo.java
AbstractGwtMojo.checkGwtUserVersion
private void checkGwtUserVersion() throws MojoExecutionException { InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream( "org/codehaus/mojo/gwt/mojoGwtVersion.properties" ); Properties properties = new Properties(); try { properties.load( inputStream ); } catch (IOException e) { throw new MojoExecutionException( "Failed to load plugin properties", e ); } finally { IOUtils.closeQuietly( inputStream ); } Artifact gwtUser = project.getArtifactMap().get( GWT_USER ); if (gwtUser != null) { String mojoGwtVersion = properties.getProperty( "gwt.version" ); //ComparableVersion with an up2date maven version ArtifactVersion mojoGwtArtifactVersion = new DefaultArtifactVersion( mojoGwtVersion ); ArtifactVersion userGwtArtifactVersion = new DefaultArtifactVersion( gwtUser.getVersion() ); if ( userGwtArtifactVersion.compareTo( mojoGwtArtifactVersion ) < 0 ) { getLog().warn( "Your project declares dependency on gwt-user " + gwtUser.getVersion() + ". This plugin is designed for at least gwt version " + mojoGwtVersion ); } } }
java
private void checkGwtUserVersion() throws MojoExecutionException { InputStream inputStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream( "org/codehaus/mojo/gwt/mojoGwtVersion.properties" ); Properties properties = new Properties(); try { properties.load( inputStream ); } catch (IOException e) { throw new MojoExecutionException( "Failed to load plugin properties", e ); } finally { IOUtils.closeQuietly( inputStream ); } Artifact gwtUser = project.getArtifactMap().get( GWT_USER ); if (gwtUser != null) { String mojoGwtVersion = properties.getProperty( "gwt.version" ); //ComparableVersion with an up2date maven version ArtifactVersion mojoGwtArtifactVersion = new DefaultArtifactVersion( mojoGwtVersion ); ArtifactVersion userGwtArtifactVersion = new DefaultArtifactVersion( gwtUser.getVersion() ); if ( userGwtArtifactVersion.compareTo( mojoGwtArtifactVersion ) < 0 ) { getLog().warn( "Your project declares dependency on gwt-user " + gwtUser.getVersion() + ". This plugin is designed for at least gwt version " + mojoGwtVersion ); } } }
[ "private", "void", "checkGwtUserVersion", "(", ")", "throws", "MojoExecutionException", "{", "InputStream", "inputStream", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResourceAsStream", "(", "\"org/codehaus/mojo/gwt/mo...
Check gwt-user dependency matches plugin version
[ "Check", "gwt", "-", "user", "dependency", "matches", "plugin", "version" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/AbstractGwtMojo.java#L311-L343
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/eclipse/EclipseUtil.java
EclipseUtil.getProjectName
public String getProjectName( MavenProject project ) { File dotProject = new File( project.getBasedir(), ".project" ); try { Xpp3Dom dom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( dotProject ) ); return dom.getChild( "name" ).getValue(); } catch ( Exception e ) { getLogger().warn( "Failed to read the .project file" ); return project.getArtifactId(); } }
java
public String getProjectName( MavenProject project ) { File dotProject = new File( project.getBasedir(), ".project" ); try { Xpp3Dom dom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( dotProject ) ); return dom.getChild( "name" ).getValue(); } catch ( Exception e ) { getLogger().warn( "Failed to read the .project file" ); return project.getArtifactId(); } }
[ "public", "String", "getProjectName", "(", "MavenProject", "project", ")", "{", "File", "dotProject", "=", "new", "File", "(", "project", ".", "getBasedir", "(", ")", ",", "\".project\"", ")", ";", "try", "{", "Xpp3Dom", "dom", "=", "Xpp3DomBuilder", ".", ...
Read the Eclipse project name for .project file. Fall back to artifactId on error @return project name in eclipse workspace
[ "Read", "the", "Eclipse", "project", "name", "for", ".", "project", "file", ".", "Fall", "back", "to", "artifactId", "on", "error" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/eclipse/EclipseUtil.java#L44-L57
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java
ClasspathBuilder.getScopeArtifacts
private List<Artifact> getScopeArtifacts( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) ) { return project.getCompileArtifacts(); } if ( SCOPE_RUNTIME.equals( scope ) ) { return project.getRuntimeArtifacts(); } else if ( SCOPE_TEST.equals( scope ) ) { return project.getTestArtifacts(); } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
java
private List<Artifact> getScopeArtifacts( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) ) { return project.getCompileArtifacts(); } if ( SCOPE_RUNTIME.equals( scope ) ) { return project.getRuntimeArtifacts(); } else if ( SCOPE_TEST.equals( scope ) ) { return project.getTestArtifacts(); } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
[ "private", "List", "<", "Artifact", ">", "getScopeArtifacts", "(", "final", "MavenProject", "project", ",", "final", "String", "scope", ")", "{", "if", "(", "SCOPE_COMPILE", ".", "equals", "(", "scope", ")", ")", "{", "return", "project", ".", "getCompileArt...
Get artifacts for specific scope. @param project @param scope @return
[ "Get", "artifacts", "for", "specific", "scope", "." ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java#L195-L213
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java
ClasspathBuilder.getSourceRoots
private List<String> getSourceRoots( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) ) { return project.getCompileSourceRoots(); } else if ( SCOPE_TEST.equals( scope ) ) { List<String> sourceRoots = new ArrayList<String>(); sourceRoots.addAll( project.getTestCompileSourceRoots() ); sourceRoots.addAll( project.getCompileSourceRoots() ); return sourceRoots; } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
java
private List<String> getSourceRoots( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) ) { return project.getCompileSourceRoots(); } else if ( SCOPE_TEST.equals( scope ) ) { List<String> sourceRoots = new ArrayList<String>(); sourceRoots.addAll( project.getTestCompileSourceRoots() ); sourceRoots.addAll( project.getCompileSourceRoots() ); return sourceRoots; } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
[ "private", "List", "<", "String", ">", "getSourceRoots", "(", "final", "MavenProject", "project", ",", "final", "String", "scope", ")", "{", "if", "(", "SCOPE_COMPILE", ".", "equals", "(", "scope", ")", "||", "SCOPE_RUNTIME", ".", "equals", "(", "scope", "...
Get source roots for specific scope. @param project @param scope @return
[ "Get", "source", "roots", "for", "specific", "scope", "." ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java#L222-L239
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java
ClasspathBuilder.getResources
private List<Resource> getResources( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) ) { return project.getResources(); } else if ( SCOPE_TEST.equals( scope ) ) { List<Resource> resources = new ArrayList<Resource>(); resources.addAll( project.getTestResources() ); resources.addAll( project.getResources() ); return resources; } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
java
private List<Resource> getResources( final MavenProject project, final String scope ) { if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) ) { return project.getResources(); } else if ( SCOPE_TEST.equals( scope ) ) { List<Resource> resources = new ArrayList<Resource>(); resources.addAll( project.getTestResources() ); resources.addAll( project.getResources() ); return resources; } else { throw new RuntimeException( "Not allowed scope " + scope ); } }
[ "private", "List", "<", "Resource", ">", "getResources", "(", "final", "MavenProject", "project", ",", "final", "String", "scope", ")", "{", "if", "(", "SCOPE_COMPILE", ".", "equals", "(", "scope", ")", "||", "SCOPE_RUNTIME", ".", "equals", "(", "scope", "...
Get resources for specific scope. @param project @param scope @return
[ "Get", "resources", "for", "specific", "scope", "." ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java#L248-L265
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java
ClasspathBuilder.getProjectReferenceId
private String getProjectReferenceId( final String groupId, final String artifactId, final String version ) { return groupId + ":" + artifactId + ":" + version; }
java
private String getProjectReferenceId( final String groupId, final String artifactId, final String version ) { return groupId + ":" + artifactId + ":" + version; }
[ "private", "String", "getProjectReferenceId", "(", "final", "String", "groupId", ",", "final", "String", "artifactId", ",", "final", "String", "version", ")", "{", "return", "groupId", "+", "\":\"", "+", "artifactId", "+", "\":\"", "+", "version", ";", "}" ]
Cut from MavenProject.java @param groupId @param artifactId @param version @return
[ "Cut", "from", "MavenProject", ".", "java" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/ClasspathBuilder.java#L303-L306
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/AbstractGwtModuleMojo.java
AbstractGwtModuleMojo.getModules
public String[] getModules() { // module has higher priority if set by expression if ( module != null ) { return new String[] { module }; } if ( modules == null ) { //Use a Set to avoid duplicate when user set src/main/java as <resource> Set<String> mods = new HashSet<String>(); Collection<String> sourcePaths = getProject().getCompileSourceRoots(); for ( String sourcePath : sourcePaths ) { File sourceDirectory = new File( sourcePath ); if ( sourceDirectory.exists() ) { DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir( sourceDirectory.getAbsolutePath() ); scanner.setIncludes( new String[] { "**/*" + DefaultGwtModuleReader.GWT_MODULE_EXTENSION } ); scanner.scan(); mods.addAll( Arrays.asList( scanner.getIncludedFiles() ) ); } } Collection<Resource> resources = getProject().getResources(); for ( Resource resource : resources ) { File resourceDirectoryFile = new File( resource.getDirectory() ); if ( !resourceDirectoryFile.exists() ) { continue; } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir( resource.getDirectory() ); scanner.setIncludes( new String[] { "**/*" + DefaultGwtModuleReader.GWT_MODULE_EXTENSION } ); scanner.scan(); mods.addAll( Arrays.asList( scanner.getIncludedFiles() ) ); } if ( mods.isEmpty() ) { getLog().warn( "GWT plugin is configured to detect modules, but none were found." ); } modules = new String[mods.size()]; int i = 0; for ( String fileName : mods ) { String path = fileName.substring( 0, fileName.length() - DefaultGwtModuleReader.GWT_MODULE_EXTENSION.length() ); modules[i++] = path.replace( File.separatorChar, '.' ); } if ( modules.length > 0 ) { getLog().info( "auto discovered modules " + Arrays.asList( modules ) ); } } return modules; }
java
public String[] getModules() { // module has higher priority if set by expression if ( module != null ) { return new String[] { module }; } if ( modules == null ) { //Use a Set to avoid duplicate when user set src/main/java as <resource> Set<String> mods = new HashSet<String>(); Collection<String> sourcePaths = getProject().getCompileSourceRoots(); for ( String sourcePath : sourcePaths ) { File sourceDirectory = new File( sourcePath ); if ( sourceDirectory.exists() ) { DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir( sourceDirectory.getAbsolutePath() ); scanner.setIncludes( new String[] { "**/*" + DefaultGwtModuleReader.GWT_MODULE_EXTENSION } ); scanner.scan(); mods.addAll( Arrays.asList( scanner.getIncludedFiles() ) ); } } Collection<Resource> resources = getProject().getResources(); for ( Resource resource : resources ) { File resourceDirectoryFile = new File( resource.getDirectory() ); if ( !resourceDirectoryFile.exists() ) { continue; } DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir( resource.getDirectory() ); scanner.setIncludes( new String[] { "**/*" + DefaultGwtModuleReader.GWT_MODULE_EXTENSION } ); scanner.scan(); mods.addAll( Arrays.asList( scanner.getIncludedFiles() ) ); } if ( mods.isEmpty() ) { getLog().warn( "GWT plugin is configured to detect modules, but none were found." ); } modules = new String[mods.size()]; int i = 0; for ( String fileName : mods ) { String path = fileName.substring( 0, fileName.length() - DefaultGwtModuleReader.GWT_MODULE_EXTENSION.length() ); modules[i++] = path.replace( File.separatorChar, '.' ); } if ( modules.length > 0 ) { getLog().info( "auto discovered modules " + Arrays.asList( modules ) ); } } return modules; }
[ "public", "String", "[", "]", "getModules", "(", ")", "{", "// module has higher priority if set by expression", "if", "(", "module", "!=", "null", ")", "{", "return", "new", "String", "[", "]", "{", "module", "}", ";", "}", "if", "(", "modules", "==", "nu...
FIXME move to DefaultGwtModuleReader !
[ "FIXME", "move", "to", "DefaultGwtModuleReader", "!" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/AbstractGwtModuleMojo.java#L84-L146
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/GenerateAsyncMojo.java
GenerateAsyncMojo.isDeprecated
private boolean isDeprecated( JavaMethod method ) { if ( method == null ) return false; for ( Annotation annotation : method.getAnnotations() ) { if ( "java.lang.Deprecated".equals( annotation.getType().getFullyQualifiedName() ) ) { return true; } } return method.getTagByName( "deprecated" ) != null; }
java
private boolean isDeprecated( JavaMethod method ) { if ( method == null ) return false; for ( Annotation annotation : method.getAnnotations() ) { if ( "java.lang.Deprecated".equals( annotation.getType().getFullyQualifiedName() ) ) { return true; } } return method.getTagByName( "deprecated" ) != null; }
[ "private", "boolean", "isDeprecated", "(", "JavaMethod", "method", ")", "{", "if", "(", "method", "==", "null", ")", "return", "false", ";", "for", "(", "Annotation", "annotation", ":", "method", ".", "getAnnotations", "(", ")", ")", "{", "if", "(", "\"j...
Determine if a client service method is deprecated. @see MGWT-352
[ "Determine", "if", "a", "client", "service", "method", "is", "deprecated", "." ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/GenerateAsyncMojo.java#L375-L389
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/GwtModule.java
GwtModule.getInherits
public Set<GwtModule> getInherits() throws GwtModuleReaderException { if ( inherits != null ) { return inherits; } inherits = new HashSet<GwtModule>(); addInheritedModules( inherits, getLocalInherits() ); return inherits; }
java
public Set<GwtModule> getInherits() throws GwtModuleReaderException { if ( inherits != null ) { return inherits; } inherits = new HashSet<GwtModule>(); addInheritedModules( inherits, getLocalInherits() ); return inherits; }
[ "public", "Set", "<", "GwtModule", ">", "getInherits", "(", ")", "throws", "GwtModuleReaderException", "{", "if", "(", "inherits", "!=", "null", ")", "{", "return", "inherits", ";", "}", "inherits", "=", "new", "HashSet", "<", "GwtModule", ">", "(", ")", ...
Build the set of inhertied modules. Due to xml inheritence mecanism, there may be cicles in the inheritence graph, so we build a set of inherited modules
[ "Build", "the", "set", "of", "inhertied", "modules", ".", "Due", "to", "xml", "inheritence", "mecanism", "there", "may", "be", "cicles", "in", "the", "inheritence", "graph", "so", "we", "build", "a", "set", "of", "inherited", "modules" ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/GwtModule.java#L140-L152
train
gwt-maven-plugin/gwt-maven-plugin
src/main/java/org/codehaus/mojo/gwt/GwtResourcesBaseMojo.java
GwtResourcesBaseMojo.getAllResourceFiles
protected Collection<ResourceFile> getAllResourceFiles() throws MojoExecutionException { try { Set<ResourceFile> sourcesAndResources = new HashSet<ResourceFile>(); Set<String> sourcesAndResourcesPath = new HashSet<String>(); sourcesAndResourcesPath.addAll( getProject().getCompileSourceRoots() ); for ( Resource resource : getProject().getResources() ) { sourcesAndResourcesPath.add( resource.getDirectory() ); } for ( String name : getModules() ) { GwtModule module = readModule( name ); sourcesAndResources.add( getDescriptor( module, sourcesAndResourcesPath ) ); int count = 1; for ( String source : module.getSources() ) { getLog().debug( "GWT sources from " + name + '.' + source ); Collection<ResourceFile> files = getAsResources( module, source, sourcesAndResourcesPath, "**/*.java" ); sourcesAndResources.addAll( files ); count += files.size(); Collection<ResourceFile> uifiles = getAsResources( module, source, sourcesAndResourcesPath, "**/*.ui.xml" ); sourcesAndResources.addAll( uifiles ); count += uifiles.size(); } for ( String source : module.getSuperSources() ) { getLog().debug( "GWT super-sources from " + name + '.' + source ); Collection<ResourceFile> files = getAsResources( module, source, sourcesAndResourcesPath, "**/*.java" ); sourcesAndResources.addAll( files ); count += files.size(); Collection<ResourceFile> uifiles = getAsResources( module, source, sourcesAndResourcesPath, "**/*.ui.xml" ); sourcesAndResources.addAll( uifiles ); count += uifiles.size(); } getLog().info( count + " source files from GWT module " + name ); } return sourcesAndResources; } catch ( GwtModuleReaderException e ) { throw new MojoExecutionException( e.getMessage(), e ); } }
java
protected Collection<ResourceFile> getAllResourceFiles() throws MojoExecutionException { try { Set<ResourceFile> sourcesAndResources = new HashSet<ResourceFile>(); Set<String> sourcesAndResourcesPath = new HashSet<String>(); sourcesAndResourcesPath.addAll( getProject().getCompileSourceRoots() ); for ( Resource resource : getProject().getResources() ) { sourcesAndResourcesPath.add( resource.getDirectory() ); } for ( String name : getModules() ) { GwtModule module = readModule( name ); sourcesAndResources.add( getDescriptor( module, sourcesAndResourcesPath ) ); int count = 1; for ( String source : module.getSources() ) { getLog().debug( "GWT sources from " + name + '.' + source ); Collection<ResourceFile> files = getAsResources( module, source, sourcesAndResourcesPath, "**/*.java" ); sourcesAndResources.addAll( files ); count += files.size(); Collection<ResourceFile> uifiles = getAsResources( module, source, sourcesAndResourcesPath, "**/*.ui.xml" ); sourcesAndResources.addAll( uifiles ); count += uifiles.size(); } for ( String source : module.getSuperSources() ) { getLog().debug( "GWT super-sources from " + name + '.' + source ); Collection<ResourceFile> files = getAsResources( module, source, sourcesAndResourcesPath, "**/*.java" ); sourcesAndResources.addAll( files ); count += files.size(); Collection<ResourceFile> uifiles = getAsResources( module, source, sourcesAndResourcesPath, "**/*.ui.xml" ); sourcesAndResources.addAll( uifiles ); count += uifiles.size(); } getLog().info( count + " source files from GWT module " + name ); } return sourcesAndResources; } catch ( GwtModuleReaderException e ) { throw new MojoExecutionException( e.getMessage(), e ); } }
[ "protected", "Collection", "<", "ResourceFile", ">", "getAllResourceFiles", "(", ")", "throws", "MojoExecutionException", "{", "try", "{", "Set", "<", "ResourceFile", ">", "sourcesAndResources", "=", "new", "HashSet", "<", "ResourceFile", ">", "(", ")", ";", "Se...
Collect GWT java source code and module descriptor to be added as resources.
[ "Collect", "GWT", "java", "source", "code", "and", "module", "descriptor", "to", "be", "added", "as", "resources", "." ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/src/main/java/org/codehaus/mojo/gwt/GwtResourcesBaseMojo.java#L64-L118
train
gwt-maven-plugin/gwt-maven-plugin
generated-archetype/some-artifact/src/main/java/com/company/server/GreetingServiceImpl.java
GreetingServiceImpl.escapeHtml
private String escapeHtml(String html) { if (html == null) { return null; } return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll( ">", "&gt;"); }
java
private String escapeHtml(String html) { if (html == null) { return null; } return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll( ">", "&gt;"); }
[ "private", "String", "escapeHtml", "(", "String", "html", ")", "{", "if", "(", "html", "==", "null", ")", "{", "return", "null", ";", "}", "return", "html", ".", "replaceAll", "(", "\"&\"", ",", "\"&amp;\"", ")", ".", "replaceAll", "(", "\"<\"", ",", ...
Escape an html string. Escaping data received from the client helps to prevent cross-site script vulnerabilities. @param html the html string to escape @return the escaped string
[ "Escape", "an", "html", "string", ".", "Escaping", "data", "received", "from", "the", "client", "helps", "to", "prevent", "cross", "-", "site", "script", "vulnerabilities", "." ]
0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc
https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/0cdd5054b43f182cc22a8acf61ec79ac42b0dfdc/generated-archetype/some-artifact/src/main/java/com/company/server/GreetingServiceImpl.java#L41-L47
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/filter/AutoAuthCriteriaParser.java
AutoAuthCriteriaParser.parse
public boolean parse(String criteria, Map<String, ? extends Object> attributes) throws CriteriaParseException { if (criteria == null) { return true; } else { try { return Boolean.parseBoolean(FREEMARKER_BUILTINS.eval(criteria, attributes)); } catch (TemplateException ex) { throw new CriteriaParseException(ex); } } }
java
public boolean parse(String criteria, Map<String, ? extends Object> attributes) throws CriteriaParseException { if (criteria == null) { return true; } else { try { return Boolean.parseBoolean(FREEMARKER_BUILTINS.eval(criteria, attributes)); } catch (TemplateException ex) { throw new CriteriaParseException(ex); } } }
[ "public", "boolean", "parse", "(", "String", "criteria", ",", "Map", "<", "String", ",", "?", "extends", "Object", ">", "attributes", ")", "throws", "CriteriaParseException", "{", "if", "(", "criteria", "==", "null", ")", "{", "return", "true", ";", "}", ...
Parses the provided criteria expression, which must have a boolean value. @param criteria the criteria expression string. If <code>null</code>, this method returns <code>true</code>. @param attributes any user attribute-value pairs. The attribute names may be used as variables. @return <code>true</code> if the provided criteria is <code>null</code> or evaluates to <code>true</code>, <code>false</code> otherwise. @throws CriteriaParseException if an error occurred parsing the criteria expression, most likely because the expression is invalid.
[ "Parses", "the", "provided", "criteria", "expression", "which", "must", "have", "a", "boolean", "value", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/filter/AutoAuthCriteriaParser.java#L49-L59
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/auth/AuthorizedUserSupport.java
AuthorizedUserSupport.getUser
public E getUser(HttpServletRequest servletRequest) { AttributePrincipal principal = getUserPrincipal(servletRequest); E result = this.userDao.getByPrincipal(principal); if (result == null) { throw new HttpStatusException(Status.FORBIDDEN, "User " + principal.getName() + " is not authorized to use this resource"); } return result; }
java
public E getUser(HttpServletRequest servletRequest) { AttributePrincipal principal = getUserPrincipal(servletRequest); E result = this.userDao.getByPrincipal(principal); if (result == null) { throw new HttpStatusException(Status.FORBIDDEN, "User " + principal.getName() + " is not authorized to use this resource"); } return result; }
[ "public", "E", "getUser", "(", "HttpServletRequest", "servletRequest", ")", "{", "AttributePrincipal", "principal", "=", "getUserPrincipal", "(", "servletRequest", ")", ";", "E", "result", "=", "this", ".", "userDao", ".", "getByPrincipal", "(", "principal", ")", ...
Returns the user object, or if there isn't one, throws an exception. @param servletRequest the HTTP servlet request. @return the user object. @throws HttpStatusException if the logged-in user isn't in the user table, which means the user is not authorized to use eureka-protempa-etl.
[ "Returns", "the", "user", "object", "or", "if", "there", "isn", "t", "one", "throws", "an", "exception", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/auth/AuthorizedUserSupport.java#L61-L68
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/config/ClientSessionListener.java
ClientSessionListener.attributeReplaced
@Override public void attributeReplaced(HttpSessionBindingEvent hse) { Object possibleClient = hse.getValue(); closeClient(possibleClient); }
java
@Override public void attributeReplaced(HttpSessionBindingEvent hse) { Object possibleClient = hse.getValue(); closeClient(possibleClient); }
[ "@", "Override", "public", "void", "attributeReplaced", "(", "HttpSessionBindingEvent", "hse", ")", "{", "Object", "possibleClient", "=", "hse", ".", "getValue", "(", ")", ";", "closeClient", "(", "possibleClient", ")", ";", "}" ]
Attempts to close the old client. @param hse the session binding event.
[ "Attempts", "to", "close", "the", "old", "client", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/config/ClientSessionListener.java#L52-L56
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/config/ClientSessionListener.java
ClientSessionListener.attributeRemoved
@Override public void attributeRemoved(HttpSessionBindingEvent hse) { Object possibleClient = hse.getValue(); closeClient(possibleClient); }
java
@Override public void attributeRemoved(HttpSessionBindingEvent hse) { Object possibleClient = hse.getValue(); closeClient(possibleClient); }
[ "@", "Override", "public", "void", "attributeRemoved", "(", "HttpSessionBindingEvent", "hse", ")", "{", "Object", "possibleClient", "=", "hse", ".", "getValue", "(", ")", ";", "closeClient", "(", "possibleClient", ")", ";", "}" ]
Attempts to close the client. @param hse the session event.
[ "Attempts", "to", "close", "the", "client", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/config/ClientSessionListener.java#L63-L67
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doDelete
protected void doDelete(String path, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { ClientResponse response = this.getResourceWrapper() .rewritten(path, HttpMethod.DELETE) .delete(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT, ClientResponse.Status.ACCEPTED); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected void doDelete(String path, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { ClientResponse response = this.getResourceWrapper() .rewritten(path, HttpMethod.DELETE) .delete(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT, ClientResponse.Status.ACCEPTED); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "void", "doDelete", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", ";", "try", "{", "ClientResponse", "response",...
Deletes the resource specified by the path. @param headers any HTTP headers. Can be <code>null</code>. @param path the path to the resource. Cannot be <code>null</code>. @throws ClientException if a status code other than 204 (No Content), 202 (Accepted), and 200 (OK) is returned.
[ "Deletes", "the", "resource", "specified", "by", "the", "path", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L129-L142
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPut
protected void doPut(String path) throws ClientException { this.readLock.lock(); try { ClientResponse response = this.getResourceWrapper() .rewritten(path, HttpMethod.PUT) .put(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected void doPut(String path) throws ClientException { this.readLock.lock(); try { ClientResponse response = this.getResourceWrapper() .rewritten(path, HttpMethod.PUT) .put(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "void", "doPut", "(", "String", "path", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", ";", "try", "{", "ClientResponse", "response", "=", "this", ".", "getResourceWrapper", "(", ")", ".", "rewritten", "...
Updates the resource specified by the path, for situations where the nature of the update is completely specified by the path alone. @param path the path to the resource. Cannot be <code>null</code>. @throws ClientException if a status code other than 204 (No Content) and 200 (OK) is returned.
[ "Updates", "the", "resource", "specified", "by", "the", "path", "for", "situations", "where", "the", "nature", "of", "the", "update", "is", "completely", "specified", "by", "the", "path", "alone", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L153-L166
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPut
protected void doPut(String path, Object o) throws ClientException { doPut(path, o, null); }
java
protected void doPut(String path, Object o) throws ClientException { doPut(path, o, null); }
[ "protected", "void", "doPut", "(", "String", "path", ",", "Object", "o", ")", "throws", "ClientException", "{", "doPut", "(", "path", ",", "o", ",", "null", ")", ";", "}" ]
Updates the resource specified by the path. Sends to the server a Content Type header for JSON. @param o the updated object, will be transmitted as JSON. It must be a Java bean or an object that the object mapper that is in use knows about. @param path the path to the resource. Cannot be <code>null</code>. @throws ClientException if a status code other than 204 (No Content) or 200 (OK) is returned.
[ "Updates", "the", "resource", "specified", "by", "the", "path", ".", "Sends", "to", "the", "server", "a", "Content", "Type", "header", "for", "JSON", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L179-L181
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doGet
protected <T> T doGet(String path, Class<T> cls) throws ClientException { return doGet(path, cls, null); }
java
protected <T> T doGet(String path, Class<T> cls) throws ClientException { return doGet(path, cls, null); }
[ "protected", "<", "T", ">", "T", "doGet", "(", "String", "path", ",", "Class", "<", "T", ">", "cls", ")", "throws", "ClientException", "{", "return", "doGet", "(", "path", ",", "cls", ",", "null", ")", ";", "}" ]
Gets the resource specified by the path. Sends to the server an Accepts header for JSON. @param <T> the type of the resource. @param path the path to the resource. Cannot be <code>null</code>. @param cls the type of the resource. Cannot be <code>null</code>. @return the resource. @throws ClientException if a status code other than 200 (OK) is returned.
[ "Gets", "the", "resource", "specified", "by", "the", "path", ".", "Sends", "to", "the", "server", "an", "Accepts", "header", "for", "JSON", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L225-L227
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doGet
protected <T> T doGet(String path, Class<T> cls, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.GET).getRequestBuilder(); requestBuilder = ensureJsonHeaders(headers, requestBuilder, false, true); ClientResponse response = requestBuilder.get(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK); return response.getEntity(cls); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected <T> T doGet(String path, Class<T> cls, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.GET).getRequestBuilder(); requestBuilder = ensureJsonHeaders(headers, requestBuilder, false, true); ClientResponse response = requestBuilder.get(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK); return response.getEntity(cls); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "<", "T", ">", "T", "doGet", "(", "String", "path", ",", "Class", "<", "T", ">", "cls", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ...
Gets the resource specified by the path. @param <T> the type of the resource. @param path the path to the resource. Cannot be <code>null</code>. @param cls the type of the resource. Cannot be <code>null</code>. @param headers any headers. if no Accepts header is provided, an Accepts header for JSON will be added. @return the resource. @throws ClientException if a status code other than 200 (OK) is returned.
[ "Gets", "the", "resource", "specified", "by", "the", "path", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L242-L255
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doGet
protected <T> T doGet(String path, MultivaluedMap<String, String> queryParams, GenericType<T> genericType) throws ClientException { return doGet(path, queryParams, genericType, null); }
java
protected <T> T doGet(String path, MultivaluedMap<String, String> queryParams, GenericType<T> genericType) throws ClientException { return doGet(path, queryParams, genericType, null); }
[ "protected", "<", "T", ">", "T", "doGet", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "queryParams", ",", "GenericType", "<", "T", ">", "genericType", ")", "throws", "ClientException", "{", "return", "doGet", "(", "path...
Gets the requested resource. Adds an appropriate Accepts header. @param <T> the type of the requested resource. @param path the path to the resource. @param queryParams any query parameters to send. @param genericType the type of the requested resource. @return the requested resource. @throws ClientException if a status code other than 200 (OK) is returned.
[ "Gets", "the", "requested", "resource", ".", "Adds", "an", "appropriate", "Accepts", "header", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L398-L400
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPost
protected <T> T doPost(String path, MultivaluedMap<String, String> formParams, Class<T> cls, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); ensurePostFormHeaders(headers, requestBuilder, true, true); ClientResponse response = requestBuilder.post(ClientResponse.class, formParams); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK); return response.getEntity(cls); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected <T> T doPost(String path, MultivaluedMap<String, String> formParams, Class<T> cls, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); ensurePostFormHeaders(headers, requestBuilder, true, true); ClientResponse response = requestBuilder.post(ClientResponse.class, formParams); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK); return response.getEntity(cls); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "<", "T", ">", "T", "doPost", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "formParams", ",", "Class", "<", "T", ">", "cls", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "thr...
Submits a form and gets back a JSON object. @param <T> the type of the object that is expected in the response. @param path the API to call. @param formParams the form parameters to send. @param cls the type of object that is expected in the response. @param headers any headers. If there is no Accepts header, an Accepts header is added for JSON. If there is no Content Type header, a Content Type header is added for forms. @return the object in the response. @throws ClientException if a status code other than 200 (OK) is returned.
[ "Submits", "a", "form", "and", "gets", "back", "a", "JSON", "object", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L460-L473
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPost
protected void doPost(String path) throws ClientException { this.readLock.lock(); try { ClientResponse response = getResourceWrapper().rewritten(path, HttpMethod.POST) .post(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected void doPost(String path) throws ClientException { this.readLock.lock(); try { ClientResponse response = getResourceWrapper().rewritten(path, HttpMethod.POST) .post(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "void", "doPost", "(", "String", "path", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", ";", "try", "{", "ClientResponse", "response", "=", "getResourceWrapper", "(", ")", ".", "rewritten", "(", "path", ...
Makes a POST call to the specified path. @param path the path to call. @throws ClientException if a status code other than 200 (OK) and 204 (No Content) is returned.
[ "Makes", "a", "POST", "call", "to", "the", "specified", "path", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L527-L539
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostForm
protected void doPostForm(String path, MultivaluedMap<String, String> formParams) throws ClientException { doPostForm(path, formParams, null); }
java
protected void doPostForm(String path, MultivaluedMap<String, String> formParams) throws ClientException { doPostForm(path, formParams, null); }
[ "protected", "void", "doPostForm", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "formParams", ")", "throws", "ClientException", "{", "doPostForm", "(", "path", ",", "formParams", ",", "null", ")", ";", "}" ]
Submits a form. Adds appropriate Accepts and Content Type headers. @param path the API to call. @param formParams the form parameters to send. @throws ClientException if a status code other than 200 (OK) and 204 (No Content) is returned.
[ "Submits", "a", "form", ".", "Adds", "appropriate", "Accepts", "and", "Content", "Type", "headers", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L550-L552
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostForm
protected void doPostForm(String path, MultivaluedMap<String, String> formParams, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); ensurePostFormHeaders(headers, requestBuilder, true, false); ClientResponse response = requestBuilder.post(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected void doPostForm(String path, MultivaluedMap<String, String> formParams, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); ensurePostFormHeaders(headers, requestBuilder, true, false); ClientResponse response = requestBuilder.post(ClientResponse.class); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "void", "doPostForm", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "formParams", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ".", "readLock...
Submits a form. @param path the API to call. @param formParams the multi-part form content. @param headers any headers to send. If no Content Type header is specified, it adds a Content Type for form data. @throws ClientException if a status code other than 200 (OK) and 204 (No Content) is returned.
[ "Submits", "a", "form", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L565-L578
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostMultipart
public void doPostMultipart(String path, FormDataMultiPart formDataMultiPart) throws ClientException { this.readLock.lock(); try { ClientResponse response = getResourceWrapper() .rewritten(path, HttpMethod.POST) .type(Boundary.addBoundary(MediaType.MULTIPART_FORM_DATA_TYPE)) .post(ClientResponse.class, formDataMultiPart); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
public void doPostMultipart(String path, FormDataMultiPart formDataMultiPart) throws ClientException { this.readLock.lock(); try { ClientResponse response = getResourceWrapper() .rewritten(path, HttpMethod.POST) .type(Boundary.addBoundary(MediaType.MULTIPART_FORM_DATA_TYPE)) .post(ClientResponse.class, formDataMultiPart); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "public", "void", "doPostMultipart", "(", "String", "path", ",", "FormDataMultiPart", "formDataMultiPart", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", ";", "try", "{", "ClientResponse", "response", "=", "getResourceWrappe...
Submits a multi-part form. Adds appropriate Accepts and Content Type headers. @param path the API to call. @param formDataMultiPart the multi-part form content. @throws ClientException if a status code other than 200 (OK) and 204 (No Content) is returned.
[ "Submits", "a", "multi", "-", "part", "form", ".", "Adds", "appropriate", "Accepts", "and", "Content", "Type", "headers", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L639-L653
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostMultipart
public void doPostMultipart(String path, FormDataMultiPart formDataMultiPart, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper() .rewritten(path, HttpMethod.POST).getRequestBuilder(); requestBuilder = ensurePostMultipartHeaders(headers, requestBuilder); ClientResponse response = requestBuilder .post(ClientResponse.class, formDataMultiPart); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
public void doPostMultipart(String path, FormDataMultiPart formDataMultiPart, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper() .rewritten(path, HttpMethod.POST).getRequestBuilder(); requestBuilder = ensurePostMultipartHeaders(headers, requestBuilder); ClientResponse response = requestBuilder .post(ClientResponse.class, formDataMultiPart); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.NO_CONTENT); response.close(); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "public", "void", "doPostMultipart", "(", "String", "path", ",", "FormDataMultiPart", "formDataMultiPart", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")",...
Submits a multi-part form. @param path the API to call. @param formDataMultiPart the multi-part form content. @param headers any headers to add. If no Content Type header is provided, this method adds a Content Type header for multi-part forms data. @throws ClientException if a status code other than 200 (OK) and 204 (No Content) is returned.
[ "Submits", "a", "multi", "-", "part", "form", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L666-L681
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostMultipart
protected void doPostMultipart(String path, InputStream inputStream) throws ClientException { doPostMultipart(path, inputStream, null); }
java
protected void doPostMultipart(String path, InputStream inputStream) throws ClientException { doPostMultipart(path, inputStream, null); }
[ "protected", "void", "doPostMultipart", "(", "String", "path", ",", "InputStream", "inputStream", ")", "throws", "ClientException", "{", "doPostMultipart", "(", "path", ",", "inputStream", ",", "null", ")", ";", "}" ]
Submits a multi-part form in an input stream. Adds appropriate Accepts and Content Type headers. @param path the the API to call. @param inputStream the multi-part form content. @throws ClientException if a status code other than 200 (OK) and 204 (No Content) is returned.
[ "Submits", "a", "multi", "-", "part", "form", "in", "an", "input", "stream", ".", "Adds", "appropriate", "Accepts", "and", "Content", "Type", "headers", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L693-L695
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostCreate
protected URI doPostCreate(String path, Object o) throws ClientException { return doPostCreate(path, o, null); }
java
protected URI doPostCreate(String path, Object o) throws ClientException { return doPostCreate(path, o, null); }
[ "protected", "URI", "doPostCreate", "(", "String", "path", ",", "Object", "o", ")", "throws", "ClientException", "{", "return", "doPostCreate", "(", "path", ",", "o", ",", "null", ")", ";", "}" ]
Creates a resource specified as a JSON object. Adds appropriate Accepts and Content Type headers. @param path the the API to call. @param o the object that will be converted to JSON for sending. Must either be a Java bean or be recognized by the object mapper. @return the URI representing the created resource, for use in subsequent operations on the resource. @throws ClientException if a status code other than 201 (Created) is returned.
[ "Creates", "a", "resource", "specified", "as", "a", "JSON", "object", ".", "Adds", "appropriate", "Accepts", "and", "Content", "Type", "headers", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L737-L739
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostCreate
protected URI doPostCreate(String path, Object o, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); requestBuilder = ensurePostCreateJsonHeaders(headers, requestBuilder, true, false); ClientResponse response = requestBuilder.post(ClientResponse.class, o); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.CREATED); try { return response.getLocation(); } finally { response.close(); } } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected URI doPostCreate(String path, Object o, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); requestBuilder = ensurePostCreateJsonHeaders(headers, requestBuilder, true, false); ClientResponse response = requestBuilder.post(ClientResponse.class, o); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.CREATED); try { return response.getLocation(); } finally { response.close(); } } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "URI", "doPostCreate", "(", "String", "path", ",", "Object", "o", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", ";", "try", "{", "W...
Creates a resource specified as a JSON object. @param path the the API to call. @param o the object that will be converted to JSON for sending. Must either be a Java bean or be recognized by the object mapper. @param headers If no Content Type header is provided, this method adds a Content Type header for JSON. @return the URI representing the created resource, for use in subsequent operations on the resource. @throws ClientException if a status code other than 200 (OK) and 201 (Created) is returned.
[ "Creates", "a", "resource", "specified", "as", "a", "JSON", "object", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L754-L771
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostCreateMultipart
protected URI doPostCreateMultipart(String path, InputStream inputStream) throws ClientException { return doPostCreateMultipart(path, inputStream, null); }
java
protected URI doPostCreateMultipart(String path, InputStream inputStream) throws ClientException { return doPostCreateMultipart(path, inputStream, null); }
[ "protected", "URI", "doPostCreateMultipart", "(", "String", "path", ",", "InputStream", "inputStream", ")", "throws", "ClientException", "{", "return", "doPostCreateMultipart", "(", "path", ",", "inputStream", ",", "null", ")", ";", "}" ]
Creates a resource specified as a multi-part form in an input stream. Adds appropriate Accepts and Content Type headers. @param path the the API to call. @param inputStream the multi-part form content. @return the URI representing the created resource, for use in subsequent operations on the resource. @throws ClientException if a status code other than 200 (OK) and 201 (Created) is returned.
[ "Creates", "a", "resource", "specified", "as", "a", "multi", "-", "part", "form", "in", "an", "input", "stream", ".", "Adds", "appropriate", "Accepts", "and", "Content", "Type", "headers", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L784-L786
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostCreateMultipart
protected URI doPostCreateMultipart(String path, InputStream inputStream, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); requestBuilder = ensurePostCreateMultipartHeaders(headers, requestBuilder); ClientResponse response = requestBuilder.post(ClientResponse.class, inputStream); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.CREATED); try { return response.getLocation(); } finally { response.close(); } } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected URI doPostCreateMultipart(String path, InputStream inputStream, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST).getRequestBuilder(); requestBuilder = ensurePostCreateMultipartHeaders(headers, requestBuilder); ClientResponse response = requestBuilder.post(ClientResponse.class, inputStream); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.CREATED); try { return response.getLocation(); } finally { response.close(); } } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "URI", "doPostCreateMultipart", "(", "String", "path", ",", "InputStream", "inputStream", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", "...
Creates a resource specified as a multi-part form in an input stream. @param path the the API to call. @param inputStream the multi-part form content. @param headers any headers to send. If no Accepts header is provided, this method as an Accepts header for text/plain. If no Content Type header is provided, this method adds a Content Type header for multi-part forms data. @return the URI representing the created resource, for use in subsequent operations on the resource. @throws ClientException if a status code other than 200 (OK) and 201 (Created) is returned.
[ "Creates", "a", "resource", "specified", "as", "a", "multi", "-", "part", "form", "in", "an", "input", "stream", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L802-L819
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostCreateMultipart
protected URI doPostCreateMultipart(String path, FormDataMultiPart formDataMultiPart) throws ClientException { this.readLock.lock(); try { ClientResponse response = getResourceWrapper() .rewritten(path, HttpMethod.POST) .type(Boundary.addBoundary(MediaType.MULTIPART_FORM_DATA_TYPE)) .accept(MediaType.TEXT_PLAIN) .post(ClientResponse.class, formDataMultiPart); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.CREATED); try { return response.getLocation(); } finally { response.close(); } } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected URI doPostCreateMultipart(String path, FormDataMultiPart formDataMultiPart) throws ClientException { this.readLock.lock(); try { ClientResponse response = getResourceWrapper() .rewritten(path, HttpMethod.POST) .type(Boundary.addBoundary(MediaType.MULTIPART_FORM_DATA_TYPE)) .accept(MediaType.TEXT_PLAIN) .post(ClientResponse.class, formDataMultiPart); errorIfStatusNotEqualTo(response, ClientResponse.Status.OK, ClientResponse.Status.CREATED); try { return response.getLocation(); } finally { response.close(); } } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "URI", "doPostCreateMultipart", "(", "String", "path", ",", "FormDataMultiPart", "formDataMultiPart", ")", "throws", "ClientException", "{", "this", ".", "readLock", ".", "lock", "(", ")", ";", "try", "{", "ClientResponse", "response", "=", "getResour...
Creates a resource specified as a multi-part form. Adds appropriate Accepts and Content Type headers. @param path the the API to call. @param formDataMultiPart the form content. @return the URI representing the created resource, for use in subsequent operations on the resource. @throws ClientException if a status code other than 200 (OK) and 201 (Created) is returned.
[ "Creates", "a", "resource", "specified", "as", "a", "multi", "-", "part", "form", ".", "Adds", "appropriate", "Accepts", "and", "Content", "Type", "headers", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L832-L851
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doPostForProxy
protected ClientResponse doPostForProxy(String path, InputStream inputStream, MultivaluedMap<String, String> parameterMap, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST, parameterMap).getRequestBuilder(); copyHeaders(headers, requestBuilder); return requestBuilder.post(ClientResponse.class, inputStream); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected ClientResponse doPostForProxy(String path, InputStream inputStream, MultivaluedMap<String, String> parameterMap, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.POST, parameterMap).getRequestBuilder(); copyHeaders(headers, requestBuilder); return requestBuilder.post(ClientResponse.class, inputStream); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "ClientResponse", "doPostForProxy", "(", "String", "path", ",", "InputStream", "inputStream", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "parameterMap", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws",...
Passes a new resource, form or other POST body to a proxied server. @param path the path to the resource. Cannot be <code>null</code>. @param inputStream the contents of the POST body. Cannot be <code>null</code>. @param parameterMap query parameters. May be <code>null</code>. @param headers any request headers to add. May be <code>null</code>. @return ClientResponse the proxied server's response information. @throws ClientException if the proxied server responds with an "error" status code, which is dependent on the server being called. @see #getResourceUrl() for the URL of the proxied server.
[ "Passes", "a", "new", "resource", "form", "or", "other", "POST", "body", "to", "a", "proxied", "server", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L868-L879
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doGetForProxy
protected ClientResponse doGetForProxy(String path, MultivaluedMap<String, String> parameterMap, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.GET, parameterMap).getRequestBuilder(); copyHeaders(headers, requestBuilder); return requestBuilder.get(ClientResponse.class); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected ClientResponse doGetForProxy(String path, MultivaluedMap<String, String> parameterMap, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.GET, parameterMap).getRequestBuilder(); copyHeaders(headers, requestBuilder); return requestBuilder.get(ClientResponse.class); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "ClientResponse", "doGetForProxy", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "parameterMap", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", "...
Gets a resource from a proxied server. @param path the path to the resource. Cannot be <code>null</code>. @param parameterMap query parameters. May be <code>null</code>. @param headers any request headers to add. @return ClientResponse the proxied server's response information. @throws ClientException if the proxied server responds with an "error" status code, which is dependent on the server being called. @see #getResourceUrl() for the URL of the proxied server.
[ "Gets", "a", "resource", "from", "a", "proxied", "server", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L978-L989
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.doDeleteForProxy
protected ClientResponse doDeleteForProxy(String path, MultivaluedMap<String, String> parameterMap, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.DELETE, parameterMap).getRequestBuilder(); copyHeaders(headers, requestBuilder); return requestBuilder.delete(ClientResponse.class); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
java
protected ClientResponse doDeleteForProxy(String path, MultivaluedMap<String, String> parameterMap, MultivaluedMap<String, String> headers) throws ClientException { this.readLock.lock(); try { WebResource.Builder requestBuilder = getResourceWrapper().rewritten(path, HttpMethod.DELETE, parameterMap).getRequestBuilder(); copyHeaders(headers, requestBuilder); return requestBuilder.delete(ClientResponse.class); } catch (ClientHandlerException ex) { throw new ClientException(ClientResponse.Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { this.readLock.unlock(); } }
[ "protected", "ClientResponse", "doDeleteForProxy", "(", "String", "path", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "parameterMap", ",", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ")", "throws", "ClientException", "{", "this", ...
Deletes a resource from a proxied server. @param path the path to the resource. Cannot be <code>null</code>. @param parameterMap query parameters. May be <code>null</code>. @param headers any request headers to add. @return ClientResponse the proxied server's response information. @throws ClientException if the proxied server responds with an "error" status code, which is dependent on the server being called. @see #getResourceUrl() for the URL of the proxied server.
[ "Deletes", "a", "resource", "from", "a", "proxied", "server", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L1004-L1015
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.errorIfStatusEqualTo
protected void errorIfStatusEqualTo(ClientResponse response, ClientResponse.Status... status) throws ClientException { errorIf(response, status, true); }
java
protected void errorIfStatusEqualTo(ClientResponse response, ClientResponse.Status... status) throws ClientException { errorIf(response, status, true); }
[ "protected", "void", "errorIfStatusEqualTo", "(", "ClientResponse", "response", ",", "ClientResponse", ".", "Status", "...", "status", ")", "throws", "ClientException", "{", "errorIf", "(", "response", ",", "status", ",", "true", ")", ";", "}" ]
If there is an unexpected status code, this method gets the status message, closes the response, and throws an exception. @param response the response. @param status the expected status code(s). @throws ClientException if the response had a status code other than those listed.
[ "If", "there", "is", "an", "unexpected", "status", "code", "this", "method", "gets", "the", "status", "message", "closes", "the", "response", "and", "throws", "an", "exception", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L1026-L1029
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.extractId
protected Long extractId(URI uri) { String uriStr = uri.toString(); return Long.valueOf(uriStr.substring(uriStr.lastIndexOf("/") + 1)); }
java
protected Long extractId(URI uri) { String uriStr = uri.toString(); return Long.valueOf(uriStr.substring(uriStr.lastIndexOf("/") + 1)); }
[ "protected", "Long", "extractId", "(", "URI", "uri", ")", "{", "String", "uriStr", "=", "uri", ".", "toString", "(", ")", ";", "return", "Long", ".", "valueOf", "(", "uriStr", ".", "substring", "(", "uriStr", ".", "lastIndexOf", "(", "\"/\"", ")", "+",...
Extracts the id of the resource specified in the response body from a POST call. @param uri The URI. @return the id of the resource.
[ "Extracts", "the", "id", "of", "the", "resource", "specified", "in", "the", "response", "body", "from", "a", "POST", "call", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L1052-L1055
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.contains
private static boolean contains(Object[] arr, Object member) { for (Object mem : arr) { if (Objects.equals(mem, member)) { return true; } } return false; }
java
private static boolean contains(Object[] arr, Object member) { for (Object mem : arr) { if (Objects.equals(mem, member)) { return true; } } return false; }
[ "private", "static", "boolean", "contains", "(", "Object", "[", "]", "arr", ",", "Object", "member", ")", "{", "for", "(", "Object", "mem", ":", "arr", ")", "{", "if", "(", "Objects", ".", "equals", "(", "mem", ",", "member", ")", ")", "{", "return...
Tests array membership. @param arr the array. @param member an object. @return <code>true</code> if the provided object is a member of the provided array, or <code>false</code> if not.
[ "Tests", "array", "membership", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L1140-L1147
train
eurekaclinical/eurekaclinical-common
src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java
EurekaClinicalClient.ensureJsonHeaders
private static WebResource.Builder ensureJsonHeaders(MultivaluedMap<String, String> headers, WebResource.Builder requestBuilder, boolean contentType, boolean accept) { boolean hasContentType = false; boolean hasAccept = false; if (headers != null) { for (Map.Entry<String, List<String>> entry : headers.entrySet()) { String key = entry.getKey(); for (String val : entry.getValue()) { if (contentType && HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(key)) { hasContentType = true; } else if (accept && HttpHeaders.ACCEPT.equalsIgnoreCase(key)) { hasAccept = true; } requestBuilder = requestBuilder.header(key, val); } } } if (!hasContentType) { requestBuilder = requestBuilder.type(MediaType.APPLICATION_JSON); } if (!hasAccept) { requestBuilder = requestBuilder.accept(MediaType.APPLICATION_JSON); } return requestBuilder; }
java
private static WebResource.Builder ensureJsonHeaders(MultivaluedMap<String, String> headers, WebResource.Builder requestBuilder, boolean contentType, boolean accept) { boolean hasContentType = false; boolean hasAccept = false; if (headers != null) { for (Map.Entry<String, List<String>> entry : headers.entrySet()) { String key = entry.getKey(); for (String val : entry.getValue()) { if (contentType && HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(key)) { hasContentType = true; } else if (accept && HttpHeaders.ACCEPT.equalsIgnoreCase(key)) { hasAccept = true; } requestBuilder = requestBuilder.header(key, val); } } } if (!hasContentType) { requestBuilder = requestBuilder.type(MediaType.APPLICATION_JSON); } if (!hasAccept) { requestBuilder = requestBuilder.accept(MediaType.APPLICATION_JSON); } return requestBuilder; }
[ "private", "static", "WebResource", ".", "Builder", "ensureJsonHeaders", "(", "MultivaluedMap", "<", "String", ",", "String", ">", "headers", ",", "WebResource", ".", "Builder", "requestBuilder", ",", "boolean", "contentType", ",", "boolean", "accept", ")", "{", ...
Adds the specified headers to the request builder. Provides default headers for JSON objects requests and submissions. @param headers the headers to add. @param requestBuilder the request builder. Cannot be <code>null</code>. @param contentType <code>true</code> to add a default Content Type header if no Content Type header is provided. @param accept <code>true</code> to add a default Accepts header if no Accepts header is provided. @return the resulting request builder. Guaranteed not <code>null</code>.
[ "Adds", "the", "specified", "headers", "to", "the", "request", "builder", ".", "Provides", "default", "headers", "for", "JSON", "objects", "requests", "and", "submissions", "." ]
1867102ff43fe94e519f76a074d5f5923e9be61c
https://github.com/eurekaclinical/eurekaclinical-common/blob/1867102ff43fe94e519f76a074d5f5923e9be61c/src/main/java/org/eurekaclinical/common/comm/clients/EurekaClinicalClient.java#L1161-L1184
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/util/image/PreviewImageView.java
PreviewImageView.checkBorderAndCenterWhenScale
private void checkBorderAndCenterWhenScale() { RectF rect = getMatrixRectF(); float deltaX = 0; float deltaY = 0; int width = getWidth(); int height = getHeight(); if (rect.width() >= width) { if (rect.left > 0) { deltaX = -rect.left; } if (rect.right < width) { deltaX = width - rect.right; } } if (rect.height() >= height) { if (rect.top > 0) { deltaY = -rect.top; } if (rect.bottom < height) { deltaY = height - rect.bottom; } } // Always center the image when it's smaller than the imageView if (rect.width() < width) { deltaX = width * 0.5f - rect.right + 0.5f * rect.width(); } if (rect.height() < height) { deltaY = height * 0.5f - rect.bottom + 0.5f * rect.height(); } scaleMatrix.postTranslate(deltaX, deltaY); }
java
private void checkBorderAndCenterWhenScale() { RectF rect = getMatrixRectF(); float deltaX = 0; float deltaY = 0; int width = getWidth(); int height = getHeight(); if (rect.width() >= width) { if (rect.left > 0) { deltaX = -rect.left; } if (rect.right < width) { deltaX = width - rect.right; } } if (rect.height() >= height) { if (rect.top > 0) { deltaY = -rect.top; } if (rect.bottom < height) { deltaY = height - rect.bottom; } } // Always center the image when it's smaller than the imageView if (rect.width() < width) { deltaX = width * 0.5f - rect.right + 0.5f * rect.width(); } if (rect.height() < height) { deltaY = height * 0.5f - rect.bottom + 0.5f * rect.height(); } scaleMatrix.postTranslate(deltaX, deltaY); }
[ "private", "void", "checkBorderAndCenterWhenScale", "(", ")", "{", "RectF", "rect", "=", "getMatrixRectF", "(", ")", ";", "float", "deltaX", "=", "0", ";", "float", "deltaY", "=", "0", ";", "int", "width", "=", "getWidth", "(", ")", ";", "int", "height",...
Prevent visual artifact when scaling
[ "Prevent", "visual", "artifact", "when", "scaling" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/PreviewImageView.java#L267-L302
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/util/image/PreviewImageView.java
PreviewImageView.getMatrixRectF
private RectF getMatrixRectF() { Matrix matrix = scaleMatrix; RectF rect = new RectF(); Drawable d = getDrawable(); if (null != d) { rect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); matrix.mapRect(rect); } return rect; }
java
private RectF getMatrixRectF() { Matrix matrix = scaleMatrix; RectF rect = new RectF(); Drawable d = getDrawable(); if (null != d) { rect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); matrix.mapRect(rect); } return rect; }
[ "private", "RectF", "getMatrixRectF", "(", ")", "{", "Matrix", "matrix", "=", "scaleMatrix", ";", "RectF", "rect", "=", "new", "RectF", "(", ")", ";", "Drawable", "d", "=", "getDrawable", "(", ")", ";", "if", "(", "null", "!=", "d", ")", "{", "rect",...
Get image boundary from matrix @return
[ "Get", "image", "boundary", "from", "matrix" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/PreviewImageView.java#L309-L318
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/util/image/PreviewImageView.java
PreviewImageView.checkMatrixBounds
private void checkMatrixBounds() { RectF rect = getMatrixRectF(); float deltaX = 0, deltaY = 0; final float viewWidth = getWidth(); final float viewHeight = getHeight(); // Check if image boundary exceeds imageView boundary if (rect.top > 0 && isCheckTopAndBottom) { deltaY = -rect.top; } if (rect.bottom < viewHeight && isCheckTopAndBottom) { deltaY = viewHeight - rect.bottom; } if (rect.left > 0 && isCheckLeftAndRight) { deltaX = -rect.left; } if (rect.right < viewWidth && isCheckLeftAndRight) { deltaX = viewWidth - rect.right; } scaleMatrix.postTranslate(deltaX, deltaY); }
java
private void checkMatrixBounds() { RectF rect = getMatrixRectF(); float deltaX = 0, deltaY = 0; final float viewWidth = getWidth(); final float viewHeight = getHeight(); // Check if image boundary exceeds imageView boundary if (rect.top > 0 && isCheckTopAndBottom) { deltaY = -rect.top; } if (rect.bottom < viewHeight && isCheckTopAndBottom) { deltaY = viewHeight - rect.bottom; } if (rect.left > 0 && isCheckLeftAndRight) { deltaX = -rect.left; } if (rect.right < viewWidth && isCheckLeftAndRight) { deltaX = viewWidth - rect.right; } scaleMatrix.postTranslate(deltaX, deltaY); }
[ "private", "void", "checkMatrixBounds", "(", ")", "{", "RectF", "rect", "=", "getMatrixRectF", "(", ")", ";", "float", "deltaX", "=", "0", ",", "deltaY", "=", "0", ";", "final", "float", "viewWidth", "=", "getWidth", "(", ")", ";", "final", "float", "v...
Check image bounday against imageView
[ "Check", "image", "bounday", "against", "imageView" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/PreviewImageView.java#L323-L343
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/conversation/ConversationManager.java
ConversationManager.loadConversationFromMetadata
private @Nullable Conversation loadConversationFromMetadata(ConversationMetadata metadata) throws SerializerException, ConversationLoadException { // we're going to scan metadata in attempt to find existing conversations ConversationMetadataItem item; // if the user was logged in previously - we should have an active conversation item = metadata.findItem(LOGGED_IN); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'logged-in' conversation..."); return loadConversation(item); } // if no users were logged in previously - we might have an anonymous conversation item = metadata.findItem(ANONYMOUS); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'anonymous' conversation..."); return loadConversation(item); } // check if we have a 'pending' anonymous conversation item = metadata.findItem(ANONYMOUS_PENDING); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'anonymous pending' conversation..."); final Conversation conversation = loadConversation(item); fetchConversationToken(conversation); return conversation; } // check if we have a 'legacy pending' conversation item = metadata.findItem(LEGACY_PENDING); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'legacy pending' conversation..."); final Conversation conversation = loadConversation(item); fetchLegacyConversation(conversation); return conversation; } // we only have LOGGED_OUT conversations ApptentiveLog.i(CONVERSATION, "No active conversations to load: only 'logged-out' conversations available"); return null; }
java
private @Nullable Conversation loadConversationFromMetadata(ConversationMetadata metadata) throws SerializerException, ConversationLoadException { // we're going to scan metadata in attempt to find existing conversations ConversationMetadataItem item; // if the user was logged in previously - we should have an active conversation item = metadata.findItem(LOGGED_IN); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'logged-in' conversation..."); return loadConversation(item); } // if no users were logged in previously - we might have an anonymous conversation item = metadata.findItem(ANONYMOUS); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'anonymous' conversation..."); return loadConversation(item); } // check if we have a 'pending' anonymous conversation item = metadata.findItem(ANONYMOUS_PENDING); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'anonymous pending' conversation..."); final Conversation conversation = loadConversation(item); fetchConversationToken(conversation); return conversation; } // check if we have a 'legacy pending' conversation item = metadata.findItem(LEGACY_PENDING); if (item != null) { ApptentiveLog.i(CONVERSATION, "Loading 'legacy pending' conversation..."); final Conversation conversation = loadConversation(item); fetchLegacyConversation(conversation); return conversation; } // we only have LOGGED_OUT conversations ApptentiveLog.i(CONVERSATION, "No active conversations to load: only 'logged-out' conversations available"); return null; }
[ "private", "@", "Nullable", "Conversation", "loadConversationFromMetadata", "(", "ConversationMetadata", "metadata", ")", "throws", "SerializerException", ",", "ConversationLoadException", "{", "// we're going to scan metadata in attempt to find existing conversations", "ConversationMe...
Attempts to load an existing conversation based on metadata file @return <code>null</code> is only logged out conversations available
[ "Attempts", "to", "load", "an", "existing", "conversation", "based", "on", "metadata", "file" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/conversation/ConversationManager.java#L235-L274
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/conversation/ConversationManager.java
ConversationManager.handleConversationStateChange
private void handleConversationStateChange(Conversation conversation) { ApptentiveLog.d(CONVERSATION, "Conversation state changed: %s", conversation); checkConversationQueue(); assertTrue(conversation != null && !conversation.hasState(UNDEFINED)); if (conversation != null && !conversation.hasState(UNDEFINED)) { ApptentiveNotificationCenter.defaultCenter() .postNotification(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE, NOTIFICATION_KEY_CONVERSATION, conversation); if (conversation.hasActiveState()) { if (appIsInForeground) { // ConversationManager listens to the foreground event to fetch interactions when it comes to foreground conversation.fetchInteractions(getContext()); // Message Manager listens to foreground/background events itself conversation.getMessageManager().attemptToStartMessagePolling(); } // Fetch app configuration fetchAppConfiguration(conversation); // Update conversation with push configuration changes that happened while it wasn't active. SharedPreferences prefs = ApptentiveInternal.getInstance().getGlobalSharedPrefs(); int pushProvider = prefs.getInt(Constants.PREF_KEY_PUSH_PROVIDER, -1); String pushToken = prefs.getString(Constants.PREF_KEY_PUSH_TOKEN, null); if (pushProvider != -1 && pushToken != null) { conversation.setPushIntegration(pushProvider, pushToken); } } updateMetadataItems(conversation); if (ApptentiveLog.canLog(VERBOSE)) { printMetadata(conversationMetadata, "Updated Metadata"); } } }
java
private void handleConversationStateChange(Conversation conversation) { ApptentiveLog.d(CONVERSATION, "Conversation state changed: %s", conversation); checkConversationQueue(); assertTrue(conversation != null && !conversation.hasState(UNDEFINED)); if (conversation != null && !conversation.hasState(UNDEFINED)) { ApptentiveNotificationCenter.defaultCenter() .postNotification(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE, NOTIFICATION_KEY_CONVERSATION, conversation); if (conversation.hasActiveState()) { if (appIsInForeground) { // ConversationManager listens to the foreground event to fetch interactions when it comes to foreground conversation.fetchInteractions(getContext()); // Message Manager listens to foreground/background events itself conversation.getMessageManager().attemptToStartMessagePolling(); } // Fetch app configuration fetchAppConfiguration(conversation); // Update conversation with push configuration changes that happened while it wasn't active. SharedPreferences prefs = ApptentiveInternal.getInstance().getGlobalSharedPrefs(); int pushProvider = prefs.getInt(Constants.PREF_KEY_PUSH_PROVIDER, -1); String pushToken = prefs.getString(Constants.PREF_KEY_PUSH_TOKEN, null); if (pushProvider != -1 && pushToken != null) { conversation.setPushIntegration(pushProvider, pushToken); } } updateMetadataItems(conversation); if (ApptentiveLog.canLog(VERBOSE)) { printMetadata(conversationMetadata, "Updated Metadata"); } } }
[ "private", "void", "handleConversationStateChange", "(", "Conversation", "conversation", ")", "{", "ApptentiveLog", ".", "d", "(", "CONVERSATION", ",", "\"Conversation state changed: %s\"", ",", "conversation", ")", ";", "checkConversationQueue", "(", ")", ";", "assertT...
region Conversation fetching
[ "region", "Conversation", "fetching" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/conversation/ConversationManager.java#L554-L591
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java
VersionHistory.getTimeAtInstallTotal
public Apptentive.DateTime getTimeAtInstallTotal() { // Simply return the first item's timestamp, if there is one. if (versionHistoryItems.size() > 0) { return new Apptentive.DateTime(versionHistoryItems.get(0).getTimestamp()); } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
java
public Apptentive.DateTime getTimeAtInstallTotal() { // Simply return the first item's timestamp, if there is one. if (versionHistoryItems.size() > 0) { return new Apptentive.DateTime(versionHistoryItems.get(0).getTimestamp()); } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
[ "public", "Apptentive", ".", "DateTime", "getTimeAtInstallTotal", "(", ")", "{", "// Simply return the first item's timestamp, if there is one.", "if", "(", "versionHistoryItems", ".", "size", "(", ")", ">", "0", ")", "{", "return", "new", "Apptentive", ".", "DateTime...
Returns the timestamp at the first install of this app that Apptentive was aware of.
[ "Returns", "the", "timestamp", "at", "the", "first", "install", "of", "this", "app", "that", "Apptentive", "was", "aware", "of", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java#L65-L71
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java
VersionHistory.getTimeAtInstallForVersionCode
public Apptentive.DateTime getTimeAtInstallForVersionCode(int versionCode) { for (VersionHistoryItem item : versionHistoryItems) { if (item.getVersionCode() == versionCode) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
java
public Apptentive.DateTime getTimeAtInstallForVersionCode(int versionCode) { for (VersionHistoryItem item : versionHistoryItems) { if (item.getVersionCode() == versionCode) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
[ "public", "Apptentive", ".", "DateTime", "getTimeAtInstallForVersionCode", "(", "int", "versionCode", ")", "{", "for", "(", "VersionHistoryItem", "item", ":", "versionHistoryItems", ")", "{", "if", "(", "item", ".", "getVersionCode", "(", ")", "==", "versionCode",...
Returns the timestamp at the first install of the current versionCode of this app that Apptentive was aware of.
[ "Returns", "the", "timestamp", "at", "the", "first", "install", "of", "the", "current", "versionCode", "of", "this", "app", "that", "Apptentive", "was", "aware", "of", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java#L76-L83
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java
VersionHistory.getTimeAtInstallForVersionName
public Apptentive.DateTime getTimeAtInstallForVersionName(String versionName) { for (VersionHistoryItem item : versionHistoryItems) { Apptentive.Version entryVersionName = new Apptentive.Version(); Apptentive.Version currentVersionName = new Apptentive.Version(); entryVersionName.setVersion(item.getVersionName()); currentVersionName.setVersion(versionName); if (entryVersionName.equals(currentVersionName)) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
java
public Apptentive.DateTime getTimeAtInstallForVersionName(String versionName) { for (VersionHistoryItem item : versionHistoryItems) { Apptentive.Version entryVersionName = new Apptentive.Version(); Apptentive.Version currentVersionName = new Apptentive.Version(); entryVersionName.setVersion(item.getVersionName()); currentVersionName.setVersion(versionName); if (entryVersionName.equals(currentVersionName)) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
[ "public", "Apptentive", ".", "DateTime", "getTimeAtInstallForVersionName", "(", "String", "versionName", ")", "{", "for", "(", "VersionHistoryItem", "item", ":", "versionHistoryItems", ")", "{", "Apptentive", ".", "Version", "entryVersionName", "=", "new", "Apptentive...
Returns the timestamp at the first install of the current versionName of this app that Apptentive was aware of.
[ "Returns", "the", "timestamp", "at", "the", "first", "install", "of", "the", "current", "versionName", "of", "this", "app", "that", "Apptentive", "was", "aware", "of", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java#L88-L99
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java
VersionHistory.isUpdateForVersionCode
public boolean isUpdateForVersionCode() { Set<Integer> uniques = new HashSet<Integer>(); for (VersionHistoryItem item : versionHistoryItems) { uniques.add(item.getVersionCode()); } return uniques.size() > 1; }
java
public boolean isUpdateForVersionCode() { Set<Integer> uniques = new HashSet<Integer>(); for (VersionHistoryItem item : versionHistoryItems) { uniques.add(item.getVersionCode()); } return uniques.size() > 1; }
[ "public", "boolean", "isUpdateForVersionCode", "(", ")", "{", "Set", "<", "Integer", ">", "uniques", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "for", "(", "VersionHistoryItem", "item", ":", "versionHistoryItems", ")", "{", "uniques", ".", ...
Returns true if the current versionCode is not the first version or build that we have seen. Basically, it just looks for two or more versionCodes. @return True if this is not the first versionCode of the app we've seen.
[ "Returns", "true", "if", "the", "current", "versionCode", "is", "not", "the", "first", "version", "or", "build", "that", "we", "have", "seen", ".", "Basically", "it", "just", "looks", "for", "two", "or", "more", "versionCodes", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java#L107-L113
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java
VersionHistory.isUpdateForVersionName
public boolean isUpdateForVersionName() { Set<String> uniques = new HashSet<String>(); for (VersionHistoryItem item : versionHistoryItems) { uniques.add(item.getVersionName()); } return uniques.size() > 1; }
java
public boolean isUpdateForVersionName() { Set<String> uniques = new HashSet<String>(); for (VersionHistoryItem item : versionHistoryItems) { uniques.add(item.getVersionName()); } return uniques.size() > 1; }
[ "public", "boolean", "isUpdateForVersionName", "(", ")", "{", "Set", "<", "String", ">", "uniques", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "VersionHistoryItem", "item", ":", "versionHistoryItems", ")", "{", "uniques", ".", "a...
Returns true if the current versionName is not the first version or build that we have seen. Basically, it just looks for two or more versionNames. @return True if this is not the first versionName of the app we've seen.
[ "Returns", "true", "if", "the", "current", "versionName", "is", "not", "the", "first", "version", "or", "build", "that", "we", "have", "seen", ".", "Basically", "it", "just", "looks", "for", "two", "or", "more", "versionNames", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/VersionHistory.java#L121-L127
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/model/InteractionManifest.java
InteractionManifest.getInteractions
public Interactions getInteractions() { try { if (!isNull(Interactions.KEY_NAME)) { Object obj = get(Interactions.KEY_NAME); if (obj instanceof JSONArray) { Interactions interactions = new Interactions(); JSONArray interactionsJSONArray = (JSONArray) obj; for (int i = 0; i < interactionsJSONArray.length(); i++) { Interaction interaction = Interaction.Factory.parseInteraction(interactionsJSONArray.getString(i)); if (interaction != null) { interactions.put(interaction.getId(), interaction); } else { // This is an unknown Interaction type. Probably for a future SDK version. } } return interactions; } } } catch (JSONException e) { ApptentiveLog.w(INTERACTIONS, e, "Unable to load Interactions from InteractionManifest."); logException(e); } return null; }
java
public Interactions getInteractions() { try { if (!isNull(Interactions.KEY_NAME)) { Object obj = get(Interactions.KEY_NAME); if (obj instanceof JSONArray) { Interactions interactions = new Interactions(); JSONArray interactionsJSONArray = (JSONArray) obj; for (int i = 0; i < interactionsJSONArray.length(); i++) { Interaction interaction = Interaction.Factory.parseInteraction(interactionsJSONArray.getString(i)); if (interaction != null) { interactions.put(interaction.getId(), interaction); } else { // This is an unknown Interaction type. Probably for a future SDK version. } } return interactions; } } } catch (JSONException e) { ApptentiveLog.w(INTERACTIONS, e, "Unable to load Interactions from InteractionManifest."); logException(e); } return null; }
[ "public", "Interactions", "getInteractions", "(", ")", "{", "try", "{", "if", "(", "!", "isNull", "(", "Interactions", ".", "KEY_NAME", ")", ")", "{", "Object", "obj", "=", "get", "(", "Interactions", ".", "KEY_NAME", ")", ";", "if", "(", "obj", "insta...
In addition to returning the Interactions contained in this payload, this method reformats the Interactions from a list into a map. The map is then used for further Interaction lookup. @return
[ "In", "addition", "to", "returning", "the", "Interactions", "contained", "in", "this", "payload", "this", "method", "reformats", "the", "Interactions", "from", "a", "list", "into", "a", "map", ".", "The", "map", "is", "then", "used", "for", "further", "Inter...
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/model/InteractionManifest.java#L29-L52
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/util/threading/ConcurrentDispatchQueue.java
ConcurrentDispatchQueue.newThread
@Override public Thread newThread(Runnable r) { return new Thread(r, getName() + " (thread-" + threadNumber.getAndIncrement() + ")"); }
java
@Override public Thread newThread(Runnable r) { return new Thread(r, getName() + " (thread-" + threadNumber.getAndIncrement() + ")"); }
[ "@", "Override", "public", "Thread", "newThread", "(", "Runnable", "r", ")", "{", "return", "new", "Thread", "(", "r", ",", "getName", "(", ")", "+", "\" (thread-\"", "+", "threadNumber", ".", "getAndIncrement", "(", ")", "+", "\")\"", ")", ";", "}" ]
region Thread factory
[ "region", "Thread", "factory" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/threading/ConcurrentDispatchQueue.java#L60-L63
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java
AutoResizeTextView.onTextChanged
@Override protected void onTextChanged(final CharSequence text, final int start, final int before, final int after) { mNeedsResize = true; // Since this view may be reused, it is good to reset the text size resetTextSize(); }
java
@Override protected void onTextChanged(final CharSequence text, final int start, final int before, final int after) { mNeedsResize = true; // Since this view may be reused, it is good to reset the text size resetTextSize(); }
[ "@", "Override", "protected", "void", "onTextChanged", "(", "final", "CharSequence", "text", ",", "final", "int", "start", ",", "final", "int", "before", ",", "final", "int", "after", ")", "{", "mNeedsResize", "=", "true", ";", "// Since this view may be reused,...
When text changes, set the force resize flag to true and reset the text size.
[ "When", "text", "changes", "set", "the", "force", "resize", "flag", "to", "true", "and", "reset", "the", "text", "size", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java#L87-L92
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java
AutoResizeTextView.onSizeChanged
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { if (w != oldw || h != oldh) { mNeedsResize = true; } }
java
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { if (w != oldw || h != oldh) { mNeedsResize = true; } }
[ "@", "Override", "protected", "void", "onSizeChanged", "(", "int", "w", ",", "int", "h", ",", "int", "oldw", ",", "int", "oldh", ")", "{", "if", "(", "w", "!=", "oldw", "||", "h", "!=", "oldh", ")", "{", "mNeedsResize", "=", "true", ";", "}", "}"...
If the text view size changed, set the force resize flag to true
[ "If", "the", "text", "view", "size", "changed", "set", "the", "force", "resize", "flag", "to", "true" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java#L97-L102
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java
AutoResizeTextView.setLineSpacing
@Override public void setLineSpacing(float add, float mult) { super.setLineSpacing(add, mult); mSpacingMult = mult; mSpacingAdd = add; }
java
@Override public void setLineSpacing(float add, float mult) { super.setLineSpacing(add, mult); mSpacingMult = mult; mSpacingAdd = add; }
[ "@", "Override", "public", "void", "setLineSpacing", "(", "float", "add", ",", "float", "mult", ")", "{", "super", ".", "setLineSpacing", "(", "add", ",", "mult", ")", ";", "mSpacingMult", "=", "mult", ";", "mSpacingAdd", "=", "add", ";", "}" ]
Override the set line spacing to update our internal reference values
[ "Override", "the", "set", "line", "spacing", "to", "update", "our", "internal", "reference", "values" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java#L134-L139
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java
AutoResizeTextView.onLayout
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (changed || mNeedsResize) { int widthLimit = (right - left) - getCompoundPaddingLeft() - getCompoundPaddingRight(); int heightLimit = (bottom - top) - getCompoundPaddingBottom() - getCompoundPaddingTop(); resizeText(widthLimit, heightLimit); } super.onLayout(changed, left, top, right, bottom); }
java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (changed || mNeedsResize) { int widthLimit = (right - left) - getCompoundPaddingLeft() - getCompoundPaddingRight(); int heightLimit = (bottom - top) - getCompoundPaddingBottom() - getCompoundPaddingTop(); resizeText(widthLimit, heightLimit); } super.onLayout(changed, left, top, right, bottom); }
[ "@", "Override", "protected", "void", "onLayout", "(", "boolean", "changed", ",", "int", "left", ",", "int", "top", ",", "int", "right", ",", "int", "bottom", ")", "{", "if", "(", "changed", "||", "mNeedsResize", ")", "{", "int", "widthLimit", "=", "("...
Resize text after measuring
[ "Resize", "text", "after", "measuring" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java#L212-L220
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java
AutoResizeTextView.resizeText
public void resizeText() { int heightLimit = getHeight() - getPaddingBottom() - getPaddingTop(); int widthLimit = getWidth() - getPaddingLeft() - getPaddingRight(); resizeText(widthLimit, heightLimit); }
java
public void resizeText() { int heightLimit = getHeight() - getPaddingBottom() - getPaddingTop(); int widthLimit = getWidth() - getPaddingLeft() - getPaddingRight(); resizeText(widthLimit, heightLimit); }
[ "public", "void", "resizeText", "(", ")", "{", "int", "heightLimit", "=", "getHeight", "(", ")", "-", "getPaddingBottom", "(", ")", "-", "getPaddingTop", "(", ")", ";", "int", "widthLimit", "=", "getWidth", "(", ")", "-", "getPaddingLeft", "(", ")", "-",...
Resize the text size with default width and height
[ "Resize", "the", "text", "size", "with", "default", "width", "and", "height" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java#L225-L230
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java
AutoResizeTextView.resizeText
public void resizeText(int width, int height) { CharSequence text = getText(); // Do not resize if the view does not have dimensions or there is no text if (text == null || text.length() == 0 || height <= 0 || width <= 0 || mTextSize == 0) { return; } if (getTransformationMethod() != null) { text = getTransformationMethod().getTransformation(text, this); } // Get the text view's paint object TextPaint textPaint = getPaint(); // Store the current text size float oldTextSize = textPaint.getTextSize(); // If there is a max text size set, use the lesser of that and the default text size float targetTextSize = mMaxTextSize > 0 ? Math.min(mTextSize, mMaxTextSize) : mTextSize; // Get the required text height int textHeight = getTextHeight(text, textPaint, width, targetTextSize); // Until we either fit within our text view or we had reached our min text size, incrementally try smaller sizes while (textHeight > height && targetTextSize > mMinTextSize) { targetTextSize = Math.max(targetTextSize - 2, mMinTextSize); textHeight = getTextHeight(text, textPaint, width, targetTextSize); } // If we had reached our minimum text size and still don't fit, append an ellipsis if (mAddEllipsis && targetTextSize == mMinTextSize && textHeight > height) { // Draw using a static layout // modified: use a copy of TextPaint for measuring TextPaint paint = new TextPaint(textPaint); // Draw using a static layout StaticLayout layout = new StaticLayout(text, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false); // Check that we have a least one line of rendered text if (layout.getLineCount() > 0) { // Since the line at the specific vertical position would be cut off, // we must trim up to the previous line int lastLine = layout.getLineForVertical(height) - 1; // If the text would not even fit on a single line, clear it if (lastLine < 0) { setText(""); } // Otherwise, trim to the previous line and add an ellipsis else { int start = layout.getLineStart(lastLine); int end = layout.getLineEnd(lastLine); float lineWidth = layout.getLineWidth(lastLine); float ellipseWidth = textPaint.measureText(mEllipsis); // Trim characters off until we have enough room to draw the ellipsis while (width < lineWidth + ellipseWidth) { lineWidth = textPaint.measureText(text.subSequence(start, --end + 1).toString()); } setText(text.subSequence(0, end) + mEllipsis); } } } // Some devices try to auto adjust line spacing, so force default line spacing // and invalidate the layout as a side effect setTextSize(TypedValue.COMPLEX_UNIT_PX, targetTextSize); setLineSpacing(mSpacingAdd, mSpacingMult); // Notify the listener if registered if (mTextResizeListener != null) { mTextResizeListener.onTextResize(this, oldTextSize, targetTextSize); } // Reset force resize flag mNeedsResize = false; }
java
public void resizeText(int width, int height) { CharSequence text = getText(); // Do not resize if the view does not have dimensions or there is no text if (text == null || text.length() == 0 || height <= 0 || width <= 0 || mTextSize == 0) { return; } if (getTransformationMethod() != null) { text = getTransformationMethod().getTransformation(text, this); } // Get the text view's paint object TextPaint textPaint = getPaint(); // Store the current text size float oldTextSize = textPaint.getTextSize(); // If there is a max text size set, use the lesser of that and the default text size float targetTextSize = mMaxTextSize > 0 ? Math.min(mTextSize, mMaxTextSize) : mTextSize; // Get the required text height int textHeight = getTextHeight(text, textPaint, width, targetTextSize); // Until we either fit within our text view or we had reached our min text size, incrementally try smaller sizes while (textHeight > height && targetTextSize > mMinTextSize) { targetTextSize = Math.max(targetTextSize - 2, mMinTextSize); textHeight = getTextHeight(text, textPaint, width, targetTextSize); } // If we had reached our minimum text size and still don't fit, append an ellipsis if (mAddEllipsis && targetTextSize == mMinTextSize && textHeight > height) { // Draw using a static layout // modified: use a copy of TextPaint for measuring TextPaint paint = new TextPaint(textPaint); // Draw using a static layout StaticLayout layout = new StaticLayout(text, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, false); // Check that we have a least one line of rendered text if (layout.getLineCount() > 0) { // Since the line at the specific vertical position would be cut off, // we must trim up to the previous line int lastLine = layout.getLineForVertical(height) - 1; // If the text would not even fit on a single line, clear it if (lastLine < 0) { setText(""); } // Otherwise, trim to the previous line and add an ellipsis else { int start = layout.getLineStart(lastLine); int end = layout.getLineEnd(lastLine); float lineWidth = layout.getLineWidth(lastLine); float ellipseWidth = textPaint.measureText(mEllipsis); // Trim characters off until we have enough room to draw the ellipsis while (width < lineWidth + ellipseWidth) { lineWidth = textPaint.measureText(text.subSequence(start, --end + 1).toString()); } setText(text.subSequence(0, end) + mEllipsis); } } } // Some devices try to auto adjust line spacing, so force default line spacing // and invalidate the layout as a side effect setTextSize(TypedValue.COMPLEX_UNIT_PX, targetTextSize); setLineSpacing(mSpacingAdd, mSpacingMult); // Notify the listener if registered if (mTextResizeListener != null) { mTextResizeListener.onTextResize(this, oldTextSize, targetTextSize); } // Reset force resize flag mNeedsResize = false; }
[ "public", "void", "resizeText", "(", "int", "width", ",", "int", "height", ")", "{", "CharSequence", "text", "=", "getText", "(", ")", ";", "// Do not resize if the view does not have dimensions or there is no text", "if", "(", "text", "==", "null", "||", "text", ...
Resize the text size with specified width and height @param width @param height
[ "Resize", "the", "text", "size", "with", "specified", "width", "and", "height" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/AutoResizeTextView.java#L238-L310
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitorSessionIO.java
LogMonitorSessionIO.saveCurrentSession
static void saveCurrentSession(Context context, LogMonitorSession session) { if (context == null) { throw new IllegalArgumentException("Context is null"); } if (session == null) { throw new IllegalArgumentException("Session is null"); } SharedPreferences prefs = getPrefs(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PREFS_KEY_EMAIL_RECIPIENTS, StringUtils.join(session.emailRecipients)); editor.apply(); }
java
static void saveCurrentSession(Context context, LogMonitorSession session) { if (context == null) { throw new IllegalArgumentException("Context is null"); } if (session == null) { throw new IllegalArgumentException("Session is null"); } SharedPreferences prefs = getPrefs(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PREFS_KEY_EMAIL_RECIPIENTS, StringUtils.join(session.emailRecipients)); editor.apply(); }
[ "static", "void", "saveCurrentSession", "(", "Context", "context", ",", "LogMonitorSession", "session", ")", "{", "if", "(", "context", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Context is null\"", ")", ";", "}", "if", "(", "s...
Saves current session to the persistent storage
[ "Saves", "current", "session", "to", "the", "persistent", "storage" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitorSessionIO.java#L55-L68
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitorSessionIO.java
LogMonitorSessionIO.deleteCurrentSession
static void deleteCurrentSession(Context context) { SharedPreferences.Editor editor = getPrefs(context).edit(); editor.remove(PREFS_KEY_EMAIL_RECIPIENTS); editor.remove(PREFS_KEY_FILTER_PID); editor.apply(); }
java
static void deleteCurrentSession(Context context) { SharedPreferences.Editor editor = getPrefs(context).edit(); editor.remove(PREFS_KEY_EMAIL_RECIPIENTS); editor.remove(PREFS_KEY_FILTER_PID); editor.apply(); }
[ "static", "void", "deleteCurrentSession", "(", "Context", "context", ")", "{", "SharedPreferences", ".", "Editor", "editor", "=", "getPrefs", "(", "context", ")", ".", "edit", "(", ")", ";", "editor", ".", "remove", "(", "PREFS_KEY_EMAIL_RECIPIENTS", ")", ";",...
Deletes current session from the persistent storage
[ "Deletes", "current", "session", "from", "the", "persistent", "storage" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitorSessionIO.java#L73-L78
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/model/JsonPayload.java
JsonPayload.registerSensitiveKeys
protected static void registerSensitiveKeys(Class<? extends JsonPayload> cls) { List<Field> fields = RuntimeUtils.listFields(cls, new RuntimeUtils.FieldFilter() { @Override public boolean accept(Field field) { return Modifier.isStatic(field.getModifiers()) && // static fields field.getAnnotation(SensitiveDataKey.class) != null && // marked as 'sensitive' field.getType().equals(String.class); // with type of String } }); if (fields.size() > 0) { List<String> keys = new ArrayList<>(fields.size()); try { for (Field field : fields) { field.setAccessible(true); String value = (String) field.get(null); keys.add(value); } SENSITIVE_KEYS_LOOKUP.put(cls, keys); } catch (Exception e) { ApptentiveLog.e(e, "Exception while registering sensitive keys"); logException(e); } } }
java
protected static void registerSensitiveKeys(Class<? extends JsonPayload> cls) { List<Field> fields = RuntimeUtils.listFields(cls, new RuntimeUtils.FieldFilter() { @Override public boolean accept(Field field) { return Modifier.isStatic(field.getModifiers()) && // static fields field.getAnnotation(SensitiveDataKey.class) != null && // marked as 'sensitive' field.getType().equals(String.class); // with type of String } }); if (fields.size() > 0) { List<String> keys = new ArrayList<>(fields.size()); try { for (Field field : fields) { field.setAccessible(true); String value = (String) field.get(null); keys.add(value); } SENSITIVE_KEYS_LOOKUP.put(cls, keys); } catch (Exception e) { ApptentiveLog.e(e, "Exception while registering sensitive keys"); logException(e); } } }
[ "protected", "static", "void", "registerSensitiveKeys", "(", "Class", "<", "?", "extends", "JsonPayload", ">", "cls", ")", "{", "List", "<", "Field", ">", "fields", "=", "RuntimeUtils", ".", "listFields", "(", "cls", ",", "new", "RuntimeUtils", ".", "FieldFi...
region Sensitive Keys
[ "region", "Sensitive", "Keys" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/model/JsonPayload.java#L259-L283
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/ApptentiveAvatarView.java
ApptentiveAvatarView.scaleImage
private ImageScale scaleImage(int imageX, int imageY, int containerX, int containerY) { ImageScale ret = new ImageScale(); // Compare aspects faster by multiplying out the divisors. if (imageX * containerY > imageY * containerX) { // Image aspect wider than container ret.scale = (float) containerX / imageX; ret.deltaY = ((float) containerY - (ret.scale * imageY)) / 2.0f; } else { // Image aspect taller than container ret.scale = (float) containerY / imageY; ret.deltaX = ((float) containerX - (ret.scale * imageX)) / 2.0f; } return ret; }
java
private ImageScale scaleImage(int imageX, int imageY, int containerX, int containerY) { ImageScale ret = new ImageScale(); // Compare aspects faster by multiplying out the divisors. if (imageX * containerY > imageY * containerX) { // Image aspect wider than container ret.scale = (float) containerX / imageX; ret.deltaY = ((float) containerY - (ret.scale * imageY)) / 2.0f; } else { // Image aspect taller than container ret.scale = (float) containerY / imageY; ret.deltaX = ((float) containerX - (ret.scale * imageX)) / 2.0f; } return ret; }
[ "private", "ImageScale", "scaleImage", "(", "int", "imageX", ",", "int", "imageY", ",", "int", "containerX", ",", "int", "containerY", ")", "{", "ImageScale", "ret", "=", "new", "ImageScale", "(", ")", ";", "// Compare aspects faster by multiplying out the divisors....
This scales the image so that it fits within the container. The container may have empty space at the ends, but the entire image will be displayed.
[ "This", "scales", "the", "image", "so", "that", "it", "fits", "within", "the", "container", ".", "The", "container", "may", "have", "empty", "space", "at", "the", "ends", "but", "the", "entire", "image", "will", "be", "displayed", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/ApptentiveAvatarView.java#L261-L274
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/EventRecord.java
EventRecord.update
public void update(double timestamp, String versionName, Integer versionCode) { last = timestamp; total++; Long countForVersionName = versionNames.get(versionName); if (countForVersionName == null) { countForVersionName = 0L; } Long countForVersionCode = versionCodes.get(versionCode); if (countForVersionCode == null) { countForVersionCode = 0L; } versionNames.put(versionName, countForVersionName + 1); versionCodes.put(versionCode, countForVersionCode + 1); }
java
public void update(double timestamp, String versionName, Integer versionCode) { last = timestamp; total++; Long countForVersionName = versionNames.get(versionName); if (countForVersionName == null) { countForVersionName = 0L; } Long countForVersionCode = versionCodes.get(versionCode); if (countForVersionCode == null) { countForVersionCode = 0L; } versionNames.put(versionName, countForVersionName + 1); versionCodes.put(versionCode, countForVersionCode + 1); }
[ "public", "void", "update", "(", "double", "timestamp", ",", "String", "versionName", ",", "Integer", "versionCode", ")", "{", "last", "=", "timestamp", ";", "total", "++", ";", "Long", "countForVersionName", "=", "versionNames", ".", "get", "(", "versionName"...
Initializes an event record or updates it with a subsequent event. @param timestamp The timestamp in seconds at which and Event occurred. @param versionName The Android versionName of the app when the event occurred. @param versionCode The Android versionCode of the app when the event occurred.
[ "Initializes", "an", "event", "record", "or", "updates", "it", "with", "a", "subsequent", "event", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/EventRecord.java#L47-L60
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/serialization/ObjectSerialization.java
ObjectSerialization.serialize
public static void serialize(File file, SerializableObject object) throws IOException { AtomicFile atomicFile = new AtomicFile(file); FileOutputStream stream = null; try { stream = atomicFile.startWrite(); DataOutputStream out = new DataOutputStream(stream); object.writeExternal(out); atomicFile.finishWrite(stream); // serialization was successful } catch (Exception e) { atomicFile.failWrite(stream); // serialization failed throw new IOException(e); // throw exception up the chain } }
java
public static void serialize(File file, SerializableObject object) throws IOException { AtomicFile atomicFile = new AtomicFile(file); FileOutputStream stream = null; try { stream = atomicFile.startWrite(); DataOutputStream out = new DataOutputStream(stream); object.writeExternal(out); atomicFile.finishWrite(stream); // serialization was successful } catch (Exception e) { atomicFile.failWrite(stream); // serialization failed throw new IOException(e); // throw exception up the chain } }
[ "public", "static", "void", "serialize", "(", "File", "file", ",", "SerializableObject", "object", ")", "throws", "IOException", "{", "AtomicFile", "atomicFile", "=", "new", "AtomicFile", "(", "file", ")", ";", "FileOutputStream", "stream", "=", "null", ";", "...
Writes an object ot a file
[ "Writes", "an", "object", "ot", "a", "file" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/serialization/ObjectSerialization.java#L28-L40
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/serialization/ObjectSerialization.java
ObjectSerialization.deserialize
public static <T extends SerializableObject> T deserialize(File file, Class<T> cls) throws IOException { FileInputStream stream = null; try { stream = new FileInputStream(file); DataInputStream in = new DataInputStream(stream); try { Constructor<T> constructor = cls.getDeclaredConstructor(DataInput.class); constructor.setAccessible(true); return constructor.newInstance(in); } catch (Exception e) { throw new IOException("Unable to instantiate class: " + cls, e); } } finally { Util.ensureClosed(stream); } }
java
public static <T extends SerializableObject> T deserialize(File file, Class<T> cls) throws IOException { FileInputStream stream = null; try { stream = new FileInputStream(file); DataInputStream in = new DataInputStream(stream); try { Constructor<T> constructor = cls.getDeclaredConstructor(DataInput.class); constructor.setAccessible(true); return constructor.newInstance(in); } catch (Exception e) { throw new IOException("Unable to instantiate class: " + cls, e); } } finally { Util.ensureClosed(stream); } }
[ "public", "static", "<", "T", "extends", "SerializableObject", ">", "T", "deserialize", "(", "File", "file", ",", "Class", "<", "T", ">", "cls", ")", "throws", "IOException", "{", "FileInputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", ...
Reads an object from a file
[ "Reads", "an", "object", "from", "a", "file" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/serialization/ObjectSerialization.java#L66-L82
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/conversation/Conversation.java
Conversation.storeInteractionManifest
public void storeInteractionManifest(String interactionManifest) { try { InteractionManifest payload = new InteractionManifest(interactionManifest); Interactions interactions = payload.getInteractions(); Targets targets = payload.getTargets(); if (interactions != null && targets != null) { setTargets(targets.toString()); setInteractions(interactions.toString()); } else { ApptentiveLog.e(CONVERSATION, "Unable to save InteractionManifest."); } } catch (JSONException e) { ApptentiveLog.w(CONVERSATION, "Invalid InteractionManifest received."); logException(e); } }
java
public void storeInteractionManifest(String interactionManifest) { try { InteractionManifest payload = new InteractionManifest(interactionManifest); Interactions interactions = payload.getInteractions(); Targets targets = payload.getTargets(); if (interactions != null && targets != null) { setTargets(targets.toString()); setInteractions(interactions.toString()); } else { ApptentiveLog.e(CONVERSATION, "Unable to save InteractionManifest."); } } catch (JSONException e) { ApptentiveLog.w(CONVERSATION, "Invalid InteractionManifest received."); logException(e); } }
[ "public", "void", "storeInteractionManifest", "(", "String", "interactionManifest", ")", "{", "try", "{", "InteractionManifest", "payload", "=", "new", "InteractionManifest", "(", "interactionManifest", ")", ";", "Interactions", "interactions", "=", "payload", ".", "g...
Made public for testing. There is no other reason to use this method directly.
[ "Made", "public", "for", "testing", ".", "There", "is", "no", "other", "reason", "to", "use", "this", "method", "directly", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/conversation/Conversation.java#L318-L333
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/conversation/Conversation.java
Conversation.migrateConversationData
boolean migrateConversationData() throws SerializerException { long start = System.currentTimeMillis(); File legacyConversationDataFile = Util.getUnencryptedFilename(conversationDataFile); if (legacyConversationDataFile.exists()) { try { ApptentiveLog.d(CONVERSATION, "Migrating %sconversation data...", hasState(LOGGED_IN) ? "encrypted " : ""); FileSerializer serializer = isAuthenticated() ? new EncryptedFileSerializer(legacyConversationDataFile, getEncryptionKey()) : new FileSerializer(legacyConversationDataFile); conversationData = (ConversationData) serializer.deserialize(); ApptentiveLog.d(CONVERSATION, "Conversation data migrated (took %d ms)", System.currentTimeMillis() - start); return true; } finally { boolean deleted = legacyConversationDataFile.delete(); ApptentiveLog.d(CONVERSATION, "Legacy conversation file deleted: %b", deleted); } } return false; }
java
boolean migrateConversationData() throws SerializerException { long start = System.currentTimeMillis(); File legacyConversationDataFile = Util.getUnencryptedFilename(conversationDataFile); if (legacyConversationDataFile.exists()) { try { ApptentiveLog.d(CONVERSATION, "Migrating %sconversation data...", hasState(LOGGED_IN) ? "encrypted " : ""); FileSerializer serializer = isAuthenticated() ? new EncryptedFileSerializer(legacyConversationDataFile, getEncryptionKey()) : new FileSerializer(legacyConversationDataFile); conversationData = (ConversationData) serializer.deserialize(); ApptentiveLog.d(CONVERSATION, "Conversation data migrated (took %d ms)", System.currentTimeMillis() - start); return true; } finally { boolean deleted = legacyConversationDataFile.delete(); ApptentiveLog.d(CONVERSATION, "Legacy conversation file deleted: %b", deleted); } } return false; }
[ "boolean", "migrateConversationData", "(", ")", "throws", "SerializerException", "{", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "File", "legacyConversationDataFile", "=", "Util", ".", "getUnencryptedFilename", "(", "conversationDataFile", ...
Attempts to migrate from the legacy clear text format. @return <code>false</code> if failed.
[ "Attempts", "to", "migrate", "from", "the", "legacy", "clear", "text", "format", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/conversation/Conversation.java#L399-L417
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/view/ApptentiveNestedScrollView.java
ApptentiveNestedScrollView.scrollToChild
public void scrollToChild(View child) { child.getDrawingRect(mTempRect); /* Offset from child's local coordinates to ScrollView coordinates */ offsetDescendantRectToMyCoords(child, mTempRect); int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect); if (scrollDelta != 0) { scrollBy(0, scrollDelta); } }
java
public void scrollToChild(View child) { child.getDrawingRect(mTempRect); /* Offset from child's local coordinates to ScrollView coordinates */ offsetDescendantRectToMyCoords(child, mTempRect); int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect); if (scrollDelta != 0) { scrollBy(0, scrollDelta); } }
[ "public", "void", "scrollToChild", "(", "View", "child", ")", "{", "child", ".", "getDrawingRect", "(", "mTempRect", ")", ";", "/* Offset from child's local coordinates to ScrollView coordinates */", "offsetDescendantRectToMyCoords", "(", "child", ",", "mTempRect", ")", "...
Scrolls the view to the given child. @param child the View to scroll to
[ "Scrolls", "the", "view", "to", "the", "given", "child", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/view/ApptentiveNestedScrollView.java#L1455-L1466
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/view/survey/SurveyQuestionChoice.java
SurveyQuestionChoice.isValid
public boolean isValid(boolean questionIsRequired) { // If required and checked, other types must have text if (questionIsRequired && isChecked() && isOtherType && (getOtherText().length() < 1)) { otherTextInputLayout.setError(" "); return false; } otherTextInputLayout.setError(null); return true; }
java
public boolean isValid(boolean questionIsRequired) { // If required and checked, other types must have text if (questionIsRequired && isChecked() && isOtherType && (getOtherText().length() < 1)) { otherTextInputLayout.setError(" "); return false; } otherTextInputLayout.setError(null); return true; }
[ "public", "boolean", "isValid", "(", "boolean", "questionIsRequired", ")", "{", "// If required and checked, other types must have text", "if", "(", "questionIsRequired", "&&", "isChecked", "(", ")", "&&", "isOtherType", "&&", "(", "getOtherText", "(", ")", ".", "leng...
An answer can only be invalid if it's checked, the question is required, and the type is "other", but nothing was typed. All answers must be valid to submit, in addition to whatever logic the question applies.
[ "An", "answer", "can", "only", "be", "invalid", "if", "it", "s", "checked", "the", "question", "is", "required", "and", "the", "type", "is", "other", "but", "nothing", "was", "typed", ".", "All", "answers", "must", "be", "valid", "to", "submit", "in", ...
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/view/survey/SurveyQuestionChoice.java#L103-L111
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/MessageManager.java
MessageManager.fetchAndStoreMessages
void fetchAndStoreMessages(final boolean isMessageCenterForeground, final boolean showToast, @Nullable final MessageFetchListener listener) { checkConversationQueue(); try { String lastMessageId = messageStore.getLastReceivedMessageId(); fetchMessages(lastMessageId, new MessageFetchListener() { @Override public void onFetchFinish(MessageManager messageManager, List<ApptentiveMessage> messages) { try { if (messages == null || messages.size() == 0) return; CompoundMessage messageOnToast = null; ApptentiveLog.d(MESSAGES,"Messages retrieved: %d", messages.size()); // Also get the count of incoming unread messages. int incomingUnreadMessages = 0; // Mark messages from server where sender is the app user as read. for (final ApptentiveMessage apptentiveMessage : messages) { if (apptentiveMessage.isOutgoingMessage()) { apptentiveMessage.setRead(true); } else { if (messageOnToast == null) { if (apptentiveMessage.getMessageType() == ApptentiveMessage.Type.CompoundMessage) { messageOnToast = (CompoundMessage) apptentiveMessage; } } incomingUnreadMessages++; // for every new message received, notify Message Center notifyInternalNewMessagesListeners((CompoundMessage) apptentiveMessage); } } messageStore.addOrUpdateMessages(messages.toArray(new ApptentiveMessage[messages.size()])); if (incomingUnreadMessages > 0) { // Show toast notification only if the foreground activity is not already message center activity if (!isMessageCenterForeground && showToast) { DispatchQueue.mainQueue().dispatchAsyncOnce(toastMessageNotifierTask.setMessage(messageOnToast)); } } // Send message to notify host app, such as unread message badge conversationQueue().dispatchAsyncOnce(hostMessageNotifierTask.setMessageCount(getUnreadMessageCount())); } finally { if (listener != null) { listener.onFetchFinish(messageManager, messages); } } } }); } catch (Exception e) { ApptentiveLog.e(MESSAGES, "Error retrieving last received message id from worker thread"); logException(e); } }
java
void fetchAndStoreMessages(final boolean isMessageCenterForeground, final boolean showToast, @Nullable final MessageFetchListener listener) { checkConversationQueue(); try { String lastMessageId = messageStore.getLastReceivedMessageId(); fetchMessages(lastMessageId, new MessageFetchListener() { @Override public void onFetchFinish(MessageManager messageManager, List<ApptentiveMessage> messages) { try { if (messages == null || messages.size() == 0) return; CompoundMessage messageOnToast = null; ApptentiveLog.d(MESSAGES,"Messages retrieved: %d", messages.size()); // Also get the count of incoming unread messages. int incomingUnreadMessages = 0; // Mark messages from server where sender is the app user as read. for (final ApptentiveMessage apptentiveMessage : messages) { if (apptentiveMessage.isOutgoingMessage()) { apptentiveMessage.setRead(true); } else { if (messageOnToast == null) { if (apptentiveMessage.getMessageType() == ApptentiveMessage.Type.CompoundMessage) { messageOnToast = (CompoundMessage) apptentiveMessage; } } incomingUnreadMessages++; // for every new message received, notify Message Center notifyInternalNewMessagesListeners((CompoundMessage) apptentiveMessage); } } messageStore.addOrUpdateMessages(messages.toArray(new ApptentiveMessage[messages.size()])); if (incomingUnreadMessages > 0) { // Show toast notification only if the foreground activity is not already message center activity if (!isMessageCenterForeground && showToast) { DispatchQueue.mainQueue().dispatchAsyncOnce(toastMessageNotifierTask.setMessage(messageOnToast)); } } // Send message to notify host app, such as unread message badge conversationQueue().dispatchAsyncOnce(hostMessageNotifierTask.setMessageCount(getUnreadMessageCount())); } finally { if (listener != null) { listener.onFetchFinish(messageManager, messages); } } } }); } catch (Exception e) { ApptentiveLog.e(MESSAGES, "Error retrieving last received message id from worker thread"); logException(e); } }
[ "void", "fetchAndStoreMessages", "(", "final", "boolean", "isMessageCenterForeground", ",", "final", "boolean", "showToast", ",", "@", "Nullable", "final", "MessageFetchListener", "listener", ")", "{", "checkConversationQueue", "(", ")", ";", "try", "{", "String", "...
Performs a request against the server to check for messages in the conversation since the latest message we already have. This method will either be run on MessagePollingThread or as an asyncTask when Push is received.
[ "Performs", "a", "request", "against", "the", "server", "to", "check", "for", "messages", "in", "the", "conversation", "since", "the", "latest", "message", "we", "already", "have", ".", "This", "method", "will", "either", "be", "run", "on", "MessagePollingThre...
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/MessageManager.java#L153-L206
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/MessageManager.java
MessageManager.onReceiveNotification
@Override public void onReceiveNotification(ApptentiveNotification notification) { checkConversationQueue(); if (notification.hasName(NOTIFICATION_ACTIVITY_STARTED) || notification.hasName(NOTIFICATION_ACTIVITY_RESUMED)) { final Activity activity = notification.getRequiredUserInfo(NOTIFICATION_KEY_ACTIVITY, Activity.class); setCurrentForegroundActivity(activity); } else if (notification.hasName(NOTIFICATION_APP_ENTERED_FOREGROUND)) { appWentToForeground(); } else if (notification.hasName(NOTIFICATION_APP_ENTERED_BACKGROUND)) { setCurrentForegroundActivity(null); appWentToBackground(); } else if (notification.hasName(NOTIFICATION_PAYLOAD_WILL_START_SEND)) { final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class); if (payload.getType().equals(PayloadType.message)) { resumeSending(); } } else if (notification.hasName(NOTIFICATION_PAYLOAD_DID_FINISH_SEND)) { final boolean successful = notification.getRequiredUserInfo(NOTIFICATION_KEY_SUCCESSFUL, Boolean.class); final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class); final Integer responseCode = notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_CODE, Integer.class); final JSONObject responseData = successful ? notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_DATA, JSONObject.class) : null; if (responseCode == -1) { pauseSending(SEND_PAUSE_REASON_NETWORK); } if (payload.getType().equals(PayloadType.message)) { onSentMessage(payload.getNonce(), responseCode, responseData); } } }
java
@Override public void onReceiveNotification(ApptentiveNotification notification) { checkConversationQueue(); if (notification.hasName(NOTIFICATION_ACTIVITY_STARTED) || notification.hasName(NOTIFICATION_ACTIVITY_RESUMED)) { final Activity activity = notification.getRequiredUserInfo(NOTIFICATION_KEY_ACTIVITY, Activity.class); setCurrentForegroundActivity(activity); } else if (notification.hasName(NOTIFICATION_APP_ENTERED_FOREGROUND)) { appWentToForeground(); } else if (notification.hasName(NOTIFICATION_APP_ENTERED_BACKGROUND)) { setCurrentForegroundActivity(null); appWentToBackground(); } else if (notification.hasName(NOTIFICATION_PAYLOAD_WILL_START_SEND)) { final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class); if (payload.getType().equals(PayloadType.message)) { resumeSending(); } } else if (notification.hasName(NOTIFICATION_PAYLOAD_DID_FINISH_SEND)) { final boolean successful = notification.getRequiredUserInfo(NOTIFICATION_KEY_SUCCESSFUL, Boolean.class); final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class); final Integer responseCode = notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_CODE, Integer.class); final JSONObject responseData = successful ? notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_DATA, JSONObject.class) : null; if (responseCode == -1) { pauseSending(SEND_PAUSE_REASON_NETWORK); } if (payload.getType().equals(PayloadType.message)) { onSentMessage(payload.getNonce(), responseCode, responseData); } } }
[ "@", "Override", "public", "void", "onReceiveNotification", "(", "ApptentiveNotification", "notification", ")", "{", "checkConversationQueue", "(", ")", ";", "if", "(", "notification", ".", "hasName", "(", "NOTIFICATION_ACTIVITY_STARTED", ")", "||", "notification", "....
region Notification Observer
[ "region", "Notification", "Observer" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/MessageManager.java#L395-L426
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/logic/ClauseParser.java
ClauseParser.parseValue
public static Object parseValue(Object value) { if (value == null) { return null; } if (value instanceof Double) { return new BigDecimal((Double) value); } else if (value instanceof Long) { return new BigDecimal((Long) value); } else if (value instanceof Integer) { return new BigDecimal((Integer) value); } else if (value instanceof Float) { return new BigDecimal((Float) value); } else if (value instanceof Short) { return new BigDecimal((Short) value); } else if (value instanceof String) { return ((String) value).trim(); } else if (value instanceof Apptentive.Version) { return value; } else if (value instanceof Apptentive.DateTime) { return value; } else if (value instanceof JSONObject) { JSONObject jsonObject = (JSONObject) value; String typeName = jsonObject.optString(KEY_COMPLEX_TYPE); if (typeName != null) { try { if (Apptentive.Version.TYPE.equals(typeName)) { return new Apptentive.Version(jsonObject); } else if (Apptentive.DateTime.TYPE.equals(typeName)) { return new Apptentive.DateTime(jsonObject); } else { throw new RuntimeException(String.format("Error parsing complex parameter with unrecognized name: \"%s\"", typeName)); } } catch (JSONException e) { throw new RuntimeException(String.format("Error parsing complex parameter: %s", Util.classToString(value)), e); } } else { throw new RuntimeException(String.format("Error: Complex type parameter missing \"%s\".", KEY_COMPLEX_TYPE)); } } // All other values, such as Boolean and String should be returned unaltered. return value; }
java
public static Object parseValue(Object value) { if (value == null) { return null; } if (value instanceof Double) { return new BigDecimal((Double) value); } else if (value instanceof Long) { return new BigDecimal((Long) value); } else if (value instanceof Integer) { return new BigDecimal((Integer) value); } else if (value instanceof Float) { return new BigDecimal((Float) value); } else if (value instanceof Short) { return new BigDecimal((Short) value); } else if (value instanceof String) { return ((String) value).trim(); } else if (value instanceof Apptentive.Version) { return value; } else if (value instanceof Apptentive.DateTime) { return value; } else if (value instanceof JSONObject) { JSONObject jsonObject = (JSONObject) value; String typeName = jsonObject.optString(KEY_COMPLEX_TYPE); if (typeName != null) { try { if (Apptentive.Version.TYPE.equals(typeName)) { return new Apptentive.Version(jsonObject); } else if (Apptentive.DateTime.TYPE.equals(typeName)) { return new Apptentive.DateTime(jsonObject); } else { throw new RuntimeException(String.format("Error parsing complex parameter with unrecognized name: \"%s\"", typeName)); } } catch (JSONException e) { throw new RuntimeException(String.format("Error parsing complex parameter: %s", Util.classToString(value)), e); } } else { throw new RuntimeException(String.format("Error: Complex type parameter missing \"%s\".", KEY_COMPLEX_TYPE)); } } // All other values, such as Boolean and String should be returned unaltered. return value; }
[ "public", "static", "Object", "parseValue", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "value", "instanceof", "Double", ")", "{", "return", "new", "BigDecimal", "(", "(", "Double...
Constructs complex types values from the JSONObjects that represent them. Turns all Numbers into BigDecimal for easier comparison. All fields and parameters must be run through this method. @param value @return null if value is a JSONObject, but not a complex type.
[ "Constructs", "complex", "types", "values", "from", "the", "JSONObjects", "that", "represent", "them", ".", "Turns", "all", "Numbers", "into", "BigDecimal", "for", "easier", "comparison", ".", "All", "fields", "and", "parameters", "must", "be", "run", "through",...
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/logic/ClauseParser.java#L66-L107
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java
ApptentiveInternal.invalidateCaches
private void invalidateCaches(Conversation conversation) { checkConversationQueue(); conversation.setInteractionExpiration(0L); Configuration config = Configuration.load(); config.setConfigurationCacheExpirationMillis(System.currentTimeMillis()); config.save(); }
java
private void invalidateCaches(Conversation conversation) { checkConversationQueue(); conversation.setInteractionExpiration(0L); Configuration config = Configuration.load(); config.setConfigurationCacheExpirationMillis(System.currentTimeMillis()); config.save(); }
[ "private", "void", "invalidateCaches", "(", "Conversation", "conversation", ")", "{", "checkConversationQueue", "(", ")", ";", "conversation", ".", "setInteractionExpiration", "(", "0L", ")", ";", "Configuration", "config", "=", "Configuration", ".", "load", "(", ...
We want to make sure the app is using the latest configuration from the server if the app or sdk version changes.
[ "We", "want", "to", "make", "sure", "the", "app", "is", "using", "the", "latest", "configuration", "from", "the", "server", "if", "the", "app", "or", "sdk", "version", "changes", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java#L621-L628
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java
ApptentiveInternal.dismissAllInteractions
public static void dismissAllInteractions() { if (!isConversationQueue()) { dispatchOnConversationQueue(new DispatchTask() { @Override protected void execute() { dismissAllInteractions(); } }); return; } ApptentiveNotificationCenter.defaultCenter().postNotification(NOTIFICATION_INTERACTIONS_SHOULD_DISMISS); }
java
public static void dismissAllInteractions() { if (!isConversationQueue()) { dispatchOnConversationQueue(new DispatchTask() { @Override protected void execute() { dismissAllInteractions(); } }); return; } ApptentiveNotificationCenter.defaultCenter().postNotification(NOTIFICATION_INTERACTIONS_SHOULD_DISMISS); }
[ "public", "static", "void", "dismissAllInteractions", "(", ")", "{", "if", "(", "!", "isConversationQueue", "(", ")", ")", "{", "dispatchOnConversationQueue", "(", "new", "DispatchTask", "(", ")", "{", "@", "Override", "protected", "void", "execute", "(", ")",...
Dismisses any currently-visible interactions. This method is for internal use and is subject to change.
[ "Dismisses", "any", "currently", "-", "visible", "interactions", ".", "This", "method", "is", "for", "internal", "use", "and", "is", "subject", "to", "change", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java#L1072-L1084
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java
ApptentiveInternal.storeManifestResponse
private void storeManifestResponse(Context context, String manifest) { try { File file = new File(ApptentiveLog.getLogsDirectory(context), Constants.FILE_APPTENTIVE_ENGAGEMENT_MANIFEST); Util.writeText(file, manifest); } catch (Exception e) { ApptentiveLog.e(CONVERSATION, e, "Exception while trying to save engagement manifest data"); logException(e); } }
java
private void storeManifestResponse(Context context, String manifest) { try { File file = new File(ApptentiveLog.getLogsDirectory(context), Constants.FILE_APPTENTIVE_ENGAGEMENT_MANIFEST); Util.writeText(file, manifest); } catch (Exception e) { ApptentiveLog.e(CONVERSATION, e, "Exception while trying to save engagement manifest data"); logException(e); } }
[ "private", "void", "storeManifestResponse", "(", "Context", "context", ",", "String", "manifest", ")", "{", "try", "{", "File", "file", "=", "new", "File", "(", "ApptentiveLog", ".", "getLogsDirectory", "(", "context", ")", ",", "Constants", ".", "FILE_APPTENT...
region Engagement Manifest Data
[ "region", "Engagement", "Manifest", "Data" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java#L1162-L1170
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java
ApptentiveInternal.updateConversationAdvertiserIdentifier
private void updateConversationAdvertiserIdentifier(Conversation conversation) { checkConversationQueue(); try { Configuration config = Configuration.load(); if (config.isCollectingAdID()) { AdvertisingIdClientInfo info = AdvertiserManager.getAdvertisingIdClientInfo(); String advertiserId = info != null && !info.isLimitAdTrackingEnabled() ? info.getId() : null; conversation.getDevice().setAdvertiserId(advertiserId); } } catch (Exception e) { ApptentiveLog.e(ADVERTISER_ID, e, "Exception while updating conversation advertiser id"); logException(e); } }
java
private void updateConversationAdvertiserIdentifier(Conversation conversation) { checkConversationQueue(); try { Configuration config = Configuration.load(); if (config.isCollectingAdID()) { AdvertisingIdClientInfo info = AdvertiserManager.getAdvertisingIdClientInfo(); String advertiserId = info != null && !info.isLimitAdTrackingEnabled() ? info.getId() : null; conversation.getDevice().setAdvertiserId(advertiserId); } } catch (Exception e) { ApptentiveLog.e(ADVERTISER_ID, e, "Exception while updating conversation advertiser id"); logException(e); } }
[ "private", "void", "updateConversationAdvertiserIdentifier", "(", "Conversation", "conversation", ")", "{", "checkConversationQueue", "(", ")", ";", "try", "{", "Configuration", "config", "=", "Configuration", ".", "load", "(", ")", ";", "if", "(", "config", ".", ...
region Advertiser Identifier
[ "region", "Advertiser", "Identifier" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveInternal.java#L1176-L1190
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/migration/Migrator.java
Migrator.jsonObjectToSerializableType
private static Serializable jsonObjectToSerializableType(JSONObject input) { String type = input.optString(Apptentive.Version.KEY_TYPE, null); try { if (type != null) { if (type.equals(Apptentive.Version.TYPE)) { return new Apptentive.Version(input); } else if (type.equals(Apptentive.DateTime.TYPE)) { return new Apptentive.DateTime(input); } } } catch (JSONException e) { ApptentiveLog.e(CONVERSATION, e, "Error migrating JSONObject."); logException(e); } return null; }
java
private static Serializable jsonObjectToSerializableType(JSONObject input) { String type = input.optString(Apptentive.Version.KEY_TYPE, null); try { if (type != null) { if (type.equals(Apptentive.Version.TYPE)) { return new Apptentive.Version(input); } else if (type.equals(Apptentive.DateTime.TYPE)) { return new Apptentive.DateTime(input); } } } catch (JSONException e) { ApptentiveLog.e(CONVERSATION, e, "Error migrating JSONObject."); logException(e); } return null; }
[ "private", "static", "Serializable", "jsonObjectToSerializableType", "(", "JSONObject", "input", ")", "{", "String", "type", "=", "input", ".", "optString", "(", "Apptentive", ".", "Version", ".", "KEY_TYPE", ",", "null", ")", ";", "try", "{", "if", "(", "ty...
Takes a legacy Apptentive Custom Data object base on JSON, and returns the modern serializable version
[ "Takes", "a", "legacy", "Apptentive", "Custom", "Data", "object", "base", "on", "JSON", "and", "returns", "the", "modern", "serializable", "version" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/migration/Migrator.java#L288-L303
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/encryption/resolvers/KeyResolver18.java
KeyResolver18.wrapSymmetricKey
private static String wrapSymmetricKey(KeyPair wrapperKey, SecretKey symmetricKey) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException { Cipher cipher = Cipher.getInstance(WRAPPER_TRANSFORMATION); cipher.init(Cipher.WRAP_MODE, wrapperKey.getPublic()); byte[] decodedData = cipher.wrap(symmetricKey); return Base64.encodeToString(decodedData, Base64.DEFAULT); }
java
private static String wrapSymmetricKey(KeyPair wrapperKey, SecretKey symmetricKey) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException { Cipher cipher = Cipher.getInstance(WRAPPER_TRANSFORMATION); cipher.init(Cipher.WRAP_MODE, wrapperKey.getPublic()); byte[] decodedData = cipher.wrap(symmetricKey); return Base64.encodeToString(decodedData, Base64.DEFAULT); }
[ "private", "static", "String", "wrapSymmetricKey", "(", "KeyPair", "wrapperKey", ",", "SecretKey", "symmetricKey", ")", "throws", "NoSuchPaddingException", ",", "NoSuchAlgorithmException", ",", "InvalidKeyException", ",", "IllegalBlockSizeException", "{", "Cipher", "cipher"...
region Key Wrapping
[ "region", "Key", "Wrapping" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/encryption/resolvers/KeyResolver18.java#L203-L211
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationCenter.java
ApptentiveNotificationCenter.resolveObserverList
private synchronized ApptentiveNotificationObserverList resolveObserverList(String name) { ApptentiveNotificationObserverList list = observerListLookup.get(name); if (list == null) { list = new ApptentiveNotificationObserverList(); observerListLookup.put(name, list); } return list; }
java
private synchronized ApptentiveNotificationObserverList resolveObserverList(String name) { ApptentiveNotificationObserverList list = observerListLookup.get(name); if (list == null) { list = new ApptentiveNotificationObserverList(); observerListLookup.put(name, list); } return list; }
[ "private", "synchronized", "ApptentiveNotificationObserverList", "resolveObserverList", "(", "String", "name", ")", "{", "ApptentiveNotificationObserverList", "list", "=", "observerListLookup", ".", "get", "(", "name", ")", ";", "if", "(", "list", "==", "null", ")", ...
Find an observer list for the specified name or creates a new one if not found.
[ "Find", "an", "observer", "list", "for", "the", "specified", "name", "or", "creates", "a", "new", "one", "if", "not", "found", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationCenter.java#L125-L132
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/comm/ApptentiveClient.java
ApptentiveClient.getErrorResponse
public static String getErrorResponse(HttpURLConnection connection, boolean isZipped) throws IOException { if (connection != null) { InputStream is = null; try { is = connection.getErrorStream(); if (is != null) { if (isZipped) { is = new GZIPInputStream(is); } } return Util.readStringFromInputStream(is, "UTF-8"); } finally { Util.ensureClosed(is); } } return null; }
java
public static String getErrorResponse(HttpURLConnection connection, boolean isZipped) throws IOException { if (connection != null) { InputStream is = null; try { is = connection.getErrorStream(); if (is != null) { if (isZipped) { is = new GZIPInputStream(is); } } return Util.readStringFromInputStream(is, "UTF-8"); } finally { Util.ensureClosed(is); } } return null; }
[ "public", "static", "String", "getErrorResponse", "(", "HttpURLConnection", "connection", ",", "boolean", "isZipped", ")", "throws", "IOException", "{", "if", "(", "connection", "!=", "null", ")", "{", "InputStream", "is", "=", "null", ";", "try", "{", "is", ...
Reads error response and returns it as a string. Handles gzipped streams. @param connection Current connection @return Error response as String @throws IOException
[ "Reads", "error", "response", "and", "returns", "it", "as", "a", "string", ".", "Handles", "gzipped", "streams", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/comm/ApptentiveClient.java#L32-L48
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/encryption/Encryptor.java
Encryptor.writeToEncryptedFile
public static void writeToEncryptedFile(EncryptionKey encryptionKey, File file, byte[] data) throws IOException, NoSuchPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException, EncryptionException { AtomicFile atomicFile = new AtomicFile(file); FileOutputStream stream = null; boolean successful = false; try { stream = atomicFile.startWrite(); stream.write(encrypt(encryptionKey, data)); atomicFile.finishWrite(stream); successful = true; } finally { if (!successful) { atomicFile.failWrite(stream); } } }
java
public static void writeToEncryptedFile(EncryptionKey encryptionKey, File file, byte[] data) throws IOException, NoSuchPaddingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException, EncryptionException { AtomicFile atomicFile = new AtomicFile(file); FileOutputStream stream = null; boolean successful = false; try { stream = atomicFile.startWrite(); stream.write(encrypt(encryptionKey, data)); atomicFile.finishWrite(stream); successful = true; } finally { if (!successful) { atomicFile.failWrite(stream); } } }
[ "public", "static", "void", "writeToEncryptedFile", "(", "EncryptionKey", "encryptionKey", ",", "File", "file", ",", "byte", "[", "]", "data", ")", "throws", "IOException", ",", "NoSuchPaddingException", ",", "InvalidAlgorithmParameterException", ",", "NoSuchAlgorithmEx...
region File IO
[ "region", "File", "IO" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/encryption/Encryptor.java#L146-L167
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveTaskManager.java
ApptentiveTaskManager.onFinishSending
@Override public void onFinishSending(PayloadSender sender, PayloadData payload, boolean cancelled, String errorMessage, int responseCode, JSONObject responseData) { ApptentiveNotificationCenter.defaultCenter() .postNotification(NOTIFICATION_PAYLOAD_DID_FINISH_SEND, NOTIFICATION_KEY_PAYLOAD, payload, NOTIFICATION_KEY_SUCCESSFUL, errorMessage == null && !cancelled ? TRUE : FALSE, NOTIFICATION_KEY_RESPONSE_CODE, responseCode, NOTIFICATION_KEY_RESPONSE_DATA, responseData); if (cancelled) { ApptentiveLog.v(PAYLOADS, "Payload sending was cancelled: %s", payload); return; // don't remove cancelled payloads from the queue } if (errorMessage != null) { ApptentiveLog.e(PAYLOADS, "Payload sending failed: %s\n%s", payload, errorMessage); if (appInBackground) { ApptentiveLog.v(PAYLOADS, "The app went to the background so we won't remove the payload from the queue"); retrySending(5000); return; } else if (responseCode == -1) { ApptentiveLog.v(PAYLOADS, "Payload failed to send due to a connection error."); retrySending(5000); return; } else if (responseCode >= 500) { ApptentiveLog.v(PAYLOADS, "Payload failed to send due to a server error."); retrySending(5000); return; } } else { ApptentiveLog.v(PAYLOADS, "Payload was successfully sent: %s", payload); } // Only let the payload be deleted if it was successfully sent, or got an unrecoverable client error. deletePayload(payload.getNonce()); }
java
@Override public void onFinishSending(PayloadSender sender, PayloadData payload, boolean cancelled, String errorMessage, int responseCode, JSONObject responseData) { ApptentiveNotificationCenter.defaultCenter() .postNotification(NOTIFICATION_PAYLOAD_DID_FINISH_SEND, NOTIFICATION_KEY_PAYLOAD, payload, NOTIFICATION_KEY_SUCCESSFUL, errorMessage == null && !cancelled ? TRUE : FALSE, NOTIFICATION_KEY_RESPONSE_CODE, responseCode, NOTIFICATION_KEY_RESPONSE_DATA, responseData); if (cancelled) { ApptentiveLog.v(PAYLOADS, "Payload sending was cancelled: %s", payload); return; // don't remove cancelled payloads from the queue } if (errorMessage != null) { ApptentiveLog.e(PAYLOADS, "Payload sending failed: %s\n%s", payload, errorMessage); if (appInBackground) { ApptentiveLog.v(PAYLOADS, "The app went to the background so we won't remove the payload from the queue"); retrySending(5000); return; } else if (responseCode == -1) { ApptentiveLog.v(PAYLOADS, "Payload failed to send due to a connection error."); retrySending(5000); return; } else if (responseCode >= 500) { ApptentiveLog.v(PAYLOADS, "Payload failed to send due to a server error."); retrySending(5000); return; } } else { ApptentiveLog.v(PAYLOADS, "Payload was successfully sent: %s", payload); } // Only let the payload be deleted if it was successfully sent, or got an unrecoverable client error. deletePayload(payload.getNonce()); }
[ "@", "Override", "public", "void", "onFinishSending", "(", "PayloadSender", "sender", ",", "PayloadData", "payload", ",", "boolean", "cancelled", ",", "String", "errorMessage", ",", "int", "responseCode", ",", "JSONObject", "responseData", ")", "{", "ApptentiveNotif...
region PayloadSender.Listener
[ "region", "PayloadSender", ".", "Listener" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveTaskManager.java#L194-L229
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveTaskManager.java
ApptentiveTaskManager.sendNextPayload
private void sendNextPayload() { singleThreadExecutor.execute(new Runnable() { @Override public void run() { try { sendNextPayloadSync(); } catch (Exception e) { ApptentiveLog.e(e, "Exception while trying to send next payload"); logException(e); } } }); }
java
private void sendNextPayload() { singleThreadExecutor.execute(new Runnable() { @Override public void run() { try { sendNextPayloadSync(); } catch (Exception e) { ApptentiveLog.e(e, "Exception while trying to send next payload"); logException(e); } } }); }
[ "private", "void", "sendNextPayload", "(", ")", "{", "singleThreadExecutor", ".", "execute", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "sendNextPayloadSync", "(", ")", ";", "}", "catch", "...
region Payload Sending
[ "region", "Payload", "Sending" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveTaskManager.java#L255-L267
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveDatabaseHelper.java
ApptentiveDatabaseHelper.onCreate
@Override public void onCreate(SQLiteDatabase db) { ApptentiveLog.d(DATABASE, "ApptentiveDatabase.onCreate(db)"); db.execSQL(SQL_CREATE_PAYLOAD_TABLE); // Leave legacy tables in place for now. db.execSQL(TABLE_CREATE_MESSAGE); db.execSQL(TABLE_CREATE_FILESTORE); db.execSQL(TABLE_CREATE_COMPOUND_FILESTORE); }
java
@Override public void onCreate(SQLiteDatabase db) { ApptentiveLog.d(DATABASE, "ApptentiveDatabase.onCreate(db)"); db.execSQL(SQL_CREATE_PAYLOAD_TABLE); // Leave legacy tables in place for now. db.execSQL(TABLE_CREATE_MESSAGE); db.execSQL(TABLE_CREATE_FILESTORE); db.execSQL(TABLE_CREATE_COMPOUND_FILESTORE); }
[ "@", "Override", "public", "void", "onCreate", "(", "SQLiteDatabase", "db", ")", "{", "ApptentiveLog", ".", "d", "(", "DATABASE", ",", "\"ApptentiveDatabase.onCreate(db)\"", ")", ";", "db", ".", "execSQL", "(", "SQL_CREATE_PAYLOAD_TABLE", ")", ";", "// Leave legac...
This function is called only for new installs, and onUpgrade is not called in that case. Therefore, you must include the latest complete set of DDL here.
[ "This", "function", "is", "called", "only", "for", "new", "installs", "and", "onUpgrade", "is", "not", "called", "in", "that", "case", ".", "Therefore", "you", "must", "include", "the", "latest", "complete", "set", "of", "DDL", "here", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveDatabaseHelper.java#L225-L234
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveDatabaseHelper.java
ApptentiveDatabaseHelper.onUpgrade
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ApptentiveLog.d(DATABASE, "Upgrade database from %d to %d", oldVersion, newVersion); try { DatabaseMigrator migrator = createDatabaseMigrator(oldVersion, newVersion); if (migrator != null) { migrator.onUpgrade(db, oldVersion, newVersion); } } catch (Exception e) { ApptentiveLog.e(DATABASE, e, "Exception while trying to migrate database from %d to %d", oldVersion, newVersion); logException(e); // if migration failed - create new table db.execSQL(SQL_DELETE_PAYLOAD_TABLE); onCreate(db); } }
java
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ApptentiveLog.d(DATABASE, "Upgrade database from %d to %d", oldVersion, newVersion); try { DatabaseMigrator migrator = createDatabaseMigrator(oldVersion, newVersion); if (migrator != null) { migrator.onUpgrade(db, oldVersion, newVersion); } } catch (Exception e) { ApptentiveLog.e(DATABASE, e, "Exception while trying to migrate database from %d to %d", oldVersion, newVersion); logException(e); // if migration failed - create new table db.execSQL(SQL_DELETE_PAYLOAD_TABLE); onCreate(db); } }
[ "@", "Override", "public", "void", "onUpgrade", "(", "SQLiteDatabase", "db", ",", "int", "oldVersion", ",", "int", "newVersion", ")", "{", "ApptentiveLog", ".", "d", "(", "DATABASE", ",", "\"Upgrade database from %d to %d\"", ",", "oldVersion", ",", "newVersion", ...
This method is called when an app is upgraded. Add alter table statements here for each version in a non-breaking switch, so that all the necessary upgrades occur for each older version.
[ "This", "method", "is", "called", "when", "an", "app", "is", "upgraded", ".", "Add", "alter", "table", "statements", "here", "for", "each", "version", "in", "a", "non", "-", "breaking", "switch", "so", "that", "all", "the", "necessary", "upgrades", "occur"...
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/ApptentiveDatabaseHelper.java#L240-L256
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java
ApptentiveNotificationObserverList.notifyObservers
void notifyObservers(ApptentiveNotification notification) { boolean hasLostReferences = false; // create a temporary list of observers to avoid concurrent modification errors List<ApptentiveNotificationObserver> temp = new ArrayList<>(observers.size()); for (int i = 0; i < observers.size(); ++i) { ApptentiveNotificationObserver observer = observers.get(i); ObserverWeakReference observerRef = ObjectUtils.as(observer, ObserverWeakReference.class); if (observerRef == null || !observerRef.isReferenceLost()) { temp.add(observer); } else { hasLostReferences = true; } } // notify observers for (int i = 0; i < temp.size(); ++i) { try { temp.get(i).onReceiveNotification(notification); } catch (Exception e) { ApptentiveLog.e(e, "Exception while posting notification: %s", notification); logException(e); // TODO: add more context info } } // clean lost references if (hasLostReferences) { for (int i = observers.size() - 1; i >= 0; --i) { final ObserverWeakReference observerRef = ObjectUtils.as(observers.get(i), ObserverWeakReference.class); if (observerRef != null && observerRef.isReferenceLost()) { observers.remove(i); } } } }
java
void notifyObservers(ApptentiveNotification notification) { boolean hasLostReferences = false; // create a temporary list of observers to avoid concurrent modification errors List<ApptentiveNotificationObserver> temp = new ArrayList<>(observers.size()); for (int i = 0; i < observers.size(); ++i) { ApptentiveNotificationObserver observer = observers.get(i); ObserverWeakReference observerRef = ObjectUtils.as(observer, ObserverWeakReference.class); if (observerRef == null || !observerRef.isReferenceLost()) { temp.add(observer); } else { hasLostReferences = true; } } // notify observers for (int i = 0; i < temp.size(); ++i) { try { temp.get(i).onReceiveNotification(notification); } catch (Exception e) { ApptentiveLog.e(e, "Exception while posting notification: %s", notification); logException(e); // TODO: add more context info } } // clean lost references if (hasLostReferences) { for (int i = observers.size() - 1; i >= 0; --i) { final ObserverWeakReference observerRef = ObjectUtils.as(observers.get(i), ObserverWeakReference.class); if (observerRef != null && observerRef.isReferenceLost()) { observers.remove(i); } } } }
[ "void", "notifyObservers", "(", "ApptentiveNotification", "notification", ")", "{", "boolean", "hasLostReferences", "=", "false", ";", "// create a temporary list of observers to avoid concurrent modification errors", "List", "<", "ApptentiveNotificationObserver", ">", "temp", "=...
Posts notification to all observers.
[ "Posts", "notification", "to", "all", "observers", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java#L36-L70
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java
ApptentiveNotificationObserverList.addObserver
boolean addObserver(ApptentiveNotificationObserver observer, boolean useWeakReference) { if (observer == null) { throw new IllegalArgumentException("Observer is null"); } if (!contains(observer)) { observers.add(useWeakReference ? new ObserverWeakReference(observer) : observer); return true; } return false; }
java
boolean addObserver(ApptentiveNotificationObserver observer, boolean useWeakReference) { if (observer == null) { throw new IllegalArgumentException("Observer is null"); } if (!contains(observer)) { observers.add(useWeakReference ? new ObserverWeakReference(observer) : observer); return true; } return false; }
[ "boolean", "addObserver", "(", "ApptentiveNotificationObserver", "observer", ",", "boolean", "useWeakReference", ")", "{", "if", "(", "observer", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Observer is null\"", ")", ";", "}", "if", ...
Adds an observer to the list without duplicates. @param useWeakReference - use weak reference if <code>true</code> @return <code>true</code> - if observer was added
[ "Adds", "an", "observer", "to", "the", "list", "without", "duplicates", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java#L78-L89
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java
ApptentiveNotificationObserverList.removeObserver
boolean removeObserver(ApptentiveNotificationObserver observer) { int index = indexOf(observer); if (index != -1) { observers.remove(index); return true; } return false; }
java
boolean removeObserver(ApptentiveNotificationObserver observer) { int index = indexOf(observer); if (index != -1) { observers.remove(index); return true; } return false; }
[ "boolean", "removeObserver", "(", "ApptentiveNotificationObserver", "observer", ")", "{", "int", "index", "=", "indexOf", "(", "observer", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "observers", ".", "remove", "(", "index", ")", ";", "return",...
Removes observer os its weak reference from the list @return <code>true</code> if observer was returned
[ "Removes", "observer", "os", "its", "weak", "reference", "from", "the", "list" ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java#L96-L103
train
apptentive/apptentive-android
apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java
ApptentiveNotificationObserverList.indexOf
private int indexOf(ApptentiveNotificationObserver observer) { for (int i = 0; i < observers.size(); ++i) { final ApptentiveNotificationObserver other = observers.get(i); if (other == observer) { return i; } final ObserverWeakReference otherReference = ObjectUtils.as(other, ObserverWeakReference.class); if (otherReference != null && otherReference.get() == observer) { return i; } } return -1; }
java
private int indexOf(ApptentiveNotificationObserver observer) { for (int i = 0; i < observers.size(); ++i) { final ApptentiveNotificationObserver other = observers.get(i); if (other == observer) { return i; } final ObserverWeakReference otherReference = ObjectUtils.as(other, ObserverWeakReference.class); if (otherReference != null && otherReference.get() == observer) { return i; } } return -1; }
[ "private", "int", "indexOf", "(", "ApptentiveNotificationObserver", "observer", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "observers", ".", "size", "(", ")", ";", "++", "i", ")", "{", "final", "ApptentiveNotificationObserver", "other", "="...
Returns an index of the observer or its weak reference. @return -1 if not found
[ "Returns", "an", "index", "of", "the", "observer", "or", "its", "weak", "reference", "." ]
887c08d7bd5ae6488a90366dfb58f58938861a93
https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/notifications/ApptentiveNotificationObserverList.java#L117-L130
train