nus-yam/ex-repair huggingface dataset:
Program: 189688
Project: 189688
Buggy source:
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
@Override public void validate(Object target,Errors errors){
  if (StringUtils.isBlank(patientClinicNumber.getIdentifier())) {
    patientClinicNumber=null;
  }
  if (StringUtils.isBlank(hivIdNumber.getIdentifier())) {
    hivIdNumber=null;
  }
  if (!(StringUtils.isBlank(telephoneContact.getValue()))) {
    if (!telephoneContact.getValue().trim().matches("String_Node_Str")) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
  }
 else {
    telephoneContact=null;
  }
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @see org.springframework.validation.Validator#validate(java.lang.Object,org.springframework.validation.Errors)
 */
@Override public void validate(Object target,Errors errors){
  if (StringUtils.isBlank(patientClinicNumber.getIdentifier())) {
    patientClinicNumber=null;
  }
  if (StringUtils.isBlank(hivIdNumber.getIdentifier())) {
    hivIdNumber=null;
  }
  if (!(StringUtils.isBlank(telephoneContact.getValue()))) {
    if (!telephoneContact.getValue().trim().matches("String_Node_Str")) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
  }
 else {
    telephoneContact=null;
  }
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  require(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
  validateField(errors,"String_Node_Str");
}
Program: 189689
Project: 189689
Buggy source:
public void controller(@RequestParam("String_Node_Str") Patient patient,@RequestParam(value="String_Node_Str",required=false) Visit visit,PageModel model,Session session){
  PatientService ps=Context.getPatientService();
  AppUiUtil.startApp("String_Node_Str",session);
  model.addAttribute("String_Node_Str",new MetadataConstants());
  model.addAttribute("String_Node_Str",patient);
  model.addAttribute("String_Node_Str",patient);
  VisitService vs=Context.getVisitService();
  List<Visit> activeVisits=vs.getActiveVisitsByPatient(patient);
  model.addAttribute("String_Node_Str",activeVisits);
  if (visit == null && activeVisits.size() > 0) {
    visit=activeVisits.get(0);
  }
  model.addAttribute("String_Node_Str",visit);
  if (activeVisits.size() == 0) {
    Visit newVisit=new Visit();
    newVisit.setPatient(patient);
    newVisit.setStartDatetime(new Date());
    newVisit.setVisitType(vs.getVisitTypeByUuid(MetadataConstants.OUTPATIENT_VISIT_TYPE_UUID));
    model.addAttribute("String_Node_Str",newVisit);
  }
  ProgramWorkflowService pws=Context.getProgramWorkflowService();
  Program hivProgram=pws.getProgramByUuid(MetadataConstants.HIV_PROGRAM_UUID);
  model.addAttribute("String_Node_Str",hivProgram);
  Program tbProgram=pws.getProgramByUuid(MetadataConstants.TB_PROGRAM_UUID);
  model.addAttribute("String_Node_Str",tbProgram);
}

Fixed version (ground truth):
public void controller(@RequestParam("String_Node_Str") Patient patient,@RequestParam(value="String_Node_Str",required=false) Visit visit,PageModel model,Session session){
  PatientService ps=Context.getPatientService();
  AppUiUtil.startApp("String_Node_Str",session);
  model.addAttribute("String_Node_Str",new MetadataConstants());
  model.addAttribute("String_Node_Str",patient);
  model.addAttribute("String_Node_Str",patient);
  VisitService vs=Context.getVisitService();
  List<Visit> activeVisits=vs.getActiveVisitsByPatient(patient);
  model.addAttribute("String_Node_Str",activeVisits);
  if (visit == null && activeVisits.size() > 0) {
    visit=activeVisits.get(0);
  }
  model.addAttribute("String_Node_Str",visit);
  Calendar now=Calendar.getInstance();
  now.set(Calendar.SECOND,0);
  now.set(Calendar.MILLISECOND,0);
  if (activeVisits.size() == 0) {
    Visit newVisit=new Visit();
    newVisit.setPatient(patient);
    newVisit.setStartDatetime(now.getTime());
    newVisit.setVisitType(vs.getVisitTypeByUuid(MetadataConstants.OUTPATIENT_VISIT_TYPE_UUID));
    model.addAttribute("String_Node_Str",newVisit);
  }
  ProgramWorkflowService pws=Context.getProgramWorkflowService();
  Program hivProgram=pws.getProgramByUuid(MetadataConstants.HIV_PROGRAM_UUID);
  model.addAttribute("String_Node_Str",hivProgram);
  Program tbProgram=pws.getProgramByUuid(MetadataConstants.TB_PROGRAM_UUID);
  model.addAttribute("String_Node_Str",tbProgram);
}
Program: 189690
Project: 189690
Buggy source:
public Object editLoginDetails(@RequestParam("String_Node_Str") Person person,@MethodParam("String_Node_Str") @BindParams("String_Node_Str") EditLoginDetailsForm form,UiUtils ui){
  ui.validate(form,form,"String_Node_Str");
  Context.getUserService().saveUser(form.getUserToSave(person),form.getPassword().equals(form.PLACEHOLDER) ? null : form.getPassword());
  return new SuccessResult("String_Node_Str");
}

Fixed version (ground truth):
public Object editLoginDetails(@RequestParam("String_Node_Str") Person person,@MethodParam("String_Node_Str") @BindParams("String_Node_Str") EditLoginDetailsForm form,UiUtils ui){
  ui.validate(form,form,"String_Node_Str");
  User user=form.getUserToSave(person);
  String newPassword=form.getPassword().equals(form.PLACEHOLDER) ? null : form.getPassword();
  if (user.getUserId() == null) {
    Context.getUserService().saveUser(user,newPassword);
  }
 else {
    Context.getUserService().saveUser(user,null);
    if (newPassword != null) {
      Context.getUserService().changePassword(user,newPassword);
    }
  }
  return new SuccessResult("String_Node_Str");
}
Program: 189691
Project: 189691
Buggy source:
public List<SimpleObject> withActiveVisits(@RequestParam(value="String_Node_Str",required=false) String query,@RequestParam(value="String_Node_Str",required=false) Integer age,@RequestParam(value="String_Node_Str",defaultValue="String_Node_Str") int ageWindow,UiUtils ui){
  List<SimpleObject> matching=search(query,null,age,ageWindow,ui);
  List<Visit> activeVisits=Context.getVisitService().getVisits(null,null,null,null,null,null,null,null,null,false,false);
  if (matching == null || matching.size() == 0) {
    List<Patient> ret=new ArrayList<Patient>();
    for (    Visit v : activeVisits) {
      if (!ret.contains(v.getPatient()))       ret.add(v.getPatient());
    }
    matching=simplePatientList(ui,ret);
  }
  Map<String,Visit> ptIds=new HashMap<String,Visit>();
  for (  Visit v : activeVisits) {
    ptIds.put(v.getPatient().getPatientId().toString(),v);
  }
  for (Iterator<SimpleObject> i=matching.iterator(); i.hasNext(); ) {
    SimpleObject candidate=i.next();
    Visit v=ptIds.get(candidate.get("String_Node_Str"));
    if (v == null) {
      i.remove();
    }
 else {
      String imgUrl=ui.resourceLink("String_Node_Str","String_Node_Str");
      candidate.put("String_Node_Str","String_Node_Str" + imgUrl + "String_Node_Str"+ ui.format(v.getVisitType())+ "String_Node_Str"+ ui.format(v.getStartDatetime())+ "String_Node_Str");
    }
  }
  return matching;
}

Fixed version (ground truth):
public List<SimpleObject> withActiveVisits(@RequestParam(value="String_Node_Str",required=false) String query,@RequestParam(value="String_Node_Str",required=false) Integer age,@RequestParam(value="String_Node_Str",defaultValue="String_Node_Str") int ageWindow,UiUtils ui){
  List<SimpleObject> matching=search(query,null,age,ageWindow,ui);
  List<Visit> activeVisits=Context.getVisitService().getVisits(null,null,null,null,null,null,null,null,null,false,false);
  if (matching == null || matching.size() == 0) {
    List<Patient> ret=new ArrayList<Patient>();
    for (    Visit v : activeVisits) {
      if (!ret.contains(v.getPatient()))       ret.add(v.getPatient());
    }
    matching=simplePatientList(ui,ret);
  }
  Map<String,Visit> ptIds=new HashMap<String,Visit>();
  for (  Visit v : activeVisits) {
    ptIds.put(v.getPatient().getPatientId().toString(),v);
  }
  for (Iterator<SimpleObject> i=matching.iterator(); i.hasNext(); ) {
    SimpleObject candidate=i.next();
    Visit v=ptIds.get(candidate.get("String_Node_Str"));
    if (v == null) {
      i.remove();
    }
 else {
      candidate.put("String_Node_Str","String_Node_Str" + ui.format(v.getVisitType()) + "String_Node_Str"+ ui.format(v.getStartDatetime())+ "String_Node_Str");
    }
  }
  return matching;
}
Program: 189692
Project: 189692
Buggy source:
@Override public Map<String,String> extractPathParameters(final String uriPath){
  final Map<String,String> pathParamNameAndValues=new HashMap<String,String>();
  final Matcher m=getPathInformation().getPathMatcher(uriPath);
  if (m.matches()) {
    for (int i=1; i <= m.groupCount(); i++) {
      final String paramName=getPathInformation().getFnParamNameForGroup(i);
      final String paramValue=m.group(i);
      pathParamNameAndValues.put(paramName,paramValue);
    }
  }
  return pathParamNameAndValues;
}

Fixed version (ground truth):
@Override public Map<String,String> extractPathParameters(final String uriPath){
  final Map<String,String> pathParamNameAndValues=new HashMap<String,String>();
  if (uriPath == null) {
    return pathParamNameAndValues;
  }
  final Matcher m=getPathInformation().getPathMatcher(uriPath);
  if (m.matches()) {
    for (int i=1; i <= m.groupCount(); i++) {
      final String paramName=getPathInformation().getFnParamNameForGroup(i);
      final String paramValue=m.group(i);
      pathParamNameAndValues.put(paramName,paramValue);
    }
  }
  return pathParamNameAndValues;
}
Program: 189693
Project: 189693
Buggy source:
@Override public boolean matchesPath(final String path){
  final Matcher m=getPathInformation().getPathMatcher(path);
  return m.matches();
}

Fixed version (ground truth):
@Override public boolean matchesPath(final String path){
  if (path == null) {
    return false;
  }
  final Matcher m=getPathInformation().getPathMatcher(path);
  return m.matches();
}
Program: 189694
Project: 189694
Buggy source:
protected void processHttpResponse(final Element httpResponse,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response) throws RestXqServiceException {
  final String strStatus=httpResponse.getAttribute(STATUS_ATTR_NAME);
  HttpStatus httpStatus=null;
  if (strStatus != null && !strStatus.isEmpty()) {
    final int status=Integer.parseInt(strStatus);
    try {
      httpStatus=HttpStatus.fromStatus(status);
    }
 catch (    final IllegalArgumentException iae) {
      throw new RestXqServiceException("String_Node_Str" + strStatus,iae);
    }
  }
  final String reason=httpResponse.getAttribute(REASON_ATTR_NAME);
  if (httpStatus != null) {
    if (reason != null && !reason.isEmpty()) {
      response.setStatus(httpStatus,reason);
    }
 else {
      response.setStatus(httpStatus);
    }
  }
  final NodeList nlHttpHeader=httpResponse.getElementsByTagNameNS(HTTP_HEADER_ELEMENT_NAME.getNamespaceURI(),HTTP_HEADER_ELEMENT_NAME.getLocalPart());
  processHttpHeaders(nlHttpHeader,serializationProperties,response);
}

Fixed version (ground truth):
protected void processHttpResponse(final Element httpResponse,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response) throws RestXqServiceException {
  final String strStatus=httpResponse.getAttribute(STATUS_ATTR_NAME);
  HttpStatus httpStatus=null;
  if (strStatus != null && !strStatus.isEmpty()) {
    final int status=Integer.parseInt(strStatus);
    try {
      httpStatus=HttpStatus.fromStatus(status);
    }
 catch (    final IllegalArgumentException iae) {
      throw new RestXqServiceException("String_Node_Str" + strStatus,iae);
    }
  }
  final String message=httpResponse.getAttribute(MESSAGE_ATTR_NAME);
  final String reason=(message == null || message.isEmpty()) ? httpResponse.getAttribute(REASON_ATTR_NAME) : message;
  if (httpStatus != null) {
    if (reason != null && !reason.isEmpty()) {
      response.setStatus(httpStatus,reason);
    }
 else {
      response.setStatus(httpStatus);
    }
  }
  final NodeList nlHttpHeader=httpResponse.getElementsByTagNameNS(HTTP_HEADER_ELEMENT_NAME.getNamespaceURI(),HTTP_HEADER_ELEMENT_NAME.getLocalPart());
  processHttpHeaders(nlHttpHeader,serializationProperties,response);
}
Program: 189695
Project: 189695
Buggy source:
/** 
 * Extract the HTTP Request Body Implementations are free to return a proxy which lazily extracts the request body if desired.
 * @param request The HTTP Request to extract the request body from
 * @return The Sequence of values extracted from the request body,typically a single item but possibly more for a multi-part request
 * @throws RestXqServiceException If an error occurred whilst processing the Request Body
 */
protected abstract Sequence extractRequestBody(final HttpRequest request) throws RestXqServiceException ;

Fixed version (ground truth):
/** 
 * Extract the HTTP Request Body Implementations are free to return a proxy which lazily extracts the request body if desired.
 * @param request The HTTP Request to extract the request body from
 * @return The Sequence of values extracted from the request body,typically a single item but possibly more for a multi-part request. If there is no request body, then Sequence.EMPTY_SEQUENCE should be returned.
 * @throws RestXqServiceException If an error occurred whilst processing the Request Body
 */
protected abstract Sequence extractRequestBody(final HttpRequest request) throws RestXqServiceException ;
Program: 189697
Project: 189697
Buggy source:
protected void processHttpResponse(final Element httpResponse,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response) throws RestXqServiceException {
  final String strStatus=httpResponse.getAttribute(STATUS_ATTR_NAME);
  HttpStatus httpStatus=null;
  if (strStatus != null && !strStatus.isEmpty()) {
    final int status=Integer.parseInt(strStatus);
    try {
      httpStatus=HttpStatus.fromStatus(status);
    }
 catch (    final IllegalArgumentException iae) {
      throw new RestXqServiceException("String_Node_Str" + strStatus,iae);
    }
  }
  final String reason=httpResponse.getAttribute(REASON_ATTR_NAME);
  if (httpStatus != null && (reason != null && !reason.isEmpty())) {
    response.setStatus(httpStatus,reason);
  }
 else {
    response.setStatus(httpStatus);
  }
  final NodeList nlHttpHeader=httpResponse.getElementsByTagNameNS(HTTP_HEADER_ELEMENT_NAME.getNamespaceURI(),HTTP_HEADER_ELEMENT_NAME.getLocalPart());
  processHttpHeaders(nlHttpHeader,serializationProperties,response);
}

Fixed version (ground truth):
protected void processHttpResponse(final Element httpResponse,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response) throws RestXqServiceException {
  final String strStatus=httpResponse.getAttribute(STATUS_ATTR_NAME);
  HttpStatus httpStatus=null;
  if (strStatus != null && !strStatus.isEmpty()) {
    final int status=Integer.parseInt(strStatus);
    try {
      httpStatus=HttpStatus.fromStatus(status);
    }
 catch (    final IllegalArgumentException iae) {
      throw new RestXqServiceException("String_Node_Str" + strStatus,iae);
    }
  }
  final String reason=httpResponse.getAttribute(REASON_ATTR_NAME);
  if (httpStatus != null) {
    if (reason != null && !reason.isEmpty()) {
      response.setStatus(httpStatus,reason);
    }
 else {
      response.setStatus(httpStatus);
    }
  }
  final NodeList nlHttpHeader=httpResponse.getElementsByTagNameNS(HTTP_HEADER_ELEMENT_NAME.getNamespaceURI(),HTTP_HEADER_ELEMENT_NAME.getLocalPart());
  processHttpHeaders(nlHttpHeader,serializationProperties,response);
}
Program: 189698
Project: 189698
Buggy source:
@Override public boolean matchesMediaType(final HttpRequest request){
  final String acceptHeader=request.getHeader(HttpHeaderName.Accept.toString());
  if (acceptHeader.indexOf(ANY_MEDIA_TYPE) > -1) {
    return true;
  }
  Matcher mtcProducesContentType=null;
  final String accepts[]=acceptHeader.split("String_Node_Str");
  for (  String accept : accepts) {
    accept=accept.toLowerCase();
    accept=accept.replaceAll("String_Node_Str","String_Node_Str");
    final int idxExt=accept.indexOf("String_Node_Str");
    if (idxExt > -1) {
      accept=accept.substring(0,idxExt);
    }
    accept=accept.replaceFirst(InternetMediaType.subtypeSeparator + "String_Node_Str",InternetMediaType.subtypeSeparator + "String_Node_Str");
    if (mtcProducesContentType == null) {
      mtcProducesContentType=getMediaTypesPatternMatcher().matcher(accept);
    }
 else {
      mtcProducesContentType=mtcProducesContentType.reset(accept);
    }
    if (mtcProducesContentType.matches()) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean matchesMediaType(final HttpRequest request){
  final String acceptHeader=request.getHeader(HttpHeaderName.Accept.toString());
  if (acceptHeader.equals(org.exquery.InternetMediaType.ANY.getMediaType())) {
    return true;
  }
  Matcher mtcProducesContentType=null;
  final String accepts[]=acceptHeader.split("String_Node_Str");
  for (  String accept : accepts) {
    accept=accept.toLowerCase();
    accept=accept.replaceAll("String_Node_Str","String_Node_Str");
    final int idxExt=accept.indexOf("String_Node_Str");
    if (idxExt > -1) {
      accept=accept.substring(0,idxExt);
    }
    accept=accept.replaceFirst(InternetMediaType.subtypeSeparator + "String_Node_Str",InternetMediaType.subtypeSeparator + "String_Node_Str");
    if (mtcProducesContentType == null) {
      mtcProducesContentType=getMediaTypesPatternMatcher().matcher(accept);
    }
 else {
      mtcProducesContentType=mtcProducesContentType.reset(accept);
    }
    if (mtcProducesContentType.matches()) {
      return true;
    }
  }
  return false;
}
Program: 189699
Project: 189699
Buggy source:
protected void processHttpHeaders(final NodeList nlHttpHeader,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response){
  for (int i=0; i < nlHttpHeader.getLength(); i++) {
    final Element elemHeader=(Element)nlHttpHeader.item(i);
    final String name=elemHeader.getAttribute(NAME_ATTR_NAME);
    final String value=elemHeader.getAttribute(VALUE_ATTR_NAME);
    response.setHeader(name,value);
  }
}

Fixed version (ground truth):
protected void processHttpHeaders(final NodeList nlHttpHeader,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response){
  for (int i=0; i < nlHttpHeader.getLength(); i++) {
    final Element elemHeader=(Element)nlHttpHeader.item(i);
    final String name=elemHeader.getAttribute(NAME_ATTR_NAME);
    final String value=elemHeader.getAttribute(VALUE_ATTR_NAME);
    if (name.equals(HttpHeader.CONTENT_TYPE.getHeaderName())) {
      serializationProperties.put(SerializationProperty.CONTENT_TYPE,value);
    }
    response.setHeader(name,value);
  }
}
Program: 189700
Project: 189700
Buggy source:
protected void processHttpHeaders(final NodeList nlHttpHeader,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response){
  for (int i=0; i < nlHttpHeader.getLength(); i++) {
    final Element elemHeader=(Element)nlHttpHeader.item(i);
    final String name=elemHeader.getAttribute(NAME_ATTR_NAME);
    final String value=elemHeader.getAttribute(VALUE_ATTR_NAME);
    if (name.equals(HttpHeader.CONTENT_TYPE.getHeaderName())) {
      serializationProperties.put(SerializationProperty.CONTENT_TYPE,value);
    }
    response.setHeader(name,value);
  }
}

Fixed version (ground truth):
protected void processHttpHeaders(final NodeList nlHttpHeader,final Map<SerializationProperty,String> serializationProperties,final HttpResponse response){
  for (int i=0; i < nlHttpHeader.getLength(); i++) {
    final Element elemHeader=(Element)nlHttpHeader.item(i);
    final String name=elemHeader.getAttribute(NAME_ATTR_NAME);
    final String value=elemHeader.getAttribute(VALUE_ATTR_NAME);
    if (name.equals(HttpHeader.CONTENT_TYPE.getHeaderName())) {
      serializationProperties.put(SerializationProperty.MEDIA_TYPE,value);
    }
    response.setHeader(name,value);
  }
}
Program: 189701
Project: 189701
Buggy source:
private ParameterAnnotationMapping parseAnnotationLiterals(final Literal parameterName,final Literal functionArgumentName,final Literal[] defaultValueLiterals) throws RestAnnotationException {
  final Cardinality requiredCardinality;
  if (defaultValueLiterals.length == 0) {
    requiredCardinality=Cardinality.ZERO_OR_MORE;
  }
 else {
    requiredCardinality=Cardinality.ONE_OR_MORE;
  }
  final ParameterAnnotationMapping mapping=super.parseAnnotationLiterals(parameterName,functionArgumentName,requiredCardinality);
  if (defaultValueLiterals.length > 0) {
    final Type requiredType;
    if (haveConsistentType(defaultValueLiterals)) {
      requiredType=defaultValueLiterals[0].getType();
    }
 else {
      requiredType=Type.ANY_SIMPLE_TYPE;
    }
    checkFnDeclaresParameterWithType(getFunctionSignature(),mapping.getParameterName(),requiredType,getInvalidDefaultValueTypeErr());
  }
  return new ParameterAnnotationMapping(mapping.getParameterName(),mapping.getFunctionArgumentName(),defaultValueLiterals);
}

Fixed version (ground truth):
private ParameterAnnotationMapping parseAnnotationLiterals(final Literal parameterName,final Literal functionArgumentName,final Literal[] defaultValueLiterals) throws RestAnnotationException {
  final Cardinality requiredCardinality;
  if (defaultValueLiterals.length == 0) {
    requiredCardinality=Cardinality.ZERO_OR_MORE;
  }
 else {
    requiredCardinality=Cardinality.ONE_OR_MORE;
  }
  final ParameterAnnotationMapping mapping=super.parseAnnotationLiterals(parameterName,functionArgumentName,requiredCardinality);
  if (defaultValueLiterals.length > 0) {
    final Type requiredType;
    if (haveConsistentType(defaultValueLiterals)) {
      requiredType=defaultValueLiterals[0].getType();
    }
 else {
      requiredType=Type.ANY_SIMPLE_TYPE;
    }
    checkFnDeclaresParameterWithType(getFunctionSignature(),mapping.getFunctionArgumentName(),requiredType,getInvalidDefaultValueTypeErr());
  }
  return new ParameterAnnotationMapping(mapping.getParameterName(),mapping.getFunctionArgumentName(),defaultValueLiterals);
}
Program: 189702
Project: 189702
Buggy source:
/** 
 * Gets the names of HTTP Header in the HTTP Request
 * @return The set of HTTP Header names
 */
public Set<String> getHeaderNames();

Fixed version (ground truth):
/** 
 * Gets the names of HTTP Header in the HTTP Request
 * @return The list of HTTP Header names
 */
public List<String> getHeaderNames();
Program: 189703
Project: 189703
Buggy source:
/** 
 * Get the names of parameters available in the request
 * @return the set of parameter names in the request
 */
public Set<String> getParameterNames();

Fixed version (ground truth):
/** 
 * Get the names of parameters available in the request
 * @return the list of parameter names in the request
 */
public List<String> getParameterNames();
Program: 189704
Project: 189704
Buggy source:
@Test public void singleWildcardMediaRange(){
  final String any=ANY.getMediaType();
  final AcceptHeader acceptHeader=new AcceptHeader(any);
  assertEquals(1,acceptHeader.getAccepts().size());
  assertEquals(ANY,acceptHeader.getAccepts().get(0).getMediaRange());
}

Fixed version (ground truth):
@Test public void singleWildcardMediaRange(){
  final String any=ANY.getMediaType();
  final AcceptHeader acceptHeader=new AcceptHeader(any);
  assertEquals(1,acceptHeader.getAccepts().size());
  assertEquals(any,acceptHeader.getAccepts().get(0).getMediaRange());
}
Program: 189705
Project: 189705
Buggy source:
/** 
 * Serialize to the body of the HTTP Response
 * @param result
 * @param response
 * @param serializationProperties
 * @throws RestXqServiceException  
 */
protected void serializeBody(final Sequence result,final HttpResponse response,final Map<SerializationProperty,String> serializationProperties) throws RestXqServiceException {
  SupportedMethod method=null;
  final String mediaType=serializationProperties.get(SerializationProperty.MEDIA_TYPE);
  if (mediaType != null && !mediaType.isEmpty()) {
    response.setContentType(mediaType);
  }
  if (method != null && method.equals(SupportedMethod.binary)) {
    serializeBinaryBody(result,response);
  }
 else {
    serializeNodeBody(result,response,serializationProperties);
  }
}

Fixed version (ground truth):
/** 
 * Serialize to the body of the HTTP Response
 * @param result
 * @param response
 * @param serializationProperties
 * @throws RestXqServiceException  
 */
protected void serializeBody(final Sequence result,final HttpResponse response,final Map<SerializationProperty,String> serializationProperties) throws RestXqServiceException {
  SupportedMethod method=null;
  try {
    final String methodProp=serializationProperties.get(SerializationProperty.METHOD);
    method=(methodProp == null ? SupportedMethod.xml : SupportedMethod.valueOf(methodProp));
  }
 catch (  final IllegalArgumentException iae) {
    System.out.println(iae.getMessage());
  }
  final String mediaType=serializationProperties.get(SerializationProperty.MEDIA_TYPE);
  if (mediaType != null && !mediaType.isEmpty()) {
    response.setContentType(mediaType);
  }
  if (method != null && method.equals(SupportedMethod.binary)) {
    serializeBinaryBody(result,response);
  }
 else {
    serializeNodeBody(result,response,serializationProperties);
  }
}
Program: 189707
Project: 189707
Buggy source:
@Override public String getValue(){
  return JSON_MEDIATYPE;
}

Fixed version (ground truth):
@Override public String getValue(){
  return OOXML_MEDIATYPE;
}
Program: 189708
Project: 189708
Buggy source:
@Override public Sequence getTypedValue(){
  return new SequenceImpl(typedArgumentValue.getTypedValue());
}

Fixed version (ground truth):
@Override public Sequence getTypedValue(){
  return typedArgumentValue.getTypedValue();
}
Program: 189710
Project: 189710
Buggy source:
@Override public Sequence getTypedValue(){
  final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
  if (formParam == null) {
    final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
    return literalsToSequence(defaultLiterals);
  }
  if (formParam instanceof String) {
    return new SequenceImpl(new StringTypedValue((String)formParam));
  }
  if (formParam instanceof InputStream) {
    return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
  }
  return null;
}

Fixed version (ground truth):
@Override public Sequence getTypedValue(){
  final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
  if (formParam == null) {
    final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
    return literalsToSequence(defaultLiterals);
  }
  if (formParam instanceof String) {
    return new SequenceImpl(new StringTypedValue((String)formParam));
  }
 else   if (formParam instanceof List) {
    final List<String> formFieldValues=(List<String>)formParam;
    return collectionToSequence(formFieldValues);
  }
 else   if (formParam instanceof InputStream) {
    return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
  }
  return null;
}
Program: 189711
Project: 189711
Buggy source:
/** 
 * @see AbstractParameterAnnotation#extractParameter(org.exquery.http.HttpRequest)
 */
@Override public TypedArgumentValue extractParameter(final HttpRequest request){
  return new TypedArgumentValue(){
    @Override public String getArgumentName(){
      return getParameterAnnotationMapping().getFunctionArgumentName();
    }
    @Override public Sequence getTypedValue(){
      final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
      if (formParam == null) {
        final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
        return literalsToSequence(defaultLiterals);
      }
      if (formParam instanceof String) {
        return new SequenceImpl(new StringTypedValue((String)formParam));
      }
      if (formParam instanceof InputStream) {
        return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
      }
      return null;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * @see AbstractParameterAnnotation#extractParameter(org.exquery.http.HttpRequest)
 */
@Override public TypedArgumentValue extractParameter(final HttpRequest request){
  return new TypedArgumentValue(){
    @Override public String getArgumentName(){
      return getParameterAnnotationMapping().getFunctionArgumentName();
    }
    @Override public Sequence getTypedValue(){
      final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
      if (formParam == null) {
        final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
        return literalsToSequence(defaultLiterals);
      }
      if (formParam instanceof String) {
        return new SequenceImpl(new StringTypedValue((String)formParam));
      }
 else       if (formParam instanceof List) {
        final List<String> formFieldValues=(List<String>)formParam;
        return collectionToSequence(formFieldValues);
      }
 else       if (formParam instanceof InputStream) {
        return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
      }
      return null;
    }
  }
;
}
Program: 189712
Project: 189712
Buggy source:
@Override public Sequence<String> getTypedValue(){
  final Object queryParam=request.getQueryParam(getParameterAnnotationMapping().getParameterName());
  if (queryParam == null) {
    final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
    if (defaultLiterals.length > 0) {
      return literalsToSequence(defaultLiterals);
    }
 else {
      return Sequence.EMPTY_SEQUENCE;
    }
  }
 else   if (queryParam instanceof String) {
    return new SequenceImpl<String>(new StringTypedValue((String)queryParam));
  }
  return null;
}

Fixed version (ground truth):
@Override public Sequence<String> getTypedValue(){
  final Object queryParam=request.getQueryParam(getParameterAnnotationMapping().getParameterName());
  if (queryParam == null) {
    final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
    if (defaultLiterals.length > 0) {
      return literalsToSequence(defaultLiterals);
    }
 else {
      return Sequence.EMPTY_SEQUENCE;
    }
  }
 else   if (queryParam instanceof String) {
    return new SequenceImpl<String>(new StringTypedValue((String)queryParam));
  }
 else   if (queryParam instanceof List) {
    final List<String> queryParamValues=(List<String>)queryParam;
    return collectionToSequence(queryParamValues);
  }
  return null;
}
Program: 189713
Project: 189713
Buggy source:
/** 
 * @see AbstractParameterAnnotation#extractParameter(org.exquery.http.HttpRequest)
 */
@Override public TypedArgumentValue<String> extractParameter(final HttpRequest request){
  return new TypedArgumentValue<String>(){
    @Override public String getArgumentName(){
      return getParameterAnnotationMapping().getFunctionArgumentName();
    }
    @Override public Sequence<String> getTypedValue(){
      final Object queryParam=request.getQueryParam(getParameterAnnotationMapping().getParameterName());
      if (queryParam == null) {
        final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
        if (defaultLiterals.length > 0) {
          return literalsToSequence(defaultLiterals);
        }
 else {
          return Sequence.EMPTY_SEQUENCE;
        }
      }
 else       if (queryParam instanceof String) {
        return new SequenceImpl<String>(new StringTypedValue((String)queryParam));
      }
      return null;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * @see AbstractParameterAnnotation#extractParameter(org.exquery.http.HttpRequest)
 */
@Override public TypedArgumentValue<String> extractParameter(final HttpRequest request){
  return new TypedArgumentValue<String>(){
    @Override public String getArgumentName(){
      return getParameterAnnotationMapping().getFunctionArgumentName();
    }
    @Override public Sequence<String> getTypedValue(){
      final Object queryParam=request.getQueryParam(getParameterAnnotationMapping().getParameterName());
      if (queryParam == null) {
        final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
        if (defaultLiterals.length > 0) {
          return literalsToSequence(defaultLiterals);
        }
 else {
          return Sequence.EMPTY_SEQUENCE;
        }
      }
 else       if (queryParam instanceof String) {
        return new SequenceImpl<String>(new StringTypedValue((String)queryParam));
      }
 else       if (queryParam instanceof List) {
        final List<String> queryParamValues=(List<String>)queryParam;
        return collectionToSequence(queryParamValues);
      }
      return null;
    }
  }
;
}
Program: 189714
Project: 189714
Buggy source:
/** 
 * Checks that a function declares a named argument with a specific compatible type
 * @param functionSignature The function signature to check for the named argument with compatible type
 * @param fnArgumentName The name of the argument to check the function signature for
 * @param requiredArgumentType The required type of the argument to check the function signature for
 * @param errorCode An error code to return in the exception of the required type could not be found
 * @throws RestAnnotationException If the named argument with a compatible required type is not declared by the function signature
 */
protected void checkFnDeclaresParameterWithType(final FunctionSignature functionSignature,final String fnArgumentName,final Type requiredArgumentType,final RestXqErrorCode errorCode) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  boolean found=false;
  for (  final FunctionArgument fnArgument : fnArguments) {
    if (fnArgument.getName().equals(fnArgumentName)) {
      if (!fnArgument.getType().isSubTypeOf(requiredArgumentType)) {
        throw new RestAnnotationException(errorCode);
      }
      found=true;
      break;
    }
  }
  if (!found) {
    throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
  }
}

Fixed version (ground truth):
/** 
 * Checks that a function declares a named argument with a specific compatible type
 * @param functionSignature The function signature to check for the named argument with compatible type
 * @param fnArgumentName The name of the argument to check the function signature for
 * @param requiredArgumentType The required type of the argument to check the function signature for
 * @param errorCode An error code to return in the exception of the required type could not be found
 * @throws RestAnnotationException If the named argument with a compatible required type is not declared by the function signature
 */
protected void checkFnDeclaresParameterWithType(final FunctionSignature functionSignature,final String fnArgumentName,final Type requiredArgumentType,final RestXqErrorCode errorCode) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  boolean found=false;
  for (  final FunctionArgument fnArgument : fnArguments) {
    if (fnArgument.getName().equals(fnArgumentName)) {
      if (!hasCompatibleType(fnArgument.getType(),requiredArgumentType)) {
        throw new RestAnnotationException(errorCode);
      }
      found=true;
      break;
    }
  }
  if (!found) {
    throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
  }
}
Program: 189715
Project: 189715
Buggy source:
protected void checkFnDeclaresParameters(final FunctionSignature functionSignature,final List<String> fnArgumentNames,final Cardinality requiredCardinality) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  for (  final String fnArgumentName : fnArgumentNames) {
    boolean found=false;
    for (    final FunctionArgument fnArgument : fnArguments) {
      if (fnArgument.getName().equals(fnArgumentName)) {
        if (!fnArgument.getCardinality().hasRequiredCardinality(requiredCardinality)) {
          throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
        }
        if (!(fnArgument.getType().hasSubType(getRequiredFunctionParameterType()) | getRequiredFunctionParameterType().hasSubType(fnArgument.getType()))) {
          throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
        }
        found=true;
        break;
      }
    }
    if (!found) {
      throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
    }
  }
}

Fixed version (ground truth):
protected void checkFnDeclaresParameters(final FunctionSignature functionSignature,final List<String> fnArgumentNames,final Cardinality requiredCardinality) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  for (  final String fnArgumentName : fnArgumentNames) {
    boolean found=false;
    for (    final FunctionArgument fnArgument : fnArguments) {
      if (fnArgument.getName().equals(fnArgumentName)) {
        if (!fnArgument.getCardinality().hasRequiredCardinality(requiredCardinality)) {
          throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
        }
        if (!hasCompatibleType(fnArgument.getType(),getRequiredFunctionParameterType())) {
          throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
        }
        found=true;
        break;
      }
    }
    if (!found) {
      throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
    }
  }
}
Program: 189716
Project: 189716
Buggy source:
protected abstract RestXqErrorCode getInvalidMediaTypeLiteralErr();

Fixed version (ground truth):
/** 
 * Get the Error Code to use when the Annotation has an invalid Media Type literal
 * @return The error code
 */
protected abstract RestXqErrorCode getInvalidMediaTypeLiteralErr();
Program: 189717
Project: 189717
Buggy source:
protected abstract RestXqErrorCode getEmptyAnnotationParamsErr();

Fixed version (ground truth):
/** 
 * Get the Error Code to use when the Annotation Parameters are Empty
 * @return The error code
 */
protected abstract RestXqErrorCode getEmptyAnnotationParamsErr();
Program: 189718
Project: 189718
Buggy source:
protected abstract RestXqErrorCode getInvalidMediaTypeErr();

Fixed version (ground truth):
/** 
 * Get the Error Code to use when the Annotation has an invalid Media Type
 * @return The error code
 */
protected abstract RestXqErrorCode getInvalidMediaTypeErr();
Program: 189721
Project: 189721
Buggy source:
/** 
 * Sorts the Services into Path Specificity descending order That is to say that the resultant sorted list should have the most specific URI's at the top! 
 * @param other Another Service
 */
@Override public int compareTo(final RestXqService other){
  if (other == null || !(other instanceof RestXqService)) {
    return 1;
  }
  return getResourceFunction().getPathAnnotation().getPathSpecificityMetric() - ((RestXqService)other).getResourceFunction().getPathAnnotation().getPathSpecificityMetric();
}

Fixed version (ground truth):
/** 
 * Sorts the Services into Path Specificity descending order That is to say that the resultant sorted list should have the most specific URI's at the top! 
 * @param other Another Service
 */
@Override public int compareTo(final RestXqService other){
  if (other == null || !(other instanceof RestXqService)) {
    return 1;
  }
  long result=getResourceFunction().getPathAnnotation().getPathSpecificityMetric() - ((RestXqService)other).getResourceFunction().getPathAnnotation().getPathSpecificityMetric();
  if (result > 0) {
    return 1;
  }
 else   if (result < 0) {
    return -1;
  }
 else {
    return 0;
  }
}
Program: 189722
Project: 189722
Buggy source:
/** 
 * Parses the Parameter Annotation Value
 * @return The Parameter to Argument Mapping described by the Parameter Annotation
 * @throws RestAnnotationException if the Parameter annotations mapping is invalid
 */
protected ParameterAnnotationMapping parseAnnotationValue() throws RestAnnotationException {
  final Literal[] annotationLiterals=getLiterals();
  if (canProvideDefaultValue()) {
    if (annotationLiterals.length < 2 || annotationLiterals.length > 3) {
      throw new RestAnnotationException(getInvalidAnnotationParamsErr());
    }
  }
 else {
    if (annotationLiterals.length != 2) {
      throw new RestAnnotationException(getInvalidAnnotationParamsErr());
    }
  }
  return parseAnnotationLiterals(annotationLiterals[0],annotationLiterals[1],annotationLiterals.length == 3 ? annotationLiterals[2] : null);
}

Fixed version (ground truth):
/** 
 * Parses the Parameter Annotation Value
 * @return The Parameter to Argument Mapping described by the Parameter Annotation
 * @throws RestAnnotationException if the Parameter annotations mapping is invalid
 */
protected ParameterAnnotationMapping parseAnnotationValue() throws RestAnnotationException {
  final Literal[] annotationLiterals=getLiterals();
  if (annotationLiterals.length != 2) {
    throw new RestAnnotationException(getInvalidAnnotationParamsErr());
  }
  return parseAnnotationLiterals(annotationLiterals[0],annotationLiterals[1],Cardinality.ZERO_OR_MORE);
}
Program: 189724
Project: 189724
Buggy source:
/** 
 * Checks that a function declares a named argument
 * @param functionSignature The function signature to check for the named argument
 * @param fnArgumentName The name of the argument to check the function signature for
 * @throws RestAnnotationException If the function arguments are not compatible with the function signature
 */
protected void checkFnDeclaresParameter(final FunctionSignature functionSignature,final String fnArgumentName) throws RestAnnotationException {
  final List<String> fnParamNames=new ArrayList<String>(1);
  fnParamNames.add(fnArgumentName);
  checkFnDeclaresParameters(functionSignature,fnParamNames);
}

Fixed version (ground truth):
protected void checkFnDeclaresParameter(final FunctionSignature functionSignature,final String fnArgumentName,final Cardinality requiredCardinality) throws RestAnnotationException {
  final List<String> fnParamNames=new ArrayList<String>(1);
  fnParamNames.add(fnArgumentName);
  checkFnDeclaresParameters(functionSignature,fnParamNames,requiredCardinality);
}
Program: 189725
Project: 189725
Buggy source:
/** 
 * Checks that a function has parameters which are compatible with those declared by an annotation on that function
 * @param functionSignature The function signature to check for declared parameters
 * @param fnArgumentNames The Function arguments to check against the function signature
 * @throws RestAnnotationException If the function arguments are not compatible with the function signature
 */
protected void checkFnDeclaresParameters(final FunctionSignature functionSignature,final List<String> fnArgumentNames) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  for (  final String fnArgumentName : fnArgumentNames) {
    boolean found=false;
    for (    final FunctionArgument fnArgument : fnArguments) {
      if (fnArgument.getName().equals(fnArgumentName)) {
        if (!fnArgument.getCardinality().hasRequiredCardinality(getRequiredFunctionParameterCardinality())) {
          throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
        }
        if (!(fnArgument.getType().hasSubType(getRequiredFunctionParameterType()) | getRequiredFunctionParameterType().hasSubType(fnArgument.getType()))) {
          throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
        }
        found=true;
        break;
      }
    }
    if (!found) {
      throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
    }
  }
}

Fixed version (ground truth):
protected void checkFnDeclaresParameters(final FunctionSignature functionSignature,final List<String> fnArgumentNames,final Cardinality requiredCardinality) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  for (  final String fnArgumentName : fnArgumentNames) {
    boolean found=false;
    for (    final FunctionArgument fnArgument : fnArguments) {
      if (fnArgument.getName().equals(fnArgumentName)) {
        if (!fnArgument.getCardinality().hasRequiredCardinality(requiredCardinality)) {
          throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
        }
        if (!(fnArgument.getType().hasSubType(getRequiredFunctionParameterType()) | getRequiredFunctionParameterType().hasSubType(fnArgument.getType()))) {
          throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
        }
        found=true;
        break;
      }
    }
    if (!found) {
      throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
    }
  }
}
Program: 189726
Project: 189726
Buggy source:
@Override public Sequence getTypedValue(){
  final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
  if (formParam == null) {
    final Literal defaultLiteral=getParameterAnnotationMapping().getDefaultValue();
    return new SequenceImpl(new StringTypedValue(defaultLiteral.getValue()));
  }
  if (formParam instanceof String) {
    return new SequenceImpl(new StringTypedValue((String)formParam));
  }
  if (formParam instanceof InputStream) {
    return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
  }
  return null;
}

Fixed version (ground truth):
@Override public Sequence getTypedValue(){
  final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
  if (formParam == null) {
    final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
    return literalsToSequence(defaultLiterals);
  }
  if (formParam instanceof String) {
    return new SequenceImpl(new StringTypedValue((String)formParam));
  }
  if (formParam instanceof InputStream) {
    return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
  }
  return null;
}
Program: 189727
Project: 189727
Buggy source:
/** 
 * @see AbstractParameterAnnotation#extractParameter(org.exquery.http.HttpRequest)
 */
@Override public TypedArgumentValue extractParameter(final HttpRequest request){
  return new TypedArgumentValue(){
    @Override public String getArgumentName(){
      return getParameterAnnotationMapping().getFunctionArgumentName();
    }
    @Override public Sequence getTypedValue(){
      final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
      if (formParam == null) {
        final Literal defaultLiteral=getParameterAnnotationMapping().getDefaultValue();
        return new SequenceImpl(new StringTypedValue(defaultLiteral.getValue()));
      }
      if (formParam instanceof String) {
        return new SequenceImpl(new StringTypedValue((String)formParam));
      }
      if (formParam instanceof InputStream) {
        return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
      }
      return null;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * @see AbstractParameterAnnotation#extractParameter(org.exquery.http.HttpRequest)
 */
@Override public TypedArgumentValue extractParameter(final HttpRequest request){
  return new TypedArgumentValue(){
    @Override public String getArgumentName(){
      return getParameterAnnotationMapping().getFunctionArgumentName();
    }
    @Override public Sequence getTypedValue(){
      final Object formParam=request.getFormParam(getParameterAnnotationMapping().getParameterName());
      if (formParam == null) {
        final Literal defaultLiterals[]=getParameterAnnotationMapping().getDefaultValues();
        return literalsToSequence(defaultLiterals);
      }
      if (formParam instanceof String) {
        return new SequenceImpl(new StringTypedValue((String)formParam));
      }
      if (formParam instanceof InputStream) {
        return new SequenceImpl<InputStream>(new Base64BinaryTypedValue((InputStream)formParam));
      }
      return null;
    }
  }
;
}