for (InformacionPagareServiceDTO aux : res_pon.getListaRespuesta()) {
String pattern_dic = "{\"Estdo\":\"%s\", \"Fecha Firma\":\"%s\", \"Fecha Grabacion\": \"%s\", \"ID Pagare\": \"%s\",\"Nombre Otorgante\": \"%s\",\"Tipo documento Otorgante\": \"%s\",\"Documento Otorgante\": \"%s\",\"Numero Pagare Entidad\": \"%s\",\"Pdf Pagare Nom\": \"%s\",\"Pdf Pagare Cont\": \"%s\"}";
if (aux.getPdfPagare() == null) {
if(dic_txt.equals("")) {
dic_txt = String.format(pattern_dic, aux.getEstadoPagare(), aux.getFechaFirmaPagare(), aux.getFechaGrabacionPagare(), aux.getIdPagareDeceval(), aux.getNombreOtorgante(), aux.getTipoDocumentoOtorgante(), aux.getNumeroDocumentoOtorgante(), aux.getNumPagareEntidad(), aux.getPdfPagare(), aux.getPdfPagare());
}else {
dic_txt += ","+String.format(pattern_dic, aux.getEstadoPagare(), aux.getFechaFirmaPagare(), aux.getFechaGrabacionPagare(), aux.getIdPagareDeceval(), aux.getNombreOtorgante(), aux.getTipoDocumentoOtorgante(), aux.getNumeroDocumentoOtorgante(), aux.getNumPagareEntidad(), aux.getPdfPagare(), aux.getPdfPagare());
}
}else {
if(dic_txt.equals("")) {
dic_txt = String.format(pattern_dic, aux.getEstadoPagare(), aux.getFechaFirmaPagare(), aux.getFechaGrabacionPagare(), aux.getIdPagareDeceval(), aux.getNombreOtorgante(), aux.getTipoDocumentoOtorgante(), aux.getNumeroDocumentoOtorgante(), aux.getNumPagareEntidad(), aux.getPdfPagare().getNombreArchivo(), aux.getPdfPagare().getContenido());
}else {
dic_txt += ","+String.format(pattern_dic, aux.getEstadoPagare(), aux.getFechaFirmaPagare(), aux.getFechaGrabacionPagare(), aux.getIdPagareDeceval(), aux.getNombreOtorgante(), aux.getTipoDocumentoOtorgante(), aux.getNumeroDocumentoOtorgante(), aux.getNumPagareEntidad(), aux.getPdfPagare().getNombreArchivo(), aux.getPdfPagare().getContenido());
}
}
}
Holy Shit
final boolean True = true;
final boolean False = false;
//why
:v
public static int maximum(int f, int g)
{
try
{
int[] far = new int[f];
far[g] = 1;
return f;
}
catch(NegativeArraySizeException e)
{
f = -f;
g = -g;
return (-maximum(f, g) == -f)? -g : -f;
}
catch(IndexOutOfBoundsException e)
{
return (maximum(g, 0) == 0)? f : g;
}
}
@Override
public ResponseEntity<AuditLogPagedResults> getLogEntries(
@ApiParam(value = "Environment ID", required = true) @PathVariable("environmentId") Long environmentId,
@ApiParam(value = "ID of the queue manager to browse") @Valid @RequestParam(value = "queueManager", required = false) Long queueManager,
@ApiParam(value = "ID of the queue to browse") @Valid @RequestParam(value = "queue", required = false) Long queue,
@ApiParam(value = "Browse for messages newer than a date/time") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @RequestParam(value = "from", required = false) @Valid LocalDateTime from,
@ApiParam(value = "Correlation ID to browse for") @Valid @RequestParam(value = "correlationId", required = false) String correlationId,
@ApiParam(value = "Page of results to return") @Valid @RequestParam(value = "page", required = false) Integer page,
@ApiParam(value = "Number of results in a page") @Valid @RequestParam(value = "pagesize", required = false) Integer pagesize) {
Pageable pageable = PageRequest.of(page != null ? page : 0, pagesize != null ? pagesize : defaultPageSize, new Sort(Sort.Direction.DESC, Audit.MSG_PUT_TIMESTAMP_FIELD));
Page<Audit> auditEntries = null;
Timestamp msgPut = (from != null ? Timestamp.valueOf(from) : null);
/*
* Environemnt is always supplied. If we have queue or queue manager, assume that's what the caller wants.
* We may also have some optional parameters - put timestamp, correlation ID
*/
if (queue != null) {
//retrieve queue name
String queueName = null;
Optional<WMQQueue> queueEntity = wmqQueueRepository.findById(queue.intValue());
queueName = queueEntity.get().getQ_name();
//see if we have timestamp or correlation ID
if (msgPut != null) {
if (correlationId != null) {
auditEntries = auditRepository.findByQNameAndCorrelIdAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, correlationId, pageable);
} else {
auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
}
} else {
if (correlationId != null) {
auditEntries = auditRepository.findByQNameAndCorrelId(queueName, correlationId, pageable);
} else {
auditEntries = auditRepository.findByQName(queueName, pageable);
}
}
} else if (queueManager != null) {
List<Integer> managerIds = Arrays.asList(queueManager.intValue());
//see if we have timestamp or correlation ID
if (msgPut != null) {
if (correlationId != null) {
auditEntries = auditRepository.findByManagerIdsAndCorrelIdAndMsgPutTimestampGreaterThanEqual(managerIds, msgPut, correlationId, pageable);
} else {
auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
}
} else {
if (correlationId != null) {
auditEntries = auditRepository.findByManagerIdsAndCorrelId(managerIds, correlationId, pageable);
} else {
auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
}
}
throw new java.lang.UnsupportedOperationException("Implementations does not exist");
} else {
List<Integer> managerIds = findManagerIds(environmentId);
if(managerIds.isEmpty()) {
//No QueueManager so no possible log entries
return ResponseEntity.ok().body(null);
}
if (msgPut != null) {
auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
} else {
auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
}
}
/*
if (correlationId != null && msgPut != null) {
auditEntries = auditRepository.findByCorrelIdAndMsgPutTimestampGreaterThanEqual(correlationId, msgPut, pageable);
} else if (queueName != null && msgPut != null) {
auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
} else if (queueName != null) {
auditEntries = auditRepository.findByQName(queueName, pageable);
} else if (correlationId != null) {
auditEntries = auditRepository.findByCorrelId(correlationId, pageable);
} else {
List<Integer> managerIds = findManagerIds(environmentId);
if(managerIds.isEmpty()) {
//No QueueManager so no possible log entries
return ResponseEntity.ok().body(null);
}
if (msgPut != null) {
auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
} else {
auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
}
}
*/
if (auditEntries != null) {
AuditLogPagedResults results = new AuditLogPagedResults();
results.setPageNumber(pageable.getPageNumber());
results.setPageSize(pageable.getPageSize());
results.setPages(auditEntries.getTotalPages());
results.setResults(mapperFacade.mapAsList(auditEntries.getContent(), AuditLogEntry.class));
return ResponseEntity.ok().body(results);
} else {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
}
}
/* (non-Javadoc)
* @see com.arcelormittal.springTemplate.web.MessagesApi#getLogEntry(java.lang.Long, java.lang.Long)
*/
@Override
public ResponseEntity<AuditLogEntry> getLogEntry(Long environmentId, Long logId) {
Optional<Audit> entry = auditRepository.findById(logId);
if (entry.isPresent()) {
return ResponseEntity.ok().body(mapperFacade.map(entry.get(), AuditLogEntry.class));
} else {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
}
}
End pint to do a dynamic query in JPA.
import java.util.Scanner;
public class ConnectFour
{
public static void main(String [] args) {
Scanner scan;
scan = new Scanner(System.in);
boolean win = false;
boolean oneone = false;
boolean onetwo = false;
boolean onethree = false;
boolean onefour = false;
boolean onefive = false;
boolean onesix = false;
boolean oneseven = false;
boolean twoone = false;
boolean twotwo = false;
boolean twothree = false;
boolean twofour = false;
boolean twofive = false;
boolean twosix = false;
boolean twoseven = false;
boolean threeone = false;
boolean threetwo = false;
boolean threethree = false;
boolean threefour = false;
boolean threefive = false;
boolean threesix = false;
boolean threeseven = false;
boolean fourone = false;
boolean fourtwo = false;
boolean fourthree = false;
boolean fourfour = false;
boolean fourfive = false;
boolean foursix = false;
boolean fourseven = false;
boolean fiveone = false;
boolean fivetwo = false;
boolean fivethree = false;
boolean fivefour = false;
boolean fivefive = false;
boolean fivesix = false;
boolean fiveseven = false;
boolean sixone = false;
boolean sixtwo = false;
boolean sixthree = false;
boolean sixfour = false;
boolean sixfive = false;
boolean sixsix = false;
boolean sixseven = false;
if(win = false) {
if(oneone = true) {
if(onetwo = true) {
if(onethree = true) {
if(onefour = true) {
winner = true;
}
}
}
else if(twotwo = true) {
if(threethree = true) {
if(fourfour = true) {
winner = true;
}
}
}
else if(twoone = true) {
if(threeone = true) {
if(fourone = true) {
winner = true;
}
}
}
}
if(onetwo = true) {
if(oneone = true) {
if(onethree = true) {
if(onefour = true) {
winner = true;
}
}
}
if(onethree = true) {
if(onefour = true) {
if(onefive = true) {
winner = true;
}
}
}
if(twothree = true) {
if(threefour = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(threetwo = true) {
if(fourtwo = true) {
winner = true;
}
}
}
}
if(onethree = true) {
if(oneone = true) {
if(onetwo = true) {
if(onefour = true) {
winner = true;
}
}
}
if(onetwo = true) {
if(onefour = true) {
if(onefive = true) {
winner = true;
}
}
}
if(onefour = true) {
if(onefive = true) {
if(onesix = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(twothree = true) {
if(threethree = true) {
if(fourthree = true) {
winner = true;
}
}
}
}
if(onefour = true) {
if(oneone = true) {
if(onetwo = true) {
if(onethree = true) {
winner = true;
}
}
}
if(onetwo = true) {
if(onethree = true) {
if(onefive = true) {
winner = true;
}
}
}
if(onethree = true) {
if(onefive = true) {
if(onesix = true) {
winner = true;
}
}
}
if(onefive = true) {
if(onesix = true) {
if(oneseven = true) {
winner = true;
}
}
}
if(twofive = true) {
if(threesix = true) {
if(fourseven = true) {
winner = true;
}
}
}
if(twothree = true) {
if(threetwo = true) {
if(fourone = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefour = true) {
if(fourfour = true) {
winner = true;
}
}
}
}
if(onefive = true) {
if(onetwo = true) {
if(onethree = true) {
if(onefour = true) {
winner = true;
}
}
}
if(onethree = true) {
if(onefour = true) {
if(onesix = true) {
winner = true;
}
}
}
if(onefour = true) {
if(onesix = true) {
if(oneseven = true) {
winner = true;
}
}
}
if(twofive = true) {
if(threefive = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threethree = true) {
if(fourtwo = true) {
winner = true;
}
}
}
}
if(onesix = true) {
if(onethree = true) {
if(onefour = true) {
if(onefive = true) {
winner = true;
}
}
}
if(onefour = true) {
if(onefive = true) {
if(oneseven = true) {
winner = true;
}
}
}
if(twosix = true) {
if(threesix = true) {
if(foursix = true) {
winner = true;
}
}
}
if(twofive = true) {
if(threefour = true) {
if(fourthree = true) {
winner = true;
}
}
}
}
if(oneseven = true) {
if(onefour = true) {
if(onefive = true) {
if(onesix = true) {
winner = true;
}
}
}
if(twoseven = true) {
if(threeseven = true) {
if(fourseven = true) {
winner = true;
}
}
}
if(twosix = true) {
if(threefive = true) {
if(fourfour = true) {
winner = true;
}
}
}
}
if(twotwo = true) {
if(twoone = true) {
if(twothree = true) {
if(twofour = true) {
winner = true;
}
}
}
if(twothree = true) {
if(twofour = true) {
if(twofive = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(fourtwo = true) {
if(fivetwo = true) {
winner = true;
}
}
}
if(onetwo = true) {
if(threetwo = true) {
if(fourtwo = true) {
winner = true;
}
}
}
if(oneone = true) {
if(threethree = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourfour = true) {
if(fivefive = true) {
winner = true;
}
}
}
}
if(twofour = true) {
if(onethree = true) {
if(threefive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(onefive = true) {
if(threethree = true) {
if(fourtwo = true) {
winner = true;
}
}
}
if(onethree = true) {
if(threefive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(threefive = true) {
if(foursix = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(onefour = true) {
if(threefour = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(threefour = true) {
if(fourfour = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(twoone = true) {
if(twotwo = true) {
if(twothree = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(twothree = true) {
if(twofive = true) {
winner = true;
}
}
}
if(twothree = true) {
if(twofive = true) {
if(twosix = true) {
winner = true;
}
}
}
if(twofive = true) {
if(twosix = true) {
if(twoseven = true) {
winner = true;
}
}
}
}
if(twosix = true) {
if(twothree = true) {
if(twofour = true) {
if(twofive = true) {
winner = true;
}
}
}
if(twofour = true) {
if(twofive = true) {
if(twoseven = true) {
winner = true;
}
}
}
if(onesix = true) {
if(threesix = true) {
if(foursix = true) {
winner = true;
}
}
}
if(threesix = true) {
if(foursix = true) {
if(fivesix = true) {
winner = true;
}
}
}
if(threefive = true) {
if(fourfour = true) {
if(fivethree = true) {
winner = true;
}
}
}
if(fourfour = true) {
if(fivethree = true) {
if(oneseven = true) {
winner = true;
}
}
}
}
if(threeone = true) {
if(fourone = true) {
if(fiveone = true) {
if(sixone = true) {
winner = true;
}
}
}
if(oneone = true) {
if(twoone = true) {
if(fourone = true) {
winner = true;
}
}
}
if(twoone = true) {
if(fourone = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(threethree = true) {
if(threefour = true) {
winner = true;
}
}
}
}
if(threethree = true) {
if(oneone = true) {
if(twotwo = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(fourfour = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(fourfour = true) {
if(fivefive = true) {
if(sixsix = true) {
winner = true;
}
}
}
if(onethree = true) {
if(twothree = true) {
if(fourthree = true) {
winner = true;
}
}
}
if(twothree = true) {
if(fourthree = true) {
if(fivethree = true) {
winner = true;
}
}
}
if(fourthree = true) {
if(fivethree = true) {
if(sixthree = true) {
winner = true;
}
}
}
if(onefive = true) {
if(twofour = true) {
if(fourtwo = true) {
winner = true;
}
}
}
if(twofour = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(threeone = true) {
if(threetwo = true) {
if(threefour = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(threefour = true) {
if(threefive = true) {
winner = true;
}
}
}
if(threefour = true) {
if(threefive = true) {
if(threesix = true) {
winner = true;
}
}
}
}
if(threefive = true) {
if(onethree = true) {
if(twofour = true) {
if(foursix = true) {
winner = true;
}
}
}
if(twofour = true) {
if(foursix = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(oneseven = true) {
if(twosix = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(twosix = true) {
if(fourfour = true) {
if(fivethree = true) {
winner = true;
}
}
}
if(fourfour = true) {
if(fivethree = true) {
if(sixtwo = true) {
winner = true;
}
}
}
if(onefive = true) {
if(twofive = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(twofive = true) {
if(fourfive = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(fourfive = true) {
if(fivefive = true) {
if(sixfive = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(threethree = true) {
if(threefour = true) {
winner = true;
}
}
}
if(threethree = true) {
if(threefour = true) {
if(threesix = true) {
winner = true;
}
}
}
if(threefour = true) {
if(threesix = true) {
if(threeseven = true) {
winner = true;
}
}
}
}
if(threeseven = true) {
if(threefour = true) {
if(threefive = true) {
if(threesix = true) {
winner = true;
}
}
}
if(sixfour = true) {
if(fivefive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(oneseven = true) {
if(twoseven = true) {
if(fourseven = true) {
winner = true;
}
}
}
if(twoseven = true) {
if(fourseven = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(fourseven = true) {
if(fiveseven = true) {
if(sixseven = true) {
winner = true;
}
}
}
}
if(fourtwo = true) {
if(fourone = true) {
if(fourthree = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(fourthree = true) {
if(fourfour = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(threeone = true) {
if(fivethree = true) {
if(sixfour = true) {
winner = true;
}
}
}
if(onetwo = true) {
if(twotwo = true) {
if(threetwo = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(threetwo = true) {
if(fivetwo = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(fivetwo = true) {
if(sixtwo = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(fiveone = true) {
if(threethree = true) {
if(twofour = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(onefive = true) {
winner = true;
}
}
}
}
if(fourfour = true) {
if(oneone = true) {
if(twotwo = true) {
if(threethree = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(threethree = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fivefive = true) {
if(sixsix = true) {
winner = true;
}
}
}
if(oneseven = true) {
if(twosix = true) {
if(threefive = true) {
winner = true;
}
}
}
if(twosix = true) {
if(threefive = true) {
if(fivethree = true) {
winner = true;
}
}
}
if(threefive = true) {
if(fivethree = true) {
if(sixtwo = true) {
winner = true;
}
}
}
if(fourone = true) {
if(fourtwo = true) {
if(fourthree = true) {
winner = true;
}
}
}
if(fourtwo = true) {
if(fourthree = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(fourthree = true) {
if(fourfive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(fourfive = true) {
if(foursix = true) {
if(fourseven = true) {
winner = true;
}
}
}
if(onefour = true) {
if(twofour = true) {
if(threefour = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefour = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(threefour = true) {
if(fivefour = true) {
if(sixfour = true) {
winner = true;
}
}
}
}
if(foursix = true) {
if(fourthree = true) {
if(fourfour = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(fourfour = true) {
if(fourfive = true) {
if(fourseven = true) {
winner = true;
}
}
}
if(onethree = true) {
if(twofour = true) {
if(threefive = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefive = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(sixfour = true) {
if(fivefive = true) {
if(threeseven = true) {
winner = true;
}
}
}
if(onesix = true) {
if(twosix = true) {
if(threesix = true) {
winner = true;
}
}
}
if(twosix = true) {
if(threesix = true) {
if(fivesix = true) {
winner = true;
}
}
}
if(twosix = true) {
if(fivesix = true) {
if(sixsix = true) {
winner = true;
}
}
}
}
if(fiveone = true) {
if(twoone = true) {
if(threeone = true) {
if(fourone = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourtwo = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(fivetwo = true) {
if(fivethree = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(twofour = true) {
if(twofive = true) {
if(threefour = true) {
winner = true;
}
}
}
}
if(fivetwo = true) {
if(twofive = true) {
if(threefour = true) {
if(fourthree = true) {
winner = true;
}
}
}
if(threefour = true) {
if(fourthree = true) {
if(sixone = true) {
winner = true;
}
}
}
if(fiveone = true) {
if(fivethree = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(fivethree = true) {
if(fivefour = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(threetwo = true) {
if(fourtwo = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(fourtwo = true) {
if(sixtwo = true) {
winner = true;
}
}
}
}
if(fivethree = true) {
if(twosix = true) {
if(threefive = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(threefive = true) {
if(fourfour = true) {
if(sixtwo = true) {
winner = true;
}
}
}
if(twothree = true) {
if(threethree = true) {
if(fourthree = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourthree = true) {
if(sixthree = true) {
winner = true;
}
}
}
if(fiveone = true) {
if(fivetwo = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(fivetwo = true) {
if(fivefour = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(fivefour = true) {
if(fivefive = true) {
if(fivesix = true) {
winner = true;
}
}
}
}
if(fivefour = true) {
if(fiveone = true) {
if(fivetwo = true) {
if(fivethree = true) {
winner = true;
}
}
}
if(fivetwo = true) {
if(fivethree = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(fivethree = true) {
if(fivefive = true) {
if(fivesix = true) {
winner = true;
}
}
}
if(fivefive = true) {
if(fivesix = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(twoone = true) {
if(threetwo = true) {
if(fourthree = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(fourthree = true) {
if(sixfive = true) {
winner = true;
}
}
}
if(twoseven = true) {
if(threesix = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(threesix = true) {
if(fourfive = true) {
if(sixthree = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefour = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(threefour = true) {
if(fourfour = true) {
if(sixfour = true) {
winner = true;
}
}
}
}
if(fivefive = true) {
if(fivetwo = true) {
if(fivethree = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(fivethree = true) {
if(fivefour = true) {
if(fivesix = true) {
winner = true;
}
}
}
if(fivefour = true) {
if(fivesix = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(twotwo = true) {
if(threethree = true) {
if(fourfour = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourfour = true) {
if(sixsix = true) {
winner = true;
}
}
}
if(twofive = true) {
if(threefive = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(threefive = true) {
if(fourfive = true) {
if(sixfive = true) {
winner = true;
}
}
}
if(threeseven = true) {
if(foursix = true) {
if(sixfour = true) {
winner = true;
}
}
}
}
if(fivesix = true) {
if(twothree = true) {
if(threefour = true) {
if(fourfive = true) {
winner = true;
}
}
}
if(threefour = true) {
if(fourfive = true) {
if(sixseven = true) {
winner = true;
}
}
}
if(sixthree = true) {
if(sixfour = true) {
if(sixfive = true) {
winner = true;
}
}
}
if(sixfour = true) {
if(sixfive = true) {
if(sixseven = true) {
winner = true;
}
}
}
if(twosix = true) {
if(threesix = true) {
if(foursix = true) {
winner = true;
}
}
}
if(threesix = true) {
if(foursix = true) {
if(sixsix = true) {
winner = true;
}
}
}
}
if(fiveseven = true) {
if(twoseven = true) {
if(threeseven = true) {
if(fourseven = true) {
winner = true;
}
}
}
if(threeseven = true) {
if(fourseven = true) {
if(sixseven = true) {
winner = true;
}
}
}
if(twofour = true) {
if(threefive = true) {
if(foursix = true) {
winner = true;
}
}
}
if(fivefour = true) {
if(fivefive = true) {
if(fivesix = true) {
winner = true;
}
}
}
}
if(sixone = true) {
if(threefour = true) {
if(fourthree = true) {
if(fivetwo = true) {
winner = true;
}
}
}
if(threeone = true) {
if(fourone = true) {
if(fiveone = true) {
winner = true;
}
}
}
if(twosix = true) {
if(threesix = true) {
if(foursix = true) {
winner = true;
}
}
}
}
if(sixthree = true) {
if(threesix = true) {
if(fourfive = true) {
if(fivefour = true) {
winner = true;
}
}
}
if(threethree = true) {
if(fourthree = true) {
if(fivethree = true) {
winner = true;
}
}
}
if(sixone = true) {
if(sixtwo = true) {
if(sixfour = true) {
winner = true;
}
}
}
if(sixtwo = true) {
if(sixfour = true) {
if(sixfive = true) {
winner = true;
}
}
}
if(sixfour = true) {
if(sixfive = true) {
if(sixsix = true) {
winner = true;
}
}
}
}
if(sixfive = true) {
if(sixtwo = true) {
if(sixthree = true) {
if(sixfour = true) {
winner = true;
}
}
}
if(sixthree = true) {
if(sixfour = true) {
if(sixsix = true) {
winner = true;
}
}
}
if(sixfour = true) {
if(sixsix = true) {
if(sixseven = true) {
winner = true;
}
}
}
if(threefive = true) {
if(fourfive = true) {
if(fivefive = true) {
winner = true;
}
}
}
if(threetwo = true) {
if(fourthree = true) {
if(fivefour = true) {
winner = true;
}
}
}
}
if(sixseven = true) {
if(threefour = true) {
if(fourfive = true) {
if(fivesix = true) {
winner = true;
}
}
}
if(threeseven = true) {
if(fourseven = true) {
if(fiveseven = true) {
winner = true;
}
}
}
if(sixfour = true) {
if(sixfive = true) {
if(sixsix = true) {
winner = true;
}
}
}
System.out.println("Where would you like to play? (Row 1, 2, 3, etc)");
String row = scan.next();
if(row.equals("Row 1")) {
if(oneone = false) {
oneone = true;
}
else if(oneone = true) {
if(onetwo = false) {
onetwo = true;
}
else if(onetwo = true) {
if(onethree = false) {
onethree = true;
}
else if(onethree = true) {
if(onefour = false) {
onefour = true;
}
else if(onefour = true) {
if(onefive = false) {
onefive = true;
}
else if(onefive = true) {
if(onesix = false) {
onesix = true;
}
else if(onesix = true) {
if(oneseven = false) {
oneseven = true;
}
}
}
}
}
}
}
else if(row.equals("Row 2")) {
if(twoone = false) {
twoone = true;
}
else if(twoone = true) {
if(twotwo = false) {
twotwo = true;
}
else if(twotwo = true) {
if(twothree = false) {
onethree = true;
}
else if(twothree = true) {
if(twofour = false) {
onefour = true;
}
else if(twofour = true) {
if(twofive = false) {
onefive = true;
}
else if(twofive = true) {
if(twosix = false) {
twosix = true;
}
else if(twosix = true) {
if(twoseven = false) {
twoseven = true;
}
}
}
}
}
}
}
else if(row.equals("Row 3")) {
if(threeone = false) {
oneone = true;
}
else if(threeone = true) {
if(threetwo = false) {
threetwo = true;
}
else if(threetwo = true) {
if(threethree = false) {
threethree = true;
}
else if(threethree = true) {
if(threefour = false) {
threefour = true;
}
else if(threefour = true) {
if(threefive = false) {
threefive = true;
}
else if(threefive = true) {
if(threesix = false) {
threesix = true;
}
else if(threesix = true) {
if(threeseven = false) {
threeseven = true;
}
}
}
}
}
}
}
else if(row.equals("Row 4")) {
if(fourone = false) {
fourone = true;
}
else if(fourone = true) {
if(fourtwo = false) {
fourtwo = true;
}
else if(fourtwo = true) {
if(fourthree = false) {
fourthree = true;
}
else if(fourthree = true) {
if(fourfour = false) {
fourfour = true;
}
else if(fourfour = true) {
if(fourfive = false) {
fourfive = true;
}
else if(fourfive = true) {
if(foursix = false) {
foursix = true;
}
else if(foursix = true) {
if(fourseven = false) {
fourseven = true;
}
}
}
}
}
}
}
}
else if(row.equals("Row 5")) {
if(fiveone = false) {
fiveone = true;
}
else if(fiveone = true) {
if(fivetwo = false) {
fivetwo = true;
}
else if(fivetwo = true) {
if(fivethree = false) {
fivethree = true;
}
else if(fivethree = true) {
if(fivefour = false) {
fivefour = true;
}
else if(fivefour = true) {
if(fivefive = false) {
fivefive = true;
}
else if(fivefive = true) {
if(fivesix = false) {
fivesix = true;
}
else if(fivesix = true) {
if(fiveseven = false) {
fiveseven = true;
}
}
}
}
}
}
else if(row.equals("Row 6")) {
if(sixone = false) {
sixone = true;
}
else if(sixone = true) {
if(sixtwo = false) {
sixtwo = true;
}
else if(sixtwo = true) {
if(sixthree = false) {
sixthree = true;
}
else if(sixthree = true) {
if(sixfour = false) {
sixfour = true;
}
else if(sixfour = true) {
if(sixfive = false) {
sixfive = true;
}
else if(sixfive = true) {
if(sixsix = false) {
sixsix = true;
}
else if(sixsix = true) {
if(sixseven = false) {
sixseven = true;
}
}
}
}
}
}
}
}
}
}
I'm a TA for a CS class at my school, graded this submission for a connect 4 project, idk wtf happened with this persons thought process tbh.....
@SuppressWarnings("unchecked")
private void addEndpointsTags(JsonArray tagsArray) throws IOException {
if (registeredHandlers == null || registeredHandlers.isEmpty()) {
return;
}
TreeSet<String> handlerNamesSorted = new TreeSet<>(registeredHandlers.keySet());
handlerNamesSorted.forEach(key -> {
StringBuilder sb = new StringBuilder();
sb.append("{\"name\":\"");
sb.append(key);
sb.append("\",\"request\":{\"name\":\"");
try {
ServiceMethodHandler handler = registeredHandlers.get(key);
Class<? extends Message> requestClass = (Class<? extends Message>)
findSubClassParameterType(handler, 0);
Class<? extends Message> responseClass = (Class<? extends Message>)
findSubClassParameterType(handler, 1);
sb.append(requestClass.getSimpleName());
sb.append("\",\"type\":\"");
sb.append(requestClass.getSimpleName());
sb.append("\",\"values\":[");
sb.append(getProtobufClassFieldDescriptions(requestClass, new HashSet<>()));
sb.append("]},\"response\":{\"name\":\"");
sb.append(responseClass.getSimpleName());
sb.append("\",\"type\":\"");
sb.append(responseClass.getSimpleName());
sb.append("\",\"values\":[");
sb.append(getProtobufClassFieldDescriptions(responseClass, new HashSet<>()));
sb.append("]},\"metadata\":{\"stream\":\"false\"}}");
} catch (Exception e) {
logger.error("Error inspecting handlers", e);
return;
}
String tag = sb.toString();
tagsArray.add(new JsonPrimitive("e-" + binaryEncode(tag)));
});
}
try
{
len = readBufferSize(reader);
}
catch (IOException xcp)
{
throw xcp;
}
I swear I didn't omit a single symbol (except for tabs at the beginning)
if (CATEGORY_NORMAL.equalsIgnoreCase(categorie)) {
return assignGroupStartWithPrefix(assignmentGroups);
} else if (CATEGORY_EXTERNAL.equalsIgnoreCase(categorie)) {
return assignGroupStartWithPrefix(assignmentGroups);
}
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
throw new AccessDeniedException("Authenticated user is not admin ");
}
@Override
public String toString() {
List<Integer> accountLevels = new ArrayList<>();
List<String> accountIds = new ArrayList<>();
for (SelectedHierarchyLevel selectedHierarchyLevel : selectedHierarchyLevels) {
accountLevels.add(selectedHierarchyLevel.getLevel());
accountIds.add(selectedHierarchyLevel.getAccountRowId());
}
vetoAreValidIds(accountIds);
StringBuilder converterString = new StringBuilder();
convert(accountLevels, converterString);
converterString.append("$");
convert(accountIds, converterString);
return converterString.toString();
}
Just because you can, doesn’t mean you should.
try {
channel.send(eventMessage);
} catch (MessageHandlingException ex) {
channel.send(eventMessage);
}
/**
* fk--folder key,dk--doc key -->value is key string
* dt--doc type,ft--folder type -->both have 19 key options:
* bom tr amend history help info loeid cust cust0-cust9 custhist
* folder type only seen as "history" in toc,why ??do we use other ones? -- it only has one child
* doc type only seen two "tr" and "history" in toc??-- it only has one child
* node with "folder type="history"" is the only child of it parent either "<doc type="tr" key="xxx" trnum="xxx"....." or "<doc type="tr" trnum="xxx""
* <folder type="history" could has more then one doc children .e.g. title="History of AMM31-32-00-720-807" in 700/amm
*
*
*
* folder element has the follwing to identify itself:
* 1, key
* 2, type="history", in this case, folder is the only child of doc element with type ="tr"?????
*
* doc element has the following to identify itself
* 1, key
* 2, type="tr" trnum="xxxxx"
* 3, type="history", in this case, doc isthe only child of a folder element???
*
*
*
* the return json format likes following:
* [
* { "data" : "A node", "children" , "state" : "open" },
* { "data" : "Only child", "state" : "closed" },
* "Ajax node"
* ]
*/
public class XMLToJson
{
private static final Map<String, String> pathMap;
static
{
Map<String, String> aMap = new HashMap<String, String>();
aMap.put("fk", "folder[@key");
aMap.put("ft", "folder[@type");
aMap.put("fth", "folder[@type='history'");
aMap.put("dk", "doc[@key");
aMap.put("dt", "doc[@type");
aMap.put("dth", "doc[@type='history'");
aMap.put("dtrn", "doc[@trnum");
pathMap = Collections.unmodifiableMap(aMap);
}
Util util = new Util();
/*
* @param url the path to TOC.xml
* @param xPathString the short format searched node path
* @throws DocumentException
*
* sample xPathString : "fk:AMM24_fk:AMM24-FM_dk"
*/
@SuppressWarnings({ "unchecked" })
public String getJson(URL url, String xPathString) throws Exception
{
Document TOCDoc = util.getDocument(url);
String jsonString = "[";
Element node = null;
if (xPathString.equals("/"))
{
node = TOCDoc.getRootElement();
}
else
{
String realXPathString = pathMapping(xPathString);
System.out.println(realXPathString);
node = (Element) TOCDoc.selectSingleNode(realXPathString);
}
//List<Element> li = node.elements();
for (Iterator<Element> i = node.elementIterator(); i.hasNext();)
{
Element elem = (Element) i.next();
String eleName = elem.getName();
Boolean hasChildren = false;
if ((elem.elements().size() > 0))
{
hasChildren = true;
//current element has children itself, state shoud be "closed"
}
List<Attribute> list = elem.attributes();
String titleAttrContent = elem.attributeValue("title");
//Boolean isFileAttr = false;
String fileAttrContent = elem.attributeValue("file");
//if (fileAttrContent.isEmpty() )
if (eleName == "doc")
{
//doc element always has "file" attribute
for (Attribute attribute : list)
{
jsonString = jsonString.concat("{");
String attrName = attribute.getName();
//System.out.println("doc arribute Name : " + attrName);
//each one has to have "data" line, "attr" line "state" line and "children" line
jsonString = jsonString.concat("'data':'").concat(titleAttrContent).concat("',");
if (attrName.equals("key"))
{
String keyContent = elem.attributeValue("key");
jsonString = jsonString.concat("'attr':{'id':'").concat(xPathString).concat("_dk:").concat(keyContent).concat("','file':'").concat(fileAttrContent).concat("'}");
break;
}
else if (attrName.equals("trnum"))
{
String trnumContent = elem.attributeValue("trnum");
jsonString = jsonString.concat("'attr':{'id':'").concat(xPathString).concat("_dtrn:").concat(trnumContent).concat("','file':'").concat(fileAttrContent).concat("'}");
break;
}
/* else if (attrName.equals("type"))//type attribute for doc element won't determite what exactly the element is
{
String typeContent = elem.attributeValue("type");
//doc element has type "history"
if (typeContent == "history"){
jsonString = jsonString.concat("'attr':{'id':'").concat(xPathString).concat("_dth,");
}else if (typeContent == "?????"){
//any values for type attribute need to concern????
}
}
else if (attrName.equals("file"))
{
}*/
}
if (hasChildren)
{
//state set up as "closed" and no need to set up "children" field
jsonString = jsonString.concat(",'state':'closed'");
}
else
{
//no need to put anything
//jsonString = jsonString.concat("'state':'???'");
}
jsonString = jsonString.concat("},");
}
else if (eleName == "folder")
{
jsonString = jsonString.concat("{");
for (Attribute attribute : list)
{
String attrName = attribute.getName();
jsonString = jsonString.concat("'data':'").concat(titleAttrContent).concat("',");
if (attrName.equals("key"))
{
String keyContent = elem.attributeValue("key");
jsonString = jsonString.concat("'attr':{'id':'").concat(xPathString).concat("_fk:").concat(keyContent).concat("'}");
if (fileAttrContent != null)
{
jsonString = jsonString.concat("','file':'").concat(fileAttrContent).concat("'}");
}
break;
}
else if (attrName.equals("type"))
{
String typeContent = elem.attributeValue("type");
//doc element has type "history"
if (typeContent == "history")
{
jsonString = jsonString.concat("'attr':{'id':'").concat(xPathString).concat("_fth,");
}
else if (typeContent == "?????")
{
//any values need to concern????
}
break;
}
}
jsonString = jsonString.concat("},");
}
continue;
}
//return list;
jsonString = jsonString.substring(0, jsonString.length() - 1);
jsonString = jsonString.concat("]");
return jsonString;
}
/*
* read xpathstring from post request and generate the real xpath for toc
*/
public String getXPathString()
{
//readPostRequest()
return null;
}
/*
* post string looks like : "fk:LOETR_dtrn:TR12-118_fth_dth"
* it represents the inner doc elemnet:
* <folder key="LOETR" type="loetr" title="List of Effective TRs" file="loetr.html">
* <doc type="tr" trnum="TR12-118" trdate="May 07/2012" title="[TR12-118] TASK AMM12-31-00-660-806 - Inspection and Removal of De-Hydrated Anti-Icing Fluid inside the Flight Control Surfaces" file="TR12-118.pdf" refloc="AMM12-31-00-660-806">
* <folder type="history" title="History of AMM12-31-00-660-806">
* <doc title="TASK 12-31-00-660-806 - Inspection and Removal of De-Hydrated Anti-Icing Fluid inside the Flight Control Surfaces" file="AMM12-31-00-660-806.pdf" type="history" refloc="AMM12-31-00-660-806"/>
* </folder>
* the xpath string should be:
* folder[@key="LOETR"]/doc[@trnum="TR12-118"]/folder[@type="history"]/doc[@type="history"]
*
*
* the String : "fk:AMM24_fk:AMM24-FM_dk:CTOC-24"
* it represents the inner doc with attribute file="CTOC-24.pdf"
* the string : "fk:AMM24_fk:AMM24-00-00_fk:AMM24-00-00-02_dk:AMM24-00-00-700-801" represents
* <folder key="AMM24" title="CH 24 - Electrical Power">
* <folder key="AMM24-FM" title="Front Matter">
* <doc key="CTOC-24" title="Table of Contents" file="CTOC-24.pdf"/>
* </folder>
* <folder key="AMM24-00-00" title="24-00-00 - General">
* <folder key="AMM24-00-00-02" title="General - Maintenance Practices">
* <doc key="AMM24-00-00-700-801" title="TASK 24-00-00-700-801 - AC Power, DC Power and Battery Maintenance Practice Recommendations" file="AMM24-00-00-700-801.pdf"/>
*
* it can be even optimized as :
* "fk:AMM24_fk:00-00_fk:02_dk:AMM24-00-00-700-801"
* if the inner key fully include the previous key, omit it, otherwise use full string
* the xpath string should be:
* folder[@key="AMM24"]/folder[@key="AMM24-00-00"]/folder[@key="AMM24-00-00-02"]/doc[@key="AMM24-00-00-700-801"]
*
* if shortXPath is ?? which means the query based on the root of the document
*
*
*/
public String pathMapping(String shortXPath) throws Exception
{
String tagetString = null;
if (shortXPath.equals(""))
{
tagetString = "//toc";
}
else
{
tagetString = "//";
}
int newStart = 0;
String segString = "";
String valueString = "";
//dth???
//need mapping all senarios
//already??
while (shortXPath.indexOf("_", newStart) > -1)
{
int keyValueSepPos = 0;
String keyString = "";//not necessary key, might be type attribute
segString = shortXPath.substring(newStart, shortXPath.indexOf("_", newStart));
newStart = shortXPath.indexOf("_", newStart) + 1;//new start search point
//System.out.println(newStart);
if (segString.indexOf(":") > 0)
{
keyValueSepPos = segString.indexOf(":");
keyString = segString.substring(0, keyValueSepPos);
valueString = segString.substring(keyValueSepPos + 1);
if (pathMap.get(keyString).length() > 0)
{
tagetString = tagetString.concat(pathMap.get(keyString));
}
else
{
throw new Exception("no mapping found");
}
tagetString = tagetString.concat("='").concat(valueString).concat("']/");
}
}
//this is for scenerio either no "_" or sub string after "_"
segString = shortXPath.substring(newStart);
System.out.println(segString);
if (segString.indexOf(":") > 0)
{
int lastKeyValueSepPos = segString.indexOf(":");
String lastKeyString = segString.substring(0, lastKeyValueSepPos);
String lastValueString = segString.substring(lastKeyValueSepPos + 1);
if (pathMap.get(lastKeyString).length() > 0)
{
tagetString = tagetString.concat(pathMap.get(lastKeyString));
}
else
{
throw new Exception("no mapping found");
}
tagetString = tagetString.concat("='").concat(lastValueString).concat("']");
}
return tagetString;
}
public static void main(String[] args) throws Exception
{
XMLToJson x2j = new XMLToJson();
String test = "fk:AMM24_fk:AMM24-FM";
test = "";
System.out.println(x2j.getJson(new URL("http://localhost:8080/WebNavSpring/q400/amm/toc.xml"), test));
//System.out.println(x2j.pathMapping(test));
}
}
easy clean code to convert XML to JSON .
if (responseCode / 100 == 2) {//success
return handleSuccess();
} else if (responseCode == 401) {
return handleNotAuthorized();
} else {
// something else
}
public void sleep(long duration) {
long start = System.currentTimeMillis();
while(true) {
if (System.currentTimeMillis() - start >= duration)
break;
}
}
Boolean b = new Boolean(true);
if (b == true){
...
}
think outside the autoboxing