id
stringlengths
36
36
text
stringlengths
1
1.25M
14033426-6405-4c45-a524-3b28870be6ce
protected int lookupCategory(int c) { // this override of lookupCategory() exists only to keep track of whether we've // passed over any dictionary characters. It calls the inherited lookupCategory() // to do the real work, and then checks whether its return value is one of the // categories represented...
cae1d8cf-18e9-4d94-b447-7a0b2986bad8
private void divideUpDictionaryRange(int startPos, int endPos) { CharacterIterator text = getText(); // the range we're dividing may begin or end with non-dictionary characters // (i.e., for line breaking, we may have leading or trailing punctuation // that needs to be kept with the word). Seek from th...
921ab57c-6aed-4b30-8a90-85d2ff10544a
public static void main(String args[]) throws FileNotFoundException, UnsupportedEncodingException, IOException { String filename = args[0]; BreakDictionary dictionary = new BreakDictionary(new FileInputStream(filename)); PrintWriter out = null; if(args.length >= 2) { out = new PrintWriter...
ebd8eff0-7b37-4474-a266-35e04219aa3b
public void printWordList(String partialWord, int state, PrintWriter out) throws IOException { if (state == 0xFFFF) { System.out.println(partialWord); if (out != null) { out.println(partialWord); } } else { for (int i = 0; i < numCols; i++) { int newState = (get...
bc21ed25-4f39-44d6-ae8a-952a95d12a37
public BreakDictionary(InputStream dictionaryStream) throws IOException { readDictionaryFile(new DataInputStream(dictionaryStream)); }
fad63b9a-7417-4813-bc6f-b9d88a8bfd90
public void readDictionaryFile(DataInputStream in) throws IOException { int l; // read in the version number (right now we just ignore it) in.readInt(); // read in the column map (this is serialized in its internal form: // an index array followed by a data array) l = in.readInt(); char[] ...
fd748e53-26e7-4d4b-bd1c-7130a2b7cde8
public final short getNextStateFromCharacter(int row, char ch) { int col = columnMap.elementAt(ch); return getNextState(row, col); }
b0af4bbb-93a1-4e73-99ae-1479e332afb1
public final short getNextState(int row, int col) { if (cellIsPopulated(row, col)) { // we map from logical to physical row number by looking up the // mapping in rowIndex; we map from logical column number to // physical column number by looking up a shift value for this // logical row and ...
b57174a3-918c-475a-b43f-30c8762bf2b3
private final boolean cellIsPopulated(int row, int col) { // look up the entry in the bitmap index for the specified row. // If it's a negative number, it's the column number of the only // populated cell in the row if (rowIndexFlagsIndex[row] < 0) { return col == -rowIndexFlagsIndex[row]; } ...
b919c129-6a08-423a-9fd0-b78c9b2f980b
private final short internalAt(int row, int col) { // the table is a one-dimensional array, so this just does the math necessary // to treat it as a two-dimensional array (we don't just use a two-dimensional // array because two-dimensional arrays are inefficient in Java) return table[row * numCols + co...
0791e5a8-53e1-45a8-bfac-0473a1101e3b
@Override protected void initChannel(SocketChannel ch) throws Exception { System.err.println("in ServerInit"); ChannelPipeline pipeline = ch.pipeline(); GlobalTrafficShapingHandler globalTrafficShapingHandler = new GlobalTrafficShapingHandler(ch.eventLoop()); trafficCounter = globalT...
38e98651-112a-4cf6-bbee-e33c28a04a05
public void run() { EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); System.out.println("in HttpServRun"); try { ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_BACKLOG, 1024); ...
dd2a6b8b-ba0e-47a6-8b5f-c4d2c78dc64c
public static void main(String[] args) { try { System.out.println("in Main"); new HttpServer().run(); } catch (Exception e) { e.printStackTrace(); } }
58d6fcf8-e101-47c2-86b8-9cf2a0e82b75
public static void addConnection(){ activeConnection++; }
c9ac83a5-99ec-47f9-8047-d5df1a28df17
synchronized public static void subConnection(){ activeConnection--; }
46a32628-d81f-47fb-ac30-5066d9f7cb6a
synchronized public static int getActiveConnection() { return activeConnection; }
132c0d68-b07e-48bd-bdfd-d2f10b836353
public static long getTotalrequest() { return totalrequest; }
f5f16445-fd5b-436e-aad2-0eb39561d32f
public static void setTotalrequest(long totalrequest) { ServerStatus.totalrequest = totalrequest; }
0286691c-8220-4bae-850a-99e7ee068371
public static void addRequest(){ totalrequest++; }
1cbd9d7d-a5ea-4cda-88c3-88911f284245
public ServerHandler(TrafficCounter trafficCounter) { this.trafficCounter = trafficCounter; }
a3f1d64e-7a41-4782-a01f-33e1b84d2e2b
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { trafficCounter.start(); InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress(); String ip = address.getHostString(); if (msg instanceof HttpRequest) { Syst...
988a6db4-1326-4d44-bdea-e2bf431e69b1
@Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { System.out.println("in ChanelReadRomplete"); ServerStatus.subConnection(); ctx.flush(); ctx.close(); }
1aa7c1e5-1c19-4cc2-9e9b-aa46922c380b
private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req, String ip) { String uri = req.getUri(); FullHttpResponse resp = null; if (uri.equalsIgnoreCase(STATUS)) { ManagerDB.addOrUpdateRequestAmount(ip, dateFormat.format(new Date())); ServerStatus.add...
87a70da7-8e20-4598-bdc2-29eb3f2cd6ea
private void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse resp) { if (!isKeepAlive(req)) { ctx.write(resp).addListener(ChannelFutureListener.CLOSE); } else { resp.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE); ctx.write(...
470ff8c0-2e4c-49e7-80e7-250be8a4060e
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { System.out.println("in ExceptionCaugh"); ServerStatus.subConnection(); cause.printStackTrace(); ctx.close(); }
3ddbfa35-191c-4fbc-b9ef-704af036221f
synchronized public void trafficLog() { trafficCounter.stop(); receivedBytes = trafficCounter.cumulativeReadBytes(); sentBytes = trafficCounter.cumulativeWrittenBytes(); speed = trafficCounter.lastWriteThroughput(); trafficCounter.resetCumulativeTime(); }
a0d767f9-b71a-4e93-ad3f-91c42c57f031
public static JPUtil getInstance() { if (instance == null) { instance = new JPUtil(); } return instance; }
d226e0ad-c442-4a16-9fdf-b35ae0fe9b2d
private JPUtil() { emf = Persistence.createEntityManagerFactory("HttpServerPU"); }
f5647b5c-4458-4323-9403-34d6633453fe
public EntityManager getManager() { return emf.createEntityManager(); }
adeba647-0d59-4d90-9063-1512d389fa2a
public void closeFactory() { emf.close(); }
639e7378-92ed-4473-b3a3-9c678cf1d287
@Override public String getPage() { return page; }
36be7459-a392-416a-b39a-cf1f5ac97205
public String createContent() { StringBuilder HTTPResponse = new StringBuilder(); HTTPResponse.append(" <h2> <p>Number of all requset: " + ServerStatus.getTotalrequest() + " </p> </h2>"); HTTPResponse.append(" <h2> <p>Number of active connections: " + ServerStatus.getActiveConnection() + " </p> ...
8f782bb8-1d45-47e8-b55c-4de1584dea19
@Override public String getPage() { return this.page; }
8f22f549-bf6d-4a1a-9690-d4d614714bba
public abstract String getPage();
b86a3c97-d9f8-4371-8ca8-c4ef84618545
public Redirects() { }
641c3774-1e7e-4a96-b39f-9098541c66cc
public Redirects(String url) { this.url = url; }
c125a99a-a251-405e-ba7f-039d66fbdc6a
public Redirects(String url, int amountRedir) { this.url = url; this.amountRedir = amountRedir; }
6b09783d-b2a6-4e6c-8f6c-075561893725
public String getUrl() { return url; }
2586999c-d365-4ae7-ae8c-b9ec23519ed6
public void setUrl(String url) { this.url = url; }
683396f9-4715-4309-9bee-72a1f0d63113
public int getAmountRedir() { return amountRedir; }
2c520aeb-0dce-4287-b2fa-2f7b907a97c5
public void setAmountRedir(int amountRedir) { this.amountRedir = amountRedir; }
d4215b57-d0a7-4ca2-bf47-304ad7ae776f
@Override public int hashCode() { int hash = 0; hash += (url != null ? url.hashCode() : 0); return hash; }
fce0eb46-34c0-4984-9f49-715211e64be8
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Redirects)) { return false; } Redirects other = (Redirects) object; if ((this.url == null && other.url != null)...
526108d7-f10f-4648-8f99-d5c42c23e6e7
@Override public String toString() { return "entitys.Redirects[ url=" + url + " ]"; }
de2edf06-8f07-4de1-a2fd-c3e841107dd2
public Connection() { }
3609bd47-3547-4a0b-b1c4-2e66225b31aa
public Connection(Integer id) { this.id = id; }
6ecc41cd-d0f1-4db6-99f3-ba49737e479a
public Connection(String srcIp, String uri, String timestamp, long sentBytes, long receivedBytes, long speed) { this.srcIp = srcIp; this.uri = uri; this.timestamp = timestamp; this.sentBytes = sentBytes; this.receivedBytes = receivedBytes; this.speed = speed; }
b44e0dd4-8b54-4231-8db1-579b62cbe81b
public Integer getId() { return id; }
3ca39555-f62e-4ce6-85c6-e8c7a2310c44
public void setId(Integer id) { this.id = id; }
62e86bdd-11e9-424d-8818-ea04d6613f18
public String getSrcIp() { return srcIp; }
45c36960-ee54-4fec-9792-9cf336916136
public void setSrcIp(String srcIp) { this.srcIp = srcIp; }
47927e64-009f-4231-9a02-c77d0ebdf864
public String getUri() { return uri; }
a94521c7-74fe-4c91-af43-7165ff4ef83d
public void setUri(String uri) { this.uri = uri; }
29130f46-e539-4add-89e5-63e0ecffb8e3
public String getTimestamp() { return timestamp; }
8f93a06f-ea4a-4200-b56a-62ca8560f5bb
public void setTimestamp(String timestamp) { this.timestamp = timestamp; }
6d63b0cc-c365-4bf8-825d-c48868ccb612
public long getSentBytes() { return sentBytes; }
2863d840-4c2d-486d-9f68-059754b03d18
public void setSentBytes(int sentBytes) { this.sentBytes = sentBytes; }
33f744e6-952b-40bb-858b-60717269ce42
public long getReceivedBytes() { return receivedBytes; }
3f7874db-1cf8-442f-9861-6920509f9036
public void setReceivedBytes(int receivedBytes) { this.receivedBytes = receivedBytes; }
f5087a57-e86a-484f-af87-90bbbc076610
@Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; }
3f474250-6e74-46a4-bfe9-27872a1ec245
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Connection)) { return false; } Connection other = (Connection) object; if ((this.id == null && other.id != null...
5c0b7915-5941-428c-9578-f66880dc39f3
@Override public String toString() { return "entitys.Connection[ id=" + id + " ]"; }
7773feb2-2d49-425c-a826-5d27eebc9cf0
public void setSpeed(int speed) { this.speed = speed; }
7fb02623-8f97-4504-ad55-edb9eb717591
public long getSpeed() { return speed; }
723ae395-57b1-43b5-8694-3590c5088d2f
public Requests() { }
c532a44b-9d12-470d-88f6-3a148ce9f518
public Requests(Integer id) { this.id = id; }
44891023-f1bb-4be4-8924-1963b2b91a20
public Requests(String ip, int requestCount, String timeLastRequest) { this.ip = ip; this.requestCount = requestCount; this.timeLastRequest = timeLastRequest; }
594a6c0d-e14f-4e05-8091-1e7f908c8f43
public Integer getId() { return id; }
cfb04865-f09f-476e-86ec-e4724fe04428
public void setId(Integer id) { this.id = id; }
a177ca99-f51a-4abe-a276-53dce49f7109
public String getIp() { return ip; }
ce1dcf5d-5312-4c45-b9e9-134243c1a311
public void setIp(String ip) { this.ip = ip; }
df8d9176-b099-402a-bd8a-51e193cde9ca
public int getRequestCount() { return requestCount; }
8d84f6d3-0703-4374-a633-affd87189ef6
public void setRequestCount(int requestCount) { this.requestCount = requestCount; }
752672c6-b2b3-470e-9234-e99e058eeb17
public String getTimeLastRequest() { return timeLastRequest; }
d1c34c79-1815-42bf-a5a8-e9322630c503
public void setTimeLastRequest(String timeLastRequest) { this.timeLastRequest = timeLastRequest; }
19d6b91a-0c3f-4b59-956d-5a11463eb2b4
@Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; }
b6a150a1-6ec2-4114-b0a3-8330a50ab8d8
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Requests)) { return false; } Requests other = (Requests) object; if ((this.id == null && other.id != null) || (...
3647598e-da56-44ef-afd1-d91d8c7021a5
@Override public String toString() { return "entitys.Requests[ id=" + id + " ]"; }
3d2448fe-8b8e-499d-939c-284e344b163e
synchronized public static void addOrUpdateRequestAmount(String ip, String timestamp){ Requests req; EntityManager manager = JPUtil.getInstance().getManager(); manager.getTransaction().begin(); try { req = manager.createNamedQuery("Requests.findByIp", Requests.class).setPa...
d7c5aa34-d0c8-44fc-afdf-d8b56d9996d7
synchronized public static void insertConnection(String src_ip, String uri,String timestamp, long sentBytes, long receivedBytes, long speed){ EntityManager manager = JPUtil.getInstance().getManager(); manager.getTransaction().begin(); manager.persist(new Connection(src_ip, uri, timestam...
5c0d4b35-0c0b-4440-b936-55ef29bd1af8
public static void insertOrUpdateURLRedirect(String url){ Redirects redURL; EntityManager manager = JPUtil.getInstance().getManager(); manager.getTransaction().begin(); try { redURL = manager.createNamedQuery("Redirects.findByUrl", Redirects.class).setParameter("url", ur...
1f3a48f8-548e-4367-ba83-79731e298a6e
public static List<Connection> getConnectionList(){ EntityManager manager = JPUtil.getInstance().getManager(); List<Connection> connectList = manager.createNamedQuery("Connection.findAll", Connection.class).getResultList(); return connectList; }
b29e7f88-7086-483e-b83a-c1406e393821
public static List<Requests> getUbiqueRequestList(){ EntityManager manager = JPUtil.getInstance().getManager(); List<Requests> uniqRequest = manager.createNamedQuery("Requests.findByRequestCount", Requests.class).setParameter("requestCount", 1).getResultList(); return uniqRequest; }
6e805658-e60d-4e10-9ec9-20f14ed9ef49
public static List<Redirects> getRedirectList(){ EntityManager manager = JPUtil.getInstance().getManager(); List<Redirects> allRedir = manager.createNamedQuery("Redirects.findAll", Redirects.class).getResultList(); return allRedir; }
dc70c040-1de5-446a-b425-217636b9f156
public static List<Requests> getIpRequestList(){ EntityManager manager = JPUtil.getInstance().getManager(); List<Requests> requestList = manager.createNamedQuery("Requests.findAll", Requests.class).getResultList(); return requestList; }
972fa37f-709e-455c-8acd-6141f1287253
public static void showLog() { showLog = true; }
3fa5247c-e38f-4b0f-9d8f-473fe33b01c7
public static void hideLog() { showLog = false; }
83745311-bb9b-4773-a5f0-01279caa9abb
private SQLUtils() { }
0296b075-107a-4eb1-ac2d-23bd90e927b4
public static String getQuerySQL(String fileName) { try (Scanner sqlFile = new Scanner(new File(fileName))) { StringBuilder sql = new StringBuilder(); while (sqlFile.hasNext()) sql.append(sqlFile.nextLine()); String actualSQL = sql.toString(); log(actualSQL); return actualSQL; } catch (FileNotFou...
3e89ebab-1d89-4819-b22a-d7fa7bad86eb
private static void log(String querySql) { if (showLog) System.out.printf("Executing %s @ %s \n", querySql, getDBURL()); }
2f3a2d1f-be8c-412e-b70a-9bf265cd4696
public static String showAllEmployeesQuery() { return getQuerySQL(SHOW_ALL_EMPLOYEES); }
4c8133d1-f823-457c-a2df-6c6097c7ad7e
public static String showEmployeesAlphabeticallyQuery() { return getQuerySQL(SHOW_EMPLOYEES_ALPHABETICALLY); }
fefe0964-7e48-4fff-a94c-e51b86ecd94f
public static String showEmployeesNamesandDepartmentsQuery() { return getQuerySQL(SHOW_EMPLOYEES_NAMESand_DEPARTMENTS); }
7e9eb5be-5cbb-4564-b4ee-560f4d068d84
public static String showEmployeesNamesandManagersQuery() { return getQuerySQL(SHOW_EMPLOYEES_NAMESand_MANAGERS); }
ff09c905-073f-432b-b355-36dd7cb5eedd
public static String showEmployeesNamesandManagersOOPQuery() { return getQuerySQL(SHOW_EMPLOYEES_NAMESand_MANAGERSOOP); }
22249b31-acf2-41c8-9aaa-11689bc04bd8
public static String getDBUser() { return config.getProperty("user"); }
cb82dfce-b16a-4135-a68a-256ce0f78f50
public static String getPassword() { return config.getProperty("password"); }
f375f7a6-5b05-4836-9906-531cdc7ba0c3
public static String getDBURL() { return config.getProperty("url"); }
0ae27bef-6ca2-4fe4-800e-9b73fd6edd4d
public static void loadDriver() { try { Class.forName(DRIVER_CLASS); } catch (ClassNotFoundException e) { throw new ConfigurationException("Cannot load driver[" + DRIVER_CLASS + "]", e); } }
2ca34a4f-5e1c-47a3-af2a-872b83ce9b71
public static Connection getConnection() { try { return DriverManager.getConnection(getDBURL(), getDBUser(), getPassword()); } catch (SQLException e) { throw new ConfigurationException( "Cannot establish a connection to [ " + getDBURL() + "]", e); } }