id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
1795594_6 | static void buildCanonicalQueryString(Map<String,String> parameters, StringBuilder sb) {
boolean firstParam = true;
for (String parameter : Ordering.natural().sortedCopy(parameters.keySet())) {
// Ignore signature parameters
if (SecurityParameter.X_Amz_Signature.parameter().equals(parameter))
continue;
if (!firstParam)
sb.append('&');
String value = parameters.get(parameter);
sb.append(HmacLoginModuleSupport.urlencode(parameter));
sb.append('=');
if (!Strings.isNullOrEmpty(value)) {
Optional<SubResource> subResource = Enums.getIfPresent(SubResource.class, parameter);
if (subResource.isPresent() && subResource.get().isObjectSubResource)
sb.append("");
else
sb.append(HmacLoginModuleSupport.urlencode(value));
}
firstParam = false;
}
} |
1795594_7 | static void buildCanonicalQueryString(Map<String,String> parameters, StringBuilder sb) {
boolean firstParam = true;
for (String parameter : Ordering.natural().sortedCopy(parameters.keySet())) {
// Ignore signature parameters
if (SecurityParameter.X_Amz_Signature.parameter().equals(parameter))
continue;
if (!firstParam)
sb.append('&');
String value = parameters.get(parameter);
sb.append(HmacLoginModuleSupport.urlencode(parameter));
sb.append('=');
if (!Strings.isNullOrEmpty(value)) {
Optional<SubResource> subResource = Enums.getIfPresent(SubResource.class, parameter);
if (subResource.isPresent() && subResource.get().isObjectSubResource)
sb.append("");
else
sb.append(HmacLoginModuleSupport.urlencode(value));
}
firstParam = false;
}
} |
1795594_8 | static StringBuilder buildCanonicalRequest(MappingHttpRequest request, String signedHeaders, String payloadHash) {
StringBuilder sb = new StringBuilder(512);
// Request method
sb.append(request.getMethod().getName());
sb.append('\n');
// Resource path
sb.append(buildCanonicalResourcePath(request.getServicePath()));
sb.append('\n');
// Query parameters
buildCanonicalQueryString(request.getParameters(), sb);
sb.append('\n');
// Headers
buildCanonicalHeaders(request, signedHeaders, sb);
sb.append('\n');
// Signed headers
sb.append(signedHeaders);
sb.append('\n');
// Payload
if (payloadHash != null)
sb.append(payloadHash);
return sb;
} |
1795594_9 | static StringBuilder buildCanonicalRequest(MappingHttpRequest request, String signedHeaders, String payloadHash) {
StringBuilder sb = new StringBuilder(512);
// Request method
sb.append(request.getMethod().getName());
sb.append('\n');
// Resource path
sb.append(buildCanonicalResourcePath(request.getServicePath()));
sb.append('\n');
// Query parameters
buildCanonicalQueryString(request.getParameters(), sb);
sb.append('\n');
// Headers
buildCanonicalHeaders(request, signedHeaders, sb);
sb.append('\n');
// Signed headers
sb.append(signedHeaders);
sb.append('\n');
// Payload
if (payloadHash != null)
sb.append(payloadHash);
return sb;
} |
1797376_0 | @Override
public Number getValue(int row, int column) {
Number result = null;
DefaultKeyedValues rowData = this.rows.get(row);
if (rowData != null) {
Comparable columnKey = this.columnKeys.get(column);
// the row may not have an entry for this key, in which case the
// return value is null
int index = rowData.getIndex(columnKey);
if (index >= 0) {
result = rowData.getValue(index);
}
}
return result;
} |
1797376_1 | public void addValue(Number value, Comparable rowKey,
Comparable columnKey) {
// defer argument checking
setValue(value, rowKey, columnKey);
} |
1797376_2 | @Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (o == this) {
return true;
}
if (!(o instanceof KeyedValues2D)) {
return false;
}
KeyedValues2D kv2D = (KeyedValues2D) o;
if (!getRowKeys().equals(kv2D.getRowKeys())) {
return false;
}
if (!getColumnKeys().equals(kv2D.getColumnKeys())) {
return false;
}
int rowCount = getRowCount();
if (rowCount != kv2D.getRowCount()) {
return false;
}
int colCount = getColumnCount();
if (colCount != kv2D.getColumnCount()) {
return false;
}
for (int r = 0; r < rowCount; r++) {
for (int c = 0; c < colCount; c++) {
Number v1 = getValue(r, c);
Number v2 = kv2D.getValue(r, c);
if (v1 == null) {
if (v2 != null) {
return false;
}
}
else {
if (!v1.equals(v2)) {
return false;
}
}
}
}
return true;
} |
1797376_3 | @Override
public Comparable getRowKey(int row) {
return this.rowKeys.get(row);
} |
1797376_4 | @Override
public Comparable getColumnKey(int column) {
return this.columnKeys.get(column);
} |
1797376_5 | public void removeValue(Comparable rowKey, Comparable columnKey) {
setValue(null, rowKey, columnKey);
// 1. check whether the row is now empty.
boolean allNull = true;
int rowIndex = getRowIndex(rowKey);
DefaultKeyedValues row = this.rows.get(rowIndex);
for (int item = 0, itemCount = row.getItemCount(); item < itemCount;
item++) {
if (row.getValue(item) != null) {
allNull = false;
break;
}
}
if (allNull) {
this.rowKeys.remove(rowIndex);
this.rows.remove(rowIndex);
}
// 2. check whether the column is now empty.
allNull = true;
//int columnIndex = getColumnIndex(columnKey);
for (DefaultKeyedValues rowItem : this.rows) {
int columnIndex = rowItem.getIndex(columnKey);
if (columnIndex >= 0 && rowItem.getValue(columnIndex) != null) {
allNull = false;
break;
}
}
if (allNull) {
for (DefaultKeyedValues rowItem : this.rows) {
int columnIndex = rowItem.getIndex(columnKey);
if (columnIndex >= 0) {
rowItem.removeValue(columnIndex);
}
}
this.columnKeys.remove(columnKey);
}
} |
1797376_6 | public void removeRow(int rowIndex) {
this.rowKeys.remove(rowIndex);
this.rows.remove(rowIndex);
} |
1797376_7 | @Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof SimpleHistogramDataset)) {
return false;
}
SimpleHistogramDataset that = (SimpleHistogramDataset) obj;
if (!this.key.equals(that.key)) {
return false;
}
if (this.adjustForBinSize != that.adjustForBinSize) {
return false;
}
if (!this.bins.equals(that.bins)) {
return false;
}
return true;
} |
1797376_8 | public void clearObservations() {
for (SimpleHistogramBin bin : this.bins) {
bin.setItemCount(0);
}
notifyListeners(new DatasetChangeEvent(this, this));
} |
1797376_9 | public void removeAllBins() {
this.bins = new ArrayList<SimpleHistogramBin>();
notifyListeners(new DatasetChangeEvent(this, this));
} |
1810705_0 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Device device = deviceResolver.resolveDevice(request);
request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device);
return true;
} |
1810705_1 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Device device = deviceResolver.resolveDevice(request);
request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device);
return true;
} |
1810705_2 | @Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
Device device = deviceResolver.resolveDevice(request);
request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device);
filterChain.doFilter(request, response);
} |
1810705_3 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810705_4 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810705_5 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810705_6 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810705_7 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810705_8 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810705_9 | public boolean isRequestForSite(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (hasMobilePath() && (requestURI.startsWith(getFullMobilePath()) || requestURI.equals(getCleanMobilePath()))) {
return false;
} else if (hasTabletPath() && (requestURI.startsWith(getFullTabletPath()) || requestURI.equals(getCleanTabletPath()))) {
return false;
}
return true;
} |
1810897_0 | @RequestMapping(value = "states", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody List<State> fetchStatesJson() {
logger.info("fetching JSON states");
return getStates();
} |
1810897_1 | @RequestMapping(value = "sendmessage", method = RequestMethod.POST, consumes = "text/plain")
public @ResponseBody String sendMessage(@RequestBody String message) {
logger.info("String message: " + message);
return "String message received! Your message: " + message;
} |
1812602_0 | public static String constructPackageName(GetUserInfoResult userInfo) {
String orgName = userInfo.getOrganizationName();
if (orgName != null) {
String orgNameDenorm = userInfo.getOrganizationName().replaceAll("(,|\\.|\\s)", "").toLowerCase();
return "com." + orgNameDenorm + ".model";
}
return "com.force.model";
} |
1812602_1 | @Override
public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) {
List<DescribeSObjectResult> filteredResult = new ArrayList<DescribeSObjectResult>();
for (DescribeSObjectResult dsr : dsrs) {
// include => objectNames.contains(name)
// exclude => !objectNames.contains(name)
if (include == objectNames.contains(dsr.getName())) {
filteredResult.add(dsr);
}
}
return filteredResult;
} |
1812602_2 | @Override
public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) {
List<DescribeSObjectResult> filteredResult = new ArrayList<DescribeSObjectResult>();
for (DescribeSObjectResult dsr : dsrs) {
// include => objectNames.contains(name)
// exclude => !objectNames.contains(name)
if (include == objectNames.contains(dsr.getName())) {
filteredResult.add(dsr);
}
}
return filteredResult;
} |
1812602_3 | @Override
public List<Field> filter(DescribeSObjectResult dsr) {
if (dsr.isCustom()) {
// Skip all fields common to Force.com custom objects
return filterInternal(dsr, CUSTOM_OBJECT_COMMON_FIELDS);
} else if (ForceJPAClassGeneratorUtils.hasAllCommonFields(dsr)) {
// Skip all fields common to Force.com standard objects
return filterInternal(dsr, STANDARD_OBJECT_COMMON_FIELDS);
}
// Skip all fields common to all Force.com objects
return filterInternal(dsr, ALL_OBJECT_COMMON_FIELDS);
} |
1812602_4 | @Override
public List<Field> filter(DescribeSObjectResult dsr) {
if (dsr.isCustom()) {
// Skip all fields common to Force.com custom objects
return filterInternal(dsr, CUSTOM_OBJECT_COMMON_FIELDS);
} else if (ForceJPAClassGeneratorUtils.hasAllCommonFields(dsr)) {
// Skip all fields common to Force.com standard objects
return filterInternal(dsr, STANDARD_OBJECT_COMMON_FIELDS);
}
// Skip all fields common to all Force.com objects
return filterInternal(dsr, ALL_OBJECT_COMMON_FIELDS);
} |
1812602_5 | @Override
public List<Field> filter(DescribeSObjectResult dsr) {
if (dsr.isCustom()) {
// Skip all fields common to Force.com custom objects
return filterInternal(dsr, CUSTOM_OBJECT_COMMON_FIELDS);
} else if (ForceJPAClassGeneratorUtils.hasAllCommonFields(dsr)) {
// Skip all fields common to Force.com standard objects
return filterInternal(dsr, STANDARD_OBJECT_COMMON_FIELDS);
}
// Skip all fields common to all Force.com objects
return filterInternal(dsr, ALL_OBJECT_COMMON_FIELDS);
} |
1812602_6 | @Override
public List<Field> filter(DescribeSObjectResult dsr) {
if (dsr.isCustom()) {
// Skip all fields common to Force.com custom objects
return filterInternal(dsr, CUSTOM_OBJECT_COMMON_FIELDS);
} else if (ForceJPAClassGeneratorUtils.hasAllCommonFields(dsr)) {
// Skip all fields common to Force.com standard objects
return filterInternal(dsr, STANDARD_OBJECT_COMMON_FIELDS);
}
// Skip all fields common to all Force.com objects
return filterInternal(dsr, ALL_OBJECT_COMMON_FIELDS);
} |
1812602_7 | @Override
public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) {
return dsrs;
} |
1812602_8 | @Override
public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) {
return dsrs;
} |
1812602_9 | @Override
public List<Field> filter(DescribeSObjectResult dsr) {
List<Field> fieldList = Lists.newArrayList(dsr.getFields());
Iterator<Field> fieldIter = fieldList.iterator();
while (fieldIter.hasNext()) {
Field field = fieldIter.next();
if (field.getType() == FieldType.reference) {
for (String referenceTo : field.getReferenceTo()) {
// Remove if there exists a reference to object for which:
//
// include and referenceObjectNames does not contain name
// OR
// exclude and referenceObjectNames contains name
if (include != referenceObjectNames.contains(referenceTo)) {
fieldIter.remove();
break;
}
}
}
}
return fieldList;
} |
1814028_0 | public synchronized Connection createConnection(String address) {
if (connectionFactory==null)
{
throw new IllegalStateException("Connection not expected. You have to call expectCall() or useConnectionFactory() first.");
}
return connectionFactory.createConnection(address);
} |
1814028_1 | public synchronized static UniversalMockRecorder expectCall() {
if (getConnectionFactory()==null)
{
UniversalMockConnectionFactory mockConnection = new UniversalMockConnectionFactory();
useConnectionFactory(mockConnection);
return mockConnection;
}
else
{
throw new IllegalArgumentException("Can not call expectCall twice. You have to call reset before each test. If you need simulate multiple requests, please call andReturn several times.");
}
} |
1814028_2 | public static UniversalMockRecorder expectCall() {
return StaticConnectionFactory.expectCall();
} |
1814028_3 | public static UniversalMockRecorder expectCall() {
return StaticConnectionFactory.expectCall();
} |
1839196_0 | public MultipleBeanSource(Object... sources) throws IllegalArgumentException {
this.sources = sources;
List<Class> declaringClasses = new ArrayList<Class>();
for (Object o : sources) {
if (declaringClasses.contains(o.getClass())) {
throw new IllegalArgumentException("You can't give two beans of the same type.");
}
declaringClasses.add(o.getClass());
}
} |
1839196_1 | @Override
public Element create(Field field) throws FormException {
Element element = null;
if (field.getDeclaringClass().isAnnotationPresent(Accessor.class)
&& (Accessor.AccessType.METHOD == field.getDeclaringClass().getAnnotation(Accessor.class).value())) {
try {
Method propertyGetter = ReflectionUtils.getPropertyGetter(field);
if (Property.class.isAssignableFrom(propertyGetter.getReturnType())) {
element = new PropertyMethodElement(field);
} else {
element = new ReadOnlyPropertyMethodElement(field);
}
} catch (NoSuchMethodException e) {
logger.log(Level.INFO, "No property getter found for " + field);
throw new FormException(e);
}
} else {
if (Property.class.isAssignableFrom(field.getType())) {
element = new PropertyFieldElement(field);
} else if (ReadOnlyProperty.class.isAssignableFrom(field.getType())) {
element = new ReadOnlyPropertyFieldElement(field);
}
}
return element;
} |
1839196_2 | @Override
public void setValue(WrappedType wrappedType) {
getProperty().setValue(wrappedType);
} |
1839196_3 | public List<Element> filter(List<Element> toFilter) throws FilterException {
List<Element> filtered = new ArrayList<Element>(toFilter);
for (String name : names) {
extractFieldByName(filtered, name);
}
return filtered;
} |
1839196_4 | public List<Element> filter(List<Element> toFilter) throws FilterException {
List<Element> remaining = new ArrayList<Element>(toFilter);
List<Element> filtered = new ArrayList<Element>();
for (String name : names) {
filtered.add(extractFieldByName(remaining, name));
}
filtered.addAll(remaining);
return filtered;
} |
1839196_5 | public List<Element> filter(List<Element> toFilter) throws FilterException {
List<Element> remaining = new ArrayList<Element>(toFilter);
List<Element> filtered = new ArrayList<Element>();
for (String name : names) {
filtered.add(extractFieldByName(remaining, name));
}
return filtered;
} |
1839196_6 | public List<Element> filter(List<Element> toFilter) {
List<Element> filtered = new ArrayList<Element>();
for (Element field : toFilter) {
if (field.getAnnotation(NonVisual.class) == null) {
filtered.add(field);
}
}
return filtered;
} |
1839196_7 | public void setSource(T source) {
this.source.set(source);
} |
1839196_8 | public void setSource(T source) {
this.source.set(source);
} |
1839196_9 | public boolean handle(Element element) {
try {
return element.getWrappedType().isEnum();
} catch (Exception e) {
}
return false;
} |
1860892_0 | protected void fireStartTask() {
fireEvent(new Event() {
@Override
public void fire(final Listener listener) {
listener.startTask();
}
});
} |
1860892_1 | @Override
public void execute(final Runnable command) {
delegate.execute(command);
} |
1860892_2 | @Override
public String command(String command) {
String filtered = command.replaceAll("GET /", "");
filtered = filtered.replaceAll(" HTTP/1.1", "");
filtered = filtered.replaceAll("%5B", "[");
filtered = filtered.replaceAll("%5D", "]");
filtered = filtered.replaceAll("%20", " ");
return delegate.command(filtered);
} |
1860892_3 | public TaskNameFactory(final TaskNames names) {
this.names = names;
} |
1860892_4 | public CreateTaskPersistence(final CreateTaskDelegate delegate, final EventsConsumer consumer,
final IdProvider provider, JiraEventFactory jiraEventFactory) {
this.delegate = delegate;
this.consumer = consumer;
this.provider = provider;
this.jiraEventFactory = jiraEventFactory;
} |
1860892_5 | public List<String> check(Class<?> class1) {
List<String> errors = new ArrayList<String>();
internalDetect(class1, errors, 0);
return errors;
} |
1860892_6 | public Adapter(Source<IN> in, final Functor<IN, OUT> functor){
output = new Source<OUT>(functor.evaluate(in.currentValue()));
in.addReceiver(new Receiver<IN>() {
@Override
public void receive(IN value) {
output.supply(functor.evaluate(value));
}
});
} |
1862490_0 | public static String resolve(final Properties props, final String expression) {
if (expression == null) return null;
final StringBuilder builder = new StringBuilder();
final char[] chars = expression.toCharArray();
final int len = chars.length;
int state = 0;
int start = -1;
int nameStart = -1;
for (int i = 0; i < len; i++) {
char ch = chars[i];
switch (state) {
case INITIAL: {
switch (ch) {
case '$': {
state = GOT_DOLLAR;
continue;
}
default: {
builder.append(ch);
continue;
}
}
// not reachable
}
case GOT_DOLLAR: {
switch (ch) {
case '$': {
builder.append(ch);
state = INITIAL;
continue;
}
case '{': {
start = i + 1;
nameStart = start;
state = GOT_OPEN_BRACE;
continue;
}
default: {
// invalid; emit and resume
builder.append('$').append(ch);
state = INITIAL;
continue;
}
}
// not reachable
}
case GOT_OPEN_BRACE: {
switch (ch) {
case ':':
case '}':
case ',': {
final String name = expression.substring(nameStart, i).trim();
final String val;
if (name.startsWith("env.")) {
val = System.getenv(name.substring(4));
} else if (name.startsWith("sys.")) {
val = System.getProperty(name.substring(4));
} else {
val = props.getProperty(name);
}
if (val != null) {
builder.append(val);
state = ch == '}' ? INITIAL : RESOLVED;
continue;
} else if (ch == ',') {
nameStart = i + 1;
continue;
} else if (ch == ':') {
start = i + 1;
state = DEFAULT;
continue;
} else {
builder.append(expression.substring(start - 2, i + 1));
state = INITIAL;
continue;
}
}
default: {
continue;
}
}
// not reachable
}
case RESOLVED: {
if (ch == '}') {
state = INITIAL;
}
continue;
}
case DEFAULT: {
if (ch == '}') {
state = INITIAL;
builder.append(expression.substring(start, i));
}
continue;
}
default:
throw new IllegalStateException();
}
}
switch (state) {
case GOT_DOLLAR: {
builder.append('$');
break;
}
case DEFAULT:
case GOT_OPEN_BRACE: {
builder.append(expression.substring(start - 2));
break;
}
}
return builder.toString();
} |
1862490_1 | public static String resolve(final Properties props, final String expression) {
if (expression == null) return null;
final StringBuilder builder = new StringBuilder();
final char[] chars = expression.toCharArray();
final int len = chars.length;
int state = 0;
int start = -1;
int nameStart = -1;
for (int i = 0; i < len; i++) {
char ch = chars[i];
switch (state) {
case INITIAL: {
switch (ch) {
case '$': {
state = GOT_DOLLAR;
continue;
}
default: {
builder.append(ch);
continue;
}
}
// not reachable
}
case GOT_DOLLAR: {
switch (ch) {
case '$': {
builder.append(ch);
state = INITIAL;
continue;
}
case '{': {
start = i + 1;
nameStart = start;
state = GOT_OPEN_BRACE;
continue;
}
default: {
// invalid; emit and resume
builder.append('$').append(ch);
state = INITIAL;
continue;
}
}
// not reachable
}
case GOT_OPEN_BRACE: {
switch (ch) {
case ':':
case '}':
case ',': {
final String name = expression.substring(nameStart, i).trim();
final String val;
if (name.startsWith("env.")) {
val = System.getenv(name.substring(4));
} else if (name.startsWith("sys.")) {
val = System.getProperty(name.substring(4));
} else {
val = props.getProperty(name);
}
if (val != null) {
builder.append(val);
state = ch == '}' ? INITIAL : RESOLVED;
continue;
} else if (ch == ',') {
nameStart = i + 1;
continue;
} else if (ch == ':') {
start = i + 1;
state = DEFAULT;
continue;
} else {
builder.append(expression.substring(start - 2, i + 1));
state = INITIAL;
continue;
}
}
default: {
continue;
}
}
// not reachable
}
case RESOLVED: {
if (ch == '}') {
state = INITIAL;
}
continue;
}
case DEFAULT: {
if (ch == '}') {
state = INITIAL;
builder.append(expression.substring(start, i));
}
continue;
}
default:
throw new IllegalStateException();
}
}
switch (state) {
case GOT_DOLLAR: {
builder.append('$');
break;
}
case DEFAULT:
case GOT_OPEN_BRACE: {
builder.append(expression.substring(start - 2));
break;
}
}
return builder.toString();
} |
1862490_2 | public static String resolve(final Properties props, final String expression) {
if (expression == null) return null;
final StringBuilder builder = new StringBuilder();
final char[] chars = expression.toCharArray();
final int len = chars.length;
int state = 0;
int start = -1;
int nameStart = -1;
for (int i = 0; i < len; i++) {
char ch = chars[i];
switch (state) {
case INITIAL: {
switch (ch) {
case '$': {
state = GOT_DOLLAR;
continue;
}
default: {
builder.append(ch);
continue;
}
}
// not reachable
}
case GOT_DOLLAR: {
switch (ch) {
case '$': {
builder.append(ch);
state = INITIAL;
continue;
}
case '{': {
start = i + 1;
nameStart = start;
state = GOT_OPEN_BRACE;
continue;
}
default: {
// invalid; emit and resume
builder.append('$').append(ch);
state = INITIAL;
continue;
}
}
// not reachable
}
case GOT_OPEN_BRACE: {
switch (ch) {
case ':':
case '}':
case ',': {
final String name = expression.substring(nameStart, i).trim();
final String val;
if (name.startsWith("env.")) {
val = System.getenv(name.substring(4));
} else if (name.startsWith("sys.")) {
val = System.getProperty(name.substring(4));
} else {
val = props.getProperty(name);
}
if (val != null) {
builder.append(val);
state = ch == '}' ? INITIAL : RESOLVED;
continue;
} else if (ch == ',') {
nameStart = i + 1;
continue;
} else if (ch == ':') {
start = i + 1;
state = DEFAULT;
continue;
} else {
builder.append(expression.substring(start - 2, i + 1));
state = INITIAL;
continue;
}
}
default: {
continue;
}
}
// not reachable
}
case RESOLVED: {
if (ch == '}') {
state = INITIAL;
}
continue;
}
case DEFAULT: {
if (ch == '}') {
state = INITIAL;
builder.append(expression.substring(start, i));
}
continue;
}
default:
throw new IllegalStateException();
}
}
switch (state) {
case GOT_DOLLAR: {
builder.append('$');
break;
}
case DEFAULT:
case GOT_OPEN_BRACE: {
builder.append(expression.substring(start - 2));
break;
}
}
return builder.toString();
} |
1862490_3 | public static int compareVersion(final String version1, final String version2) {
return INSTANCE.compare(version1, version2);
} |
1862492_0 | public void setWriter(final Writer writer) {
synchronized (outputLock) {
super.setWriter(writer);
final OutputStream oldStream = this.outputStream;
outputStream = null;
safeFlush(oldStream);
safeClose(oldStream);
}
} |
1862492_1 | public void setWriter(final Writer writer) {
synchronized (outputLock) {
super.setWriter(writer);
final OutputStream oldStream = this.outputStream;
outputStream = null;
safeFlush(oldStream);
safeClose(oldStream);
}
} |
1863627_0 | @Override
public ClusterNode assignClusterNode() {
lock.lock();
try {
while (!currentlyOwningTask.get()) {
taskAcquired.awaitUninterruptibly();
}
} catch (Exception e) {
logger.error("Exception while waiting for task to be acquired");
return null;
} finally {
lock.unlock();
}
return clusterNodeRef.get();
} |
1867246_0 | @Override
public boolean isAuthenticated() {
if (tokenExpiration != null && new Date().compareTo(tokenExpiration) >= 0) {
return false;
} else {
return super.isAuthenticated();
}
} |
1867246_1 | @Override
public boolean isAuthenticated() {
if (tokenExpiration != null && new Date().compareTo(tokenExpiration) >= 0) {
return false;
} else {
return super.isAuthenticated();
}
} |
1867246_2 | @Override
public boolean isAuthenticated() {
if (tokenExpiration != null && new Date().compareTo(tokenExpiration) >= 0) {
return false;
} else {
return super.isAuthenticated();
}
} |
1867246_3 | @Override
public boolean isAuthenticated() {
if (tokenExpiration != null && new Date().compareTo(tokenExpiration) >= 0) {
return false;
} else {
return super.isAuthenticated();
}
} |
1867246_4 | public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!supports(authentication.getClass())) {
throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted");
}
SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication;
SAMLMessageStorage store = token.getMessageStore();
SAMLMessageContext context = token.getCredentials();
SAMLCredential credential;
try {
credential = consumer.processAuthenticationResponse(context, store);
} catch (SAMLException e) {
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
throw new AuthenticationServiceException("Error validating SAML message", e);
} catch (ValidationException e) {
log.debug("Error validating signature", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error validating SAML message signature", e);
} catch (org.opensaml.xml.security.SecurityException e) {
log.debug("Error validating signature", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error validating SAML message signature", e);
} catch (DecryptionException e) {
log.debug("Error decrypting SAML message", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error decrypting SAML message", e);
}
Object userDetails = getUserDetails(credential);
Object principal = getPrincipal(credential, userDetails);
Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails);
Date expiration = getExpirationDate(credential);
ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements);
result.setDetails(userDetails);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null);
return result;
} |
1867246_5 | public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!supports(authentication.getClass())) {
throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted");
}
SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication;
SAMLMessageStorage store = token.getMessageStore();
SAMLMessageContext context = token.getCredentials();
SAMLCredential credential;
try {
credential = consumer.processAuthenticationResponse(context, store);
} catch (SAMLException e) {
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
throw new AuthenticationServiceException("Error validating SAML message", e);
} catch (ValidationException e) {
log.debug("Error validating signature", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error validating SAML message signature", e);
} catch (org.opensaml.xml.security.SecurityException e) {
log.debug("Error validating signature", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error validating SAML message signature", e);
} catch (DecryptionException e) {
log.debug("Error decrypting SAML message", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error decrypting SAML message", e);
}
Object userDetails = getUserDetails(credential);
Object principal = getPrincipal(credential, userDetails);
Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails);
Date expiration = getExpirationDate(credential);
ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements);
result.setDetails(userDetails);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null);
return result;
} |
1867246_6 | public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!supports(authentication.getClass())) {
throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted");
}
SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication;
SAMLMessageStorage store = token.getMessageStore();
SAMLMessageContext context = token.getCredentials();
SAMLCredential credential;
try {
credential = consumer.processAuthenticationResponse(context, store);
} catch (SAMLException e) {
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
throw new AuthenticationServiceException("Error validating SAML message", e);
} catch (ValidationException e) {
log.debug("Error validating signature", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error validating SAML message signature", e);
} catch (org.opensaml.xml.security.SecurityException e) {
log.debug("Error validating signature", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error validating SAML message signature", e);
} catch (DecryptionException e) {
log.debug("Error decrypting SAML message", e);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context);
throw new AuthenticationServiceException("Error decrypting SAML message", e);
}
Object userDetails = getUserDetails(credential);
Object principal = getPrincipal(credential, userDetails);
Collection<GrantedAuthority> entitlements = getEntitlements(credential, userDetails);
Date expiration = getExpirationDate(credential);
ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(expiration, principal, credential, entitlements);
result.setDetails(userDetails);
samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.SUCCESS, context, result, null);
return result;
} |
1867246_7 | public String getIdpSelectionPath() {
return idpSelectionPath;
} |
1867246_8 | protected boolean processFilter(HttpServletRequest request) {
return SAMLUtil.processFilter(filterProcessesUrl, request);
} |
1867246_9 | protected boolean processFilter(HttpServletRequest request) {
return SAMLUtil.processFilter(filterProcessesUrl, request);
} |
1870998_0 | public static <T> T sendAndReceive(String soapUrl, String soapAction,
String msgTpl, Object[] msgArgs, WSConverter<T> converter) {
if (msgArgs != null && msgArgs.length > 0)
msgTpl = java.text.MessageFormat.format(msgTpl, msgArgs);
StreamSource source = new StreamSource(new StringReader(msgTpl));
StringResult xmlResult = new StringResult();
WebServiceTemplate webServiceTemplate = buildWebServiceTemplate();
webServiceTemplate.sendSourceAndReceiveToResult(soapUrl, source,
new SoapActionCallback(soapAction), xmlResult);
return converter.convert(xmlResult.toString());
} |
1870998_1 | public static <T> T sendAndReceive(String soapUrl, String soapAction,
String msgTpl, Object[] msgArgs, WSConverter<T> converter) {
if (msgArgs != null && msgArgs.length > 0)
msgTpl = java.text.MessageFormat.format(msgTpl, msgArgs);
StreamSource source = new StreamSource(new StringReader(msgTpl));
StringResult xmlResult = new StringResult();
WebServiceTemplate webServiceTemplate = buildWebServiceTemplate();
webServiceTemplate.sendSourceAndReceiveToResult(soapUrl, source,
new SoapActionCallback(soapAction), xmlResult);
return converter.convert(xmlResult.toString());
} |
1870998_2 | public Object format(Object context, Object value) {
// 判断是否应该格式化链接
if (!this.isLinkable(context, value)) {
return value != null ? value.toString() : "";
}
Object _value;
if (value instanceof Formater) {
_value = ((Formater<?>) value).format(context, value);
} else {
_value = value;
}
String label = this.getLinkText(context, value);
if (label != null && label.length() > 0) {
Object[] params = getParams(context, _value);
String href = MessageFormat.format(this.urlPattern, params);
return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value));
} else {
return " ";
}
} |
1870998_3 | public Object format(Object context, Object value) {
// 判断是否应该格式化链接
if (!this.isLinkable(context, value)) {
return value != null ? value.toString() : "";
}
Object _value;
if (value instanceof Formater) {
_value = ((Formater<?>) value).format(context, value);
} else {
_value = value;
}
String label = this.getLinkText(context, value);
if (label != null && label.length() > 0) {
Object[] params = getParams(context, _value);
String href = MessageFormat.format(this.urlPattern, params);
return buildLinkHtml(label, href, this.getTaskbarTitle(context, value), this.moduleKey, this.getWinId(context, value));
} else {
return " ";
}
} |
1870998_4 | @Override
public Object format(Object context, Object value) {
StringBuffer v = new StringBuffer();
// 前置图标
appendIcons(this.getIconsBeforeText(context, value), v);
// 显示的文本
Object _value = this.formatValue(context, value);
if (_value != null)
v.append(_value);
// 后置图标
appendIcons(this.getIconsAfterText(context, value), v);
if (v.length() > 0) {
return v.toString();
} else {
return " ";
}
} |
1870998_5 | public IconTextFormater addIconBeforeText(Icon icon) {
this.getIconsBeforeText().add(icon);
return this;
} |
1870998_6 | public IconTextFormater addIconAfterText(Icon icon) {
this.getIconsAfterText().add(icon);
return this;
} |
1870998_7 | public Object parse(Object data) {
if (this.tpl == null)
return null;
return FreeMarkerUtils.format(this.tpl, data);
} |
1870998_8 | public Actor loadByCode(String actorCode) {
return this.actorDao.loadByCode(actorCode);
} |
1870998_9 | public List<Actor> findFollower(Long masterId, Integer[] relationTypes,
Integer[] followerTypes) {
return this.actorDao.findFollower(masterId, relationTypes,
followerTypes);
} |
1872106_0 | static boolean nameIsValid(String name) {
return name.matches("[\\p{L}-]+");
} |
1875775_0 | InputStream getStream() {
return this.getClass().getResourceAsStream("/META-INF/bootstrap.taglib.xml");
} |
1875775_1 | public FaceletTaglibType getTaglib() {
return taglib;
} |
1878370_0 | protected List<Range> getRangeMatches(String line, String[] words) {
List<Range> ranges = new ArrayList<Range>();
if (words == null) {
return ranges;
}
String lowerline = line.toLowerCase();
int idx = 0;
int end = 0;
for (String word : words) {
idx = lowerline.indexOf(word, idx);
while (idx >= 0) {
end = idx + word.length();
ranges.add(new Range(idx, end, line.substring(idx, end)));
idx = lowerline.indexOf(word, idx + word.length());
}
}
return ranges;
} |
1878370_1 | protected List<Range> getRangeMatches(String line, String[] words) {
List<Range> ranges = new ArrayList<Range>();
if (words == null) {
return ranges;
}
String lowerline = line.toLowerCase();
int idx = 0;
int end = 0;
for (String word : words) {
idx = lowerline.indexOf(word, idx);
while (idx >= 0) {
end = idx + word.length();
ranges.add(new Range(idx, end, line.substring(idx, end)));
idx = lowerline.indexOf(word, idx + word.length());
}
}
return ranges;
} |
1878370_2 | protected void testLine(Report report, int linenum, String line) {
List<Range> includedRanges = getRangeMatches(line, included);
List<Range> excludedRanges = getRangeMatches(line, excluded);
for (Range range : includedRanges) {
if (range.overlaps(excludedRanges)) {
continue; // Excluded: skip
}
report.error(linenum, range.match, range.start, range.end, line);
}
} |
1878370_3 | public void check(Report report, File file) {
FileReader reader = null;
BufferedReader buf = null;
report.fileStart(file);
try {
reader = new FileReader(file);
buf = new BufferedReader(reader);
int linenum = 0;
String line;
while ((line = buf.readLine()) != null) {
linenum++;
testLine(report, linenum, line);
}
}
catch (IOException e) {
report.exception(e);
}
finally {
IOUtil.close(buf);
IOUtil.close(reader);
report.fileEnd();
}
} |
1878370_4 | public void check(Report report, File file) {
FileReader reader = null;
BufferedReader buf = null;
report.fileStart(file);
try {
reader = new FileReader(file);
buf = new BufferedReader(reader);
int linenum = 0;
String line;
while ((line = buf.readLine()) != null) {
linenum++;
testLine(report, linenum, line);
}
}
catch (IOException e) {
report.exception(e);
}
finally {
IOUtil.close(buf);
IOUtil.close(reader);
report.fileEnd();
}
} |
1878370_5 | @Override
public void check(Report report, File file) {
header.check(report, file);
} |
1878370_6 | @Override
public void check(Report report, File file) {
header.check(report, file);
} |
1878370_7 | @Override
public void check(Report report, File file) {
header.check(report, file);
} |
1878370_8 | public void check(Report report, File file) {
try {
String fileHeader[] = readFileHeader(file);
int maxLines = Math.min(header.length, fileHeader.length);
for (int fileIdx = 0, regexIdx = 0; regexIdx < maxLines; fileIdx++, regexIdx++) {
while (!fileHeader[fileIdx].matches(header[regexIdx]) && optional[regexIdx]) {
regexIdx++;
if (regexIdx >= maxLines) {
// At end of headerlist
report.pass(file);
return;
}
}
if (!fileHeader[fileIdx].matches(header[regexIdx])) {
report.violation(file, "header", fileIdx, "Header line #%d \"%s\" does not match regex \"%s\"",
fileIdx, fileHeader[fileIdx], header[regexIdx]);
return;
}
}
report.pass(file);
}
catch (IOException e) {
report.failure(file, e);
}
} |
1878370_9 | public static JavaClass assertIsInterface(File java) throws IOException {
JavaDocBuilder builder = new JavaDocBuilder();
JavaSource src = builder.addSource(java);
JavaClass jc = getClassName(src, java);
Assert.assertThat("Failed to parse java source: " + java.getAbsolutePath(), jc, notNullValue());
String msg = String.format("JavaSource: (%s) should be an interface: %s", jc.getName(), java);
Assert.assertThat(msg, jc.isInterface(), is(true));
return jc;
} |
1886360_0 | public static String reverse(String s) {
return new StringBuilder(s).reverse().toString();
} |
1886360_1 | public static boolean isPalindrome(String s) {
return s.equals(reverse(s));
} |
1886360_2 | public static boolean isPalindrome(String s) {
return s.equals(reverse(s));
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.