public static <T> Iterable<T> iterable(final T values[]) { return (new Iterable<T>() { @Override public Iterator<T> iterator() { return new Iterator<T>() { private int idx = 0; @Override public boolean hasNext() { return (this.idx < values.length); } @Override public T next() { return (values[this.idx++]); } @Override public void remove() { throw new NotImplementedException(); } }; } }); }
/** * Wrap an Iterable around an Enumeration * @param <T> * @param e * @return */ public static <T> Iterable<T> iterable(final Enumeration<T> e) { return (new Iterable<T>() { @Override public Iterator<T> iterator() { return new Iterator<T>() { @Override public boolean hasNext() { return (e.hasMoreElements()); } @Override public T next() { return (e.nextElement()); } @Override public void remove() { throw new NotImplementedException(); } }; } }); }
/** * Wrap an Iterable around an Enumeration that is automatically * cast to the specified type * @param <T> * @param e * @return */ public static <T> Iterable<T> iterable(final Enumeration<?> e, Class<T> castType) { return (new Iterable<T>() { @Override public Iterator<T> iterator() { return new Iterator<T>() { @Override public boolean hasNext() { return (e.hasMoreElements()); } @SuppressWarnings("unchecked") @Override public T next() { return ((T)e.nextElement()); } @Override public void remove() { throw new NotImplementedException(); } }; } }); }
/** * Removes the table descriptor from the local cache and returns it. * If not in read only mode, it also deletes the entire table directory(!) * from the FileSystem. */ @Override public HTableDescriptor remove(final TableName tablename) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot remove a table descriptor - in read only mode"); } Path tabledir = getTableDir(tablename); if (this.fs.exists(tabledir)) { if (!this.fs.delete(tabledir, true)) { throw new IOException("Failed delete of " + tabledir.toString()); } } HTableDescriptor descriptor = this.cache.remove(tablename); if (descriptor == null) { return null; } else { return descriptor; } }
/** * Create a new HTableDescriptor in HDFS in the specified table directory. Happens when we create * a new table or snapshot a table. * @param tableDir table directory under which we should write the file * @param htd description of the table to write * @param forceCreation if <tt>true</tt>,then even if previous table descriptor is present it will * be overwritten * @return <tt>true</tt> if the we successfully created the file, <tt>false</tt> if the file * already exists and we weren't forcing the descriptor creation. * @throws IOException if a filesystem error occurs */ public boolean createTableDescriptorForTableDirectory(Path tableDir, HTableDescriptor htd, boolean forceCreation) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot create a table descriptor - in read only mode"); } FileStatus status = getTableInfoPath(fs, tableDir); if (status != null) { LOG.debug("Current tableInfoPath = " + status.getPath()); if (!forceCreation) { if (fs.exists(status.getPath()) && status.getLen() > 0) { if (readTableDescriptor(fs, status, false).equals(htd)) { LOG.debug("TableInfo already exists.. Skipping creation"); return false; } } } } Path p = writeTableDescriptor(fs, htd, tableDir, status); return p != null; }
@Override public Iterator<T> iterator() { return new Iterator<T>() { private int returned = 0; @Override public boolean hasNext() { return this.returned < 2; } @Override public T next() { if (++this.returned == 1) return getFirst(); else if (this.returned == 2) return getSecond(); else throw new IllegalAccessError("this.returned=" + this.returned); } @Override public void remove() { throw new NotImplementedException(); } }; }
@Override public AppiumResponse safeHandle(IHttpRequest request) { try { int requestedType = getPayload(request).getInt("type"); NetworkConnectionEnum networkType = NetworkConnectionEnum.getNetwork(requestedType); switch (networkType) { case WIFI: return WifiHandler.toggle(true, getSessionId(request)); case DATA: case AIRPLANE: case ALL: case NONE: return new AppiumResponse(getSessionId(request), WDStatus.UNKNOWN_ERROR, new NotImplementedException("Setting Network Connection to: " + networkType.getNetworkType() + " :is not implemented")); default: return new AppiumResponse(getSessionId(request), WDStatus.UNKNOWN_ERROR, new UiAutomator2Exception("Invalid Network Connection type: "+ requestedType)); } } catch (JSONException e) { Logger.error("Exception while reading JSON: ", e); return new AppiumResponse(getSessionId(request), WDStatus.JSON_DECODER_ERROR, e); } }
@Override public Instruction gen(GeneratorContext ctx, Set_stmtContext rule) throws OrcaException { if (rule.set_stmt_names() != null) { return genSetNames(ctx, rule.set_stmt_names()); } if (rule.set_stmt_character_set() != null) { return genSetCharSet(ctx, rule.set_stmt_character_set()); } else if (rule.set_stmt_variable() != null){ return genSetVariables(ctx, rule.set_stmt_variable()); } else { throw new NotImplementedException(); } }
private static void setColumnDefault(ColumnAttributes attrs, Column_constraint_defaultContext rule) { if (rule.literal_value() != null) { String value = rule.literal_value().getText(); if (value.equalsIgnoreCase("null")) { attrs.setDefaultValue(null); } else { attrs.setDefaultValue(value); } } else if (rule.signed_number() != null) { attrs.setDefaultValue(rule.signed_number().getText()); } else { throw new NotImplementedException(); } }
/** * Create parameter names for excluding the tags of the query. The returned parameters will * already be prefixed with a colon. * * @param formula * the formula to process * @return the comma separated list of parameter names */ protected String createParameterNames(LogicalTagFormula formula) { if (formula.isNegated()) { throw new NotImplementedException("Negated tag formulas cannot be used" + " in a RelatedRankedTagQuery"); } StringBuilder sb = new StringBuilder(); if (formula instanceof AtomicTagFormula) { sb.append(":"); sb.append(createParameterName((AtomicTagFormula) formula)); } else { String prefix = ":"; CompoundTagFormula compoundFormula = (CompoundTagFormula) formula; for (AtomicTagFormula atom : compoundFormula.getPositiveAtoms()) { sb.append(prefix); sb.append(createParameterName(atom)); prefix = ", :"; } } return sb.toString(); }
@Override public long eval(VdmContext ctx, Heap heap, Parameters params, long pRecord) { long pValue = upstream.eval(ctx, heap, params, pRecord); if (pValue == 0) { return 0; } int type = Value.getType(heap, pValue); if (type == Value.TYPE_BYTES) { return pValue; } else if (type == Value.TYPE_BLOB) { return pValue; } else if (type == Value.TYPE_STRING) { long pBytes = FishObject.toBytes(heap, pValue); return pBytes; } else { throw new NotImplementedException(); } }
/** * transform a tag formula to a string Note: only supports non negative conjunction, which will * result in a comma separated list * * @param f * the formula * @param separator * the separator used during tag parsing * @return the string representation */ public String tagFormulaToString(LogicalTagFormula f, String separator) { if (f instanceof AtomicTagFormula) { return ((AtomicTagFormula) f).getTag(); } CompoundTagFormula cf = (CompoundTagFormula) f; if (cf.isNegated() || cf.isDisjunction()) { throw new NotImplementedException("Creating string representation of disjunction or" + " negations is not supported."); } String prefix = ""; StringBuilder sb = new StringBuilder(); AtomicTagFormula[] atoms = cf.getPositiveAtoms(); for (int i = 0; i < atoms.length; i++) { sb.append(prefix); sb.append(atoms[i].getTag()); prefix = separator + " "; } return sb.toString(); }
@Override public Object run(VdmContext ctx, Parameters params) { TableMeta table = Checks.tableExist(ctx.getSession(), this.tableName); try { ctx.getSession().lockTable(table.getId(), LockLevel.EXCLUSIVE, false); // copy the table over to a new one ObjectName newName = ctx.getMetaService().findUniqueName(ctx.getTransaction(), this.tableName); new CreateTable(newName).run(ctx, params); // ..... more more to be implemented throw new NotImplementedException(); } finally { ctx.getSession().unlockTable(table.getId()); } }
@Override public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) { if (getHandle().playerNetServerHandler == null) return false; /* int x = loc.getBlockX(); int y = loc.getBlockY(); int z = loc.getBlockZ(); int cx = x >> 4; int cz = z >> 4; if (sx <= 0 || sy <= 0 || sz <= 0) { return false; } if ((x + sx - 1) >> 4 != cx || (z + sz - 1) >> 4 != cz || y < 0 || y + sy > 128) { return false; } if (data.length != (sx * sy * sz * 5) / 2) { return false; } Packet51MapChunk packet = new Packet51MapChunk(x, y, z, sx, sy, sz, data); getHandle().playerConnection.sendPacket(packet); return true; */ throw new NotImplementedException("Chunk changes do not yet work"); // TODO: Chunk changes. }
@Nullable private static Object getTypeForClass(Class clazz, String input, @Nullable CommandSender sender) throws InputException { if (clazz == null) { throw new IllegalArgumentException("Cannot determine input type for null class"); } if (clazz.equals(String.class)) { return input; } else if (clazz.isPrimitive()) { return getPrimitive(clazz, input); } else if (clazz.equals(Class.class)) { return getBukkitClass(input); } else if (clazz.equals(Material.class)) { return getMaterial(input); } else if (clazz.equals(MaterialData.class)) { return getMaterialData(input); } else if (clazz.equals(Location.class)) { return getLocation(input, sender); } else if (clazz.equals(Entity.class)) { return getEntity(input, sender); } else if (clazz.equals(UUID.class)) { return getUUID(input, sender); } else if (clazz.equals(GameMode.class)) { return getGameMode(input); } else if (clazz.equals(Difficulty.class)) { return getDifficulty(input); } else if (Enum.class.isAssignableFrom(clazz)) { // Do not use for all enum types, lacks magic value support return getValueFromEnum(clazz, input); } else if (clazz.equals(ItemStack.class)) { return getItemStack(input, sender); } else if (clazz.equals(Class[].class)) { return getBukkitClasses(input); } throw new InputException(new NotImplementedException("Input handling for class type " + clazz.getSimpleName() + " not implemented yet")); }
@Override public IntegrityConstraint clone(){ try { throw new NotImplementedException("The clone method should be implemented in the subtypes!"); } catch (NotImplementedException e) { e.printStackTrace(); } return null; }
/** * Adds (or updates) the table descriptor to the FileSystem * and updates the local cache with it. */ @Override public void add(HTableDescriptor htd) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot add a table descriptor - in read only mode"); } if (TableName.META_TABLE_NAME.equals(htd.getTableName())) { throw new NotImplementedException(); } if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(htd.getTableName().getNameAsString())) { throw new NotImplementedException( "Cannot add a table descriptor for a reserved subdirectory name: " + htd.getNameAsString()); } updateTableDescriptor(htd); }
/** * Update table descriptor on the file system * @throws IOException Thrown if failed update. * @throws NotImplementedException if in read only mode */ @VisibleForTesting Path updateTableDescriptor(HTableDescriptor htd) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot update a table descriptor - in read only mode"); } Path tableDir = getTableDir(htd.getTableName()); Path p = writeTableDescriptor(fs, htd, tableDir, getTableInfoPath(tableDir)); if (p == null) throw new IOException("Failed update"); LOG.info("Updated tableinfo=" + p); if (usecache) { this.cache.put(htd.getTableName(), htd); } return p; }
/** * Deletes all the table descriptor files from the file system. * Used in unit tests only. * @throws NotImplementedException if in read only mode */ public void deleteTableDescriptorIfExists(TableName tableName) throws IOException { if (fsreadonly) { throw new NotImplementedException("Cannot delete a table descriptor - in read only mode"); } Path tableDir = getTableDir(tableName); Path tableInfoDir = new Path(tableDir, TABLEINFO_DIR); deleteTableDescriptorFiles(fs, tableInfoDir, Integer.MAX_VALUE); }
private void loadRules(Transaction trx, TableMeta tableMeta) { int tableId = tableMeta.getId(); GTable table = this.orca.getHumpback().getTable(Orca.SYSNS, TABLEID_SYSRULE); if (table == null) { return; } byte[] start = KeyMaker.gen(tableMeta.getId()); byte[] end = KeyMaker.gen(tableMeta.getId() + 1); long options = ScanOptions.excludeEnd(0); for (RowIterator i=table.scan(trx.getTrxId(), trx.getTrxTs(), start, end, options); i.next();) { Row rrow = i.getRow(); SlowRow row = SlowRow.from(rrow); if (row == null) { break; } row.setMutable(false); if (tableId != (int)row.get(ColumnId.sysrule_table_id.getId())) { continue; } int type = (Integer)row.get(ColumnId.sysrule_rule_type.getId()); if (type == Rule.PrimaryKey.ordinal()) { PrimaryKeyMeta pk = new PrimaryKeyMeta(row); tableMeta.pk = pk; } else if (type == Rule.Index.ordinal()) { IndexMeta index = new IndexMeta(row); tableMeta.getIndexes().add(index); } else if (type == Rule.ForeignKey.ordinal()) { ForeignKeyMeta fk = new ForeignKeyMeta(row); tableMeta.getForeignKeys().add(fk); } else { throw new NotImplementedException(); } } }
public static Storage load(StorageType type, String name, File directory, FruitSQL mySQL, String table) throws IOException, SQLException { switch(type) { case YAML: return loadFromYAML(directory, name); case MYSQL: return loadFromMySQL(mySQL, name, table); default: throw new NotImplementedException("StorageType '" + type + "' is not yet implemented."); } }
private static Operator genSingleValueQuery(GeneratorContext ctx, Planner cursorMeta, Expr_selectContext rule) { if (rule.select_stmt().select_or_values().size() != 1) { throw new NotImplementedException(); } CursorMaker select = (CursorMaker) new Select_or_valuesGenerator().genSubquery(ctx, rule.select_stmt(), cursorMeta); if (select.getCursorMeta().getColumnCount() != 1) { throw new OrcaException("Operand should contain 1 column"); } return new OpSingleValueQuery(select); }
@Override protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception { HttpServletRequest req = (HttpServletRequest) request.getNativeRequest(); Class<?> clazz = parameter.getParameterType(); Object bean = clazz.newInstance(); for (Field field : FieldUtil.listFields(clazz)) { String fieldName = field.getName(); Class<?> type = field.getType(); Object obj; if (List.class.equals(type)) { Class<?> subType = (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; obj = this.toList(fieldName, subType, req); } else if (Map.class.equals(type)) { throw new NotImplementedException("Map类型未实现."); } else if (Set.class.equals(type)) { throw new NotImplementedException("Set类型未实现."); } else { String value = RequestBodyParser.getParameter(req, fieldName); // logger.info("fieldName:" + fieldName + " value:" + value); if (value == null) { continue; } obj = toObject(value, type, fieldName); } field.setAccessible(true); field.set(bean, obj); } return bean; }
private DataValueDto getValueAsDataSourceValue(ResultSet row, String columnName, DataValueType columnTypeName) throws SQLException { switch (columnTypeName) { case DOUBLE: return getValueAsDataSourceValueDoubleWeb(row, columnName); case DATE: return getValueAsDataSourceValueDateWeb(row, columnName); case INTEGER: return getValueAsDataSourceValueIntegerWeb(row, columnName); case STRING: return getValueAsDataSourceValueStringWeb(row, columnName); default: throw new NotImplementedException("Not recognized column type."); } }
private String prepareDataSection(DataValueType dataValueType, String data) { switch (dataValueType) { case DOUBLE: return data; case DATE: return "'" + LocalDate.parse(data.substring(DATA_BEGIN_INDEX, DATA_END_INDEX)) + "'"; case INTEGER: return data; case STRING: return "'" + data + "'"; default: throw new NotImplementedException("Not recognized column type."); } }
public static SmaphAnnotator getSmaph(SmaphVersion v, WikipediaInterface wikiApi, WikipediaToFreebase wikiToFreeb, WAT2Annotator auxAnnotator, EntityToAnchors e2a, boolean includeS2, Websearch ws, SmaphConfig c, int greedyStepLimit) throws FileNotFoundException, ClassNotFoundException, IOException { URL model = getDefaultModel(v, ws, true, includeS2, true, -1); URL zscore = getDefaultZscoreNormalizer(v, ws, true, includeS2, true, -1); SmaphAnnotator a = null; switch (v) { case ANNOTATION_REGRESSOR: { AnnotationRegressor ar = getCachedAnnotationRegressor(model); FeatureNormalizer fn = getCachedFeatureNormalizer(zscore, new GreedyFeaturePack()); a = getDefaultSmaphParam(wikiApi, wikiToFreeb, auxAnnotator, e2a, new NoEntityFilter(), null, new IndividualLinkback(ar, fn, wikiApi, wikiToFreeb, e2a, DEFAULT_ANCHOR_MENTION_ED), true, includeS2, true, ws, c); } break; case ENTITY_FILTER: { EntityFilter ef = getCachedSvmEntityFilter(model); FeatureNormalizer norm = getCachedFeatureNormalizer(zscore, new EntityFeaturePack()); a = getDefaultSmaphParam(wikiApi, wikiToFreeb, auxAnnotator, e2a, ef, norm, new DummyLinkBack(), true, includeS2, true, ws, c); } break; case COLLECTIVE: { BindingRegressor bindingRegressor = getCachedBindingRegressor(model); CollectiveLinkBack lb = new CollectiveLinkBack(wikiApi, wikiToFreeb, e2a, new DefaultBindingGenerator(), bindingRegressor, new NoFeatureNormalizer()); a = getDefaultSmaphParam(wikiApi, wikiToFreeb, auxAnnotator, e2a, new NoEntityFilter(), null, lb, true, includeS2, true, ws, c); } break; case GREEDY: { Pair<List<AnnotationRegressor>,List<FeatureNormalizer> > regressorsAndNormalizers = getGreedyRegressors(ws, true, includeS2, true); List<AnnotationRegressor> regressors = regressorsAndNormalizers.getFirst(); List<FeatureNormalizer> normalizers = regressorsAndNormalizers.getSecond(); if (regressors.isEmpty()) throw new IllegalArgumentException("Could not find models."); if (greedyStepLimit >= 0){ regressors = regressors.subList(0, greedyStepLimit); normalizers = normalizers.subList(0, greedyStepLimit); } GreedyLinkback lbGreedy = new GreedyLinkback(regressors, normalizers, wikiApi, wikiToFreeb, e2a, DEFAULT_ANCHOR_MENTION_ED); a = getDefaultSmaphParam(wikiApi, wikiToFreeb, auxAnnotator, e2a, new NoEntityFilter(), null, lbGreedy, true, includeS2, true, ws, c); } break; default: throw new NotImplementedException(); } a.appendName(String.format(" - %s, %s%s", v, ws, includeS2 ? "" : ", excl. S2")); return a; }
/** * Iterator is not implemented, as it is not needed. */ @Override public Iterator<E> iterator() { throw new NotImplementedException(); }
@Override public HashMap<String, FlowPortInfo> queryPortInfo(VirtualizationConnectorElement vc, String region, HashMap<String, FlowInfo> portsQuery) throws Exception { throw new NotImplementedException("NSC SDN Controller does not support flow based query"); }
@Override public Collection<Location> convert(Collection<LocationDTO> d) { throw new NotImplementedException(LocationConverter.class); }
@Override public Employee convert(EmployeeDTO d) { throw new NotImplementedException(EmployeeConverter.class); }
@Override public Collection<Employee> convert(Collection<EmployeeDTO> d) { throw new NotImplementedException(EmployeeConverter.class); }
@Override public Collection<SlackChannel> convertToDTO(Collection<Channels> s) { throw new NotImplementedException(ChannelConverter.class); }
@Override public Channels convert(SlackChannel d) { throw new NotImplementedException(ChannelConverter.class); }
@Override public Collection<Channels> convert(Collection<SlackChannel> d) { throw new NotImplementedException(ChannelConverter.class); }
@Override public Collection<SlackChannel> convert(Collection<SlackChannelDTO> d) { throw new NotImplementedException(SlackChannelConverter.class); }