List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:it.intecs.pisa.toolbox.util.URLReader.java
public static void writeURLContentToXML(String infoXmlFile, String fileName) throws Exception { try {/* www . jav a 2s .co m*/ String host = null; String url = null; int port = 0; Element infoXml = new DOMUtil().fileToDocument(new File(infoXmlFile)).getDocumentElement(); if (infoXml != null) { host = infoXml.getAttribute("newVersionHost"); url = infoXml.getAttribute("newVersionUrl"); String portStr = infoXml.getAttribute("newVersionPort"); Integer portInt = new Integer(portStr); port = portInt.intValue(); } String fileContent = (String) getURLContent(host, url, port); if (fileContent == null) return; fileContent = fileContent.substring(fileContent.indexOf("<"), fileContent.lastIndexOf(">") + 1); File newFile = new File(fileName); FileWriter fw = new FileWriter(newFile); fw.write(fileContent); fw.close(); } catch (Exception e) { e.printStackTrace(System.out); return; } }
From source file:edu.asu.ca.kaushik.algorithms.structures.InteractionGraph.java
private static double calculateNumCoveringRows(Integer[] row, ColGroup colGr1, ColGroup colGr2, int v) { Integer[] rowCopy = Arrays.copyOf(row, row.length); rowCopy = markCols(rowCopy, colGr1); rowCopy = markCols(rowCopy, colGr2); double exp = 0; for (Integer i : rowCopy) { if (i.intValue() == v) { exp = exp + 1.0d;/* ww w . j a v a 2s . co m*/ } } return Math.pow(v, exp); }
From source file:com.safi.workshop.application.ChooseSafiServerWorkspaceData.java
/** * Return true if the protocol used to encode the argument memento is compatible with * the receiver's implementation and false otherwise. *///from w ww .ja v a 2 s .c o m private static boolean compatibleFileProtocol(IMemento memento) { IMemento protocolMemento = memento.getChild(XML.PROTOCOL); if (protocolMemento == null) { return false; } Integer version = protocolMemento.getInteger(XML.VERSION); return version != null && version.intValue() == PERS_ENCODING_VERSION; }
From source file:com.aurel.track.persist.TDashboardTabPeer.java
/** * Gets the last used sort order//from w w w . j av a 2 s. c om * @param objectID * @return */ public static Integer getNextSortOrder(Integer objectID) { Integer sortOrder = null; String max = "max(" + SORTORDER + ")"; Criteria crit = new Criteria(); crit.add(PARENT, objectID); crit.addSelectColumn(max); try { sortOrder = ((Record) doSelectVillageRecords(crit).get(0)).getValue(1).asIntegerObj(); } catch (Exception e) { } if (sortOrder != null) { sortOrder = new Integer(sortOrder.intValue() + 1); } else { sortOrder = new Integer(0); } LOGGER.debug("Next tab sort order=" + sortOrder); return sortOrder; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.teachersBody.ReadProfessorshipsAndResponsibilitiesByDepartmentAndExecutionPeriod.java
@Atomic public static List run(String departmentId, String executionYearID, Integer semester, Integer teacherType) throws FenixServiceException { ExecutionYear executionYear = null;//from w w w. j a v a2 s . co m if (executionYearID != null) { executionYear = FenixFramework.getDomainObject(executionYearID); } final ExecutionSemester executionSemester = executionYear.getExecutionSemesterFor(semester); if (semester.intValue() != 0 && executionSemester == null) { throw new FenixServiceException("error.noExecutionPeriod"); } final Department department = FenixFramework.getDomainObject(departmentId); if (department == null) { throw new FenixServiceException("error.noDepartment"); } final List<Teacher> teachers = department.getAllCurrentTeachers(); Iterator iter = teachers.iterator(); List professorships = new ArrayList(); List responsibleFors = new ArrayList(); while (iter.hasNext()) { Teacher teacher = (Teacher) iter.next(); Collection teacherProfessorships = null; if (executionYear == null) { teacherProfessorships = teacher.getProfessorships(); } else { if (semester.intValue() == 0) { teacherProfessorships = teacher.getProfessorships(executionYear); } else { teacherProfessorships = teacher.getProfessorships(executionSemester); } } if (teacherProfessorships != null) { professorships.addAll(teacherProfessorships); } List teacherResponsibleFors; List<Professorship> teacherResponsibleForsAux = null; if (executionYear == null) { teacherResponsibleFors = teacher.responsibleFors(); } else { teacherResponsibleForsAux = teacher.responsibleFors(); teacherResponsibleFors = new ArrayList<Professorship>(); for (Professorship professorship : teacherResponsibleForsAux) { if (professorship.getExecutionCourse().getExecutionPeriod().getExecutionYear() .equals(executionYear)) { teacherResponsibleFors.add(professorship); } } } if (teacherResponsibleFors != null) { responsibleFors.addAll(teacherResponsibleFors); } } List detailedProfessorships = getDetailedProfessorships(professorships, responsibleFors, teacherType); // Cleaning out possible null elements inside the list Iterator itera = detailedProfessorships.iterator(); while (itera.hasNext()) { Object dp = itera.next(); if (dp == null) { itera.remove(); } } Collections.sort(detailedProfessorships, new Comparator() { @Override public int compare(Object o1, Object o2) { DetailedProfessorship detailedProfessorship1 = (DetailedProfessorship) o1; DetailedProfessorship detailedProfessorship2 = (DetailedProfessorship) o2; int result = detailedProfessorship1.getInfoProfessorship().getInfoExecutionCourse().getExternalId() .compareTo(detailedProfessorship2.getInfoProfessorship().getInfoExecutionCourse() .getExternalId()); if (result == 0 && (detailedProfessorship1.getResponsibleFor().booleanValue() || detailedProfessorship2.getResponsibleFor().booleanValue())) { if (detailedProfessorship1.getResponsibleFor().booleanValue()) { return -1; } if (detailedProfessorship2.getResponsibleFor().booleanValue()) { return 1; } } return result; } }); List result = new ArrayList(); iter = detailedProfessorships.iterator(); List temp = new ArrayList(); while (iter.hasNext()) { DetailedProfessorship detailedProfessorship = (DetailedProfessorship) iter.next(); if (temp.isEmpty() || ((DetailedProfessorship) temp.get(temp.size() - 1)).getInfoProfessorship() .getInfoExecutionCourse() .equals(detailedProfessorship.getInfoProfessorship().getInfoExecutionCourse())) { temp.add(detailedProfessorship); } else { result.add(temp); temp = new ArrayList(); temp.add(detailedProfessorship); } } if (!temp.isEmpty()) { result.add(temp); } return result; }
From source file:com.adito.policyframework.ResourceUtil.java
/** * Filter a list of {@link Integer} objects containing resource ids for * those that have a global favorite.//www .j a va 2 s . c o m * * @param resources resources * @param resourceType resource type * @return filtered list of resources that have favorites * @throws Exception on any error */ public static List filterResourceIdsForGlobalFavorites(List resources, ResourceType resourceType) throws Exception { List l = new ArrayList(); for (Iterator i = resources.iterator(); i.hasNext();) { Integer r = (Integer) i.next(); if (SystemDatabaseFactory.getInstance().getFavorite(resourceType.getResourceTypeId(), null, r.intValue()) != null) { l.add(r); } } return l; }
From source file:com.aurel.track.admin.customize.treeConfig.field.FieldConfigBL.java
public static FieldConfigTO createFieldConfigTO(WorkItemContext workItemContext, TFieldBean fieldBean, Locale locale) {/*w w w.j av a2 s. com*/ FieldConfigTO fieldConfigTO = new FieldConfigTO(); Integer fieldID = fieldBean.getObjectID(); fieldConfigTO.setFieldID(fieldID); FieldType fieldType = FieldTypeManager.getInstance().getType(fieldID); TypeRendererRT fieldTypeRendererRT = null; IFieldTypeRT fieldTypeRT = null; if (fieldType != null) { fieldType.setFieldID(fieldID); fieldTypeRendererRT = fieldType.getRendererRT(); fieldTypeRT = fieldType.getFieldTypeRT(); } TFieldConfigBean fieldConfigBean = (TFieldConfigBean) workItemContext.getFieldConfigs().get(fieldID); String tooltip = null; if (fieldConfigBean != null) { tooltip = fieldConfigBean.getTooltip(); if (fieldTypeRT != null && tooltip != null) { Map<String, Object> labelContext = fieldTypeRT.getLabelContext(fieldID, workItemContext.getWorkItemBean().getAttribute(fieldID, null), locale); if (labelContext != null && !labelContext.isEmpty()) { Template tooltipTemplate = getTooltipTemplate(tooltip); StringWriter labelWriter = new StringWriter(); try { tooltipTemplate.process(labelContext, labelWriter); tooltip = labelWriter.toString(); } catch (Exception e) { LOGGER.debug("Processing template: " + labelWriter.toString() + " failed with " + e.getMessage()); } } } fieldConfigTO.setLabel(fieldConfigBean.getLabel()); } if (tooltip == null) { tooltip = ""; } fieldConfigTO.setTooltip(tooltip); Integer accesFlag = null; if (workItemContext.getFieldRestrictions() != null) { accesFlag = workItemContext.getFieldRestrictions().get(fieldID); } boolean readonly = false; boolean invisible = false; if (accesFlag != null) { if (accesFlag.intValue() == TRoleFieldBean.ACCESSFLAG.NOACCESS) { readonly = true; invisible = true; } else { invisible = false; readonly = (accesFlag.intValue() == TRoleFieldBean.ACCESSFLAG.READ_ONLY); } } fieldConfigTO.setReadonly(readonly); Set<Integer> readOnlyFields = getReadOnlySet(); if (readOnlyFields.contains(fieldID)) { fieldConfigTO.setReadonly(true); } else { fieldConfigTO.setRequired(fieldBean.isRequiredString() || fieldConfigBean.isRequiredString()); } fieldConfigTO.setInvisible(invisible); boolean hasDependences = ItemFieldRefreshBL.hasDependences(fieldBean, workItemContext); fieldConfigTO.setHasDependences(hasDependences); if (hasDependences) { fieldConfigTO.setClientSideRefresh(ItemFieldRefreshBL.isClientSideRefresh(fieldID)); } //TODO validate JSON if (fieldTypeRendererRT != null) { fieldConfigTO.setJsonData(fieldTypeRendererRT.createJsonData(fieldBean, workItemContext)); } return fieldConfigTO; }
From source file:com.alibaba.otter.shared.common.utils.meta.DdlUtils.java
private static Column readColumn(DatabaseMetaDataWrapper metaData, Map<String, Object> values) throws SQLException { Column column = new Column(); column.setName((String) values.get("COLUMN_NAME")); column.setDefaultValue((String) values.get("COLUMN_DEF")); column.setTypeCode(((Integer) values.get("DATA_TYPE")).intValue()); String typeName = (String) values.get("TYPE_NAME"); // column.setType(typeName); if ((typeName != null) && typeName.startsWith("TIMESTAMP")) { column.setTypeCode(Types.TIMESTAMP); }//from ww w .ja va 2 s . c o m // modify 2013-09-25?unsigned if ((typeName != null) && StringUtils.containsIgnoreCase(typeName, "UNSIGNED")) { // unsigned???? switch (column.getTypeCode()) { case Types.TINYINT: column.setTypeCode(Types.SMALLINT); break; case Types.SMALLINT: column.setTypeCode(Types.INTEGER); break; case Types.INTEGER: column.setTypeCode(Types.BIGINT); break; case Types.BIGINT: column.setTypeCode(Types.DECIMAL); break; default: break; } } Integer precision = (Integer) values.get("NUM_PREC_RADIX"); if (precision != null) { column.setPrecisionRadix(precision.intValue()); } String size = (String) values.get("COLUMN_SIZE"); if (size == null) { size = (String) _defaultSizes.get(new Integer(column.getTypeCode())); } // we're setting the size after the precision and radix in case // the database prefers to return them in the size value column.setSize(size); int scale = 0; Object dec_digits = values.get("DECIMAL_DIGITS"); if (dec_digits instanceof String) { scale = (dec_digits == null) ? 0 : NumberUtils.toInt(dec_digits.toString()); } else if (dec_digits instanceof Integer) { scale = (dec_digits == null) ? 0 : (Integer) dec_digits; } if (scale != 0) { column.setScale(scale); } column.setRequired("NO".equalsIgnoreCase(((String) values.get("IS_NULLABLE")).trim())); column.setDescription((String) values.get("REMARKS")); return column; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.importer.ExcelImportUtilities.java
/** * Reads the content from the specified {@code row}. The specified {@code headline} defines the * head names associated with the column indexes. Only these specified columns will be read * and returned.//from w ww.ja va2 s . co m * * @param row the row to read the content from * @param headline the map containing headline names associated with the headline column indexes * @return the map containing headline names associated with the specified {@code row} content */ public static Map<String, Cell> readRow(Row row, Map<String, Integer> headline) { final Map<String, Cell> result = new HashMap<String, Cell>(); for (Map.Entry<String, Integer> headlineEntry : headline.entrySet()) { String headlineName = headlineEntry.getKey(); Integer columnIndex = headlineEntry.getValue(); Cell curCell = row.getCell(columnIndex.intValue(), Row.CREATE_NULL_AS_BLANK); if (curCell == null) { // may happen if a single cell was deleted/has no contents --> avoid the mapping to null continue; } LOGGER.debug(" {0}={1}", headlineName, curCell); result.put(headlineName, curCell); } return result; }
From source file:com.frank.search.solr.core.ResultHelper.java
static <T> Map<Object, GroupResult<T>> convertGroupQueryResponseToGroupResultMap(Query query, Map<String, Object> objectNames, QueryResponse response, SolrTemplate solrTemplate, Class<T> clazz) { GroupResponse groupResponse = response.getGroupResponse(); SolrDocumentList sdl = response.getResults(); if (groupResponse == null) { return Collections.emptyMap(); }//w ww . j a v a 2s . co m Map<Object, GroupResult<T>> result = new LinkedHashMap<Object, GroupResult<T>>(); List<GroupCommand> values = groupResponse.getValues(); for (GroupCommand groupCommand : values) { List<GroupEntry<T>> groupEntries = new ArrayList<GroupEntry<T>>(); for (Group group : groupCommand.getValues()) { SolrDocumentList documentList = group.getResult(); List<T> beans = solrTemplate.convertSolrDocumentListToBeans(documentList, clazz); Page<T> page = new PageImpl<T>(beans, query.getGroupOptions().getPageRequest(), documentList.getNumFound()); groupEntries.add(new SimpleGroupEntry<T>(group.getGroupValue(), page)); } int matches = groupCommand.getMatches(); Integer ngroups = groupCommand.getNGroups(); String name = groupCommand.getName(); PageImpl<GroupEntry<T>> page; if (ngroups != null) { page = new PageImpl<GroupEntry<T>>(groupEntries, query.getPageRequest(), ngroups.intValue()); } else { page = new PageImpl<GroupEntry<T>>(groupEntries); } SimpleGroupResult<T> groupResult = new SimpleGroupResult<T>(matches, ngroups, name, page); result.put(name, groupResult); if (objectNames.containsKey(name)) { result.put(objectNames.get(name), groupResult); } } return result; }