code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public final void processInput()
{
inputChanged();
validate();
if (hasErrorMessage())
{
invalid();
}
else
{
valid();
updateModel();
}
}
|
This method will retrieve the request parameter, validate it, and if valid update the model.
These are the same steps as would be performed by the form.
This is useful when a formcomponent is used outside a form.
|
processInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@Override
public FormComponent<T> setLabel(IModel<String> labelModel)
{
super.setLabel(labelModel);
return this;
}
|
The value will be made available to the validator property by means of ${label}. It does not
have any specific meaning to FormComponent itself.
@param labelModel
@return this for chaining
|
setLabel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public void setModelValue(final String[] value)
{
convertedInput = convertValue(value);
updateModel();
}
|
Sets the value for a form component.
@param value
The value
|
setModelValue
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final FormComponent<T> setRequired(final boolean required)
{
if (!required && getType() != null && getType().isPrimitive())
{
throw new WicketRuntimeException(
"FormComponent has to be required when the type is primitive class: " + this);
}
if (required != isRequired())
{
addStateChange();
}
setFlag(FLAG_REQUIRED, required);
return this;
}
|
Sets the required flag
@param required
@return this for chaining
|
setRequired
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public FormComponent<T> setType(Class<?> type)
{
typeName = type == null ? null : type.getName();
if (type != null && type.isPrimitive())
{
setRequired(true);
}
return this;
}
|
Sets the type that will be used when updating the model for this component. If no type is
specified String type is assumed.
@param type
@return this for chaining
|
setType
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@Override
public void updateModel()
{
setModelObject(getConvertedInput());
}
|
Updates this components model from the request, it expects that the object is already
converted through the convertInput() call that is called by the validate() method when a form
is being processed.
By default it just does this:
<pre>
setModelObject(getConvertedInput());
</pre>
<strong>DO NOT CALL THIS METHOD DIRECTLY UNLESS YOU ARE SURE WHAT YOU ARE DOING. USUALLY UPDATING
YOUR MODEL IS HANDLED BY THE FORM, NOT DIRECTLY BY YOU.</strong>
|
updateModel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final void valid()
{
clearInput();
onValid();
}
|
Called to indicate that the user input is valid.
|
valid
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public void validate()
{
// clear any previous feedback messages
if (hasFeedbackMessage())
{
getFeedbackMessages().clear();
}
// validate
validateRequired();
if (isValid())
{
convertInput();
if (isValid())
{
if (isRequired() && getConvertedInput() == null && isInputNullable())
{
reportRequiredError();
}
else
{
validateValidators();
}
}
}
}
|
Performs full validation of the form component, which consists of calling validateRequired(),
convertInput(), and validateValidators(). This method should only be used if the form
component needs to be fully validated outside the form process.
|
validate
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public void convertInput()
{
if (typeName == null)
{
try
{
convertedInput = convertValue(getInputAsArray());
}
catch (ConversionException e)
{
error(newValidationError(e));
}
}
else
{
final IConverter<T> converter = getConverter(getType());
try
{
convertedInput = converter.convertToObject(getInput(), getLocale());
}
catch (ConversionException e)
{
error(newValidationError(e));
}
}
}
|
Converts and validates the conversion of the raw input string into the object specified by
{@link FormComponent#getType()} and records any thrown {@link ConversionException}s.
Converted value is available through {@link FormComponent#getConvertedInput()}.
<p>
Usually the user should do custom conversions by specifying an {@link IConverter} by
registering it with the application by overriding {@link Application#getConverterLocator()},
or at the component level by overriding {@link #getConverter(Class)} .
</p>
<strong>DO NOT CALL THIS METHOD DIRECTLY UNLESS YOU ARE SURE WHAT YOU ARE DOING. USUALLY UPDATING
YOUR MODEL IS HANDLED BY THE FORM, NOT DIRECTLY BY YOU.</strong>
@see IConverterLocator
@see Application#newConverterLocator()
@see IConverter#convertToObject(String, Locale)
@see #newValidationError(ConversionException)
|
convertInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected ValidationError newValidationError(ConversionException cause)
{
ValidationError error = new ValidationError(cause.getMessage());
if (cause.getResourceKey() != null)
{
error.addKey(cause.getResourceKey());
}
if (typeName == null)
{
if (cause.getTargetType() != null)
{
error.addKey("ConversionError." + Classes.simpleName(cause.getTargetType()));
}
error.addKey("ConversionError");
}
else
{
String simpleName = Classes.simpleName(getType());
error.addKey("IConverter." + simpleName);
error.addKey("IConverter");
error.setVariable("type", simpleName);
}
final Locale locale = cause.getLocale();
if (locale != null)
{
error.setVariable("locale", locale);
}
error.setVariable("exception", cause);
Format format = cause.getFormat();
if (format instanceof SimpleDateFormat)
{
error.setVariable("format", ((SimpleDateFormat)format).toLocalizedPattern());
}
Map<String, Object> variables = cause.getVariables();
if (variables != null)
{
error.getVariables().putAll(variables);
}
return error;
}
|
This method is called, when the validation triggered by {@link FormComponent#convertInput()}
failed with a {@link ConversionException}, to construct a {@link ValidationError} based on
the exception.
<p>
Override this method to modify the ValidationError object, e.g. add a custom variable for
message substitution:
<p>
<pre>
new FormComponent<T>(id)
{
protected ValidationError newValidationError(ConversionException cause)
{
return super.newValidationError(cause).setVariable("foo", foovalue);
}
};
</pre>
@param cause
the original cause
@return {@link ValidationError}
|
newValidationError
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SuppressWarnings("unchecked")
protected T convertValue(String[] value) throws ConversionException
{
return (T)(value != null && value.length > 0 && value[0] != null ? trim(value[0]) : null);
}
|
Subclasses should overwrite this if the conversion is not done through the type field and the
{@link IConverter}. <strong>WARNING: this method may be removed in future versions.</strong>
If conversion fails then a ConversionException should be thrown
@param value
The value can be the getInput() or through a cookie
@return The converted value. default returns just the given value
@throws ConversionException
If input can't be converted
|
convertValue
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected String getModelValue()
{
return getDefaultModelObjectAsString();
}
|
@return Value to return when model value is needed
|
getModelValue
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected final int inputAsInt()
{
final String string = getInput();
try
{
return Integer.parseInt(string);
}
catch (NumberFormatException e)
{
throw new IllegalArgumentException(
exceptionMessage("Internal error. Request string '" + string +
"' not a valid integer"));
}
}
|
Gets the request parameter for this component as an int.
@return The value in the request for this component
|
inputAsInt
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected final int inputAsInt(final int defaultValue)
{
final String string = getInput();
if (string != null)
{
try
{
return Integer.parseInt(string);
}
catch (NumberFormatException e)
{
throw new IllegalArgumentException(exceptionMessage("Request string '" + string +
"' is not a valid integer"));
}
}
else
{
return defaultValue;
}
}
|
Gets the request parameter for this component as an int, using the given default in case no
corresponding request parameter was found.
@param defaultValue
Default value to return if request does not have an integer for this component
@return The value in the request for this component
|
inputAsInt
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected final int[] inputAsIntArray()
{
final String[] strings = getInputAsArray();
if (strings != null)
{
final int[] ints = new int[strings.length];
for (int i = 0; i < strings.length; i++)
{
ints[i] = Integer.parseInt(strings[i]);
}
return ints;
}
return null;
}
|
Gets the request parameters for this component as ints.
@return The values in the request for this component
|
inputAsIntArray
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected void onDisabled(final ComponentTag tag)
{
tag.put("disabled", "disabled");
}
|
Called by {@link #onComponentTag(ComponentTag)} when the component is disabled. By default,
this method will add a disabled="disabled" attribute to the tag. Components may override this
method to tweak the tag as they think is fit.
@param tag
the tag that is being rendered
|
onDisabled
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@Deprecated
protected void onRequired(final ComponentTag tag)
{
}
|
Called by {@link #onComponentTag(ComponentTag)} when the component is required.
@param tag
the tag that is being rendered
|
onRequired
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected boolean shouldTrimInput()
{
return true;
}
|
Determines whether or not this component should trim its input prior to processing it. The
default value is <code>true</code>
@return True if the input should be trimmed.
|
shouldTrimInput
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected String trim(String string)
{
String trimmed = string;
if (trimmed != null && shouldTrimInput())
{
trimmed = trimmed.trim();
}
return trimmed;
}
|
Trims the input according to {@link #shouldTrimInput()}
@param string
@return trimmed input if {@link #shouldTrimInput()} returns true, unchanged input otherwise
|
trim
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected final void validateRequired()
{
if (!checkRequired())
{
reportRequiredError();
}
}
|
Checks if the raw input value is not null if this component is required.
|
validateRequired
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected void reportRequiredError()
{
error(new ValidationError().addKey("Required"));
}
|
Reports required error against this component
|
reportRequiredError
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
@SuppressWarnings("unchecked")
protected final void validateValidators()
{
final IValidatable<T> validatable = newValidatable();
boolean isNull = getConvertedInput() == null;
IValidator<T> validator;
for (Behavior behavior : getBehaviors())
{
if (isBehaviorAccepted(behavior) == false)
{
continue;
}
validator = null;
if (behavior instanceof ValidatorAdapter)
{
validator = ((ValidatorAdapter<T>)behavior).getValidator();
}
else if (behavior instanceof IValidator)
{
validator = (IValidator<T>)behavior;
}
if (validator != null)
{
if (isNull == false || validator instanceof INullAcceptingValidator<?>)
{
try
{
validator.validate(validatable);
}
catch (Exception e)
{
throw new WicketRuntimeException("Exception '" + e.getMessage() +
"' occurred during validation " + validator.getClass().getName() +
" on component " + getPath(), e);
}
}
if (!isValid())
{
break;
}
}
}
}
|
Validates this component using the component's validators.
|
validateValidators
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public final void updateAutoLabels(AjaxRequestTarget target)
{
AutoLabelMarker marker = getMetaData(AutoLabelResolver.MARKER_KEY);
if (marker == null)
{
// this component does not have an auto label
return;
}
marker.updateFrom(this, target);
}
|
Updates auto label css classes such as error/required during ajax updates when the labels may
not be directly repainted in the response.
@param target
|
updateAutoLabels
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
public static <S> void updateCollectionModel(FormComponent<Collection<S>> formComponent)
{
Collection<S> convertedInput = formComponent.getConvertedInput();
if (convertedInput == null) {
convertedInput = Collections.emptyList();
}
Collection<S> collection = formComponent.getModelObject();
if (collection == null)
{
collection = new ArrayList<>(convertedInput);
formComponent.setModelObject(collection);
}
else
{
boolean modified = false;
formComponent.modelChanging();
try
{
collection.clear();
collection.addAll(convertedInput);
modified = true;
}
catch (UnsupportedOperationException unmodifiable)
{
if (logger.isDebugEnabled())
{
logger.debug("An error occurred while trying to modify the collection attached to "
+ formComponent, unmodifiable);
}
collection = new ArrayList<>(convertedInput);
}
try
{
formComponent.getModel().setObject(collection);
}
catch (Exception noSetter)
{
if (!modified)
{
throw new WicketRuntimeException("An error occurred while trying to set the collection attached to "
+ formComponent, noSetter);
}
else if (logger.isDebugEnabled())
{
logger.debug("An error occurred while trying to set the collection attached to "
+ formComponent, noSetter);
}
}
formComponent.modelChanged();
}
}
|
Update the model of a {@link FormComponent} containing a {@link Collection}.
If the model object does not yet exists, a new {@link ArrayList} is filled with the converted
input and used as the new model object. Otherwise the existing collection is modified
in-place, then {@link Model#setObject(Object)} is called with the same instance: it allows
the Model to be notified of changes even when {@link Model#getObject()} returns a different
{@link Collection} at every invocation.
@param <S>
collection type
@param formComponent
the form component to update
@see FormComponent#updateModel()
@throws WicketRuntimeException
if the existing model object collection is unmodifiable and no setter exists
|
updateCollectionModel
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
|
MIT
|
protected Boolean initialValue()
{
return Boolean.FALSE;
}
|
A flag indicating whether this session entry is being re-set in the Session.
<p>
Web containers intercept
{@link javax.servlet.http.HttpSession#setAttribute(String, Object)} to detect changes and
replicate the session. If the attribute has been already bound in the session then
{@link SessionEntry#valueUnbound(HttpSessionBindingEvent)} might get called - this flag
helps us to ignore the invocation in that case.
@see SessionEntry#valueUnbound(HttpSessionBindingEvent)
|
initialValue
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
|
MIT
|
protected void bind()
{
context.bind();
}
|
Bind the session
@see IPageManagerContext#bind()
|
bind
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
public void setSessionAttribute(String key, Serializable value)
{
context.setSessionAttribute(key, value);
}
|
@see IPageManagerContext#setSessionAttribute(String, Serializable)
@param key
@param value
|
setSessionAttribute
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
public Serializable getSessionAttribute(final String key)
{
return context.getSessionAttribute(key);
}
|
@see IPageManagerContext#getSessionAttribute(String)
@param key
@return the session attribute
|
getSessionAttribute
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
public String getSessionId()
{
return context.getSessionId();
}
|
@see IPageManagerContext#getSessionId()
@return session id
|
getSessionId
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
protected IManageablePage findPage(final int id)
{
for (IManageablePage page : touchedPages)
{
if (page.getPageId() == id)
{
return page;
}
}
return null;
}
|
@param id
@return null, if not found
|
findPage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
protected void touch(final IManageablePage page)
{
if (findPage(page.getPageId()) == null)
{
touchedPages.add(page);
}
}
|
Touches a page, so it will be stored in the page stores
at the end of the request cycle
@param page The page to mark as dirty
|
touch
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
protected void untouch(final IManageablePage page)
{
Iterator<IManageablePage> iterator = touchedPages.iterator();
while (iterator.hasNext())
{
IManageablePage touchedPage = iterator.next();
if (touchedPage.getPageId() == page.getPageId())
{
iterator.remove();
break;
}
}
}
|
@param page The page to unmark as dirty, so it won't be stored
at the end of the request cycle
|
untouch
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
protected void commitRequest()
{
// store pages that are not stateless
if (touchedPages.isEmpty() == false)
{
List<IManageablePage> statefulPages = new ArrayList<IManageablePage>(
touchedPages.size());
for (IManageablePage page : touchedPages)
{
statefulPages.add(page);
}
if (statefulPages.isEmpty() == false)
{
storeTouchedPages(statefulPages);
}
}
}
|
Modified by Robin to remove the logic to check stateless page as otherwise Wicket reports error
when a page containing "wicket:enclosure" is accessed anonymously and is redirected to signin page
|
commitRequest
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/page/RequestAdapter.java
|
MIT
|
@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass)
{
return new StringResourceStream("");
}
|
A dummy page that is used to create a new WebSocketRequestHandler for
web socket connections to WebSocketResource
|
getMarkupResourceStream
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java
|
MIT
|
public static RequestCycle get()
{
return ThreadContext.getRequestCycle();
}
|
Returns request cycle associated with current thread.
@return request cycle instance or <code>null</code> if no request cycle is associated with
current thread.
|
get
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public Response getOriginalResponse()
{
return originalResponse;
}
|
Get the original response the request was created with. Access to the original response may
be necessary if the response has been temporarily replaced but the components require methods
from original response (i.e. cookie methods of WebResponse, etc).
@return The original response object.
|
getOriginalResponse
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
@Override
public final UrlRenderer getUrlRenderer()
{
if (urlRenderer == null)
{
urlRenderer = newUrlRenderer();
}
return urlRenderer;
}
|
Returns {@link UrlRenderer} for this {@link RequestCycle}.
@return UrlRenderer instance.
|
getUrlRenderer
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
protected IRequestHandler resolveRequestHandler()
{
return requestMapper.mapRequest(request);
}
|
Resolves current request to a {@link IRequestHandler}.
@return RequestHandler instance
|
resolveRequestHandler
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
protected int getExceptionRetryCount()
{
int retries = 10;
if (Application.exists())
{
retries = Application.get().getRequestCycleSettings().getExceptionRetryCount();
}
return retries;
}
|
@return How many times will Wicket attempt to render the exception request handler before
giving up.
|
getExceptionRetryCount
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public boolean processRequest()
{
try
{
set(this);
listeners.onBeginRequest(this);
onBeginRequest();
IRequestHandler handler = resolveRequestHandler();
if (handler != null)
{
execute(handler);
return true;
}
// Did not find any suitable handler, thus not executing the request
log.debug(
"No suitable handler found for URL {}, falling back to container to process this request",
request.getUrl());
}
catch (Exception e)
{
IRequestHandler handler = handleException(e);
if (handler != null)
{
listeners.onExceptionRequestHandlerResolved(this, handler, e);
executeExceptionRequestHandler(handler, getExceptionRetryCount());
listeners.onRequestHandlerExecuted(this, handler);
}
else
{
log.error("Error during request processing. URL=" + request.getUrl(), e);
}
return true;
}
finally
{
set(null);
}
return false;
}
|
Processes the request.
@return <code>true</code> if the request resolved to a Wicket request, <code>false</code>
otherwise.
|
processRequest
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
private void execute(IRequestHandler handler)
{
Args.notNull(handler, "handler");
try
{
listeners.onRequestHandlerResolved(this, handler);
requestHandlerExecutor.execute(handler);
listeners.onRequestHandlerExecuted(this, handler);
}
catch (RuntimeException e)
{
IRequestHandler replacement = requestHandlerExecutor.resolveHandler(e);
if (replacement != null)
{
execute(replacement);
}
else
{
throw e;
}
}
}
|
Executes a request handler and fires pre/post listener methods
@param handler
|
execute
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public boolean processRequestAndDetach()
{
boolean result;
try
{
result = processRequest();
}
finally
{
detach();
}
return result;
}
|
Convenience method that processes the request and detaches the {@link RequestCycle}.
@return <code>true</code> if the request resolved to a Wicket request, <code>false</code>
otherwise.
|
processRequestAndDetach
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
protected IRequestHandler handleException(final Exception e)
{
IRequestHandler handler = listeners.onException(this, e);
if (handler != null)
{
return handler;
}
return exceptionMapper.map(e);
}
|
Return {@link IRequestHandler} for the given exception.
@param e
@return RequestHandler instance
|
handleException
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void setRequest(Request request)
{
// It would be mighty nice if request was final. However during multipart it needs to be set
// to
// MultipartServletWebRequest by Form. It can't be done before creating the request cycle
// (in wicket filter)
// because only the form knows max upload size
this.request = request;
}
|
INTERNAL This method is for internal Wicket use. Do not call it yourself unless you know what
you are doing.
@param request
|
setRequest
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public final <T> RequestCycle setMetaData(final MetaDataKey<T> key, final T object)
{
metaData = key.set(metaData, object);
return this;
}
|
Sets the metadata for this request cycle using the given key. If the metadata object is not
of the correct type for the metadata key, an IllegalArgumentException will be thrown. For
information on creating MetaDataKeys, see {@link MetaDataKey}.
@param key
The singleton key for the metadata
@param object
The metadata object
@param <T>
@throws IllegalArgumentException
@see MetaDataKey
|
setMetaData
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public final <T> T getMetaData(final MetaDataKey<T> key)
{
return key.get(metaData);
}
|
Gets metadata for this request cycle using the given key.
@param <T>
The type of the metadata
@param key
The key for the data
@return The metadata or null if no metadata was found for the given key
@see MetaDataKey
|
getMetaData
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public final CharSequence urlFor(ResourceReference reference, PageParameters params)
{
ResourceUrlCacheKey key = new ResourceUrlCacheKey(reference, params);
CharSequence url = resourceUrlCache.get(key);
if (url == null) {
ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(
reference, params);
url = urlFor(handler);
resourceUrlCache.put(key, url);
}
return url;
}
|
Returns a rendered {@link Url} for the resource reference
@param reference
resource reference
@param params
parameters for the resource or {@code null} if none
@return {@link Url} for the reference
|
urlFor
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public final <C extends Page> CharSequence urlFor(final Class<C> pageClass,
final PageParameters parameters)
{
PageUrlCacheKey key = new PageUrlCacheKey(pageClass, parameters);
CharSequence url = pageUrlCache.get(key);
if (url == null) {
IRequestHandler handler = new BookmarkablePageRequestHandler(
new PageProvider(pageClass, parameters));
url = urlFor(handler);
pageUrlCache.put(key, url);
}
return url;
}
|
Returns a rendered bookmarkable URL that references a given page class using a given set of
page parameters. Since the URL which is returned contains all information necessary to
instantiate and render the page, it can be stored in a user's browser as a stable bookmark.
@param <C>
@param pageClass
Class of page
@param parameters
Parameters to page or {@code null} if none
@return Bookmarkable URL to page
|
urlFor
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void onDetach()
{
try
{
onEndRequest();
listeners.onEndRequest(this);
}
catch (RuntimeException e)
{
log.error("Exception occurred during onEndRequest", e);
}
try
{
requestHandlerExecutor.detach();
}
catch (RuntimeException exception)
{
handleDetachException(exception);
}
finally
{
listeners.onDetach(this);
}
if (Session.exists())
{
Session.get().detach();
}
}
|
Called after request processing is complete, usually takes care of detaching state
|
onDetach
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
private void handleDetachException(RuntimeException exception)
{
boolean isBufferedResponse = true;
if (Application.exists())
{
isBufferedResponse = Application.get().getRequestCycleSettings().getBufferResponse();
}
//if application is using a buffered response strategy,
//then we display exception to user.
if (isBufferedResponse)
{
throw exception;
}
else
{
log.error("Error detaching RequestCycle", exception);
}
}
|
Called to handle a {@link java.lang.RuntimeException} that might be
thrown during detaching phase.
@param exception
|
handleDetachException
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void setResponsePage(IRequestablePage page)
{
if (page instanceof Page)
{
((Page) page).setStatelessHint(false);
}
scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(new PageProvider(page),
RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT));
}
|
Convenience method for setting next page to be rendered.
@param page
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void setResponsePage(Class<? extends IRequestablePage> pageClass)
{
setResponsePage(pageClass, null, RenderPageRequestHandler.RedirectPolicy.ALWAYS_REDIRECT);
}
|
Convenience method for setting next page to be rendered.
@param pageClass
The class of the page to render
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void setResponsePage(Class<? extends IRequestablePage> pageClass, RenderPageRequestHandler.RedirectPolicy redirectPolicy)
{
setResponsePage(pageClass, null, redirectPolicy);
}
|
Convenience method for setting next page to be rendered.
@param pageClass
The class of the page to render
@param redirectPolicy
The policy to use when deciding whether to redirect or not
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void setResponsePage(Class<? extends IRequestablePage> pageClass,
PageParameters parameters)
{
setResponsePage(pageClass, parameters, RenderPageRequestHandler.RedirectPolicy.ALWAYS_REDIRECT);
}
|
Convenience method for setting next page to be rendered.
@param pageClass
The class of the page to render
@param parameters
The query parameters for the page to be rendered
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void setResponsePage(Class<? extends IRequestablePage> pageClass,
PageParameters parameters, RenderPageRequestHandler.RedirectPolicy redirectPolicy)
{
IPageProvider provider = new PageProvider(pageClass, parameters);
scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(provider,
redirectPolicy));
}
|
Convenience method for setting next page to be rendered.
@param pageClass
The class of the page to render
@param parameters
The query parameters for the page to be rendered
@param redirectPolicy
The policy to use when deciding whether to redirect or not
|
setResponsePage
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public final long getStartTime()
{
return startTime;
}
|
@return The start time for this request
|
getStartTime
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public IRequestHandler getActiveRequestHandler()
{
return requestHandlerExecutor.getActive();
}
|
@see RequestHandlerStack#getActive()
@return active handler on executor
|
getActiveRequestHandler
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public IRequestHandler getRequestHandlerScheduledAfterCurrent()
{
return requestHandlerExecutor.next();
}
|
@see RequestHandlerStack#next()
@return the handler scheduled to be executed after current by the executor
|
getRequestHandlerScheduledAfterCurrent
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
public void replaceAllRequestHandlers(final IRequestHandler handler)
{
requestHandlerExecutor.replaceAll(handler);
}
|
@see RequestHandlerStack#replaceAll(IRequestHandler)
@param handler
|
replaceAllRequestHandlers
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
@SuppressWarnings("unchecked")
public <T extends IRequestHandler> T find(final Class<T> type)
{
if (type == null)
{
return null;
}
IRequestHandler result = getActiveRequestHandler();
if (result == null || type.isAssignableFrom(result.getClass()) == false)
{
result = getRequestHandlerScheduledAfterCurrent();
if (result == null || type.isAssignableFrom(result.getClass()) == false)
{
result = null;
}
}
return (T)result;
}
|
Finds a IRequestHandler which is either the currently executing handler or is scheduled to be
executed.
@return the found IRequestHandler or {@code null}
|
find
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java
|
MIT
|
@Override
public String run()
{
return System.getProperty("line.separator");
}
|
Constructs something like <em>;jsessionid=</em>. This is what {@linkplain Strings#stripJSessionId(String)}
actually uses.
|
run
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String afterFirst(final String s, final char c)
{
if (s == null)
{
return null;
}
final int index = s.indexOf(c);
if (index == -1)
{
return "";
}
return s.substring(index + 1);
}
|
Returns everything after the first occurrence of the given character in s.
@param s
The string
@param c
The character
@return Everything after the first occurrence of the given character in s. If the character
cannot be found, an empty string is returned.
|
afterFirst
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String afterFirstPathComponent(final String path, final char separator)
{
return afterFirst(path, separator);
}
|
Gets everything after the first path component of a path using a given separator. If the
separator cannot be found, an empty String is returned.
<p>
For example, afterFirstPathComponent("foo:bar:baz", ':') would return "bar:baz" and
afterFirstPathComponent("foo", ':') would return "".
@param path
The path to parse
@param separator
The path separator character
@return Everything after the first component in the path
|
afterFirstPathComponent
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String afterLast(final String s, final char c)
{
if (s == null)
{
return null;
}
final int index = s.lastIndexOf(c);
if (index == -1)
{
return "";
}
return s.substring(index + 1);
}
|
Returns everything after the last occurrence of the given character in s.
@param s
The string
@param c
The character
@return Everything after the last occurrence of the given character in s. If the character
cannot be found, an empty string is returned.
|
afterLast
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String beforeFirst(final String s, final char c)
{
if (s == null)
{
return null;
}
final int index = s.indexOf(c);
if (index == -1)
{
return "";
}
return s.substring(0, index);
}
|
Returns everything before the first occurrence of the given character in s.
@param s
The string
@param c
The character
@return Everything before the first occurrence of the given character in s. If the character
cannot be found, an empty string is returned.
|
beforeFirst
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String beforeLast(final String s, final char c)
{
if (s == null)
{
return null;
}
final int index = s.lastIndexOf(c);
if (index == -1)
{
return "";
}
return s.substring(0, index);
}
|
Returns everything before the last occurrence of the given character in s.
@param s
The string
@param c
The character
@return Everything before the last occurrence of the given character in s. If the character
cannot be found, an empty string is returned.
|
beforeLast
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String beforeLastPathComponent(final String path, final char separator)
{
return beforeLast(path, separator);
}
|
Gets everything before the last path component of a path using a given separator. If the
separator cannot be found, the path itself is returned.
<p>
For example, beforeLastPathComponent("foo.bar.baz", '.') would return "foo.bar" and
beforeLastPathComponent("foo", '.') would return "".
@param path
The path to parse
@param separator
The path separator character
@return Everything before the last component in the path
|
beforeLastPathComponent
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String capitalize(final String s)
{
if (s == null)
{
return null;
}
final char[] chars = s.toCharArray();
if (chars.length > 0)
{
chars[0] = Character.toUpperCase(chars[0]);
}
return new String(chars);
}
|
Capitalizes a string.
@param s
The string
@return The capitalized string
|
capitalize
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static CharSequence escapeMarkup(final CharSequence s)
{
return escapeMarkup(s, false);
}
|
Converts a Java String to an HTML markup string, but does not convert normal spaces to
non-breaking space entities (<nbsp>).
@param s
The characters to escape
@see Strings#escapeMarkup(CharSequence, boolean)
@return The escaped string
|
escapeMarkup
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static CharSequence escapeMarkup(final CharSequence s, final boolean escapeSpaces)
{
return escapeMarkup(s, escapeSpaces, false);
}
|
Converts a Java String to an HTML markup String by replacing illegal characters with HTML
entities where appropriate. Spaces are converted to non-breaking spaces (<nbsp>) if
escapeSpaces is true, tabs are converted to four non-breaking spaces, less than signs are
converted to &lt; entities and greater than signs to &gt; entities.
@param s
The characters to escape
@param escapeSpaces
True to replace ' ' with nonbreaking space
@return The escaped string
|
escapeMarkup
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static CharSequence escapeMarkup(final CharSequence s, final boolean escapeSpaces,
final boolean convertToHtmlUnicodeEscapes)
{
if (s == null)
{
return null;
}
int len = s.length();
final AppendingStringBuffer buffer = new AppendingStringBuffer((int)(len * 1.1));
for (int i = 0; i < len; i++)
{
final char c = s.charAt(i);
if (NONCHARACTERS.contains(c))
{
continue;
}
switch (c)
{
case '\t' :
if (escapeSpaces)
{
// Assumption is four space tabs (sorry, but that's
// just how it is!)
buffer.append(" ");
}
else
{
buffer.append(c);
}
break;
case ' ' :
if (escapeSpaces)
{
buffer.append(" ");
}
else
{
buffer.append(c);
}
break;
case '<' :
buffer.append("<");
break;
case '>' :
buffer.append(">");
break;
case '&' :
buffer.append("&");
break;
case '"' :
buffer.append(""");
break;
case '\'' :
buffer.append("'");
break;
default :
int ci = 0xffff & c;
if (
// if this is non-printable and not whitespace (TAB, LF, CR)
((ci < 32) && (ci != 9) && (ci != 10) && (ci != 13)) ||
// or non-ASCII (XXX: why 160+ ?!) and need to UNICODE escape it
(convertToHtmlUnicodeEscapes && (ci > 159)))
{
buffer.append("&#");
buffer.append(Integer.toString(ci));
buffer.append(';');
}
else
{
// ASCII or whitespace
buffer.append(c);
}
break;
}
}
return buffer;
}
|
Converts a Java String to an HTML markup String by replacing illegal characters with HTML
entities where appropriate. Spaces are converted to non-breaking spaces (<nbsp>) if
escapeSpaces is true, tabs are converted to four non-breaking spaces, less than signs are
converted to &lt; entities and greater than signs to &gt; entities.
@param s
The characters to escape
@param escapeSpaces
True to replace ' ' with nonbreaking space
@param convertToHtmlUnicodeEscapes
True to convert non-7 bit characters to unicode HTML (&#...)
@return The escaped string
|
escapeMarkup
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static CharSequence unescapeMarkup(final String markup)
{
String unescapedMarkup = StringEscapeUtils.unescapeHtml(markup);
return unescapedMarkup;
}
|
Unescapes the escaped entities in the <code>markup</code> passed.
@param markup
The source <code>String</code> to unescape.
@return the unescaped markup or <code>null</null> if the input is <code>null</code>
|
unescapeMarkup
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String firstPathComponent(final String path, final char separator)
{
if (path == null)
{
return null;
}
final int index = path.indexOf(separator);
if (index == -1)
{
return path;
}
return path.substring(0, index);
}
|
Gets the first path component of a path using a given separator. If the separator cannot be
found, the path itself is returned.
<p>
For example, firstPathComponent("foo.bar", '.') would return "foo" and
firstPathComponent("foo", '.') would return "foo".
@param path
The path to parse
@param separator
The path separator character
@return The first component in the path or path itself if no separator characters exist.
|
firstPathComponent
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String fromEscapedUnicode(final String escapedUnicodeString)
{
int off = 0;
char[] in = escapedUnicodeString.toCharArray();
int len = in.length;
char[] out = new char[len];
char aChar;
int outLen = 0;
int end = off + len;
while (off < end)
{
aChar = in[off++];
if (aChar == '\\')
{
aChar = in[off++];
if (aChar == 'u')
{
// Read the xxxx
int value = 0;
for (int i = 0; i < 4; i++)
{
aChar = in[off++];
switch (aChar)
{
case '0' :
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
value = (value << 4) + aChar - '0';
break;
case 'a' :
case 'b' :
case 'c' :
case 'd' :
case 'e' :
case 'f' :
value = (value << 4) + 10 + aChar - 'a';
break;
case 'A' :
case 'B' :
case 'C' :
case 'D' :
case 'E' :
case 'F' :
value = (value << 4) + 10 + aChar - 'A';
break;
default :
throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
}
}
out[outLen++] = (char)value;
}
else
{
if (aChar == 't')
{
aChar = '\t';
}
else if (aChar == 'r')
{
aChar = '\r';
}
else if (aChar == 'n')
{
aChar = '\n';
}
else if (aChar == 'f')
{
aChar = '\f';
}
out[outLen++] = aChar;
}
}
else
{
out[outLen++] = aChar;
}
}
return new String(out, 0, outLen);
}
|
Converts encoded \uxxxx to unicode chars and changes special saved chars to their
original forms.
@param escapedUnicodeString
escaped unicode string, like '\u4F60\u597D'.
@return The actual unicode. Can be used for instance with message bundles
|
fromEscapedUnicode
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static boolean isEmpty(final CharSequence string)
{
return (string == null) || (string.length() == 0) ||
(string.toString().trim().length() == 0);
}
|
Checks whether the <code>string</code> is considered empty. Empty means that the string may
contain whitespace, but no visible characters.
"\n\t " is considered empty, while " a" is not.
@param string
The string
@return True if the string is null or ""
|
isEmpty
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static boolean isEqual(final String string1, final String string2)
{
if ((string1 == null) && (string2 == null))
{
return true;
}
if (isEmpty(string1) && isEmpty(string2))
{
return true;
}
if ((string1 == null) || (string2 == null))
{
return false;
}
return string1.equals(string2);
}
|
Checks whether two strings are equals taken care of 'null' values and treating 'null' same as
trim(string).equals("")
@param string1
@param string2
@return true, if both strings are equal
|
isEqual
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static boolean isTrue(final String s) throws StringValueConversionException
{
if (s != null)
{
if (s.equalsIgnoreCase("true"))
{
return true;
}
if (s.equalsIgnoreCase("false"))
{
return false;
}
if (s.equalsIgnoreCase("on") || s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("y") ||
s.equalsIgnoreCase("1"))
{
return true;
}
if (s.equalsIgnoreCase("off") || s.equalsIgnoreCase("no") || s.equalsIgnoreCase("n") ||
s.equalsIgnoreCase("0"))
{
return false;
}
if (isEmpty(s))
{
return false;
}
throw new StringValueConversionException("Boolean value \"" + s + "\" not recognized");
}
return false;
}
|
Converts the text in <code>s</code> to a corresponding boolean. On, yes, y, true and 1 are
converted to <code>true</code>. Off, no, n, false and 0 (zero) are converted to
<code>false</code>. An empty string is converted to <code>false</code>. Conversion is
case-insensitive, and does <em>not</em> take internationalization into account.
'Ja', 'Oui', 'Igen', 'Nein', 'Nee', 'Non', 'Nem' are all illegal values.
@param s
the value to convert into a boolean
@return Boolean the converted value of <code>s</code>
@throws StringValueConversionException
when the value of <code>s</code> is not recognized.
|
isTrue
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String lastPathComponent(final String path, final char separator)
{
if (path == null)
{
return null;
}
final int index = path.lastIndexOf(separator);
if (index == -1)
{
return path;
}
return path.substring(index + 1);
}
|
Gets the last path component of a path using a given separator. If the separator cannot be
found, the path itself is returned.
<p>
For example, lastPathComponent("foo.bar", '.') would return "bar" and
lastPathComponent("foo", '.') would return "foo".
@param path
The path to parse
@param separator
The path separator character
@return The last component in the path or path itself if no separator characters exist.
|
lastPathComponent
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static CharSequence replaceAll(final CharSequence s, final CharSequence searchFor,
CharSequence replaceWith)
{
if (s == null)
{
return null;
}
// If searchFor is null or the empty string, then there is nothing to
// replace, so returning s is the only option here.
if ((searchFor == null) || "".equals(searchFor))
{
return s;
}
// If replaceWith is null, then the searchFor should be replaced with
// nothing, which can be seen as the empty string.
if (replaceWith == null)
{
replaceWith = "";
}
String searchString = searchFor.toString();
// Look for first occurrence of searchFor
int matchIndex = search(s, searchString, 0);
if (matchIndex == -1)
{
// No replace operation needs to happen
return s;
}
else
{
// Allocate a AppendingStringBuffer that will hold one replacement
// with a
// little extra room.
int size = s.length();
final int replaceWithLength = replaceWith.length();
final int searchForLength = searchFor.length();
if (replaceWithLength > searchForLength)
{
size += (replaceWithLength - searchForLength);
}
final AppendingStringBuffer buffer = new AppendingStringBuffer(size + 16);
int pos = 0;
do
{
// Append text up to the match
append(buffer, s, pos, matchIndex);
// Add replaceWith text
buffer.append(replaceWith);
// Find next occurrence, if any
pos = matchIndex + searchForLength;
matchIndex = search(s, searchString, pos);
}
while (matchIndex != -1);
// Add tail of s
buffer.append(s.subSequence(pos, s.length()));
// Return processed buffer
return buffer;
}
}
|
Replace all occurrences of one string replaceWith another string.
@param s
The string to process
@param searchFor
The value to search for
@param replaceWith
The value to searchFor replaceWith
@return The resulting string with searchFor replaced with replaceWith
|
replaceAll
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String replaceHtmlEscapeNumber(String str)
{
if (str == null)
{
return null;
}
Matcher matcher = HTML_NUMBER_REGEX.matcher(str);
while (matcher.find())
{
int pos = matcher.start();
int end = matcher.end();
int number = Integer.parseInt(str.substring(pos + 2, end - 1));
char ch = (char)number;
str = str.substring(0, pos) + ch + str.substring(end);
matcher = HTML_NUMBER_REGEX.matcher(str);
}
return str;
}
|
Replace HTML numbers like 值 by the appropriate character.
@param str
The text to be evaluated
@return The text with "numbers" replaced
|
replaceHtmlEscapeNumber
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String[] split(final String s, final char c)
{
if (s == null || s.length() == 0)
{
return NO_STRINGS;
}
final List<String> strings = new ArrayList<>();
int pos = 0;
while (true)
{
int next = s.indexOf(c, pos);
if (next == -1)
{
strings.add(s.substring(pos));
break;
}
else
{
strings.add(s.substring(pos, next));
}
pos = next + 1;
}
final String[] result = new String[strings.size()];
strings.toArray(result);
return result;
}
|
Simpler, faster version of String.split() for splitting on a simple character.
@param s
The string to split
@param c
The character to split on
@return The array of strings
|
split
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String stripEnding(final String s, final String ending)
{
if (s == null)
{
return null;
}
// Stripping a null or empty string from the end returns the
// original string.
if ((ending == null) || "".equals(ending))
{
return s;
}
final int endingLength = ending.length();
final int sLength = s.length();
// When the length of the ending string is larger
// than the original string, the original string is returned.
if (endingLength > sLength)
{
return s;
}
final int index = s.lastIndexOf(ending);
final int endpos = sLength - endingLength;
if (index == endpos)
{
return s.substring(0, endpos);
}
return s;
}
|
Strips the ending from the string <code>s</code>.
@param s
The string to strip
@param ending
The ending to strip off
@return The stripped string or the original string if the ending did not exist
|
stripEnding
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String stripJSessionId(final String url)
{
if (Strings.isEmpty(url))
{
return url;
}
// http://.../abc;jsessionid=...?param=...
int ixSemiColon = url.toLowerCase(Locale.ROOT).indexOf(SESSION_ID_PARAM);
if (ixSemiColon == -1)
{
return url;
}
int ixQuestionMark = url.indexOf('?');
if (ixQuestionMark == -1)
{
// no query paramaters; cut off at ";"
// http://.../abc;jsession=...
return url.substring(0, ixSemiColon);
}
if (ixQuestionMark <= ixSemiColon)
{
// ? is before ; - no jsessionid in the url
return url;
}
return url.substring(0, ixSemiColon) + url.substring(ixQuestionMark);
}
|
Strip any jsessionid and possibly other redundant info that might be in our way.
@param url
The url to strip
@return The stripped url
|
stripJSessionId
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static Boolean toBoolean(final String s) throws StringValueConversionException
{
return isTrue(s);
}
|
Converts the string s to a Boolean. See <code>isTrue</code> for valid values of s.
@param s
The string to convert.
@return Boolean <code>TRUE</code> when <code>isTrue(s)</code>.
@throws StringValueConversionException
when s is not a valid value
@see #isTrue(String)
|
toBoolean
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static char toChar(final String s) throws StringValueConversionException
{
if (s != null)
{
if (s.length() == 1)
{
return s.charAt(0);
}
else
{
throw new StringValueConversionException("Expected single character, not \"" + s +
"\"");
}
}
throw new StringValueConversionException("Character value was null");
}
|
Converts the 1 character string s to a character.
@param s
The 1 character string to convert to a char.
@return Character value to convert
@throws StringValueConversionException
when the string is longer or shorter than 1 character, or <code>null</code>.
|
toChar
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String toEscapedUnicode(final String unicodeString)
{
if ((unicodeString == null) || (unicodeString.length() == 0))
{
return unicodeString;
}
int len = unicodeString.length();
int bufLen = len * 2;
StringBuilder outBuffer = new StringBuilder(bufLen);
for (int x = 0; x < len; x++)
{
char aChar = unicodeString.charAt(x);
if (NONCHARACTERS.contains(aChar))
{
continue;
}
// Handle common case first, selecting largest block that
// avoids the specials below
if ((aChar > 61) && (aChar < 127))
{
if (aChar == '\\')
{
outBuffer.append('\\');
outBuffer.append('\\');
continue;
}
outBuffer.append(aChar);
continue;
}
switch (aChar)
{
case ' ' :
if (x == 0)
{
outBuffer.append('\\');
}
outBuffer.append(' ');
break;
case '\t' :
outBuffer.append('\\');
outBuffer.append('t');
break;
case '\n' :
outBuffer.append('\\');
outBuffer.append('n');
break;
case '\r' :
outBuffer.append('\\');
outBuffer.append('r');
break;
case '\f' :
outBuffer.append('\\');
outBuffer.append('f');
break;
case '=' : // Fall through
case ':' : // Fall through
case '#' : // Fall through
case '!' :
outBuffer.append('\\');
outBuffer.append(aChar);
break;
default :
if ((aChar < 0x0020) || (aChar > 0x007e))
{
outBuffer.append('\\');
outBuffer.append('u');
outBuffer.append(toHex((aChar >> 12) & 0xF));
outBuffer.append(toHex((aChar >> 8) & 0xF));
outBuffer.append(toHex((aChar >> 4) & 0xF));
outBuffer.append(toHex(aChar & 0xF));
}
else
{
outBuffer.append(aChar);
}
}
}
return outBuffer.toString();
}
|
Converts unicodes to encoded \uxxxx.
@param unicodeString
The unicode string
@return The escaped unicode string, like '\u4F60\u597D'.
|
toEscapedUnicode
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static CharSequence toMultilineMarkup(final CharSequence s)
{
if (s == null)
{
return null;
}
final AppendingStringBuffer buffer = new AppendingStringBuffer();
int newlineCount = 0;
buffer.append("<p>");
for (int i = 0; i < s.length(); i++)
{
final char c = s.charAt(i);
switch (c)
{
case '\n' :
newlineCount++;
break;
case '\r' :
break;
default :
if (newlineCount == 1)
{
buffer.append("<br/>");
}
else if (newlineCount > 1)
{
buffer.append("</p><p>");
}
buffer.append(c);
newlineCount = 0;
break;
}
}
if (newlineCount == 1)
{
buffer.append("<br/>");
}
else if (newlineCount > 1)
{
buffer.append("</p><p>");
}
buffer.append("</p>");
return buffer;
}
|
Converts a String to multiline HTML markup by replacing newlines with line break entities
(<br/>) and multiple occurrences of newline with paragraph break entities (<p>).
@param s
String to transform
@return String with all single occurrences of newline replaced with <br/> and all
multiple occurrences of newline replaced with <p>.
|
toMultilineMarkup
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String toString(final Object object)
{
if (object == null)
{
return null;
}
if (object instanceof Throwable)
{
return toString((Throwable)object);
}
if (object instanceof String)
{
return (String)object;
}
if ((object instanceof String[]) && (((String[])object).length == 1))
{
return ((String[])object)[0];
}
return object.toString();
}
|
Converts the given object to a string. Does special conversion for {@link Throwable
throwables} and String arrays of length 1 (in which case it just returns to string in that
array, as this is a common thing to have in the Servlet API).
@param object
The object
@return The string
|
toString
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
private static char toHex(final int nibble)
{
return HEX_DIGIT[(nibble & 0xF)];
}
|
Convert a nibble to a hex character
@param nibble
the nibble to convert.
@return hex character
|
toHex
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static int lengthInBytes(final String string, final Charset charset)
{
Args.notNull(string, "string");
if (charset != null)
{
try
{
return string.getBytes(charset.name()).length;
}
catch (UnsupportedEncodingException e)
{
throw new RuntimeException(
"StringResourceStream created with unsupported charset: " + charset.name());
}
}
else
{
return string.getBytes().length;
}
}
|
Calculates the length of string in bytes, uses specified <code>charset</code> if provided.
@param string
@param charset
(optional) character set to use when converting string to bytes
@return length of string in bytes
|
lengthInBytes
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static boolean startsWith(final String str, final String prefix,
final boolean caseSensitive)
{
if (caseSensitive)
{
return str.startsWith(prefix);
}
else
{
return str.toLowerCase(Locale.ROOT).startsWith(prefix.toLowerCase(Locale.ROOT));
}
}
|
Extended {@link String#startsWith(String)} with support for case sensitivity
@param str
@param prefix
@param caseSensitive
@return <code>true</code> if <code>str</code> starts with <code>prefix</code>
|
startsWith
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static int indexOf(final CharSequence sequence, final char ch)
{
if (sequence != null)
{
for (int i = 0; i < sequence.length(); i++)
{
if (sequence.charAt(i) == ch)
{
return i;
}
}
}
return -1;
}
|
returns the zero-based index of a character within a char sequence. this method mainly exists
as an faster alternative for <code>sequence.toString().indexOf(ch)</code>.
@param sequence
character sequence
@param ch
character to search for
@return index of character within character sequence or <code>-1</code> if not found
|
indexOf
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String toHexString(byte[] bytes)
{
Args.notNull(bytes, "bytes");
final StringBuilder hex = new StringBuilder(bytes.length << 1);
for (final byte b : bytes)
{
hex.append(toHex(b >> 4));
hex.append(toHex(b));
}
return hex.toString();
}
|
convert byte array to hex string
@param bytes
bytes to convert to hexadecimal representation
@return hex string
|
toHexString
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static <T extends Enum<T>> T toEnum(final CharSequence value, final Class<T> enumClass)
{
Args.notNull(enumClass, "enumClass");
Args.notNull(value, "value");
try
{
return Enum.valueOf(enumClass, value.toString());
}
catch (Exception e)
{
throw new StringValueConversionException(
String.format("Cannot convert '%s' to enum constant of type '%s'.", value, enumClass), e);
}
}
|
Return this value as en enum value.
@param value
the value to convert to an enum value
@param enumClass
the enum type
@return an enum value
|
toEnum
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
public static String defaultIfEmpty(String originalString, String defaultValue)
{
return isEmpty(originalString) ? defaultValue : originalString;
}
|
Returns the original string if this one is not empty (i.e. {@link #isEmpty(CharSequence)} returns false),
otherwise the default one is returned. The default string might be itself an empty one.
@param originalString
the original sting value
@param defaultValue
the default string to return if the original is empty
@return the original string value if not empty, the default one otherwise
|
defaultIfEmpty
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/apache/wicket/util/string/Strings.java
|
MIT
|
private HttpCookie checkSameSite(HttpCookie cookie)
{
if (cookie == null || cookie.getSameSite() != null)
return cookie;
//sameSite is not set, use the default configured for the context, if one exists
SameSite contextDefault = HttpCookie.getSameSiteDefault(_channel.getRequest().getServletContext());
if (contextDefault == null)
return cookie; //no default set
return new HttpCookie(cookie.getName(),
cookie.getValue(),
cookie.getDomain(),
cookie.getPath(),
cookie.getMaxAge(),
cookie.isHttpOnly(),
cookie.isSecure(),
cookie.getComment(),
cookie.getVersion(),
contextDefault);
}
|
Check that samesite is set on the cookie. If not, use a
context default value, if one has been set.
@param cookie the cookie to check
@return either the original cookie, or a new one that has the samesit default set
|
checkSameSite
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
MIT
|
@Override
public void sendError(int code, String message) throws IOException
{
if (isIncluding())
return;
switch (code)
{
case -1:
_channel.abort(new IOException(message));
break;
case HttpStatus.PROCESSING_102:
sendProcessing();
break;
default:
_channel.getState().sendError(code, message);
break;
}
}
|
Send an error response.
<p>In addition to the servlet standard handling, this method supports some additional codes:</p>
<dl>
<dt>102</dt><dd>Send a partial PROCESSING response and allow additional responses</dd>
<dt>-1</dt><dd>Abort the HttpChannel and close the connection/stream</dd>
</dl>
@param code The error code
@param message The message
@throws IOException If an IO problem occurred sending the error response.
|
sendError
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
MIT
|
public void sendProcessing() throws IOException
{
if (_channel.isExpecting102Processing() && !isCommitted())
{
_channel.sendResponse(HttpGenerator.PROGRESS_102_INFO, null, true);
}
}
|
Sends a 102-Processing response.
If the connection is an HTTP connection, the version is 1.1 and the
request has a Expect header starting with 102, then a 102 response is
sent. This indicates that the request still be processed and real response
can still be sent. This method is called by sendError if it is passed 102.
@throws IOException if unable to send the 102 response
@see javax.servlet.http.HttpServletResponse#sendError(int)
|
sendProcessing
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
MIT
|
public void sendRedirect(int code, String location) throws IOException
{
sendRedirect(code, location, false);
}
|
Sends a response with one of the 300 series redirection codes.
@param code the redirect status code
@param location the location to send in {@code Location} headers
@throws IOException if unable to send the redirect
|
sendRedirect
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
MIT
|
public void sendRedirect(String location, boolean consumeAll) throws IOException
{
sendRedirect(getHttpChannel().getRequest().getHttpVersion().getVersion() < HttpVersion.HTTP_1_1.getVersion()
? HttpServletResponse.SC_MOVED_TEMPORARILY : HttpServletResponse.SC_SEE_OTHER, location, consumeAll);
}
|
Sends a response with a HTTP version appropriate 30x redirection.
@param location the location to send in {@code Location} headers
@param consumeAll if True, consume any HTTP/1 request input before doing the redirection. If the input cannot
be consumed without blocking, then add a `Connection: close` header to the response.
@throws IOException if unable to send the redirect
|
sendRedirect
|
java
|
theonedev/onedev
|
server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/org/eclipse/jetty/server/Response.java
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.