Java Code Examples for java.util.List#toString()
The following examples show how to use
java.util.List#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlurResultSetRecords.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
private String getValue(Record record, String columnNameWithFamilyName, String family) { int index = columnNameWithFamilyName.indexOf('.'); if (family.equals(columnNameWithFamilyName.substring(0, index))) { String columnName = columnNameWithFamilyName.substring(index + 1); List<String> values = new ArrayList<String>(); for (Column col : record.columns) { if (columnName.equals(col.getName())) { values.add(col.getValue()); } } if (values.size() == 1) { return values.get(0); } else { return values.toString(); } } else { return null; } }
Example 2
Source File: JtlTotals.java From acmeair with Apache License 2.0 | 6 votes |
public String cntByTimeString() { DecimalFormat df = new DecimalFormat(DECIMAL_PATTERN); List<String> millisStr = new LinkedList<String>(); Iterator <Entry<Integer,Integer>>iter = millisMap.entrySet().iterator(); while(iter.hasNext()) { Entry<Integer,Integer> millisEntry = iter.next(); Integer bucket = (Integer)millisEntry.getKey(); Integer bucketCount = (Integer)millisEntry.getValue(); int minMillis = bucket.intValue() * millisPerBucket; int maxMillis = (bucket.intValue() + 1) * millisPerBucket; millisStr.add( df.format(minMillis/MILLIS_PER_SECOND)+" s "+ "- "+ df.format(maxMillis/MILLIS_PER_SECOND)+" s "+ "= " + bucketCount); } return millisStr.toString(); }
Example 3
Source File: ArrayElems.java From swift-t with Apache License 2.0 | 6 votes |
private List<Type> findCompatibleTypes(Context context, List<SwiftAST> exprs) throws UserException, TypeMismatchException { if (exprs.size() == 0) { return Collections.<Type>singletonList(new WildcardType()); } else { List<Type> valTypes = new ArrayList<Type>(exprs.size()); for (SwiftAST elem: exprs) { valTypes.add(TypeChecker.findExprType(context, elem)); } List<Type> possibleTypes = Types.typeIntersection(valTypes); if (possibleTypes.size() == 0) { throw new TypeMismatchException(context, "Elements in array" + " constructor have incompatible types: " + valTypes.toString()); } return possibleTypes; } }
Example 4
Source File: BuilderForwarding.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void insertintObject() { StringBuilder sb = new StringBuilder("012345"); List<String> ls = new ArrayList<String>(); ls.add("A"); ls.add("B"); String lsString = ls.toString(); assertEquals( sb.insert(2, ls).toString(), "01"+lsString+"2345"); try { sb.insert(sb.length()+1, ls); throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException"); } catch (StringIndexOutOfBoundsException soob) { // expected: passed } catch (Throwable t) { throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException, but instead threw:" + t); } }
Example 5
Source File: BuilderForwarding.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void insertintObject() { StringBuilder sb = new StringBuilder("012345"); List<String> ls = new ArrayList<String>(); ls.add("A"); ls.add("B"); String lsString = ls.toString(); assertEquals( sb.insert(2, ls).toString(), "01"+lsString+"2345"); try { sb.insert(sb.length()+1, ls); throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException"); } catch (StringIndexOutOfBoundsException soob) { // expected: passed } catch (Throwable t) { throw new RuntimeException("Test failed: should have thrown StringIndexOutOfBoundsException, but instead threw:" + t); } }
Example 6
Source File: GraphComparer.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Utility method that determines if two lists of nodes are equivalent. * * @param list1 The first list of nodes. * @param list2 The second list of nodes. * @return <tt>true</tt> if the equivalent of each node in <tt>list1</tt> * is found in <tt>list2</tt>, and vice versa. */ private boolean equivLists(List list1, List list2) { if (list1 == null) { return (list2 == null); } else if (list2 == null) { return false; } if (list1.size() != list2.size()) { return false; } for (Iterator i = list1.iterator(); i.hasNext(); ) { if (! list2.contains(equivalences.getEquiv(i.next()))) { return false; } } // Since getEquiv() should be symmetric, and we've confirmed that // the lists are the same size, the next loop shouldn't really // be necessary. But just in case something is fouled up, we // include this loop as an assertion check. for (Iterator i = list2.iterator(); i.hasNext(); ) { if (! list1.contains(equivalences.getEquiv(i.next()))) { throw new IllegalArgumentException("equivLists: " + list2.toString() + " contains all the equivalents of " + list1.toString() + ", but the reverse is not true."); } } return true; }
Example 7
Source File: SingleIndexWriteFailureException.java From phoenix with Apache License 2.0 | 5 votes |
/** * Failed to write the passed mutations to an index table for some reason. * @param targetTableName index table to which we attempted to write * @param mutations mutations that were attempted * @param cause underlying reason for the failure */ public SingleIndexWriteFailureException(String targetTableName, List<Mutation> mutations, Exception cause, boolean disableIndexOnFailure) { super(cause, disableIndexOnFailure); this.table = targetTableName; this.mutationsMsg = mutations.toString(); }
Example 8
Source File: Schema.java From macrobase with Apache License 2.0 | 5 votes |
public String toString() { int d = columnNames.size(); List<String> pairs = new ArrayList<>(d); for (int i = 0; i < d; i++) { pairs.add(columnNames.get(i)+":"+columnTypes.get(i)); } return pairs.toString(); }
Example 9
Source File: EventFilterController.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void preCreateEntity( ProgramStageInstanceFilter eventFilter ) { List<String> errors = psiFilterService.validate( eventFilter ); if ( !errors.isEmpty() ) { throw new IllegalQueryException( errors.toString() ); } }
Example 10
Source File: ArrayType.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException { if ( value == null ) { return "null"; } int length = Array.getLength(value); List list = new ArrayList(length); Type elemType = getElementType(factory); for ( int i=0; i<length; i++ ) { list.add( elemType.toLoggableString( Array.get(value, i), factory ) ); } return list.toString(); }
Example 11
Source File: ContentNegotiatingViewResolver.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public View resolveViewName(String viewName, Locale locale) throws Exception { RequestAttributes attrs = RequestContextHolder.getRequestAttributes(); Assert.state(attrs instanceof ServletRequestAttributes, "No current ServletRequestAttributes"); List<MediaType> requestedMediaTypes = getMediaTypes(((ServletRequestAttributes) attrs).getRequest()); if (requestedMediaTypes != null) { List<View> candidateViews = getCandidateViews(viewName, locale, requestedMediaTypes); View bestView = getBestView(candidateViews, requestedMediaTypes, attrs); if (bestView != null) { return bestView; } } String mediaTypeInfo = logger.isDebugEnabled() && requestedMediaTypes != null ? " given " + requestedMediaTypes.toString() : ""; if (this.useNotAcceptableStatusCode) { if (logger.isDebugEnabled()) { logger.debug("Using 406 NOT_ACCEPTABLE" + mediaTypeInfo); } return NOT_ACCEPTABLE_VIEW; } else { logger.debug("View remains unresolved" + mediaTypeInfo); return null; } }
Example 12
Source File: Board.java From codenjoy with GNU General Public License v3.0 | 4 votes |
private String listToString(List<? extends Object> list) { String result = list.toString(); return result.substring(1, result.length() - 1); }
Example 13
Source File: LingeredAppForJps.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static File buildJar() throws IOException { String className = LingeredAppForJps.class.getName(); File jar = new File(className + ".jar"); String testClassPath = System.getProperty("test.class.path", "?"); File manifestFile = new File(className + ".mf"); String nl = System.getProperty("line.separator"); try (BufferedWriter output = new BufferedWriter(new FileWriter(manifestFile))) { output.write("Main-Class: " + className + nl); } List<String> jarArgs = new ArrayList<>(); jarArgs.add("-cfm"); jarArgs.add(jar.getAbsolutePath()); jarArgs.add(manifestFile.getAbsolutePath()); for (String path : testClassPath.split(File.pathSeparator)) { String classFullName = path + File.separator + className + ".class"; File f = new File(classFullName); if (f.exists()) { jarArgs.add("-C"); jarArgs.add(path); jarArgs.add("."); System.out.println("INFO: scheduled to jar " + path); break; } } System.out.println("Running jar " + jarArgs.toString()); sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); if (!jarTool.run(jarArgs.toArray(new String[jarArgs.size()]))) { throw new IOException("jar failed: args=" + jarArgs.toString()); } manifestFile.delete(); jar.deleteOnExit(); // Print content of jar file System.out.println("Content of jar file" + jar.getAbsolutePath()); jarArgs = new ArrayList<>(); jarArgs.add("-tvf"); jarArgs.add(jar.getAbsolutePath()); jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); if (!jarTool.run(jarArgs.toArray(new String[jarArgs.size()]))) { throw new IOException("jar failed: args=" + jarArgs.toString()); } return jar; }
Example 14
Source File: CubeDesc.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public void validateAggregationGroups() { int index = 1; for (AggregationGroup agg : getAggregationGroups()) { if (agg.getIncludes() == null) { logger.error("Aggregation group " + index + " 'includes' field not set"); throw new IllegalStateException("Aggregation group " + index + " includes field not set"); } if (agg.getSelectRule() == null) { logger.error("Aggregation group " + index + " 'select_rule' field not set"); throw new IllegalStateException("Aggregation group " + index + " select rule field not set"); } Set<String> includeDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); getDims(includeDims, agg.getIncludes()); Set<String> mandatoryDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); getDims(mandatoryDims, agg.getSelectRule().mandatoryDims); ArrayList<Set<String>> hierarchyDimsList = Lists.newArrayList(); Set<String> hierarchyDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); getDims(hierarchyDimsList, hierarchyDims, agg.getSelectRule().hierarchyDims); ArrayList<Set<String>> jointDimsList = Lists.newArrayList(); Set<String> jointDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); getDims(jointDimsList, jointDims, agg.getSelectRule().jointDims); if (!includeDims.containsAll(mandatoryDims) || !includeDims.containsAll(hierarchyDims) || !includeDims.containsAll(jointDims)) { List<String> notIncluded = Lists.newArrayList(); final Iterable<String> all = Iterables .unmodifiableIterable(Iterables.concat(mandatoryDims, hierarchyDims, jointDims)); for (String dim : all) { if (includeDims.contains(dim) == false) { notIncluded.add(dim); } } Collections.sort(notIncluded); logger.error( "Aggregation group " + index + " Include dimensions not containing all the used dimensions"); throw new IllegalStateException("Aggregation group " + index + " 'includes' dimensions not include all the dimensions:" + notIncluded.toString()); } if (CollectionUtils.containsAny(mandatoryDims, hierarchyDims)) { logger.warn("Aggregation group " + index + " mandatory dimensions overlap with hierarchy dimensions: " + ensureOrder(CollectionUtils.intersection(mandatoryDims, hierarchyDims))); } if (CollectionUtils.containsAny(mandatoryDims, jointDims)) { logger.warn("Aggregation group " + index + " mandatory dimensions overlap with joint dimensions: " + ensureOrder(CollectionUtils.intersection(mandatoryDims, jointDims))); } if (CollectionUtils.containsAny(hierarchyDims, jointDims)) { logger.error("Aggregation group " + index + " hierarchy dimensions overlap with joint dimensions"); throw new IllegalStateException( "Aggregation group " + index + " hierarchy dimensions overlap with joint dimensions: " + ensureOrder(CollectionUtils.intersection(hierarchyDims, jointDims))); } if (hasSingleOrNone(hierarchyDimsList)) { logger.error("Aggregation group " + index + " require at least 2 dimensions in a hierarchy"); throw new IllegalStateException( "Aggregation group " + index + " require at least 2 dimensions in a hierarchy."); } if (hasSingleOrNone(jointDimsList)) { logger.error("Aggregation group " + index + " require at least 2 dimensions in a joint"); throw new IllegalStateException( "Aggregation group " + index + " require at least 2 dimensions in a joint"); } Pair<Boolean, Set<String>> overlap = hasOverlap(hierarchyDimsList, hierarchyDims); if (overlap.getFirst() == true) { logger.error("Aggregation group " + index + " a dimension exist in more than one hierarchy: " + ensureOrder(overlap.getSecond())); throw new IllegalStateException("Aggregation group " + index + " a dimension exist in more than one hierarchy: " + ensureOrder(overlap.getSecond())); } overlap = hasOverlap(jointDimsList, jointDims); if (overlap.getFirst() == true) { logger.error("Aggregation group " + index + " a dimension exist in more than one joint: " + ensureOrder(overlap.getSecond())); throw new IllegalStateException("Aggregation group " + index + " a dimension exist in more than one joint: " + ensureOrder(overlap.getSecond())); } index++; } }
Example 15
Source File: DatastoreBookshelfExample.java From spring-cloud-gcp with Apache License 2.0 | 4 votes |
@ShellMethod("Loads books released after a specified year: find-by-year-greater-than <year>") public String findByYearGreaterThan(int year) { List<Book> books = this.bookRepository.findByYearGreaterThan(year); return books.toString(); }
Example 16
Source File: DownloadEngineStatus.java From TorrentEngine with GNU General Public License v3.0 | 4 votes |
public static String getPeerString(TorrentEngineCore core) throws NamingException { List<String> peers = new ArrayList<>(); List<DownloadManager> managers = core.getGlobalManager().getDownloadManagers(); final Map<String, Long> rawPeers = new HashMap<>(); final Map<String, String> peerType = new HashMap<>(); for (DownloadManager m : managers) { try { for (PEPeer p : m.getPeerManager().getPeers()) { Long speed = rawPeers.get(p.getIPHostName()); Long speedLocal = p.getStats().getDataReceiveRate(); if (speed != null) { speed = speed + speedLocal; } else { speed = speedLocal; } String iphostname = p.getIPHostName(); rawPeers.put(iphostname, speed); String prot = p.getProtocol(); // if (prot.contains("HTTP")){ // prot = "http"; // }else if (prot.contains("FTP")){ // prot = "ftp"; // }else{ // prot = ""; // } if (prot.contains("TCP")) { prot = ""; } peerType.put(iphostname, prot); } } catch (Exception e) { System.out.println("Error with peer list " + m.getDisplayName()); } } List<String> tosort = new ArrayList<>(rawPeers.keySet()); Collections.sort(tosort, new Comparator<String>() { @Override public int compare(String o1, String o2) { long o1r = rawPeers.get(o1); long o2r = rawPeers.get(o2); if (o2r > o1r) { return 1; } else if (o2r == o1r) { return 0; } else { return -1; } } }); int count = 0; for (String opstring : tosort) { long dlrate = rawPeers.get(opstring); //if (dlrate != 0){ count++; String pstring = tryForDNSName(opstring); // only show some peers but show all edu if (!(count > 3) || pstring.contains(".edu")) { String type = peerType.get(opstring); // add space if (!"".equals(type)) { type = " " + type; } pstring = pstring + " " + Formatter.humanReadableByteCount(dlrate, true) + "/s" + type; peers.add(pstring); } } // for (int i = 0; i < peers.size() ; i++){ // // peers.set(i, peers.get(i) + " " + peerType.get); // } return tosort.size() + " Mirrors " + peers.toString(); }
Example 17
Source File: GMS.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * GemStoneAddition - send prepare-for-view-change message and wait for * responses. Return a list of addresses that didn't respond */ List<IpAddress> sendPrepareForViewChange(View newView, Collection<IpAddress> mbrs, boolean mcast) { int size=-1; ViewId vid = newView.getVid(); synchronized (prepare_collector) { // GemStoneAddition bug34505 prepare_collector.reset(vid, mbrs); size=prepare_collector.size(); } boolean timedout=false; GmsHeader hdr=new GmsHeader(GmsHeader.PREPARE_FOR_VIEW); // GemStoneAddition - when PWNing an existing view, we have to unicast // because NAKACK will reject a mcast message from a non-member if (mcast) { Message view_change_msg=new Message(); // bcast to all members view_change_msg.setObject(newView); view_change_msg.isHighPriority = true; view_change_msg.putHeader(name, hdr); passDown(new Event(Event.MSG, view_change_msg)); } else { for (IpAddress dest: mbrs) { if (dest.equals(this.local_addr)) { synchronized(prepare_collector) { prepare_collector.ack(dest, null); } } else { Message msg = new Message(); msg.isHighPriority = true; msg.putHeader(name, hdr); msg.setObject(newView); msg.setDest(dest); // if (trace) // log.trace("sending PREPARE_FOR_VIEW to " + dest); passDown(new Event(Event.MSG, msg)); } } } try { // log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "DEBUG: before waiting for prepare-acks, collector state is " + prepare_collector); prepare_collector.waitForAllAcks(view_ack_collection_timeout); // log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "DEBUG: after waiting for prepare-acks, collector state is " + prepare_collector); } catch(TimeoutException e) { // timeout processing is handled below, along with members declared dead during view preparation // see bug #47295 timedout=true; } //log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "received acks from " + prepare_collector.getReceived()); List missing; String missingStr; String receivedStr = null; boolean logMissing = false; synchronized (prepare_collector) { missing = prepare_collector.getMissingAcks(); missing.addAll(prepare_collector.getSuspectedMembers()); missing.removeAll(newView.getSuspectedMembers()); // don't reprocess members that are already kicked out missing.remove(this.local_addr); // don't suspect myself - I might be shutting down // bug #44342 - if the member has sent a shutdown message then it's okay for (Iterator<IpAddress> it=missing.iterator(); it.hasNext(); ) { IpAddress addr = it.next(); if (!newView.containsMember(addr) || this.stack.gfPeerFunctions.isShuttingDown(addr)) { it.remove(); } } logMissing = missing.size() > 0; if (logMissing) { // note who has acked while under synchronization receivedStr = prepare_collector.getReceived().toString(); } } if (logMissing && !this.stack.getChannel().closing()) { missingStr = missing.toString(); log.getLogWriter().warning( ExternalStrings.GMS_FAILED_TO_COLLECT_ALL_ACKS_0_FOR_VIEW_PREPARATION_1_AFTER_2_MS_MISSING_ACKS_FROM_3_RECEIVED_4_LOCAL_ADDR_5, new Object[] {Integer.valueOf(size), newView, Long.valueOf(view_ack_collection_timeout), missingStr, receivedStr, local_addr}/*, new Exception("stack trace")*/); } return missing; }
Example 18
Source File: GMS.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * GemStoneAddition - send prepare-for-view-change message and wait for * responses. Return a list of addresses that didn't respond */ List<IpAddress> sendPrepareForViewChange(View newView, Collection<IpAddress> mbrs, boolean mcast) { int size=-1; ViewId vid = newView.getVid(); synchronized (prepare_collector) { // GemStoneAddition bug34505 prepare_collector.reset(vid, mbrs); size=prepare_collector.size(); } boolean timedout=false; GmsHeader hdr=new GmsHeader(GmsHeader.PREPARE_FOR_VIEW); // GemStoneAddition - when PWNing an existing view, we have to unicast // because NAKACK will reject a mcast message from a non-member if (mcast) { Message view_change_msg=new Message(); // bcast to all members view_change_msg.setObject(newView); view_change_msg.isHighPriority = true; view_change_msg.putHeader(name, hdr); passDown(new Event(Event.MSG, view_change_msg)); } else { for (IpAddress dest: mbrs) { if (dest.equals(this.local_addr)) { synchronized(prepare_collector) { prepare_collector.ack(dest, null); } } else { Message msg = new Message(); msg.isHighPriority = true; msg.putHeader(name, hdr); msg.setObject(newView); msg.setDest(dest); // if (trace) // log.trace("sending PREPARE_FOR_VIEW to " + dest); passDown(new Event(Event.MSG, msg)); } } } try { // log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "DEBUG: before waiting for prepare-acks, collector state is " + prepare_collector); prepare_collector.waitForAllAcks(view_ack_collection_timeout); // log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "DEBUG: after waiting for prepare-acks, collector state is " + prepare_collector); } catch(TimeoutException e) { // timeout processing is handled below, along with members declared dead during view preparation // see bug #47295 timedout=true; } //log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "received acks from " + prepare_collector.getReceived()); List missing; String missingStr; String receivedStr = null; boolean logMissing = false; synchronized (prepare_collector) { missing = prepare_collector.getMissingAcks(); missing.addAll(prepare_collector.getSuspectedMembers()); missing.removeAll(newView.getSuspectedMembers()); // don't reprocess members that are already kicked out missing.remove(this.local_addr); // don't suspect myself - I might be shutting down // bug #44342 - if the member has sent a shutdown message then it's okay for (Iterator<IpAddress> it=missing.iterator(); it.hasNext(); ) { IpAddress addr = it.next(); if (!newView.containsMember(addr) || this.stack.gfPeerFunctions.isShuttingDown(addr)) { it.remove(); } } logMissing = missing.size() > 0; if (logMissing) { // note who has acked while under synchronization receivedStr = prepare_collector.getReceived().toString(); } } if (logMissing && !this.stack.getChannel().closing()) { missingStr = missing.toString(); log.getLogWriter().warning( ExternalStrings.GMS_FAILED_TO_COLLECT_ALL_ACKS_0_FOR_VIEW_PREPARATION_1_AFTER_2_MS_MISSING_ACKS_FROM_3_RECEIVED_4_LOCAL_ADDR_5, new Object[] {Integer.valueOf(size), newView, Long.valueOf(view_ack_collection_timeout), missingStr, receivedStr, local_addr}/*, new Exception("stack trace")*/); } return missing; }
Example 19
Source File: CreateFeedbackQuestionAction.java From teammates with GNU General Public License v2.0 | 4 votes |
@Override public ActionResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); String feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); FeedbackQuestionCreateRequest request = getAndValidateRequestBody(FeedbackQuestionCreateRequest.class); FeedbackQuestionAttributes attributes = FeedbackQuestionAttributes.builder() .withCourseId(courseId) .withFeedbackSessionName(feedbackSessionName) .withGiverType(request.getGiverType()) .withRecipientType(request.getRecipientType()) .withQuestionNumber(request.getQuestionNumber()) .withNumberOfEntitiesToGiveFeedbackTo(request.getNumberOfEntitiesToGiveFeedbackTo()) .withShowResponsesTo(request.getShowResponsesTo()) .withShowGiverNameTo(request.getShowGiverNameTo()) .withShowRecipientNameTo(request.getShowRecipientNameTo()) .withQuestionDetails(request.getQuestionDetails()) .withQuestionDescription(request.getQuestionDescription()) .build(); // validate questions (giver & recipient) String err = attributes.getQuestionDetails().validateGiverRecipientVisibility(attributes); if (!err.isEmpty()) { throw new InvalidHttpRequestBodyException(err); } // validate questions (question details) FeedbackQuestionDetails questionDetails = attributes.getQuestionDetails(); if (questionDetails instanceof FeedbackMsqQuestionDetails) { FeedbackMsqQuestionDetails msqQuestionDetails = (FeedbackMsqQuestionDetails) questionDetails; int numOfGeneratedMsqChoices = logic.getNumOfGeneratedChoicesForParticipantType( attributes.getCourseId(), msqQuestionDetails.getGenerateOptionsFor()); msqQuestionDetails.setNumOfGeneratedMsqChoices(numOfGeneratedMsqChoices); questionDetails = msqQuestionDetails; } List<String> questionDetailsErrors = questionDetails.validateQuestionDetails(); if (!questionDetailsErrors.isEmpty()) { throw new InvalidHttpRequestBodyException(questionDetailsErrors.toString()); } try { attributes = logic.createFeedbackQuestion(attributes); } catch (InvalidParametersException e) { throw new InvalidHttpRequestBodyException(e.getMessage(), e); } return new JsonResult(new FeedbackQuestionData(attributes)); }
Example 20
Source File: Translator.java From spacewalk with GNU General Public License v2.0 | 2 votes |
/** * Converts a List to a String * @param l list to be converted * @return List.toString() */ public static String list2String(List l) { return (l == null) ? "" : l.toString(); }