List of usage examples for java.lang Integer toOctalString
public static String toOctalString(int i)
From source file:org.apache.impala.datagenerator.HBaseTestDataRegionAssigment.java
/** * Returns non-printable characters in escaped octal, otherwise returns the characters. */// w w w. j av a 2s. c om public static String printKey(byte[] key) { StringBuilder result = new StringBuilder(); for (int i = 0; i < key.length; ++i) { if (!Character.isISOControl(key[i])) { result.append((char) key[i]); } else { result.append("\\"); result.append(Integer.toOctalString(key[i])); } } return result.toString(); }
From source file:org.dbmfs.DatabaseFilesystem.java
public int mknod(String path, int mode, int rdev) throws FuseException { log.info("mknod " + path + " " + mode + " " + rdev); if (readOnlyMount) throw new FuseException("Read Only").initErrno(FuseException.EACCES); // ?"."????????? if (DbmfsUtil.isHiddenFile(path)) { //System.out.println(path + " is hidden file"); return 0; }/* w w w. j a v a 2 s. c o m*/ // ????offset limit??? path = DbmfsUtil.convertRealPath(path.trim()); String modeStr = Integer.toOctalString(mode); String pathType = ""; String fileBlockIdx = null; if (modeStr.indexOf("100") == 0) { // Regular File pathType = "file"; fileBlockIdx = "-1"; } else if (modeStr.indexOf("40") == 0) { // Directory pathType = "dir"; throw new FuseException("Directory not created").initErrno(FuseException.EACCES); } else { return Errno.EINVAL; } StringBuilder infomationBuf = new StringBuilder(); infomationBuf.append(pathType); infomationBuf.append("\t").append("1"); infomationBuf.append("\t").append("0"); infomationBuf.append("\t").append("0"); infomationBuf.append("\t").append("0"); infomationBuf.append("\t").append((System.currentTimeMillis() / 1000L)); infomationBuf.append("\t").append("0"); infomationBuf.append("\t").append(mode); infomationBuf.append("\t").append(rdev); infomationBuf.append("\t").append(System.nanoTime()); if (fileBlockIdx != null) { infomationBuf.append("\t").append(fileBlockIdx); } try { String checkInfomation = dbmfsCore.getInfomation(path); if (checkInfomation != null && !checkInfomation.trim().equals("")) return Errno.EEXIST; if (!dbmfsCore.createTmpiNode(path.trim(), infomationBuf.toString())) return Errno.EEXIST; } catch (FuseException fe) { throw fe; } catch (Exception e) { new FuseException(e); } return 0; }
From source file:org.eclipse.rdf4j.rio.RDFWriterTest.java
protected RDFWriterTest(RDFWriterFactory writerF, RDFParserFactory parserF) { rdfWriterFactory = writerF;// ww w. ja v a 2s.co m rdfParserFactory = parserF; vf = SimpleValueFactory.getInstance(); exNs = "http://example.org/"; bnode = vf.createBNode("anon"); bnodeEmpty = vf.createBNode(""); bnodeSingleLetter = vf.createBNode("a"); bnodeDuplicateLetter = vf.createBNode("aa"); bnodeNumeric = vf.createBNode("123"); bnodeDashes = vf.createBNode("a-b"); bnodeSpecialChars = vf.createBNode("$%^&*()!@#$a-b<>?\"'[]{}|\\"); bnodeSingleUseSubject = vf.createBNode("bnodeSingleUseSubject"); bnodeSingleUseObject = vf.createBNode("bnodeSingleUseObject"); bnodeUseAcrossContextsSubject = vf.createBNode("bnodeUseAcrossContextsSubject"); bnodeUseAcrossContextsSubjectAndObject = vf.createBNode("bnodeUseAcrossContextsSubjectAndObject"); bnodeUseAcrossContextsObject = vf.createBNode("bnodeUseAcrossContextsObject"); uri1 = vf.createIRI(exNs, "uri1"); uri2 = vf.createIRI(exNs, "uri2"); uri3 = vf.createIRI(exNs, "uri3."); uri4 = vf.createIRI(exNs, "uri4#me"); uri5 = vf.createIRI(exNs, "uri5/you"); plainLit = vf.createLiteral("plain"); dtLit = vf.createLiteral(1); langLit = vf.createLiteral("test", "en"); litWithNewlineAtEnd = vf.createLiteral("literal with newline at end\n"); litWithNewlineAtStart = vf.createLiteral("\nliteral with newline at start"); litWithMultipleNewlines = vf.createLiteral("\nliteral \nwith newline at start\n"); litWithSingleQuotes = vf.createLiteral("'''some single quote text''' - abc"); litWithDoubleQuotes = vf.createLiteral("\"\"\"some double quote text\"\"\" - abc"); litBigPlaceholder = vf.createLiteral(prng.nextDouble()); potentialSubjects = new ArrayList<Resource>(); potentialSubjects.add(bnode); potentialSubjects.add(bnodeEmpty); potentialSubjects.add(bnodeSingleLetter); potentialSubjects.add(bnodeDuplicateLetter); potentialSubjects.add(bnodeNumeric); potentialSubjects.add(bnodeDashes); potentialSubjects.add(bnodeSpecialChars); potentialSubjects.add(uri1); potentialSubjects.add(uri2); potentialSubjects.add(uri3); potentialSubjects.add(uri4); potentialSubjects.add(uri5); for (int i = 0; i < 50; i++) { potentialSubjects.add(vf.createBNode()); } for (int i = 0; i < 50; i++) { potentialSubjects.add(vf.createBNode(Integer.toHexString(i))); } for (int i = 1; i < 50; i++) { potentialSubjects.add(vf.createBNode("a" + Integer.toHexString(i).toUpperCase())); } for (int i = 1; i < 50; i++) { potentialSubjects.add(vf.createBNode("a" + Integer.toHexString(i).toLowerCase())); } for (int i = 0; i < 200; i++) { potentialSubjects .add(vf.createIRI(exNs + Integer.toHexString(i) + "/a" + Integer.toOctalString(i % 133))); } Collections.shuffle(potentialSubjects, prng); potentialObjects = new ArrayList<Value>(); potentialObjects.addAll(potentialSubjects); potentialObjects.add(plainLit); potentialObjects.add(dtLit); potentialObjects.add(langLit); // FIXME: SES-879: The following break the RDF/XML parser/writer // combination in terms of getting the same number of triples back as we // start with if (rdfParserFactory.getRDFFormat().equals(RDFFormat.RDFXML)) { // System.out.println("FIXME: SES-879: RDFXML Parser does not // preserve literals starting or ending in newline character"); } else { potentialObjects.add(litWithNewlineAtEnd); potentialObjects.add(litWithNewlineAtStart); potentialObjects.add(litWithMultipleNewlines); } potentialObjects.add(litWithSingleQuotes); potentialObjects.add(litWithDoubleQuotes); potentialObjects.add(litBigPlaceholder); Collections.shuffle(potentialObjects, prng); potentialPredicates = new ArrayList<IRI>(); // In particular, the following fuzz tests the ability of the parser to // cater for rdf:type predicates with literal endings, in unknown // situations. All parsers/writers should preserve these statements, // even // if they have shortcuts for URIs potentialPredicates.add(RDF.TYPE); potentialPredicates.add(RDF.NIL); potentialPredicates.add(RDF.FIRST); potentialPredicates.add(RDF.REST); potentialPredicates.add(SKOS.ALT_LABEL); potentialPredicates.add(SKOS.PREF_LABEL); potentialPredicates.add(SKOS.BROADER_TRANSITIVE); potentialPredicates.add(OWL.ONTOLOGY); potentialPredicates.add(OWL.ONEOF); potentialPredicates.add(DC.TITLE); potentialPredicates.add(DCTERMS.ACCESS_RIGHTS); potentialPredicates.add(FOAF.KNOWS); potentialPredicates.add(EARL.SUBJECT); potentialPredicates.add(RDFS.LABEL); potentialPredicates.add(SP.DEFAULT_PROPERTY); potentialPredicates.add(SP.TEXT_PROPERTY); potentialPredicates.add(SP.BIND_CLASS); potentialPredicates.add(SP.DOCUMENT_PROPERTY); potentialPredicates.add(SPIN.LABEL_TEMPLATE_PROPERTY); potentialPredicates.add(SESAME.DIRECTTYPE); Collections.shuffle(potentialPredicates, prng); }
From source file:org.openrdf.rio.RDFWriterTest.java
protected RDFWriterTest(RDFWriterFactory writerF, RDFParserFactory parserF) { rdfWriterFactory = writerF;//from w w w . j a v a 2 s .c om rdfParserFactory = parserF; vf = new SimpleValueFactory(); exNs = "http://example.org/"; bnode = vf.createBNode("anon"); bnodeEmpty = vf.createBNode(""); bnodeSingleLetter = vf.createBNode("a"); bnodeDuplicateLetter = vf.createBNode("aa"); bnodeNumeric = vf.createBNode("123"); bnodeDashes = vf.createBNode("a-b"); bnodeSpecialChars = vf.createBNode("$%^&*()!@#$a-b<>?\"'[]{}|\\"); uri1 = vf.createIRI(exNs, "uri1"); uri2 = vf.createIRI(exNs, "uri2"); uri3 = vf.createIRI(exNs, "uri3."); plainLit = vf.createLiteral("plain"); dtLit = vf.createLiteral(1); langLit = vf.createLiteral("test", "en"); litWithNewlineAtEnd = vf.createLiteral("literal with newline at end\n"); litWithNewlineAtStart = vf.createLiteral("\nliteral with newline at start"); litWithMultipleNewlines = vf.createLiteral("\nliteral \nwith newline at start\n"); litWithSingleQuotes = vf.createLiteral("'''some single quote text''' - abc"); litWithDoubleQuotes = vf.createLiteral("\"\"\"some double quote text\"\"\" - abc"); litBigPlaceholder = vf.createLiteral(prng.nextDouble()); potentialSubjects = new ArrayList<Resource>(); potentialSubjects.add(bnode); potentialSubjects.add(bnodeEmpty); potentialSubjects.add(bnodeSingleLetter); potentialSubjects.add(bnodeDuplicateLetter); potentialSubjects.add(bnodeNumeric); potentialSubjects.add(bnodeDashes); potentialSubjects.add(bnodeSpecialChars); potentialSubjects.add(uri1); potentialSubjects.add(uri2); potentialSubjects.add(uri3); for (int i = 0; i < 50; i++) { potentialSubjects.add(vf.createBNode()); } for (int i = 0; i < 50; i++) { potentialSubjects.add(vf.createBNode(Integer.toHexString(i))); } for (int i = 1; i < 50; i++) { potentialSubjects.add(vf.createBNode("a" + Integer.toHexString(i).toUpperCase())); } for (int i = 1; i < 50; i++) { potentialSubjects.add(vf.createBNode("a" + Integer.toHexString(i).toLowerCase())); } for (int i = 0; i < 200; i++) { potentialSubjects .add(vf.createIRI(exNs + Integer.toHexString(i) + "/a" + Integer.toOctalString(i % 133))); } Collections.shuffle(potentialSubjects, prng); potentialObjects = new ArrayList<Value>(); potentialObjects.addAll(potentialSubjects); potentialObjects.add(plainLit); potentialObjects.add(dtLit); potentialObjects.add(langLit); // FIXME: SES-879: The following break the RDF/XML parser/writer // combination in terms of getting the same number of triples back as we // start with if (rdfParserFactory.getRDFFormat().equals(RDFFormat.RDFXML)) { // System.out.println("FIXME: SES-879: RDFXML Parser does not preserve literals starting or ending in newline character"); } else { potentialObjects.add(litWithNewlineAtEnd); potentialObjects.add(litWithNewlineAtStart); potentialObjects.add(litWithMultipleNewlines); } potentialObjects.add(litWithSingleQuotes); potentialObjects.add(litWithDoubleQuotes); potentialObjects.add(litBigPlaceholder); Collections.shuffle(potentialObjects, prng); potentialPredicates = new ArrayList<IRI>(); // In particular, the following fuzz tests the ability of the parser to // cater for rdf:type predicates with literal endings, in unknown // situations. All parsers/writers should preserve these statements, even // if they have shortcuts for URIs potentialPredicates.add(RDF.TYPE); potentialPredicates.add(RDF.NIL); potentialPredicates.add(RDF.FIRST); potentialPredicates.add(RDF.REST); potentialPredicates.add(SKOS.ALT_LABEL); potentialPredicates.add(SKOS.PREF_LABEL); potentialPredicates.add(SKOS.BROADER_TRANSITIVE); potentialPredicates.add(OWL.ONTOLOGY); potentialPredicates.add(OWL.ONEOF); potentialPredicates.add(DC.TITLE); potentialPredicates.add(DCTERMS.ACCESS_RIGHTS); potentialPredicates.add(FOAF.KNOWS); potentialPredicates.add(EARL.SUBJECT); potentialPredicates.add(RDFS.LABEL); potentialPredicates.add(SP.DEFAULT_PROPERTY); potentialPredicates.add(SP.TEXT_PROPERTY); potentialPredicates.add(SP.BIND_CLASS); potentialPredicates.add(SP.DOCUMENT_PROPERTY); potentialPredicates.add(SPIN.LABEL_TEMPLATE_PROPERTY); potentialPredicates.add(SESAME.DIRECTTYPE); Collections.shuffle(potentialPredicates, prng); }
From source file:org.pentaho.di.trans.steps.sftpscan.client.SFTPClient.java
private RemoteFile buildRemoteFile(String currentFolder, LsEntry lse) { RemoteFile rf = new RemoteFile(); rf.setPath(currentFolder);/*from w w w.j a v a2 s .co m*/ rf.setName(lse.getFilename()); rf.setPermissions(Integer.toOctalString(lse.getAttrs().getPermissions() & 07777)); rf.setSize(lse.getAttrs().getSize()); rf.setUid(lse.getAttrs().getUId()); rf.setGid(lse.getAttrs().getGId()); rf.setAccessDate(new Date(lse.getAttrs().getATime() * 1000L)); rf.setModificationDate(new Date(lse.getAttrs().getMTime() * 1000L)); return rf; }
From source file:org.springframework.data.hadoop.test.support.StandaloneHadoopCluster.java
/** * Gets the current umask.//from ww w . j av a 2 s . co m */ private String getCurrentUmask(String tmpDir, Configuration config) throws IOException { try { LocalFileSystem localFS = FileSystem.getLocal(config); return Integer.toOctalString(localFS.getFileStatus(new Path(getTmpDir())).getPermission().toShort()); } catch (Exception e) { return null; } }
From source file:org.wisdom.framework.vertx.VertxDispatcherTest.java
@Test public void testWebSocketWithMultiClients() throws InterruptedException, IOException { // Prepare the configuration prepareServer();//from w w w . j a v a2 s . co m final ServerWebSocket socket1 = mock(ServerWebSocket.class); final Socket sock1 = new Socket(socket1); final ServerWebSocket socket2 = mock(ServerWebSocket.class); final Socket sock2 = new Socket(socket2); MyWebSocketListener listener = new MyWebSocketListener(); server.register(listener); server.addSocket("/hello", sock1); // The listener should have been notified. assertThat(listener.opened).isNotNull(); server.received("/hello", "message".getBytes(Charsets.UTF_8), sock1); // The listener should have received the message. assertThat(listener.lastMessage).isEqualTo("message"); assertThat(listener.lastClient).isEqualTo(Integer.toOctalString(socket1.hashCode())); server.addSocket("/hello", sock2); server.received("/hello", "message2".getBytes(Charsets.UTF_8), sock2); assertThat(listener.lastMessage).isEqualTo("message2"); assertThat(listener.lastClient).isEqualTo(Integer.toOctalString(socket2.hashCode())); server.removeSocket("/hello", sock1); server.removeSocket("/hello", sock2); assertThat(listener.closed).isNotNull(); }
From source file:sos.net.SOSFTP.java
@Override public boolean mkdir(final String pathname, final int pintPosixPermissions) throws IOException { boolean flgRet = makeDirectory(pathname); this.sendCommand("CHMOD " + Integer.toOctalString(pintPosixPermissions) + " " + pathname); return flgRet; }
From source file:spade.reporter.CDM.java
/** * Return null if null arguments/*from w w w .j a va 2 s. com*/ * * @param permission * @return null/Octal representation of permissions */ private String getPermissionSHORTAsString(SHORT permission) { if (permission == null) { return null; } else { ByteBuffer bb = ByteBuffer.allocate(2); bb.put(permission.bytes()[0]); bb.put(permission.bytes()[1]); int permissionShort = bb.getShort(0); return Integer.toOctalString(permissionShort); } }
From source file:su.comp.bk.arch.ComputerFactoryTest.java
protected boolean execute(int address, String expectedOutput) { boolean isSuccess = false; Cpu cpu = computer.getCpu();/*from w w w .j a va2 s . c om*/ cpu.writeRegister(false, Cpu.PC, address); long startTime = System.currentTimeMillis(); while ((System.currentTimeMillis() - startTime) < MAX_EXECUTION_TIME || terminal.getWrittenData().length() > Terminal.MAX_DATA_LENGTH) { try { cpu.executeNextOperation(); if (cpu.isHaltMode()) { throw new IllegalStateException("HALT mode"); } } catch (Exception e) { e.printStackTrace(); fail("can't execute operation, PC: 0" + Integer.toOctalString(cpu.readRegister(false, Cpu.PC))); } if (expectedOutput.equals(terminal.getWrittenData())) { isSuccess = true; break; } } return isSuccess; }