@Override public void execute() throws BuildException { Properties properties = new Properties(); Path path = file.toPath(); if (file.exists()) { try { properties.load(Files.newBufferedReader(path, StandardCharsets.UTF_8)); } catch (IOException e) { throw new BuildException(e); } } Version version = new Version(properties.getProperty(PROPERTY, "0.0.0")); version.increment(importance); String value = version.toString(); properties.setProperty(PROPERTY, value); getProject().setProperty(PROPERTY, value); try { properties.store(Files.newBufferedWriter(path, StandardCharsets.UTF_8), null); } catch (IOException e) { throw new BuildException(e); } }
private Version createVersion(int version) { Version v; final int N = versions.size(); if (N == mMaxVersions) { // recycle the last version object & bitmap v = versions.get(N - 1); versions.remove(N - 1); v.version = version; bottom = versions.get(N - 2).version; v.bitmap.eraseColor(0); } else { v = new Version(version); if (v.bitmap == null) { // XXX handle memory error return null; } } if (versions.size() > 0) { // XXX: this will be slow; maybe we can do the alloc & copy at commit time v.canvas.drawBitmap(versions.get(0).bitmap, x * mTileSize, y * mTileSize, null); } versions.add(0, v); top = version; if (mDebug && DEBUG_VERBOSE) { Log.v(TAG, String.format("createVersion %d: [%2d,%2d] %s", version, x, y, debugVersions())); } return v; }
// Apagar Receita public void delete() { for (Version version : getVersionSet()) { version.delete(); } setCookbookManager(null); super.deleteDomainObject(); }
/** * Returns the version of the upscaledb library. * * <p>This method wraps the native ups_get_version function. * * <p>More information: <a * href="http://files.upscaledb.com/documentation/html/group__ups__static.html#gafce76ae71a43853d63cfb891b960ce34">C * documentation</a> * * @return the upscaledb version tuple */ public static Version getVersion() { Version v = new Version(); v.major = ups_get_version(0); v.minor = ups_get_version(1); v.revision = ups_get_version(2); return v; }
private void assertIsNewer(String basever, String testver) { Version vbase = new Version(basever); Version vtest = new Version(testver); assertTrue( "Version [" + testver + "] should be newer than [" + basever + "]", vtest.isNewerThan(vbase)); }
private void testGenericVersion( final int major, final int minor, final int patch, final String input) { final Version version = Version.parseVersion(input); Assert.assertEquals(major, version.getMajor()); Assert.assertEquals(minor, version.getMinor()); Assert.assertEquals(patch, version.getPatch()); }
/** * Returns the upper bound of valid versions given a minimum version and a {@link MatchRule}. * * @param min the minimum Version, the lower bound of the valid version range. * @param rule the {@link MatchRule} to use for determining the upper bound (<code>max</code>). * @return the upper bound of valid versions given a minimum version and a {@link MatchRule}. */ private static VersionRangeEndPoint getUpperBoundForRule( VersionRangeEndPoint min, MatchRule rule) { VersionRangeEndPoint max = min.changeLocation(EndPointLocation.UPPER); if (!max.isInclusive()) max = max.changeInclusive(true); Version upperEndPoint = max.getEndPoint(); boolean changed = false; switch (rule) { case GreaterOrEqual: upperEndPoint = upperEndPoint.changeMajor(Integer.MAX_VALUE); case Equivalent: upperEndPoint = upperEndPoint.changeMinor(Integer.MAX_VALUE); case Compatible: upperEndPoint = upperEndPoint.changeRelease(Integer.MAX_VALUE); upperEndPoint = upperEndPoint.changePatchLevel(Integer.MAX_VALUE); changed = true; case Perfect: if (changed) max = max.changeVersion(upperEndPoint); return max; default: throw new RuntimeException( "The MatchRule enum has been extended but the " + "'getUpperBoundForRule' method hasn't been updated!"); } }
public static void testBumpIncludeFile() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("bump-included"); project.setTrace(true); Version old = new Version(project.getProperty("Bundle-Version")); assertEquals(new Version(1, 0, 0), old); project.bump("=+0"); Processor processor = new Processor(); processor.setProperties(project.getFile("include.txt")); Version newv = new Version(processor.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(1, newv.getMajor()); assertEquals(1, newv.getMinor()); assertEquals(0, newv.getMicro()); } finally { IO.deleteWithException(tmp); } }
static Version getPrevVersion(String code) { // query(String table, String[] columns, String selection, String[] selectionArgs, String // groupBy, String having, String orderBy) Cursor cursor = sqlite.query( res.getString(R.string.DATABASE_TABLE_VERSION), null, null, null, null, null, res.getString(R.string.KEY_ORDER) + " DESC"); cursor.moveToFirst(); Version r; boolean found = false; while (!found) { r = new Version(cursor, res); if (r.getCode().equals(code)) { found = true; } if (cursor.isLast()) { cursor .moveToFirst(); // if still not found, then this version must be the last one. So the // target version is the first entry break; } cursor.moveToNext(); } r = new Version(cursor, res); cursor.close(); return r; }
public int compareTo(Version arg) { final int minNums = Math.min(nums.length, arg.getVersionNumbers().length); int diff = 0; for (int i = 0; i < minNums; i++) { if (nums[i] > arg.getVersionNumbers()[i]) { diff++; break; } else if (nums[i] < arg.getVersionNumbers()[i]) { diff--; break; } else { continue; } } if (diff == 0) { if (nums.length > arg.getVersionNumbers().length) { diff++; } else if (nums.length < arg.getVersionNumbers().length) { diff--; } } return diff; }
public final void exception(java.lang.String value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._exception = value; v.setBit(EXCEPTION_INDEX); endWrite_(outer, inner); }
public final void isDone(boolean value) { org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._isDone = value; v.setBit(IS_DONE_INDEX); endWrite_(outer, inner); }
public Version getLatestFromMcVersion(String McVersion) { for (Version version : versionList) { if (MatchHelper.doStringsMatch(McVersion, version.getMcVersion())) { return version; } } return null; }
private static ProtocolHandler loadHandler(UpgradeRequest request) { for (Version version : Version.values()) { if (version.validate(request)) { return version.createHandler(false); } } return null; }
/** * The method holds the behaviour for when the EOF marker is not found. Depending on the CRAM * version this will be ignored, a warning issued or an exception produced. * * @param version CRAM version to assume */ public static void eofNotFound(final Version version) { if (version.compatibleWith(CramVersions.CRAM_v3)) { log.error("Incomplete data: EOF marker not found."); throw new RuntimeException("EOF not found."); } if (version.compatibleWith(CramVersions.CRAM_v2_1)) log.warn("EOF marker not found, possibly incomplete file/stream."); }
public StubModule addDependency(String moduleId, String minVersion, String maxVersion) { DependencyInfo dependency = new DependencyInfo(); dependency.setId(moduleId); dependency.setMinVersion(Version.create(minVersion)); dependency.setMaxVersion(Version.create(maxVersion)); dependencies.add(dependency); return this; }
public static Version get(final byte ver) throws UnsupportedVersionException { for (final Version version : Version.values()) { if (ver == version.ordinal()) { return version; } } throw new UnsupportedVersionException( "Can't lookup version: " + ver, UnsupportedVersionException.UnknownVersion); }
@Test public void testFindDefaultVersion() { recreateVersions(); Version version = versionRepository.findDefault(docId); assertNotNull(version); assertThat(version.getDocId(), is(docId)); assertThat(version.getNo(), is(3)); }
@Test public void testCreate() { recreateVersions(); Version version = versionRepository.create(docId, userId); assertNotNull(version); assertThat(version.getDocId(), is(docId)); assertThat(version.getNo(), is(6)); assertThat(version.getCreatedBy(), equalTo(userRepository.findOne(userId))); }
protected final void result_(java.lang.Object value) { if (value instanceof org.objectfabric.TObject && ((org.objectfabric.TObject) value).resource() != resource()) wrongResource_(); org.objectfabric.TObject.Transaction outer = current_(); org.objectfabric.TObject.Transaction inner = startWrite_(outer); Version v = (Version) getOrCreateVersion_(inner); v._result_ = value; v.setBit(RESULT__INDEX); endWrite_(outer, inner); }
private void verifyBundleCU() { final String bundleCUId = flavor + configSpec + ORG_ECLIPSE_CORE_COMMANDS; IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(bundleCUId), new NullProgressMonitor()); assertEquals(1, queryResultSize(queryResult)); IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next(); assertNull(fragment.getFilter()); // no filter if config spec is ANY assertTrue(fragment.getVersion().equals(version)); assertFalse(fragment.isSingleton()); final Collection<IProvidedCapability> providedCapabilities = fragment.getProvidedCapabilities(); verifyProvidedCapability( providedCapabilities, IInstallableUnit.NAMESPACE_IU_ID, bundleCUId, version); verifyProvidedCapability( providedCapabilities, "org.eclipse.equinox.p2.flavor", flavor + configSpec, version); //$NON-NLS-1$ assertEquals(2, providedCapabilities.size()); assertEquals(0, fragment.getRequirements().size()); final Collection<IRequirement> hostRequirements = fragment.getHost(); verifyRequiredCapability( hostRequirements, "osgi.bundle", ORG_ECLIPSE_CORE_COMMANDS, new VersionRange(BUNDLE_VERSION)); // $NON-NLS-1$ verifyRequiredCapability( hostRequirements, "org.eclipse.equinox.p2.eclipse.type", "bundle", new VersionRange(Version.create("1.0.0"), true, Version.create("2.0.0"), false), 1, 1, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertTrue(hostRequirements.size() == 2); final Collection<ITouchpointData> touchpointData = fragment.getTouchpointData(); assertEquals(1, touchpointData.size()); ITouchpointData data = touchpointData.iterator().next(); ITouchpointInstruction instruction = data.getInstruction("install"); // $NON-NLS-1$ assertEquals("installBundle(bundle:${artifact})", instruction.getBody()); // $NON-NLS-1$ instruction = data.getInstruction("uninstall"); // $NON-NLS-1$ assertEquals("uninstallBundle(bundle:${artifact})", instruction.getBody()); // $NON-NLS-1$ instruction = data.getInstruction("configure"); // $NON-NLS-1$ assertEquals("setStartLevel(startLevel:2);", instruction.getBody()); // $NON-NLS-1$ instruction = data.getInstruction("unconfigure"); // $NON-NLS-1$ assertEquals("setStartLevel(startLevel:-1);", instruction.getBody()); // $NON-NLS-1$ }
/** * Reads the bits in the {@link com.application.food.zxing.common.BitMatrix} representing the * finder pattern in the correct order in order to reconstitute the codewords bytes contained * within the QR Code. * * @return bytes encoded within the QR Code * @throws com.application.food.zxing.FormatException if the exact number of bytes expected is not * read */ byte[] readCodewords() throws FormatException { FormatInformation formatInfo = readFormatInformation(); Version version = readVersion(); // Get the data mask for the format used in this QR Code. This will exclude // some bits from reading as we wind through the bit matrix. DataMask dataMask = DataMask.forReference((int) formatInfo.getDataMask()); int dimension = bitMatrix.getHeight(); dataMask.unmaskBitMatrix(bitMatrix, dimension); BitMatrix functionPattern = version.buildFunctionPattern(); boolean readingUp = true; byte[] result = new byte[version.getTotalCodewords()]; int resultOffset = 0; int currentByte = 0; int bitsRead = 0; // Read columns in pairs, from right to left for (int j = dimension - 1; j > 0; j -= 2) { if (j == 6) { // Skip whole column with vertical alignment pattern; // saves time and makes the other code proceed more cleanly j--; } // Read alternatingly from bottom to top then top to bottom for (int count = 0; count < dimension; count++) { int i = readingUp ? dimension - 1 - count : count; for (int col = 0; col < 2; col++) { // Ignore bits covered by the function pattern if (!functionPattern.get(j - col, i)) { // Read a bit bitsRead++; currentByte <<= 1; if (bitMatrix.get(j - col, i)) { currentByte |= 1; } // If we've made a whole byte, save it off if (bitsRead == 8) { result[resultOffset++] = (byte) currentByte; bitsRead = 0; currentByte = 0; } } } } readingUp ^= true; // readingUp = !readingUp; // switch directions } if (resultOffset != version.getTotalCodewords()) { throw FormatException.getFormatInstance(); } return result; }
protected void setUp() throws Exception { super.setUp(); b1 = createIU("B", Version.create("1.0.0"), false); b2 = createIU("B", Version.create("2.0.0"), false); b3 = createIU("B", Version.create("3.0.0"), false); b4 = createIU("B", Version.create("4.0.0"), false); // B's dependency is missing IRequirement[] reqA = new IRequirement[4]; reqA[0] = MetadataFactory.createRequirement( IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0,1.0.0]"), null, true, false, true); reqA[1] = MetadataFactory.createRequirement( IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0,2.0.0]"), null, true, false, true); reqA[2] = MetadataFactory.createRequirement( IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[3.0.0,3.0.0]"), null, true, false, true); reqA[3] = MetadataFactory.createRequirement( IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[4.0.0,4.0.0]"), null, true, false, true); a1 = createIU("A", Version.create("1.0.0"), reqA); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, b4}); profile = createProfile("TestProfile." + getName()); planner = createPlanner(); }
public static void testBump() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("p1"); int size = project.getProperties().size(); Version old = new Version(project.getProperty("Bundle-Version")); System.err.println("Old version " + old); project.bump("=+0"); Version newv = new Version(project.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(old.getMajor(), newv.getMajor()); assertEquals(old.getMinor() + 1, newv.getMinor()); assertEquals(0, newv.getMicro()); assertEquals(size, project.getProperties().size()); assertEquals("sometime", newv.getQualifier()); } finally { IO.deleteWithException(tmp); } }
public static String[] sortVersionArray(String[] versionList) { List<Version> versions = new ArrayList<PubYamlUtils.Version>(); for (Object o : versionList) { versions.add(new Version(o.toString())); } Collections.sort(versions); List<String> strings = new ArrayList<String>(); for (Version version : versions) { strings.add(version.toString()); } return strings.toArray(new String[strings.size()]); }
protected void onProjectOpened(Project project) { final ProjectFile jedaJar = ProjectFile.get(project, this.jedaLibraryPath()); if (!jedaJar.exists()) { jedaJar.createFrom(this.jedaLibraryResourcePath()); } final Version projectVersion = this.projectVersion(project); final Version pluginVersion = this.pluginVersion(); if (pluginVersion != null && projectVersion != null && pluginVersion.compareTo(projectVersion) > 0 && pluginVersion.major == projectVersion.major) { this.updateProject(project); } }
private int compare(Revision a, Revision b) { if (Arrays.equals(a._id, b._id)) return 0; Version va = getVersion(a); Version vb = getVersion(b); int n = va.compareTo(vb); if (n != 0) return n; if (a.created != b.created) return a.created > b.created ? 1 : -1; for (int i = 0; i < a._id.length; i++) if (a._id[i] != b._id[i]) return a._id[i] > b._id[i] ? 1 : -1; return 0; }
/* * Test that the constant VERSION_2_0 is immutable. */ public void testImmutable() throws IOException, URISyntaxException, ParseException { super.testImmutable(); try { version.setMinVersion("3.0"); fail("UnsupportedOperationException should be thrown"); } catch (UnsupportedOperationException uoe) { } try { version.setMaxVersion("5.0"); fail("UnsupportedOperationException should be thrown"); } catch (UnsupportedOperationException uoe) { } }
public boolean contains(String otherVersionStr) { if (!Version.isValidVersionString(otherVersionStr)) { return false; } Version otherVersion = new Version(otherVersionStr); int compareMin = isMinUnbounded() ? 1 : otherVersion.compareTo(new Version(minVersion)); int compareMax = isMaxUnbounded() ? -1 : otherVersion.compareTo(new Version(maxVersion)); boolean greaterThanMin = compareMin > 0 || (isMinInclusive() && compareMin == 0); boolean lessThanMax = compareMax < 0 || (isMaxInclusive() && compareMax == 0); return greaterThanMin && lessThanMax; }
@Test public void testSetDefault() { recreateVersions(); assertThat(versionRepository.findDefault(docId).getNo(), is(3)); versionRepository.updateDefaultNo(docId, 4, userId); Version version = versionRepository.findDefault(docId); assertNotNull(version); assertThat(version.getDocId(), is(docId)); assertThat(version.getNo(), is(4)); assertThat(version.getModifiedBy(), equalTo(userRepository.findOne(userId))); }