public void testEnhanceDefer() throws IOException { NetcdfDataset ncd = NetcdfDataset.openDataset( filename, EnumSet.of(NetcdfDataset.Enhance.ScaleMissing), -1, null, null); VariableDS enhancedVar = (VariableDS) ncd.findVariable("t1"); NetcdfDataset ncdefer = NetcdfDataset.openDataset( filename, EnumSet.of(NetcdfDataset.Enhance.ScaleMissingDefer), -1, null, null); VariableDS deferVar = (VariableDS) ncdefer.findVariable("t1"); Array data = enhancedVar.read(); Array dataDefer = deferVar.read(); System.out.printf("Enhanced="); NCdumpW.printArray(data); System.out.printf("%nDeferred="); NCdumpW.printArray(dataDefer); System.out.printf("%nProcessed="); CompareNetcdf2 nc = new CompareNetcdf2(new Formatter(System.out), false, false, true); assert !nc.compareData(enhancedVar.getShortName(), data, dataDefer, false); IndexIterator ii = dataDefer.getIndexIterator(); while (ii.hasNext()) { double val = deferVar.convertScaleOffsetMissing(ii.getDoubleNext()); ii.setDoubleCurrent(val); } NCdumpW.printArray(dataDefer); assert nc.compareData(enhancedVar.getShortName(), data, dataDefer, false); ncd.close(); ncdefer.close(); }
private void init() { this.transform_ = this.createJSTransform(); this.mouseWentDown() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDown(o, e);}}"); this.mouseWentUp() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseUp(o, e);}}"); this.mouseDragged() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDrag(o, e);}}"); this.mouseMoved() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseMoved(o, e);}}"); this.touchStarted() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchStarted(o, e);}}"); this.touchEnded() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchEnded(o, e);}}"); this.touchMoved() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchMoved(o, e);}}"); this.setSelectionAreaPadding(0, EnumSet.of(Side.Top)); this.setSelectionAreaPadding(20, EnumSet.of(Side.Left, Side.Right)); this.setSelectionAreaPadding(30, EnumSet.of(Side.Bottom)); if (this.chart_ != null) { this.chart_.addAxisSliderWidget(this); } }
private void internalScrollTo(long newX, long newY, boolean moveViewPort) { if (this.imageWidth_ != Infinite) { newX = Math.min(this.imageWidth_ - this.viewPortWidth_, Math.max((long) 0, newX)); } if (this.imageHeight_ != Infinite) { newY = Math.min(this.imageHeight_ - this.viewPortHeight_, Math.max((long) 0, newY)); } if (moveViewPort) { this.contents_.setOffsets(new WLength((double) -newX), EnumSet.of(Side.Left)); this.contents_.setOffsets(new WLength((double) -newY), EnumSet.of(Side.Top)); } this.generateGridItems(newX, newY); this.viewPortChanged_.trigger(this.currentX_, this.currentY_); }
/** * Get the active cipher suites. * * <p>In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, such as * TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT negotiate these cipher suites in * TLS 1.1 or later mode. * * <p>Therefore, when the active protocols only include TLS 1.1 or later, the client cannot * request to negotiate those obsoleted cipher suites. That is, the obsoleted suites should not be * included in the client hello. So we need to create a subset of the enabled cipher suites, the * active cipher suites, which does not contain obsoleted cipher suites of the minimum active * protocol. * * <p>Return empty list instead of null if no active cipher suites. */ CipherSuiteList getActiveCipherSuites() { if (activeCipherSuites == null) { if (activeProtocols == null) { activeProtocols = getActiveProtocols(); } ArrayList<CipherSuite> suites = new ArrayList<>(); if (!(activeProtocols.collection().isEmpty()) && activeProtocols.min.v != ProtocolVersion.NONE.v) { for (CipherSuite suite : enabledCipherSuites.collection()) { if (suite.obsoleted > activeProtocols.min.v && suite.supported <= activeProtocols.max.v) { if (algorithmConstraints.permits( EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { suites.add(suite); } } else if (debug != null && Debug.isOn("verbose")) { if (suite.obsoleted <= activeProtocols.min.v) { System.out.println("Ignoring obsoleted cipher suite: " + suite); } else { System.out.println("Ignoring unsupported cipher suite: " + suite); } } } } activeCipherSuites = new CipherSuiteList(suites); } return activeCipherSuites; }
/* * Get the active protocol versions. * * In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, * such as TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT * negotiate these cipher suites in TLS 1.1 or later mode. * * For example, if "TLS_RSA_EXPORT_WITH_RC4_40_MD5" is the * only enabled cipher suite, the client cannot request TLS 1.1 or * later, even though TLS 1.1 or later is enabled. We need to create a * subset of the enabled protocols, called the active protocols, which * contains protocols appropriate to the list of enabled Ciphersuites. * * Return empty list instead of null if no active protocol versions. */ ProtocolList getActiveProtocols() { if (activeProtocols == null) { ArrayList<ProtocolVersion> protocols = new ArrayList<>(4); for (ProtocolVersion protocol : enabledProtocols.collection()) { boolean found = false; for (CipherSuite suite : enabledCipherSuites.collection()) { if (suite.isAvailable() && suite.obsoleted > protocol.v && suite.supported <= protocol.v) { if (algorithmConstraints.permits( EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { protocols.add(protocol); found = true; break; } else if (debug != null && Debug.isOn("verbose")) { System.out.println("Ignoring disabled cipher suite: " + suite + " for " + protocol); } } else if (debug != null && Debug.isOn("verbose")) { System.out.println("Ignoring unsupported cipher suite: " + suite + " for " + protocol); } } if (!found && (debug != null) && Debug.isOn("handshake")) { System.out.println("No available cipher suite for " + protocol); } } activeProtocols = new ProtocolList(protocols); } return activeProtocols; }
@Test @SuppressWarnings("unchecked") public void modificationDuringTransactionCausesAbort() throws Exception { Map<String, String> testMap = getRuntime().getObjectsView().open(CorfuRuntime.getStreamID("A"), SMRMap.class); assertThat(testMap.put("a", "z")); getRuntime().getObjectsView().TXBegin(); assertThat(testMap.put("a", "a")).isEqualTo("z"); assertThat(testMap.put("a", "b")).isEqualTo("a"); assertThat(testMap.get("a")).isEqualTo("b"); CompletableFuture cf = CompletableFuture.runAsync( () -> { Map<String, String> testMap2 = getRuntime() .getObjectsView() .open( UUID.nameUUIDFromBytes("A".getBytes()), SMRMap.class, null, EnumSet.of(ObjectOpenOptions.NO_CACHE), SerializerType.JSON); testMap2.put("a", "f"); }); cf.join(); assertThatThrownBy(() -> getRuntime().getObjectsView().TXEnd()) .isInstanceOf(TransactionAbortedException.class); }
void expand(int row, int column, int rowSpan, int columnSpan) { int newNumRows = row + rowSpan; int curNumColumns = this.getColumnCount(); int newNumColumns = Math.max(curNumColumns, column + columnSpan); if (newNumRows > this.getRowCount() || newNumColumns > curNumColumns) { if (newNumColumns == curNumColumns && this.getRowCount() >= this.headerRowCount_) { this.rowsAdded_ += newNumRows - this.getRowCount(); } else { this.flags_.set(BIT_GRID_CHANGED); } this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); for (int r = this.getRowCount(); r < newNumRows; ++r) { this.rows_.add(new WTableRow(this, newNumColumns)); } if (newNumColumns > curNumColumns) { for (int r = 0; r < this.getRowCount(); ++r) { WTableRow tr = this.rows_.get(r); tr.expand(newNumColumns); } for (int c = curNumColumns; c <= column; ++c) { this.columns_.add(new WTableColumn(this)); } } } }
public void testGetRow() throws SmartsheetException, IOException { smartsheet .sheetResources() .rowResources() .getRow(sheet.getId(), newRows.get(0).getId(), null, null); row = smartsheet .sheetResources() .rowResources() .getRow( sheet.getId(), newRows.get(0).getId(), EnumSet.of(RowInclusion.COLUMNS, RowInclusion.COLUMN_TYPE), EnumSet.of(ObjectExclusion.NONEXISTENT_CELLS)); assertNotNull(row); }
@Test public void rejectAllStorageOperationsBeingInInappropriateState() throws Exception { // -- generate list of "inappropriate" states final List<String> states = new LinkedList<>(); final EnumSet<StorageNode.StorageState> allowedStates = EnumSet.of(StorageNode.StorageState.RECOVERING, StorageNode.StorageState.RUNNING); for (StorageNode.StorageState s : StorageNode.StorageState.values()) { if (!allowedStates.contains(s)) { states.add(s.name()); } } // -- for (String s : states) { if (!node.getState().equals(s)) { manageNode(new ControlMessage.Builder().setState(s)); } assertEquals(s, node.getState()); for (StorageOperation op : allOperations) { // TODO: rewrite with Exception Matcher to introduce message checking try { node.onStorageRequest(op); fail(); } catch (IllegalStateException ex) { } } } }
Main() { super( 20, EnumSet.of( DisplayFlags.SIMULATION, DisplayFlags.TIME, DisplayFlags.NETWORK, DisplayFlags.TRAFFIC)); }
public static class Params { public ControlEnvironment environment; public Model model; public Appearance appearance; public Transition transition = new ListUtils.DefaultTransition(); public ListClickHandler clickHandler; public String name; public Set<Flags> flags = EnumSet.of(Flags.EMPTY_LINE_BOTTOM); }
/** * Adds a nested layout item to the grid. * * <p>Calls {@link #addLayout(WLayout layout, int row, int column, int rowSpan, int columnSpan, * EnumSet alignment) addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, * alignment))} */ public final void addLayout( WLayout layout, int row, int column, int rowSpan, int columnSpan, AlignmentFlag alignmen, AlignmentFlag... alignment) { addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment)); }
/** * Adds a widget to the grid. * * <p>Calls {@link #addWidget(WWidget widget, int row, int column, int rowSpan, int columnSpan, * EnumSet alignment) addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, * alignment))} */ public final void addWidget( WWidget widget, int row, int column, int rowSpan, int columnSpan, AlignmentFlag alignmen, AlignmentFlag... alignment) { addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment)); }
private static void static_files_copy(Path abs_path_from, Path abs_path_to) throws IOException { Path from = abs_path_from.resolve("static"); Path to = abs_path_to.resolve("static"); java.nio.file.Files.walkFileTree( from, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new CopyDirectoryVisitor(from, to)); }
/** * Adds a layout item to the grid. * * <p>Calls {@link #addItem(WLayoutItem item, int row, int column, int rowSpan, int columnSpan, * EnumSet alignment) addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, * alignment))} */ public final void addItem( WLayoutItem item, int row, int column, int rowSpan, int columnSpan, AlignmentFlag alignmen, AlignmentFlag... alignment) { addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment)); }
/** Delete a column and all its contents. */ public void deleteColumn(int column) { for (int i = 0; i < this.getRowCount(); ++i) { this.rows_.get(i).deleteColumn(column); } if ((int) column <= this.columns_.size()) {; this.columns_.remove(0 + column); } this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
void repaintRow(WTableRow row) { if (row.getRowNum() >= (int) (this.getRowCount() - this.rowsAdded_)) { return; } if (!(this.rowsChanged_ != null)) { this.rowsChanged_ = new HashSet<WTableRow>(); } this.rowsChanged_.add(row); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
/** Inserts an empty row. */ public WTableRow insertRow(int row) { if (row >= this.getRowCount()) { return this.getRowAt(row); } else { WTableRow tableRow = new WTableRow(this, this.getColumnCount()); this.rows_.add(0 + row, tableRow); this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); return tableRow; } }
public Set<Color> toEnumSet() { if (isColorless()) { return EnumSet.of(Color.COLORLESS); } List<Color> list = new ArrayList<Color>(); for (Color c : Color.values()) { if (hasAnyColor(c.getColormask())) { list.add(c); } } return EnumSet.copyOf(list); }
private AnnotationCrawler(final TypeRepr.ClassType type, final ElemType target) { super(Opcodes.ASM4); this.myType = type; this.myTarget = target; final Set<ElemType> targets = myAnnotationTargets.get(type); if (targets == null) { myAnnotationTargets.put(type, EnumSet.of(target)); } else { targets.add(target); } myUsages.add(UsageRepr.createClassUsage(myContext, type.myClassName)); }
/** * Retrieves information on a package identified by an {@link IPkgDesc}. * * @param descriptor {@link IPkgDesc} describing a package. * @return The first package found with the same descriptor or null. */ @Nullable public LocalPkgInfo getPkgInfo(@NonNull IPkgDesc descriptor) { for (LocalPkgInfo pkg : getPkgsInfos(EnumSet.of(descriptor.getType()))) { IPkgDesc d = pkg.getDesc(); if (d.equals(descriptor)) { return pkg; } } return null; }
boolean featureInstall(Feature feature) { String name = feature.getName(); String version = feature.getVersion(); EnumSet<Option> options = EnumSet.of(Option.Verbose); try { featuresService.installFeature(name, version, options); return true; } catch (Exception e) { logger.error("Unable to uninstall feature: " + name, e); return false; } }
private void generateGridItems(long newX, long newY) { WVirtualImage.Rect newNb = this.neighbourhood(newX, newY, this.viewPortWidth_, this.viewPortHeight_); long i1 = newNb.x1 / this.gridImageSize_; long j1 = newNb.y1 / this.gridImageSize_; long i2 = newNb.x2 / this.gridImageSize_ + 1; long j2 = newNb.y2 / this.gridImageSize_ + 1; for (int invisible = 0; invisible < 2; ++invisible) { for (long i = i1; i < i2; ++i) { for (long j = j1; j < j2; ++j) { long key = this.gridKey(i, j); WImage it = this.grid_.get(key); if (it == null) { boolean v = this.visible(i, j); if (v && !(invisible != 0) || !v && invisible != 0) { long brx = i * this.gridImageSize_ + this.gridImageSize_; long bry = j * this.gridImageSize_ + this.gridImageSize_; brx = Math.min(brx, this.imageWidth_); bry = Math.min(bry, this.imageHeight_); WImage img = this.createImage( i * this.gridImageSize_, j * this.gridImageSize_, (int) (brx - i * this.gridImageSize_), (int) (bry - j * this.gridImageSize_)); img.setAttributeValue("onmousedown", "return false;"); this.contents_.addWidget(img); img.setPositionScheme(PositionScheme.Absolute); img.setOffsets(new WLength((double) i * this.gridImageSize_), EnumSet.of(Side.Left)); img.setOffsets(new WLength((double) j * this.gridImageSize_), EnumSet.of(Side.Top)); this.grid_.put(key, img); } } } } } this.currentX_ = newX; this.currentY_ = newY; this.cleanGrid(); }
/** Inserts an empty column. */ public WTableColumn insertColumn(int column) { for (int i = 0; i < this.rows_.size(); ++i) { this.rows_.get(i).insertColumn(column); } WTableColumn tableColumn = null; if ((int) column <= this.columns_.size()) { tableColumn = new WTableColumn(this); this.columns_.add(0 + column, tableColumn); } this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); return tableColumn; }
public void handle(Start event) { trigger( new GetIpRequest( false, EnumSet.of( GetIpRequest.NetworkInterfacesMask.IGNORE_LOCAL_ADDRESSES, GetIpRequest.NetworkInterfacesMask.IGNORE_TEN_DOT_PRIVATE)), resolveIp.getPositive(ResolveIpPort.class)); logger.info("Starting"); ScheduleTimeout st = new ScheduleTimeout(30 * 1000); MsgTimeout mt = new MsgTimeout(st); st.setTimeoutEvent(mt); trigger(st, timer.getPositive(Timer.class)); }
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info( "Web application configuration, using profiles: {}", Arrays.toString(env.getActiveProfiles())); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) { initCachingHttpHeadersFilter(servletContext, disps); } log.info("Web application fully configured"); }
/** * Construct table schema from info stored in SSTable's Stats.db * * @param desc SSTable's descriptor * @return Restored CFMetaData * @throws IOException when Stats.db cannot be read */ public static CFMetaData metadataFromSSTable(Descriptor desc) throws IOException { if (!desc.version.storeRows()) throw new IOException("pre-3.0 SSTable is not supported."); EnumSet<MetadataType> types = EnumSet.of(MetadataType.VALIDATION, MetadataType.STATS, MetadataType.HEADER); Map<MetadataType, MetadataComponent> sstableMetadata = desc.getMetadataSerializer().deserialize(desc, types); ValidationMetadata validationMetadata = (ValidationMetadata) sstableMetadata.get(MetadataType.VALIDATION); SerializationHeader.Component header = (SerializationHeader.Component) sstableMetadata.get(MetadataType.HEADER); IPartitioner partitioner = SecondaryIndexManager.isIndexColumnFamily(desc.cfname) ? new LocalPartitioner(header.getKeyType()) : FBUtilities.newPartitioner(validationMetadata.partitioner); CFMetaData.Builder builder = CFMetaData.Builder.create("keyspace", "table").withPartitioner(partitioner); header .getStaticColumns() .entrySet() .stream() .forEach( entry -> { ColumnIdentifier ident = ColumnIdentifier.getInterned(UTF8Type.instance.getString(entry.getKey()), true); builder.addStaticColumn(ident, entry.getValue()); }); header .getRegularColumns() .entrySet() .stream() .forEach( entry -> { ColumnIdentifier ident = ColumnIdentifier.getInterned(UTF8Type.instance.getString(entry.getKey()), true); builder.addRegularColumn(ident, entry.getValue()); }); builder.addPartitionKey("PartitionKey", header.getKeyType()); for (int i = 0; i < header.getClusteringTypes().size(); i++) { builder.addClusteringColumn( "clustering" + (i > 0 ? i : ""), header.getClusteringTypes().get(i)); } return builder.build(); }
/** * Move a table row from its original position to a new position. * * <p>The table expands automatically when the <code>to</code> row is beyond the current table * dimensions. * * <p> * * @see WTable#moveColumn(int from, int to) */ public void moveRow(int from, int to) { if (from < 0 || from >= (int) this.rows_.size()) { logger.error( new StringWriter() .append("moveRow: the from index is not a valid row index.") .toString()); return; } WTableRow from_tr = this.getRowAt(from); this.rows_.remove(from_tr); if (to > (int) this.rows_.size()) { this.getRowAt(to); } this.rows_.add(0 + to, from_tr); this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
private static EnumSet<IDevice.HardwareFeature> getRequiredHardwareFeatures( List<UsesFeature> requiredFeatures) { // Currently, this method is hardcoded to only search if the list of required features includes // a watch. // We may not want to search the device for every possible feature, but only a small subset of // important // features, starting with hardware type watch.. for (UsesFeature feature : requiredFeatures) { AndroidAttributeValue<String> name = feature.getName(); if (name != null && UsesFeature.HARDWARE_TYPE_WATCH.equals(name.getStringValue())) { return EnumSet.of(IDevice.HardwareFeature.WATCH); } } return EnumSet.noneOf(IDevice.HardwareFeature.class); }
/** * Returns the targets (platforms & addons) that are available in the SDK. The target list is * created on demand the first time then cached. It will not refreshed unless {@link * #clearLocalPkg} is called to clear platforms and/or add-ons. * * <p>The array can be empty but not null. */ @NonNull public IAndroidTarget[] getTargets() { synchronized (mLocalPackages) { if (mCachedTargets == null) { List<IAndroidTarget> result = Lists.newArrayList(); LocalPkgInfo[] pkgsInfos = getPkgsInfos(EnumSet.of(PkgType.PKG_PLATFORM, PkgType.PKG_ADDON)); for (LocalPkgInfo info : pkgsInfos) { assert info instanceof LocalPlatformPkgInfo; IAndroidTarget target = ((LocalPlatformPkgInfo) info).getAndroidTarget(); if (target != null) { result.add(target); } } mCachedTargets = result; } return mCachedTargets.toArray(new IAndroidTarget[mCachedTargets.size()]); } }