Java Code Examples for java.util.List#get()
The following examples show how to use
java.util.List#get() .
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: JSONLDW3CAnnotationPageMessageConverter.java From elucidate-server with MIT License | 6 votes |
@Override @SuppressWarnings("unchecked") protected String getStringRepresentation(W3CAnnotationPage w3cAnnotationPage, MediaType contentType) throws Exception { Map<String, Object> jsonMap = w3cAnnotationPage.getJsonMap(); JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts); Format format = jsonLdProfile.getFormats().get(0); if (format.equals(Format.COMPACTED)) { jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions); } else if (format.equals(Format.EXPANDED)) { List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions); jsonMap = (Map<String, Object>) jsonList.get(0); } else if (format.equals(Format.FLATTENED)) { jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions); } else { throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes()); } jsonMap = reorderJsonAttributes(jsonMap); return JsonUtils.toPrettyString(jsonMap); }
Example 2
Source File: WarpDb.java From warpdb with Apache License 2.0 | 6 votes |
/** * Get a model instance by class type and id. Return null if not found. * * @param <T> Generic type. * @param clazz Entity class. * @param id Id value. * @return Entity bean found by id. */ public <T> T fetch(Class<T> clazz, Serializable id) { Mapper<T> mapper = getMapper(clazz); if (mapper.ids.length != 1) { throw new IllegalArgumentException(mapper.ids.length + " id values are expected but actual 1."); } log.debug("SQL: " + mapper.selectSQL); List<T> list = (List<T>) jdbcTemplate.query(mapper.selectSQL, new Object[] { id }, mapper.rowMapper); if (list.isEmpty()) { return null; } T t = list.get(0); try { mapper.postLoad.invoke(t); } catch (IllegalAccessException | InvocationTargetException e) { throw new PersistenceException(e); } return t; }
Example 3
Source File: SyntaxServerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testDidClose() throws Exception { URI fileURI = openFile("maven/salut4", "src/main/java/java/TestSyntaxError.java"); Job.getJobManager().join(SyntaxDocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); String fileUri = ResourceUtils.fixURI(fileURI); TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileUri); server.didClose(new DidCloseTextDocumentParams(identifier)); Job.getJobManager().join(SyntaxDocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics"); assertEquals(2, diagnosticReports.size()); PublishDiagnosticsParams params = diagnosticReports.get(1); assertEquals(fileUri, params.getUri()); assertNotNull(params.getDiagnostics()); assertTrue(params.getDiagnostics().isEmpty()); }
Example 4
Source File: ConditionalDisplayOfParagraphsTest.java From docx-stamper with MIT License | 6 votes |
private void paragraphsInNestedTablesAreRemoved(WordprocessingMLPackage document) { final List<Tbl> tables = new ArrayList<>(); CoordinatesWalker walker = new BaseCoordinatesWalker(document) { @Override protected void onTable(TableCoordinates tableCoordinates) { tables.add(tableCoordinates.getTable()); } }; walker.walk(); Tbl nestedTable = tables.get(1); Tc cell = (Tc) ((JAXBElement) ((Tr) nestedTable.getContent().get(1)).getContent().get(0)).getValue(); P p1 = (P) cell.getContent().get(0); Assert.assertEquals(1, cell.getContent().size()); Assert.assertEquals("This paragraph stays untouched.", new ParagraphWrapper(p1).getText()); }
Example 5
Source File: GetHDFSTest.java From localization_nifi with Apache License 2.0 | 6 votes |
@Test public void testAutomaticDecompression() throws IOException { GetHDFS proc = new TestableGetHDFS(kerberosProperties); TestRunner runner = TestRunners.newTestRunner(proc); runner.setProperty(PutHDFS.DIRECTORY, "src/test/resources/testdata"); runner.setProperty(GetHDFS.FILE_FILTER_REGEX, "random.*.gz"); runner.setProperty(GetHDFS.KEEP_SOURCE_FILE, "true"); runner.setProperty(GetHDFS.COMPRESSION_CODEC, "AUTOMATIC"); runner.run(); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(GetHDFS.REL_SUCCESS); assertEquals(1, flowFiles.size()); MockFlowFile flowFile = flowFiles.get(0); assertTrue(flowFile.getAttribute(CoreAttributes.FILENAME.key()).equals("randombytes-1")); InputStream expected = getClass().getResourceAsStream("/testdata/randombytes-1"); flowFile.assertContentEquals(expected); }
Example 6
Source File: ExceptionUtils.java From tddl5 with Apache License 2.0 | 6 votes |
public static void throwSQLException(List<SQLException> exceptions, String sql, Map<Integer, ParameterContext> parameter) throws SQLException { if (exceptions != null && !exceptions.isEmpty()) { SQLException first = exceptions.get(0); if (sql != null) { log.info(("TDDL SQL EXECUTE ERROR REPORTER:" + getErrorContext(sql, parameter, SQL_EXECUTION_ERROR_CONTEXT_MESSAGE)), first); } for (int i = 1, n = exceptions.size(); i < n; i++) { if (sql != null) { log.info(("layer:" + n + "TDDL SQL EXECUTE ERROR REPORTER :" + getErrorContext(sql, parameter, SQL_EXECUTION_ERROR_CONTEXT_MESSAGE)), exceptions.get(i)); } } throw mergeException(exceptions); } }
Example 7
Source File: rowContext.java From openbd-core with GNU General Public License v3.0 | 6 votes |
int [] getAllColumnTypes(){ List<int[]> allTypesList = new ArrayList<int[]>(); int totalCols = 0; Enumeration<String> keys = tables.keys(); // loop thru' all the tables getting all the column types while ( keys.hasMoreElements() ){ int [] colTypes = getTableColumnTypes( keys.nextElement() ); allTypesList.add( colTypes ); totalCols += colTypes.length; } int [] allTableColTypes = new int [ totalCols ]; int allColumnsIndex = 0; for ( int i = 0; i < allTypesList.size(); i++ ){ int [] tableCols = allTypesList.get(i); for ( int j = 0; j < tableCols.length; j++ ){ allTableColTypes[ allColumnsIndex ] = tableCols[ j ]; allColumnsIndex++; } } return allTableColTypes; }
Example 8
Source File: JRouteEditDialog.java From jeveassets with GNU General Public License v2.0 | 6 votes |
public RouteResult show(Map<Long, SolarSystem> systemCache, Graph<SolarSystem> filteredGraph, RouteResult routeResult) { updating = true; this.filteredGraph = filteredGraph; this.systemCache = systemCache; this.routeResult = routeResult; this.returnResult = null; //Reset model.removeAllElements(); for (List<SolarSystem> jumps : routeResult.getRoute()) { SolarSystem solarSystem = jumps.get(0); Route route = new Route(solarSystem.getLocationID(), solarSystem.getSystem()); model.addElement(route); } jAvoid.setText(TabsRouting.get().resultEditAvoid(program.getRoutingTab().getAvoidString())); jSecurity.setText((TabsRouting.get().resultEditSecurity(program.getRoutingTab().getSecurityString()))); calculateInfo(routeResult.getJumps()); updating = false; boolean valid = recalculateRoutes(); if (valid) { setVisible(true); } return returnResult; }
Example 9
Source File: UpdateOrgInfoListener.java From MicroCommunity with Apache License 2.0 | 6 votes |
/** * business to instance 过程 * * @param dataFlowContext 数据对象 * @param business 当前业务对象 */ @Override protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) { JSONObject data = business.getDatas(); Map info = new HashMap(); info.put("bId", business.getbId()); info.put("operate", StatusConstant.OPERATE_ADD); //组织信息 List<Map> businessOrgInfos = orgServiceDaoImpl.getBusinessOrgInfo(info); if (businessOrgInfos != null && businessOrgInfos.size() > 0) { for (int _orgIndex = 0; _orgIndex < businessOrgInfos.size(); _orgIndex++) { Map businessOrgInfo = businessOrgInfos.get(_orgIndex); flushBusinessOrgInfo(businessOrgInfo, StatusConstant.STATUS_CD_VALID); orgServiceDaoImpl.updateOrgInfoInstance(businessOrgInfo); if (businessOrgInfo.size() == 1) { dataFlowContext.addParamOut("orgId", businessOrgInfo.get("org_id")); } } } }
Example 10
Source File: L10N.java From carina with Apache License 2.0 | 5 votes |
/** * get Default Locale * * @return Locale */ public static Locale getDefaultLocale() { List<Locale> locales = LocaleReader.init(Configuration .get(Parameter.LOCALE)); if (locales.size() == 0) { throw new RuntimeException("Undefined default locale specified! Review 'locale' setting in _config.properties."); } return locales.get(0); }
Example 11
Source File: DataSourceSyncRecorder.java From dble with GNU General Public License v2.0 | 5 votes |
/** * remove the old data */ private void remove(long time) { final List<Record> recordsAll = this.asyncRecords; while (recordsAll.size() > 0) { Record record = recordsAll.get(0); if (time >= record.time + SWAP_TIME) { recordsAll.remove(0); } else { break; } } }
Example 12
Source File: WebViewEventDispatcher.java From oim-fx with MIT License | 5 votes |
@Override protected void layoutChildren() { List<Node> managed = getManagedChildren(); double width = getWidth(); double height = getHeight(); double top = getInsets().getTop(); double right = getInsets().getRight(); double left = getInsets().getLeft(); double bottom = getInsets().getBottom(); for (int i = 0; i < managed.size(); i++) { Node child = managed.get(i); layoutInArea(child, left, top, width - left - right, height - top - bottom, 0, Insets.EMPTY, true, true, HPos.CENTER, VPos.CENTER); } }
Example 13
Source File: BaseExtensionHelper.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * @param type the name of the extension * @param allowOverride if true, the last registered participant will be * returned, thus "overriding" any previously * registered participants. If false, an exception * is thrown if more than one participant is * registered. * @return the participant for the given extension type, or null if none * is registered. */ public static Object getParticipant(String type, boolean allowOverride) { List<Object> participants = getParticipants(type); if (participants.isEmpty()) { return null; } if (!allowOverride && participants.size() > 1) { // only one participant may be used for this throw new RuntimeException("More than one participant is registered for type:" + type); } return participants.get(participants.size() - 1); }
Example 14
Source File: ReplyErrorHandler.java From mongodb-async-driver with Apache License 2.0 | 5 votes |
/** * Creates an exception from the {@link Reply}. * * @param reply * The raw reply. * @param knownError * If true then the reply is assumed to be an error reply. * @return The exception created. */ protected MongoDbException asError(final Reply reply, final boolean knownError) { final List<Document> results = reply.getResults(); if (results.size() == 1) { final Document doc = results.get(0); final Element okElem = doc.get("ok"); final Element errorNumberElem = doc.get(ERROR_CODE_FIELD); Element errorMessageElem = null; for (int i = 0; (errorMessageElem == null) && (i < ERROR_MESSAGE_FIELDS.size()); ++i) { errorMessageElem = doc.get(ERROR_MESSAGE_FIELDS.get(i)); } if (okElem != null) { final int okValue = toInt(okElem); if (okValue != 1) { return asError(reply, okValue, toInt(errorNumberElem), asString(errorMessageElem)); } else if ((errorMessageElem != null) && !(errorMessageElem instanceof NullElement)) { return asError(reply, okValue, toInt(errorNumberElem), asString(errorMessageElem)); } } else if (knownError) { return asError(reply, -1, toInt(errorNumberElem), asString(errorMessageElem)); } } else if (knownError) { return new QueryFailedException(reply, new MongoDbException( "Unknown Error.")); } return null; }
Example 15
Source File: TreeListDialogField.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Adds elements at the end of the tree list. */ public boolean addElements(List<E> elements) { int nElements= elements.size(); if (nElements > 0) { // filter duplicated ArrayList<E> elementsToAdd= new ArrayList<E>(nElements); for (int i= 0; i < nElements; i++) { E elem= elements.get(i); if (!fElements.contains(elem)) { elementsToAdd.add(elem); } } if (!elementsToAdd.isEmpty()) { fElements.addAll(elementsToAdd); if (isOkToUse(fTreeControl)) { fTree.add(fParentElement, elementsToAdd.toArray()); for (int i= 0; i < elementsToAdd.size(); i++) { fTree.expandToLevel(elementsToAdd.get(i), fTreeExpandLevel); } } dialogFieldChanged(); return true; } } return false; }
Example 16
Source File: SelectWindowFunctionAnalyzerTest.java From crate with Apache License 2.0 | 5 votes |
@Test public void testOverWithFrameDefinition() { QueriedSelectRelation analysis = e.analyze("select avg(x) OVER (PARTITION BY x ORDER BY x " + "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) from t"); List<Symbol> outputSymbols = analysis.outputs(); assertThat(outputSymbols.size(), is(1)); assertThat(outputSymbols.get(0), instanceOf(WindowFunction.class)); WindowFunction windowFunction = (WindowFunction) outputSymbols.get(0); assertThat(windowFunction.arguments().size(), is(1)); WindowFrameDefinition frameDefinition = windowFunction.windowDefinition().windowFrameDefinition(); assertThat(frameDefinition.mode(), is(WindowFrame.Mode.RANGE)); assertThat(frameDefinition.start().type(), is(FrameBound.Type.UNBOUNDED_PRECEDING)); assertThat(frameDefinition.end().type(), is(FrameBound.Type.UNBOUNDED_FOLLOWING)); }
Example 17
Source File: ArrayUtils.java From modbus4j with GNU General Public License v3.0 | 5 votes |
/** * <p>toIntArray.</p> * * @param list a {@link java.util.List} object. * @return an array of {@link int} objects. */ public static int[] toIntArray(List<Integer> list) { int[] result = new int[list.size()]; for (int i = 0; i < result.length; i++) result[i] = list.get(i); return result; }
Example 18
Source File: MD5Loader.java From lwjglbook with Apache License 2.0 | 4 votes |
private static AnimatedFrame processAnimationFrame(MD5Model md5Model, MD5AnimModel animModel, MD5Frame frame, List<Matrix4f> invJointMatrices) { AnimatedFrame result = new AnimatedFrame(); MD5BaseFrame baseFrame = animModel.getBaseFrame(); List<MD5Hierarchy.MD5HierarchyData> hierarchyList = animModel.getHierarchy().getHierarchyDataList(); List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints(); int numJoints = joints.size(); float[] frameData = frame.getFrameData(); for (int i = 0; i < numJoints; i++) { MD5JointInfo.MD5JointData joint = joints.get(i); MD5BaseFrame.MD5BaseFrameData baseFrameData = baseFrame.getFrameDataList().get(i); Vector3f position = baseFrameData.getPosition(); Quaternionf orientation = baseFrameData.getOrientation(); int flags = hierarchyList.get(i).getFlags(); int startIndex = hierarchyList.get(i).getStartIndex(); if ((flags & 1) > 0) { position.x = frameData[startIndex++]; } if ((flags & 2) > 0) { position.y = frameData[startIndex++]; } if ((flags & 4) > 0) { position.z = frameData[startIndex++]; } if ((flags & 8) > 0) { orientation.x = frameData[startIndex++]; } if ((flags & 16) > 0) { orientation.y = frameData[startIndex++]; } if ((flags & 32) > 0) { orientation.z = frameData[startIndex++]; } // Update Quaternion's w component orientation = MD5Utils.calculateQuaternion(orientation.x, orientation.y, orientation.z); // Calculate translation and rotation matrices for this joint Matrix4f translateMat = new Matrix4f().translate(position); Matrix4f rotationMat = new Matrix4f().rotate(orientation); Matrix4f jointMat = translateMat.mul(rotationMat); // Joint position is relative to joint's parent index position. Use parent matrices // to transform it to model space if (joint.getParentIndex() > -1) { Matrix4f parentMatrix = result.getLocalJointMatrices()[joint.getParentIndex()]; jointMat = new Matrix4f(parentMatrix).mul(jointMat); } result.setMatrix(i, jointMat, invJointMatrices.get(i)); } return result; }
Example 19
Source File: SubselectFetchTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void testSubselectFetchWithLimit() { Session s = openSession(); Transaction t = s.beginTransaction(); Parent p = new Parent("foo"); p.getChildren().add( new Child("foo1") ); p.getChildren().add( new Child("foo2") ); Parent q = new Parent("bar"); q.getChildren().add( new Child("bar1") ); q.getChildren().add( new Child("bar2") ); Parent r = new Parent("aaa"); r.getChildren().add( new Child("aaa1") ); s.persist(p); s.persist(q); s.persist(r); t.commit(); s.close(); s = openSession(); t = s.beginTransaction(); getSessions().getStatistics().clear(); List parents = s.createQuery("from Parent order by name desc") .setMaxResults(2) .list(); p = (Parent) parents.get(0); q = (Parent) parents.get(1); assertFalse( Hibernate.isInitialized( p.getChildren() ) ); assertFalse( Hibernate.isInitialized( p.getMoreChildren() ) ); assertFalse( Hibernate.isInitialized( q.getChildren() ) ); assertFalse( Hibernate.isInitialized( q.getMoreChildren() ) ); assertEquals( p.getMoreChildren().size(), 0 ); assertEquals( p.getChildren().size(), 2 ); assertTrue( Hibernate.isInitialized( q.getChildren() ) ); assertTrue( Hibernate.isInitialized( q.getMoreChildren() ) ); assertEquals( 3, getSessions().getStatistics().getPrepareStatementCount() ); r = (Parent) s.get( Parent.class, r.getName() ); assertTrue( Hibernate.isInitialized( r.getChildren() ) ); assertFalse( Hibernate.isInitialized( r.getMoreChildren() ) ); assertEquals( r.getChildren().size(), 1 ); assertEquals( r.getMoreChildren().size(), 0 ); s.delete(p); s.delete(q); s.delete(r); t.commit(); s.close(); }
Example 20
Source File: FrameworkUtil.java From sling-whiteboard with Apache License 2.0 | 4 votes |
private Object parse_substring() throws InvalidSyntaxException { StringBuilder sb = new StringBuilder(filterChars.length - pos); List<String> operands = new ArrayList<String>(10); parseloop: while (true) { char c = filterChars[pos]; switch (c) { case ')' : { if (sb.length() > 0) { operands.add(sb.toString()); } break parseloop; } case '(' : { throw new InvalidSyntaxException("Invalid value: " + filterstring.substring(pos), filterstring); } case '*' : { if (sb.length() > 0) { operands.add(sb.toString()); } sb.setLength(0); operands.add(null); pos++; break; } case '\\' : { pos++; c = filterChars[pos]; /* fall through into default */ } default : { sb.append(c); pos++; break; } } } int size = operands.size(); if (size == 0) { return ""; } if (size == 1) { Object single = operands.get(0); if (single != null) { return single; } } return operands.toArray(new String[0]); }