blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
listlengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
313
782a635166e33976f9ce1af7dcb702411a07e669
d9477e8e6e0d823cf2dec9823d7424732a7563c4
/plugins/SVNPlugin/tags/0.5.1/src/ise/plugin/svn/gui/SVNInfoPanel.java
51b43e9504f0ee10c295827d52ac6e8298a49679
[]
no_license
RobertHSchmidt/jedit
48fd8e1e9527e6f680de334d1903a0113f9e8380
2fbb392d6b569aefead29975b9be12e257fbe4eb
refs/heads/master
2023-08-30T02:52:55.676638
2018-07-11T13:28:01
2018-07-11T13:28:01
140,587,948
1
0
null
null
null
null
UTF-8
Java
false
false
14,239
java
/* Copyright (c) 2007, Dale Anson All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package ise.plugin.svn.gui; import java.awt.GridLayout; import java.io.*; import java.util.*; import javax.swing.*; import javax.swing.border.EtchedBorder; import ise.java.awt.KappaLayout; import java.text.BreakIterator; import java.text.DateFormat; import java.text.SimpleDateFormat; import org.tmatesoft.svn.cli.command.SVNCommandEventProcessor; import org.tmatesoft.svn.cli.SVNArgument; import org.tmatesoft.svn.cli.SVNCommand; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNLock; import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNFormatUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.ISVNInfoHandler; import org.tmatesoft.svn.core.wc.ISVNOptions; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCClient; import org.tmatesoft.svn.core.wc.SVNWCUtil; import org.tmatesoft.svn.core.wc.xml.SVNXMLInfoHandler; import org.tmatesoft.svn.core.wc.xml.SVNXMLSerializer; public class SVNInfoPanel extends JPanel { private static final DateFormat DATE_FORMAT = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z (EE, d MMM yyyy)", Locale.getDefault() ); public SVNInfoPanel( List<SVNInfo> infos ) { super( new GridLayout( 0, 1, 0, 3 ) ); for ( SVNInfo info : infos ) { addInfo( info ); } } private void addInfo( SVNInfo info ) { JPanel panel = new JPanel( new KappaLayout() ); add(panel); panel.setBorder(new EtchedBorder()); KappaLayout.Constraints con = KappaLayout.createConstraint(); con.p = 3; con.a = KappaLayout.W; con.y = -1; if ( !info.isRemote() ) { ++con.y; JLabel label = new JLabel( "Path:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( SVNFormatUtil.formatPath( info.getFile() ) ); con.x = 1; panel.add( value, con ); } else if ( info.getPath() != null ) { String path = info.getPath(); path = path.replace( '/', File.separatorChar ); ++con.y; JLabel label = new JLabel( "Path:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( path ); con.x = 1; panel.add( value, con ); } if ( info.getKind() != SVNNodeKind.DIR ) { String v = ""; if ( info.isRemote() ) { v = SVNPathUtil.tail( info.getPath() ); } else { v = info.getFile().getName(); } ++con.y; JLabel label = new JLabel( "Name:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( v ); con.x = 1; panel.add( value, con ); } if (info.getURL() != null) { ++con.y; JLabel label = new JLabel( "URL:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( info.getURL().toString() ); con.x = 1; panel.add( value, con ); } if ( info.getRepositoryRootURL() != null ) { ++con.y; JLabel label = new JLabel( "Repository Root:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( info.getRepositoryRootURL().toString() ); con.x = 1; panel.add( value, con ); } if ( info.isRemote() && info.getRepositoryUUID() != null ) { ++con.y; JLabel label = new JLabel( "Repository UUID:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( info.getRepositoryUUID() ); con.x = 1; panel.add( value, con ); } if ( info.getRevision() != null && info.getRevision().isValid() ) { ++con.y; JLabel label = new JLabel( "Revision:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( String.valueOf(info.getRevision()) ); con.x = 1; panel.add( value, con ); } if ( info.getKind() == SVNNodeKind.DIR ) { ++con.y; JLabel label = new JLabel( "Node Kind:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( "directory" ); con.x = 1; panel.add( value, con ); } else if ( info.getKind() == SVNNodeKind.FILE ) { ++con.y; JLabel label = new JLabel( "Node Kind:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( "file" ); con.x = 1; panel.add( value, con ); } else if ( info.getKind() == SVNNodeKind.NONE ) { ++con.y; JLabel label = new JLabel( "Node Kind:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( "none" ); con.x = 1; panel.add( value, con ); } else { ++con.y; JLabel label = new JLabel( "Node Kind:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( "unknown" ); con.x = 1; panel.add( value, con ); } if ( info.getSchedule() == null && !info.isRemote() ) { ++con.y; JLabel label = new JLabel( "Schedule:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( "normal" ); con.x = 1; panel.add( value, con ); } else if ( !info.isRemote() ) { ++con.y; JLabel label = new JLabel( "Schedule:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( info.getSchedule() ); con.x = 1; panel.add( value, con ); } if ( info.getAuthor() != null ) { ++con.y; JLabel label = new JLabel( "Last Changed Author:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( info.getAuthor() ); con.x = 1; panel.add( value, con ); } if ( info.getCommittedRevision() != null && info.getCommittedRevision().getNumber() >= 0 ) { ++con.y; JLabel label = new JLabel( "Last Changed Rev:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( String.valueOf(info.getCommittedRevision()) ); con.x = 1; panel.add( value, con ); } if ( info.getCommittedDate() != null ) { ++con.y; JLabel label = new JLabel( "Last Changed Date:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel( formatDate( info.getCommittedDate() ) ); con.x = 1; panel.add( value, con ); } if ( !info.isRemote() ) { if ( info.getTextTime() != null ) { ++con.y; JLabel label = new JLabel( "Text Last Updated:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(formatDate( info.getTextTime() )); con.x = 1; panel.add( value, con ); } if ( info.getPropTime() != null ) { ++con.y; JLabel label = new JLabel( "Properties Last Updated:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(formatDate( info.getPropTime() )); con.x = 1; panel.add( value, con ); } if ( info.getChecksum() != null ) { ++con.y; JLabel label = new JLabel( "Checksum:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(info.getChecksum()); con.x = 1; panel.add( value, con ); } if ( info.getCopyFromURL() != null ) { ++con.y; JLabel label = new JLabel( "Copied From URL:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(info.getCopyFromURL().toString()); con.x = 1; panel.add( value, con ); } if ( info.getCopyFromRevision() != null && info.getCopyFromRevision().getNumber() >= 0 ) { ++con.y; JLabel label = new JLabel( "Copied From Rev:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(String.valueOf(info.getCopyFromRevision())); con.x = 1; panel.add( value, con ); } if ( info.getConflictOldFile() != null ) { ++con.y; JLabel label = new JLabel( "Conflict Previous Base File:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(info.getConflictOldFile().getName()); con.x = 1; panel.add( value, con ); } if ( info.getConflictWrkFile() != null ) { ++con.y; JLabel label = new JLabel( "Conflict Previous Working File:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(info.getConflictWrkFile().getName()); con.x = 1; panel.add( value, con ); } if ( info.getConflictNewFile() != null ) { ++con.y; JLabel label = new JLabel( "Conflict Current Base File:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(info.getConflictNewFile().getName()); con.x = 1; panel.add( value, con ); } if ( info.getPropConflictFile() != null ) { ++con.y; JLabel label = new JLabel( "Conflict Properties File:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(info.getPropConflictFile().getName()); con.x = 1; panel.add( value, con ); } } if ( info.getLock() != null ) { SVNLock lock = info.getLock(); ++con.y; JLabel label = new JLabel( "Lock Token:" ); con.x = 0; panel.add( label, con ); JLabel value = new JLabel(lock.getID()); con.x = 1; panel.add( value, con ); ++con.y; label = new JLabel( "Lock Owner:" ); con.x = 0; panel.add( label, con ); value = new JLabel(lock.getOwner()); con.x = 1; panel.add( value, con ); ++con.y; label = new JLabel( "Lock Created:" ); con.x = 0; panel.add( label, con ); value = new JLabel(formatDate( lock.getCreationDate() )); con.x = 1; panel.add( value, con ); if ( lock.getComment() != null ) { ++con.y; label = new JLabel( "Lock Comment" ); con.x = 0; panel.add( label, con ); int lineCount = getLineCount( lock.getComment() ); StringBuffer sb = new StringBuffer(); if ( lineCount == 1 ) { sb.append( "(1 line)" ); } else { sb.append( "(" + lineCount + " lines)" ); } sb.append( ":\n" + lock.getComment() + "\n" ); value = new JLabel(sb.toString()); con.x = 1; panel.add( value, con ); } } } private String formatDate( Date date ) { return DATE_FORMAT.format( date ); } private int getLineCount( String s ) { int count = 0; BreakIterator boundary = BreakIterator.getLineInstance(); int start = boundary.first(); for ( int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next() ) { ++count; } return count; } }
[ "daleanson@6b1eeb88-9816-0410-afa2-b43733a0f04e" ]
daleanson@6b1eeb88-9816-0410-afa2-b43733a0f04e
507e96cc0f25ee1eaed8ce9653b5c3d1d85b60c0
a919bf3ad2b6d518438997be02b0f630ab99aefb
/src/com/ibm/igf/resources/LocaleResources_en_GB.java
ae9fe3f980029be38bb6fafd6ac8a7842e5679e7
[]
no_license
DJBruteForce/ICNPluginExample
3dbcd4d794dcc10c7ecf2aed6d3219946be5ca80
6399079a174a33a99acffe830979c3a0d654e097
refs/heads/master
2020-05-23T13:42:47.732391
2018-08-09T20:20:50
2018-08-09T20:20:50
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,304
java
package com.ibm.igf.resources; /** * This type was created in VisualAge. */ public class LocaleResources_en_GB extends java.util.ListResourceBundle { static final Object[][] contents = { { "GUIDATEFORMAT", "dd/MM/yyyy" }, { "DefaultFrameTitle", "GIL/GB" }, { "COAOffLetter#Label", "Offering Letter Number" }, { "COACOAAmountLabel", "COA Amount" }, { "COACustNameLabel", "Customer Name" }, { "COACurrencyLabel", "Currency" }, { "COANumberLabel", "COA Number" }, { "COAOffLettValDateLabel", "Offering Letter Validity Date" }, { "COATitle", "Index COA" }, { "COASaveButtonLabel", "Save" }, { "COACancelButtonLabel", "Cancel" }, { "OLOffLetter#Label", "Offering Letter Number" }, { "OLAmountLabel", "Offering Letter Amount" }, { "OLCustNameLabel", "Customer Name" }, { "OLCurrencyLabel", "Currency" }, { "OLCustNumberLabel", "Customer Number" }, { "OLTitle", "Index Offering Letter" }, { "OLSaveButtonLabel", "Save" }, { "OLCancelButtonLabel", "Cancel" }, }; /** * LocaleResource_en_US constructor comment. */ public LocaleResources_en_GB() { super(); } /** * getContents method comment. */ protected java.lang.Object[][] getContents() { return contents; } }
6b1ebdbc11ad9654f7e4a1e15b19b0ed0728e385
9c8a96f69666fda2be4d11c8f2c0a40bb44c68e7
/src/main/java/com/binarySearch/BinaryNode.java
2cb294818fb6471d1a0dd5da823c280c8d9be4ca
[]
no_license
Prarthana-git/Binary-Search-Tree
15a777a3a3fcd6561622c8d83da1cfba28fabe5a
0f8292814fdf5c93962aaac32a8096788203395e
refs/heads/master
2023-06-05T06:09:50.286088
2021-06-10T16:12:25
2021-06-10T16:12:25
375,411,539
0
0
null
null
null
null
UTF-8
Java
false
false
912
java
package com.binarySearch; public class BinaryNode <T>{ T data; BinaryNode<T> left; BinaryNode<T> right; /** * this constructor initialize the data,left value and right value. * @param data */ public BinaryNode(T data) { this.data = data; this.left = null; this.right = null; } /** * this class have these getdata to get the values and setdata method to assign values. * @return */ public T getData() { return data; } public void setData(T data) { this.data = data; } public BinaryNode<T> getLeft() { return left; } public void setLeft(BinaryNode<T> left) { this.left = left; } public BinaryNode<T> getRight() { return right; } public void setRight(BinaryNode<T> right) { this.right =right; } }
966014bbaad65831ec7ccfc45ab26517b961be8b
a0db6dc2641e0ee5d44e25f4ba7a53ae151a59b6
/src/com/ulyssecarion/pdb/DistanceTablesBuilderTest.java
f4b2ec6098b5ccff66814944edb80af23ab94edd
[]
no_license
ucarion/PDBSandbox
3e8d7ce895608033d348434b508891d9701f85a6
a848c88d3c19852097f9a3d604a6095374a16d09
refs/heads/master
2016-09-05T13:49:31.592467
2013-06-24T23:54:31
2013-06-24T23:54:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,278
java
package com.ulyssecarion.pdb; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import org.biojava.bio.structure.Element; import org.junit.Test; public class DistanceTablesBuilderTest { @Test public void test4ACL() { Map<String, Long> result = DistanceTablesBuilder.buildTableFor("4ACL"); assertTrue(DistanceTablesBuilder.matches(result, Element.Au, Element.N, 4.0, 4.1)); assertTrue(DistanceTablesBuilder.matches(result, Element.Au, Element.C, 5.2, 5.3)); assertTrue(DistanceTablesBuilder.matches(result, Element.Au, Element.O, 7.0, 7.1)); } @Test public void testMatchesNonmetallicLigands() { Map<String, Long> result = DistanceTablesBuilder.buildTableFor("3TWY"); // the O is in a SO4 ligand assertTrue(DistanceTablesBuilder.matches(result, Element.O, Element.N, 2.0, 3.0)); } @Test public void testWorksWithLigandlessMolecules() { // let's test this on DNA that doesn't have any ligands assertEquals(DistanceTablesBuilder.buildTableFor("1T2K").keySet() .size(), 0); } @Test public void testCrOnFullPDB() { List<String> expected = new ArrayList<>(); expected.add("1HUZ"); expected.add("2Z68"); expected.add("1ZQE"); expected.add("9ICC"); expected.add("1LM2"); expected.add("1SM8"); expected.add("1J3F"); expected.add("1HUO"); expected.add("2A01"); Collections.sort(expected); List<String> crN = DistanceTablesBuilder.getMatchesInRange( DistanceTableSerializer.deserialize(Element.Cr, Element.N), 1.7, 8); Collections.sort(crN); assertEquals(expected, crN); } @Test public void testSpeedOnFullPDB() { // we really need this to work within under a second -- Na-N is probably // one of the queries that will get the most hits. long start = System.currentTimeMillis(); DistanceTablesBuilder.getMatchesInRange( DistanceTableSerializer.deserialize(Element.Na, Element.N), 1.7, 8); long stop = System.currentTimeMillis(); assertTrue(stop - start < 1000); } @Test public void test1J3F() { Map<String, Long> map = DistanceTablesBuilder.buildTableFor("1J3F"); // each of these are hits double[] hits = { 1.8, 6.8, 7.7 }; for (double hit : hits) { assertTrue(DistanceTablesBuilder.matches(map, Element.Cr, Element.O, hit, hit)); } // none of these are hits double[] misses = { 1.7, 3.0, 3.5, 4.0, 4.5, 5.0 }; for (double miss : misses) { assertFalse(DistanceTablesBuilder.matches(map, Element.Cr, Element.O, miss, miss)); } } @Test public void testTable() { List<String> ids = new ArrayList<>(); ids.add("4ACL"); ids.add("3QL0"); ids.add("3QL1"); List<String> results1 = new ArrayList<>(); results1.add("4ACL"); results1.add("3QL0"); Map<String, Map<String, Long>> table = DistanceTablesBuilder .buildTable(ids); assertEquals(results1, DistanceTablesBuilder.getMatchesInRange(table, Element.Na, Element.N, 1.7, 8.0)); List<String> results2 = new ArrayList<>(); results2.add("3QL0"); assertEquals(results2, DistanceTablesBuilder.getMatchesInRange(table, Element.Na, Element.N, 1.7, 4.6)); } }
1dd6eac0d227d1a344649205c93f78ccb6d9b305
c406a30c7353ba540e2e84b4337712df7e3ff121
/src/com/hypo/unionfind/LCS_124.java
fcbb308d9e4700d1e89ebd53bf0651fcfb9c18cb
[]
no_license
hypo123/LintCode
6676997bd626654c0e163ce2eb94137f259f331a
9f9c1bcc3956dde71cdbf74ec20dc2deea42345c
refs/heads/master
2021-01-15T15:31:03.011687
2018-04-23T12:39:57
2018-04-23T12:39:57
61,115,753
0
0
null
null
null
null
UTF-8
Java
false
false
1,365
java
package com.hypo.unionfind; import java.util.HashMap; /** * lintcode124 最长连续数列 [middle] * 给定一个未排序的整数数组,找出最长连续序列的长度 */ public class LCS_124 { private static int longestConsecutive(int[] num) { int result = 0; //<键值,连续序列长度> HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); for(int n : num) { if(!map.containsKey(n)) { //由连续序列的最左边和最右边记录当前连续序列的长度. int left = map.containsKey(n-1) ? map.get(n-1) : 0; int right = map.containsKey(n+1) ? map.get(n+1) : 0; //四种情况 //A. 左:234 右:678 插5 max=3+3+1 //B. 左:234 右: 插5 max=3+1 //C. 左: 右:678 插5 max=3+1 //D. 左: 右: 插5 max=1 int max = left + right + 1; map.put(n, max); result = Math.max(result, max); map.put(n - left, max); map.put(n + right , max); } } return result; } public static void main(String[] args) { // TODO Auto-generated method stub int[] num = {100, 4, 200, 1, 3, 2}; System.out.println(LCS_124.longestConsecutive(num)); } }
8c56131dc7ad31c9ac77c606d82ec0f4ecf71d76
ffc5a6c514d7c4c9ce36dd2de93974d16a15ca5f
/gen/com/skew/mws/BuildConfig.java
44f045626dd46572b0c25abe6b7da74d96f9d4cf
[]
no_license
SkewtechIndia-Android/MWS
3deb440542f6ec2b8a729ecb8b5164ee8ab22167
38a720ce44c7c55ce947388868578115aff8f301
refs/heads/master
2021-03-12T23:42:06.169943
2015-04-24T13:15:11
2015-04-24T13:15:11
34,518,175
0
0
null
null
null
null
UTF-8
Java
false
false
154
java
/** Automatically generated file. DO NOT MODIFY */ package com.skew.mws; public final class BuildConfig { public final static boolean DEBUG = true; }
f27527dda45bf842d89192cff1dbf27d4bc026ea
e92cda89f4a32f1e89d5862d0480d2e14c2d64ca
/teams/anatid19/Supply.java
7ab9e0ddf86f7c5fc963c5a9b7f987b90e8d59da
[]
no_license
TheDuck314/battlecode2015
e2d29e518137c563c265f854a27faba2c78c16cf
845e52bec1a7cb9f3f7f19a3415b5635d44a2fa6
refs/heads/master
2016-09-05T21:26:23.066985
2015-02-16T17:34:22
2015-02-16T17:34:22
28,834,784
14
5
null
null
null
null
UTF-8
Java
false
false
15,001
java
package anatid19; import battlecode.common.*; public class Supply extends Bot { public static void shareSupply() throws GameActionException { RobotInfo[] nearbyAllies = rc.senseNearbyRobots(GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED, us); double mySupply = rc.getSupplyLevel(); int myUpkeep = rc.getType().supplyUpkeep; double myTurnsOfSupplyLeft = mySupply / myUpkeep; if (myTurnsOfSupplyLeft < 4) return; // no sense spending bytecodes sharing if there's not much to share int resupplyDroneID = MessageBoard.RESUPPLY_DRONE_ID.readInt(); RobotInfo allyToSupply = null; double minTurnsOfSupplyLeft = myTurnsOfSupplyLeft; for (RobotInfo ally : nearbyAllies) { if (needsSupply(ally.type) && ally.ID != resupplyDroneID) { double allyTurnsOfSupplyLeft = ally.supplyLevel / ally.type.supplyUpkeep; if (allyTurnsOfSupplyLeft < minTurnsOfSupplyLeft) { minTurnsOfSupplyLeft = allyTurnsOfSupplyLeft; allyToSupply = ally; } } } if (allyToSupply != null) { double allySupply = allyToSupply.supplyLevel; int allyUpkeep = allyToSupply.type.supplyUpkeep; // we solve: (my supply - x) / (my upkeep) = (ally supply + x) / (ally upkeep) double transferAmount = (mySupply * allyUpkeep - allySupply * myUpkeep) / (myUpkeep + allyUpkeep); if (transferAmount > 20) { Debug.indicate("supply", 2, "transferring " + (int) transferAmount + " to " + allyToSupply.location.toString() + " to even things up"); rc.transferSupplies((int) transferAmount, allyToSupply.location); } } } // turn mod 3 = 0 -> bots compete to determine max supply need // turn mod 3 = 1 -> resupply drone(s) read max supply need // turn mod 3 = 2 -> resupply drone(s) reset max supply need comms channels static int numTurnsSupplyRequestUnfulfilled = 0; public static void requestResupplyIfNecessary() throws GameActionException { if (Clock.getRoundNum() % 3 == 0) return; // can only request supply on certain turns double travelTimeFromHQ = Math.sqrt(here.distanceSquaredTo(ourHQ)); // lookaheadTurns increases as our supply request remains unfulfilled, giving // us higher and higher priority over time double lookaheadTurns = 2.0 * travelTimeFromHQ; int mySupplyNeeded = (int) (lookaheadTurns * rc.getType().supplyUpkeep - rc.getSupplyLevel()); if (mySupplyNeeded <= 0) { numTurnsSupplyRequestUnfulfilled = 0; return; } else { numTurnsSupplyRequestUnfulfilled++; } int totalSupplyUpkeepNearby = rc.getType().supplyUpkeep; double totalSupplyNearby = rc.getSupplyLevel(); RobotInfo[] nearbyAllies = rc.senseNearbyRobots(GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED, us); for (RobotInfo ally : nearbyAllies) { totalSupplyUpkeepNearby += ally.type.supplyUpkeep; totalSupplyNearby += ally.supplyLevel; } int supplyRequestSize = (int) ((lookaheadTurns + numTurnsSupplyRequestUnfulfilled) * totalSupplyUpkeepNearby - totalSupplyNearby); Debug.indicate("supply", 0, " supplyUpkeepNearby = " + totalSupplyUpkeepNearby + "; supplyNearby = " + totalSupplyNearby); Debug.indicate("supply", 1, "supply requestSize: " + supplyRequestSize + "; turns unfulfilled = " + numTurnsSupplyRequestUnfulfilled); if (supplyRequestSize > MessageBoard.MAX_SUPPLY_NEEDED.readInt()) { MessageBoard.MAX_SUPPLY_NEEDED.writeInt(supplyRequestSize); MessageBoard.NEEDIEST_SUPPLY_LOC.writeMapLocation(here); } } static MapLocation supplyRunnerDest = null; static double supplyRunnerNeed = 0; static boolean onSupplyRun = true; static MapLocation supplyRunnerLastLoc = null; static int supplyRunnerTurnsSinceMove = 0; public static void runSupplies() throws GameActionException { MessageBoard.RESUPPLY_DRONE_ID.writeInt(rc.getID()); if (here.equals(supplyRunnerLastLoc)) { supplyRunnerTurnsSinceMove++; if (supplyRunnerTurnsSinceMove >= 50 && here.distanceSquaredTo(ourHQ) > GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED) { System.out.println("supply runner disintegrating"); rc.disintegrate(); } } else { supplyRunnerTurnsSinceMove = 0; } supplyRunnerLastLoc = here; // read supply needs if (Clock.getRoundNum() % 3 == 1) { supplyRunnerNeed = MessageBoard.MAX_SUPPLY_NEEDED.readInt(); if (supplyRunnerNeed > 0) { supplyRunnerDest = MessageBoard.NEEDIEST_SUPPLY_LOC.readMapLocation(); Debug.indicate("supply", 0, "max supply needed = " + supplyRunnerNeed + " at " + supplyRunnerDest.toString()); } else { supplyRunnerDest = null; Debug.indicate("supply", 0, "no supply need"); } } // reset supply need comms channels if (Clock.getRoundNum() % 3 == 2) { MessageBoard.MAX_SUPPLY_NEEDED.writeInt(0); } if (supplyRunnerDest != null && here.distanceSquaredTo(supplyRunnerDest) < 35) { if (supplyRunnerTransferSupplyAtDest()) { onSupplyRun = false; // supplies have been dropped off; return to HQ } } else { // try helping out whoever we encounter on the way to the main destination supplyRunnerTryOpportunisticTransferSupply(); } if (onSupplyRun) { // call off a supply run if the need vanishes or if we run out of spare supply if (supplyRunnerNeed == 0 || supplyRunnerSpareSupplyAmount() <= 0) { onSupplyRun = false; } } else { // start a supply run when there is need and we have enough supply to fulfill it if (supplyRunnerNeed > 0) { double supplyNeededForRun = supplyRunnerNeed + RobotType.DRONE.supplyUpkeep * Math.sqrt(ourHQ.distanceSquaredTo(supplyRunnerDest)); if (rc.getSupplyLevel() > supplyNeededForRun) { onSupplyRun = true; } else { rc.setIndicatorLine(here, supplyRunnerDest, 255, 0, 0); } } } MapLocation[] enemyTowers = rc.senseEnemyTowerLocations(); RobotInfo[] nearbyEnemies = rc.senseNearbyRobots(35, them); if(supplyRunnerRetreatIfNecessary(nearbyEnemies, enemyTowers)) return; NavSafetyPolicy safetyPolicy = new SafetyPolicyAvoidAllUnits(enemyTowers, nearbyEnemies); if (onSupplyRun) { NewNav.goTo(supplyRunnerDest, safetyPolicy); Debug.indicate("supply", 2, "going to supply dest"); rc.setIndicatorLine(here, supplyRunnerDest, 0, 255, 0); } else { NewNav.goTo(ourHQ, safetyPolicy); Debug.indicate("supply", 2, "returning to HQ"); } } private static boolean supplyRunnerTransferSupplyAtDest() throws GameActionException { int transferAmount = (int) supplyRunnerSpareSupplyAmount(); if (transferAmount <= 0) return true; // we didn't succeed but we are out of supply so it's like we succeeded RobotInfo[] nearbyAllies = rc.senseNearbyRobots(GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED, us); double minSupply = 1e99; RobotInfo allyToSupply = null; for (RobotInfo ally : nearbyAllies) { if (needsSupply(ally.type)) { if (ally.supplyLevel < minSupply) { minSupply = ally.supplyLevel; allyToSupply = ally; } } } if (allyToSupply != null) { Debug.indicate("supply", 1, "dropping off " + transferAmount + " supplies at destination"); rc.transferSupplies(transferAmount, allyToSupply.location); return true; } else { return false; } } // We're not at our main supply destination, but we give people we encounter // on the way however much they need. However we don't give them all of our // supply because we are saving it for the main destination. private static void supplyRunnerTryOpportunisticTransferSupply() throws GameActionException { RobotInfo[] nearbyAllies = rc.senseNearbyRobots(GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED, us); double travelTimeFromHQ = Math.sqrt(here.distanceSquaredTo(ourHQ)); double transferAmount = 0; RobotInfo transferTarget = null; for (RobotInfo ally : nearbyAllies) { if (needsSupply(ally.type)) { double supplyNeed = 2 * travelTimeFromHQ * ally.type.supplyUpkeep - ally.supplyLevel; if (supplyNeed > transferAmount) { transferAmount = supplyNeed; transferTarget = ally; } } } if (transferTarget != null) { transferAmount = Math.min(transferAmount, supplyRunnerSpareSupplyAmount()); if (transferAmount > 1) { Debug.indicate("supply", 1, "opportunistically transferring " + transferAmount + " to " + transferTarget.location); rc.transferSupplies((int) transferAmount, transferTarget.location); } } } private static double supplyRunnerSpareSupplyAmount() { return rc.getSupplyLevel() - 2 * RobotType.DRONE.supplyUpkeep * Math.sqrt(here.distanceSquaredTo(ourHQ)); } private static boolean needsSupply(RobotType rt) { return !rt.isBuilding && rt != RobotType.BEAVER && rt != RobotType.MISSILE; } private static boolean needToRetreat(RobotInfo[] nearbyEnemies) { for (RobotInfo enemy : nearbyEnemies) { switch (enemy.type) { case MISSILE: if (here.distanceSquaredTo(enemy.location) <= 15) return true; break; case LAUNCHER: if (here.distanceSquaredTo(enemy.location) <= 24) return true; break; default: if (enemy.type.attackRadiusSquared >= here.distanceSquaredTo(enemy.location)) return true; break; } } return false; } private static boolean supplyRunnerRetreatIfNecessary(RobotInfo[] nearbyEnemies, MapLocation[] enemyTowers) throws GameActionException { if(!needToRetreat(nearbyEnemies)) return false; Direction bestRetreatDir = null; RobotInfo currentClosestEnemy = Util.closest(nearbyEnemies, here); boolean mustMoveOrthogonally = false; if (rc.getCoreDelay() >= 0.6 && currentClosestEnemy.type == RobotType.MISSILE) mustMoveOrthogonally = true; int bestDistSq = here.distanceSquaredTo(currentClosestEnemy.location); for (Direction dir : Direction.values()) { if (!rc.canMove(dir)) continue; if (mustMoveOrthogonally && dir.isDiagonal()) continue; MapLocation retreatLoc = here.add(dir); if (inEnemyTowerOrHQRange(retreatLoc, enemyTowers)) continue; RobotInfo closestEnemy = Util.closest(nearbyEnemies, retreatLoc); int distSq = retreatLoc.distanceSquaredTo(closestEnemy.location); if (distSq > bestDistSq) { bestDistSq = distSq; bestRetreatDir = dir; } } if (bestRetreatDir != null) { rc.move(bestRetreatDir); return true; } return false; } static double hqLastSupply = 0; static double hqSupplyReservedForResupplyDrone = 0; static final double HQ_SUPPLY_DRONE_RESERVE_RATIO = 0.5; static final double HQ_SUPPLY_TURN_BUILDUP_LIMIT = 100.0; public static void hqGiveSupply() throws GameActionException { // reserve a fraction of the supply just generated for the resupply drone hqSupplyReservedForResupplyDrone += HQ_SUPPLY_DRONE_RESERVE_RATIO * BotHQ.totalSupplyGenerated; // need to make sure vast amounts of supply don't build up unused if only the supply drone is visiting the HQ. // so every turn a fraction of the unreserved supply is reserved for the drone hqSupplyReservedForResupplyDrone += (rc.getSupplyLevel() - hqSupplyReservedForResupplyDrone) / HQ_SUPPLY_TURN_BUILDUP_LIMIT; Debug.indicate("supply", 0, "supply reserved for drone = " + hqSupplyReservedForResupplyDrone); // feed the resupply drone if it's around int resupplyDroneID = MessageBoard.RESUPPLY_DRONE_ID.readInt(); if (rc.canSenseRobot(resupplyDroneID)) { MapLocation resupplyDroneLoc = rc.senseRobot(resupplyDroneID).location; if (ourHQ.distanceSquaredTo(resupplyDroneLoc) <= GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED) { Debug.indicate("supply", 1, "transferring " + hqSupplyReservedForResupplyDrone + " to resupply drone"); rc.transferSupplies((int) hqSupplyReservedForResupplyDrone, resupplyDroneLoc); hqSupplyReservedForResupplyDrone = 0; } } // feed nearby robots whatever supply is not reserved for the resupply drone RobotInfo[] nearbyAllies = rc.senseNearbyRobots(GameConstants.SUPPLY_TRANSFER_RADIUS_SQUARED, us); double minTurnsOfSupplyLeft = 1e99; RobotInfo allyToSupply = null; for (RobotInfo ally : nearbyAllies) { if (needsSupply(ally.type) && ally.ID != resupplyDroneID) { double allyTurnsOfSupplyLeft = ally.supplyLevel / ally.type.supplyUpkeep; if (allyTurnsOfSupplyLeft < minTurnsOfSupplyLeft) { minTurnsOfSupplyLeft = allyTurnsOfSupplyLeft; allyToSupply = ally; } } } if (allyToSupply != null) { int transferAmount = (int) (rc.getSupplyLevel() - hqSupplyReservedForResupplyDrone); if (transferAmount > 0) { Debug.indicate("supply", 2, "transferring " + transferAmount + " to " + allyToSupply.location.toString()); rc.transferSupplies(transferAmount, allyToSupply.location); } } else { Debug.indicate("supply", 0, "no non-drone to supply :("); } } }
e87ce71a0b9c8b9295dd2d754b7448df3e6105b0
b15a75a5587d48df62b889305825e6e5acb30ec5
/src/main/java/com/gcit/training/spring/lms/dao/genre/GenreDAO.java
03cbe40e67e4047afecabcd760ee618ecfd99b95
[]
no_license
serret887/GCITMVC
661d5aa27feabd44c1640011f87bede8a62fbf01
e342985a340d6cf1b676db95dfeb4af1747fa717
refs/heads/master
2021-01-10T04:56:32.300458
2016-03-14T19:41:06
2016-03-14T19:41:06
52,397,218
0
0
null
2020-06-08T18:30:48
2016-02-23T22:45:54
Java
UTF-8
Java
false
false
3,814
java
package com.gcit.training.spring.lms.dao.genre; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.PreparedStatementCreator; import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.support.GeneratedKeyHolder; import org.springframework.jdbc.support.KeyHolder; import com.gcit.training.spring.lms.dao.BaseDAO; import com.gcit.training.spring.lms.dao.DAO; import com.gcit.training.spring.lms.entity.Author; import com.gcit.training.spring.lms.entity.Genre; public class GenreDAO extends BaseDAO<Genre> implements DAO<Genre> { private static final String SELECT_BY_ID = "select * from tbl_genre where genre_id = ? "; private static final String UPDATE = "update tbl_genre set genre_name = ? where genre_id = ? "; private static final String DELETE = "delete from tbl_genre where genre_id = ? "; private static final String INSERT = "insert into tbl_genre (genre_name) values (?) "; private static final String SELECT = "select * from tbl_genre"; private static final String SELECT_BY_NAME = "select * from tbl_genre where genre_name like ? "; @Autowired private ExtractFirstDataGenre extractFirstData; @Autowired private ExtractFullDataGenre extractFullData; @Override public List<Genre> readAll(int pageNo) { return template.query(SELECT, extractFullData); } @Override public List<Genre> readFirstLevel(int pageNo) { return template.query(SELECT, extractFirstData); } @Override public int add(Genre item) { final String genreName = item.getGenreName(); KeyHolder keyHolder = new GeneratedKeyHolder(); template.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement(INSERT, new String[] { "id" }); ps.setString(1, genreName); return ps; } }, keyHolder); return keyHolder.getKey().intValue(); } @Override public Genre getById(int id) { List<Genre> genre = template.query(SELECT_BY_ID, new Object[] { id }, extractFirstData); if (genre.isEmpty()) return null; return genre.get(0); } @Override public List<Genre> searchByName(String searchString, int pageNo) { return template.query(SELECT_BY_NAME, new Object[] { searchString }, extractFirstData); } @Override public void delete(Genre item) { template.update(DELETE, new Object[] { item.getGenreId() }); } @Override public void update(Genre item) { template.update(UPDATE, new Object[] { item.getGenreName(), item.getGenreId() }); } // @Override // public List<Genre> extractData(ResultSet rs) { // List<Genre> genres = new ArrayList<Genre>(); // BookDAO adao = new BookDAO(conn); // try { // while(rs.next()){ // Genre genre = new Genre(); // genre.setGenreName(rs.getString("genre_name")); // genre.setGenreId(rs.getInt("genre_id")); // genre.setBooks(adao.readFirstLevel("select * from tbl_book where bookId // IN (select bookId from tbl_book_genres where genre_id = ?)",new // Object[]{genre.getGenreId()})); // genres.add(genre); // } // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // return genres; // } // // @Override // public List<Genre> extractDataFirstLevel(ResultSet rs) { // List<Genre> genres = new ArrayList<Genre>(); // try { // while (rs.next()) { // Genre genre = new Genre(); // genre.setGenreName(rs.getString("genre_name")); // genre.setGenreId(rs.getInt("genre_id")); // genres.add(genre); // } // } catch (SQLException e) { // // // TODO Auto-generated catch block // e.printStackTrace(); // } // return genres; // } }
3c82f9a2741fecedd576767d0b50fcb2ce3dd50b
2a8f7b524944ff248952329303bfdbff2c55bafa
/app/src/main/java/com/bluewave/nfcgame/net/UserClient.java
d8592ab944fd4f8e15f5319c7e8c8e58b3145128
[]
no_license
ColaGom/NfcGame
2ff1c9ca0ce80177d5d94876579bcc0c73c790cb
132d67858f87c6b0cef30fb77907754b9211430b
refs/heads/master
2021-01-17T20:57:13.811906
2016-06-21T08:59:08
2016-06-21T08:59:08
61,116,219
0
0
null
null
null
null
UTF-8
Java
false
false
2,316
java
package com.bluewave.nfcgame.net; import android.os.Handler; import android.util.Log; import com.android.volley.Response; import com.android.volley.VolleyError; import com.bluewave.nfcgame.model.User; import com.google.gson.Gson; import com.navercorp.volleyextensions.volleyer.Volleyer; import org.json.JSONException; import org.json.JSONObject; import cn.pedant.SweetAlert.SweetAlertDialog; /** * Created by Developer on 2016-06-17. */ public class UserClient extends Client { private final static String TAG = "UserClient"; private final static String URL = "http://shindnjswn.cafe24.com/api/user.php"; private final static String TAG_LOGIN = "login"; public static void login(String nickname, final Handler handler, final SweetAlertDialog dialog) { dialog.setTitleText("로그인..."); dialog.show(); Volleyer.volleyer().post(URL) .addStringPart(NAME_TAG, TAG_LOGIN) .addStringPart("nickname", nickname) .withListener(new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d(TAG, TAG_LOGIN + " response : " + response); dialog.dismiss(); try { JSONObject jsonObject = new JSONObject(response); if(jsonObject.getBoolean("error")){ handler.onFail(); }else{ User user = new Gson().fromJson(jsonObject.getString("user"), User.class); handler.onSuccess(user); } } catch (JSONException e) { e.printStackTrace(); handler.onFail(); } } }) .withErrorListener(new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { dialog.dismiss(); handler.onFail(); Log.d(TAG, TAG_LOGIN + " error"); } }) .execute(); } }
732f5bfe8f8b1c5065583547006573ca109de9ff
139960e2d7d55e71c15e6a63acb6609e142a2ace
/mobile_app1/module116/src/main/java/module116packageJava0/Foo508.java
e33339f29b16d24ee5367a411b4e9d148aca5394
[ "Apache-2.0" ]
permissive
uber-common/android-build-eval
448bfe141b6911ad8a99268378c75217d431766f
7723bfd0b9b1056892cef1fef02314b435b086f2
refs/heads/master
2023-02-18T22:25:15.121902
2023-02-06T19:35:34
2023-02-06T19:35:34
294,831,672
83
7
Apache-2.0
2021-09-24T08:55:30
2020-09-11T23:27:37
Java
UTF-8
Java
false
false
946
java
package module116packageJava0; import java.lang.Integer; public class Foo508 { Integer int0; Integer int1; Integer int2; public void foo0() { new module116packageJava0.Foo507().foo18(); } public void foo1() { foo0(); } public void foo2() { foo1(); } public void foo3() { foo2(); } public void foo4() { foo3(); } public void foo5() { foo4(); } public void foo6() { foo5(); } public void foo7() { foo6(); } public void foo8() { foo7(); } public void foo9() { foo8(); } public void foo10() { foo9(); } public void foo11() { foo10(); } public void foo12() { foo11(); } public void foo13() { foo12(); } public void foo14() { foo13(); } public void foo15() { foo14(); } public void foo16() { foo15(); } public void foo17() { foo16(); } public void foo18() { foo17(); } }
6599d3e2c96c2f1dc8290571603dfe60c59b65df
e59ccd9e58239f3fea1dd376cf7dc44b32768f44
/java-web/src/main/java/step11/Servlet07.java
865be2d1360e59c79c5ec39b21aff2037c380647
[]
no_license
zerox7066/bitcamp
9cdb962478ce5d6f406fecfe6aae1db9cd2575b1
3759bf5c9b2c4d7ffa2cf37196e26e12478ccbe2
refs/heads/master
2021-09-03T14:04:30.247015
2018-01-09T15:35:15
2018-01-09T15:35:15
104,423,465
0
0
null
null
null
null
UTF-8
Java
false
false
988
java
// 쿠키(cookie) package step11; import java.io.IOException; import java.io.PrintWriter; import java.net.URLEncoder; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @SuppressWarnings("serial") @WebServlet("/step11/Servlet07") public class Servlet07 extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //res.addCookie(new Cookie("이름", "hong")); res.addCookie(new Cookie("name", URLEncoder.encode("ABC123홍길동", "UTF-8"))); res.setContentType("text/plain;charset=UTF-8"); PrintWriter out = res.getWriter(); out.println("쿠키를 보냈음!"); } }
54cb3b80e69b14912ca3232279d4bf1eb8a16e31
f216bd447c660a824383ed9e0112d3068fe37f2b
/WebBackend/app/api/json/models/GenericSuccessModel.java
0bb354b6c62672f1ce9b09dfacedb565866e753f
[]
no_license
chriskdon/FlockProto
014d2ebeab02b64bf0220488a1d5c15f67f23f91
239814c68ddebe511c38c68aee2295d6616cadc0
refs/heads/master
2021-01-22T12:29:01.961445
2014-11-10T13:07:49
2014-11-10T13:07:49
13,990,390
0
1
null
null
null
null
UTF-8
Java
false
false
704
java
package api.json.models; /** * Created by chriskellendonk on 11/14/2013. */ public class GenericSuccessModel extends JsonModelBase { public String message; /** * Error response without message */ public GenericSuccessModel() { this(null); } /** * Error response with message. * * @param message Message to send. */ public GenericSuccessModel(String message) { this.message = message; } @Override public String toJsonString() { try { return mapper.writeValueAsString(this); } catch (Exception ex) { return "{\"status\":" + STATUS_OKAY + ",\"message\":null}"; } } }
cfbd8476c16f085703faa5f48228dd0709964506
e1ea18df1b3ab585cdb73c1eb180640de265ab1a
/src/main/java/com/github/rodionovsasha/commentservice/services/CommentService.java
6d2ba5889fcb9dbc76f117cd9d02848b8b6c5f2f
[ "MIT" ]
permissive
rodionovsasha/CommentService
435821b990958fff10519e4b283d6c21674708d0
9bb37233390837b27423257a4d85c94715443d01
refs/heads/master
2021-01-23T09:25:44.354187
2018-05-31T11:31:30
2018-05-31T11:31:30
102,579,938
1
0
MIT
2018-05-31T11:31:31
2017-09-06T07:54:31
Groovy
UTF-8
Java
false
false
395
java
package com.github.rodionovsasha.commentservice.services; import com.github.rodionovsasha.commentservice.entities.Comment; import java.util.List; public interface CommentService { Comment add(String content, int topicId, int userId); void update(int commentId, int userId, String content); void archive(int commentId, int userId); List<Comment> findByTopic(int topicId); }
d6b95d655758fd7cc8d3c17da3e499e2210d7308
bebb61cefbaa79978329427d24b485da5161a41c
/String rotation/Main.java
45537db4f82606f870d468be8995f6269c500007
[]
no_license
hari284/Playground
45c5cc29d38ad168027bc20a5c4a942868f1cd82
8afccdb470fc82e6dd2271b7fe656bd9319c744f
refs/heads/master
2020-04-23T16:56:12.220391
2019-07-20T21:00:31
2019-07-20T21:00:31
171,315,070
0
0
null
null
null
null
UTF-8
Java
false
false
588
java
#include<stdio.h> #include <string.h> int Rotation_check(char *st1, char *st2) {int j; int rotation; char temp[20]; for(int i=strlen(st1)-1;i>=0;i--) { if(st2[i] == st1[0]) { rotation = i; break; } } for(int index = 0; index < strlen(st1); index++) { j = (index + rotation) % strlen(st1); temp[j] = st1[index]; } if(strcmp(temp,st2) == 0) printf("Yes"); else printf("No"); //Type your code here } int main() { char st1[20], st2[20]; scanf("%s\n",st1); scanf("%s\n",st2); Rotation_check(st1, st2); return 0; }
a0d8d6d1134362b8632c25417cf07d5a381f722e
b0c915c455942644dbd7db6046fddb2f85258f6a
/src/cn/med/controller/MedicineController.java
024d51e777e855970704422d4f7ab4274ecb9edb
[]
no_license
yueweiran/NuclearMedicine
ff5e1daf18d1c56382e2997eab9aeeefae0fd793
293cb24dee3e9743267e98fbd5a8b5b6f4a23bfd
refs/heads/master
2020-11-27T04:15:39.797312
2019-12-21T02:14:28
2019-12-21T02:14:28
229,300,315
0
0
null
null
null
null
UTF-8
Java
false
false
7,819
java
package cn.med.controller; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.UUID; import javax.servlet.http.HttpServletRequest; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import cn.med.common.ResponseResult; import cn.med.common.SysUtils; import cn.med.common.SystemTimeTypeTimestamp; import cn.med.common.TimeChange; import cn.med.entity.Medicine; import cn.med.service.MedicineService; @Controller @ResponseBody public class MedicineController { @Autowired private MedicineService medicineService; /** * 查询全部药品集合 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/select/medicineList/medicine", method = RequestMethod.GET) public ResponseResult medicineeList(HttpServletRequest request) throws Exception{ ResponseResult result = null; try { List<Medicine> medicine = medicineService.selectAllMedicine(); if (medicine != null){ result = new ResponseResult(); result.setCode(1); result.setMsg("查询成功"); result.setData(medicine); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("查询失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("查询失败"); } return result; } /** * 查询单个药品 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/select/medicine/medicineId", method = RequestMethod.GET) public ResponseResult medicineOne(@Param("mId")int mId,HttpServletRequest request) throws Exception{ ResponseResult result = null; try { Medicine medicine = medicineService.selectByPrimaryKey(mId); if (medicine != null){ result = new ResponseResult(); result.setCode(1); result.setMsg("查询成功"); result.setData(medicine); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("查询失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("查询失败"); } return result; } /** * 查询单个药品根据药品名 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/select/medicine/medName", method = RequestMethod.POST) public ResponseResult selectBymedName(@Param("medName")String medName,HttpServletRequest request) throws Exception{ String medName2 = medName+"%"; ResponseResult result = null; try { List<Medicine> medicine = medicineService.selectBymedName(medName2); if (medicine != null){ result = new ResponseResult(); result.setCode(1); result.setMsg("查询成功"); result.setData(medicine); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("查询失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("查询失败"); } return result; } /** * 删除多个 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/delete/medicine/medicines", method = RequestMethod.POST) public ResponseResult deleteByAll(@RequestParam(value = "datas[]") int[] datas,HttpServletRequest request) throws Exception{ ResponseResult result = null; try { int numb = medicineService.deleteByAll(datas); if (numb == 1){ result = new ResponseResult(); result.setCode(1); result.setMsg("删除成功"); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("删除失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("删除失败"); } return result; } /** * 删除单个药品 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/delete/medicine/medicineId", method = RequestMethod.POST) public ResponseResult deleteByPrimaryKey(@Param("mId")int mId,HttpServletRequest request) throws Exception{ ResponseResult result = null; try { int numb = medicineService.deleteByPrimaryKey(mId); if (numb == 1){ result = new ResponseResult(); result.setCode(1); result.setMsg("删除成功"); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("删除失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("删除失败"); } return result; } /** * 插入单个药品 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/insert/medicine/medicine", method = RequestMethod.POST) public ResponseResult insert(@Param("medName")String medName,HttpServletRequest request) throws Exception{ TimeChange timeChange = new TimeChange(); SystemTimeTypeTimestamp sttt = new SystemTimeTypeTimestamp(); System.out.println(sttt.getSystemTimeTypeTimestap()); Medicine medicine = new Medicine(medName,sttt.getSystemTimeTypeTimestap()); ResponseResult result = null; try { int numb = medicineService.insert(medicine); if (numb == 1){ String proNum_Str = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); Long proNum = null; if(proNum_Str!=null){ proNum = Long.parseLong(proNum_Str.toString().trim()); } result = new ResponseResult(); result.setCode(1); result.setMsg("插入成功"); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("插入失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("插入失败"); } return result; } /** * 修改单个药品 * @return * @throws Exception * Writer : xz */ @RequestMapping(value = "/update/medicine/medicine", method = RequestMethod.POST) public ResponseResult updateByPrimaryKey(@Param("mId")Integer mId, @Param("medName")String medName,HttpServletRequest request) throws Exception{ TimeChange timeChange = new TimeChange(); SystemTimeTypeTimestamp sttt = new SystemTimeTypeTimestamp(); System.out.println(sttt.getSystemTimeTypeTimestap()); Medicine medicine = new Medicine(mId,medName); ResponseResult result = null; try { int numb = medicineService.updateByPrimaryKey(medicine); if (numb == 1){ result = new ResponseResult(); result.setCode(1); result.setMsg("修改成功"); return result; } else { result = new ResponseResult(); result.setCode(2); result.setMsg("修改失败"); return result; } } catch (Exception e) { e.printStackTrace(); // 返回结果 result = new ResponseResult(); result.setCode(3); result.setMsg("修改失败"); } return result; } }
6c9b9aada1b56279a19c9e34d25f8bd70a0a4675
a0873fd7d98262e86e29c2279da42a8899bf7582
/Junit&TestNG/src/com/wbl/testng/TestHomePage4.java
a6dad043b9a726d773e3d24aa0aa2a964cfcf6e6
[]
no_license
medhawbl/JanClassCode
ce50a21993b892d3942b0fe42b88749c1277a88b
ee4c53ae6766bd2da09d90de9b723344601b4d39
refs/heads/master
2021-01-20T17:02:53.714373
2017-05-27T00:06:18
2017-05-27T00:06:18
83,361,613
0
5
null
null
null
null
UTF-8
Java
false
false
696
java
package com.wbl.testng; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.wbl.main.HomePage; public class TestHomePage4 { HomePage hp; @BeforeClass(alwaysRun=true) public void beforeClass(){ hp = new HomePage(); } @Test(priority=0) public void testLogin(){ Assert.assertEquals("success",hp.login()); } @Test(priority=1) public void testRecordings(){ Assert.assertEquals("playing",hp.recordings()); } @Test(priority=2) public void testPresentation(){ Assert.assertEquals(10,hp.presentations()); } @Test(priority=3) public void testLogout(){ Assert.assertEquals("logout",hp.logout()); } }
573dc30cd07b6c005b6f2765de852c751e535bdd
40711484fbf4fafc57414f8baa26f3b326bd0ae1
/netty-sample/src/main/java/com/my/netty/chapter2/EchoServer.java
ad12085eda34d223da81bd94e1b9c5c301bb6ca2
[]
no_license
rkzhang/netty-sample
454cd8f46a95c0ebd57bf265a035f561c6ada303
6310ce723113691bb90f69d9721d249e80891114
refs/heads/master
2021-01-01T19:39:55.016135
2017-08-04T06:19:28
2017-08-04T06:19:28
98,637,917
0
0
null
null
null
null
UTF-8
Java
false
false
2,267
java
package com.my.netty.chapter2; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.timeout.IdleStateEvent; import io.netty.handler.timeout.IdleStateHandler; import io.netty.util.CharsetUtil; public class EchoServer { private final int port; public EchoServer(int port) { this.port = port; } public static void main(String[] args) throws Exception{ new EchoServer(8080).start(); } public void start() throws Exception { final EchoServerHandler serverHandler = new EchoServerHandler(); EventLoopGroup group = new NioEventLoopGroup(); //创建EventLoopGroup try { ServerBootstrap b = new ServerBootstrap(); b.group(group) .channel(NioServerSocketChannel.class) //指定所使用的NIO传输Channel .localAddress(new InetSocketAddress(port)) //指定所使用的套接字地址 .childHandler(new ChannelInitializer<SocketChannel>() { //添加一个EchoServerHandler到子Channel的ChannelPipeline @Override protected void initChannel(SocketChannel ch) throws Exception { //EchoServerHandler被标注为@Shareable,所以我们总是使用同样的实例 ch.pipeline().addLast(serverHandler); //使用一个EchoServerHandler的实例初始化每一个新的Channel; } }); ChannelFuture f = b.bind().sync(); //异步地绑定服务器,调用sync()方法阻塞等待直到绑定完成 System.out.println("应用服务启动..."); f.channel().closeFuture().sync(); //获取Channel的CloseFuture,并且阻塞当前线程直到它完成 System.out.println("应用服务关闭..."); } finally { group.shutdownGracefully().sync(); System.out.println("资源回收..."); } } }
c476e9f3b5862797b6664432ed6f075ae4fc2a9f
c91878eb6e81a3cc11e94712875fd770b0defe45
/src/main/java/ua/kh/baklanov/web/command/service/TypesTVCommand.java
67abc695d245b40c236513eaa0935894dda732d8
[]
no_license
bezcontrol/heroku
dac1b8b77999ac801d1eb4f008f0475aa72a3925
10fac548c095c7ebd90e2d2d5fc7105eec527e76
refs/heads/master
2022-07-01T23:53:40.404023
2020-03-17T16:54:52
2020-03-17T16:54:52
248,021,799
0
0
null
2022-06-21T03:00:34
2020-03-17T16:40:47
JavaScript
UTF-8
Java
false
false
1,141
java
package ua.kh.baklanov.web.command.service; import org.apache.log4j.Logger; import ua.kh.baklanov.Route; import ua.kh.baklanov.db.dao.TVDAO; import ua.kh.baklanov.exception.DbException; import ua.kh.baklanov.exception.Messages; import ua.kh.baklanov.service.DAOService; import ua.kh.baklanov.service.DefaultService; import ua.kh.baklanov.web.command.Command; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; public class TypesTVCommand extends Command { private static final Logger LOG = Logger.getLogger(TypesTVCommand.class); @Override public String execute(HttpServletRequest request, HttpServletResponse response) { List<String> tvTypes; DAOService service = new DefaultService(); try { TVDAO tvDAO = service.getTVDao(); tvTypes=tvDAO.getTypes(); } catch (DbException e) { LOG.error(Messages.ERROR_TV_DAO + TypesTVCommand.class.getName(), e); return Route.PAGE_ERROR_PAGE; } request.setAttribute("tvTypes", tvTypes); return Route.TV_SERVICE; } }
c8e7b94e56d81175c94ebdd8c49e536d16db351a
604bd0bfed9f7b1c11d1abe9e9b1cd3a6965ff72
/trumobiconnect2.3_updated/src/com/cognizant/trumobi/commonabstractclass/TruMobiBaseSherlockActivity.java
27ad365f48c5fec6b152c41b52fe07eae8d7dcec
[ "Apache-2.0" ]
permissive
tank2014gz/test
fea33331112a991a9bee7ea7b0227dfd3cc0a4d6
22e5ab217256220bbab0b1acd29e96b749744bbe
refs/heads/master
2021-01-14T10:49:23.339521
2014-01-07T13:05:55
2014-01-07T13:05:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,928
java
package com.cognizant.trumobi.commonabstractclass; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; import android.view.KeyEvent; import android.view.MotionEvent; import com.TruBoxSDK.SharedPreferences; import com.actionbarsherlock.app.SherlockActivity; import com.cognizant.trumobi.log.PersonaLog; /** * * KEYCODE AUTHOR PURPOSE * PIN_SCREEN_ISSUE 367712 PIN Screen Issue on Email Notification * */ public class TruMobiBaseSherlockActivity extends SherlockActivity{ public LocalBroadcastManager mLocalBcMgr; public static boolean bkillActivity = false; public static Context context; private static String TAG = TruMobiBaseSherlockActivity.class.getName(); @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); context = this; mLocalBcMgr = LocalBroadcastManager.getInstance(this); TruMobiTimerClass.userInteractedTrigger(); new SharedPreferences(this).edit() .putBoolean("appinBG", false).commit(); // PIN_SCREEN_ISSUE } // PIN_SCREEN_ISSUE, Added --> @Override protected void onUserLeaveHint() { // TODO Auto-generated method stub super.onUserLeaveHint(); new SharedPreferences(this).edit() .putBoolean("appinBG", true).commit(); // PIN_SCREEN_ISSUE } // PIN_SCREEN_ISSUE, <-- @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); // mLocalBcMgr.unregisterReceiver(mMessageReceiver); // TruMobiTimerClass.userInteractedStopTimer(); //PIM_TIMER_CHG } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); new SharedPreferences(this).edit() .putBoolean("appinBG", false).commit(); // PIN_SCREEN_ISSUE //DATA_WIPE_CHG if(bkillActivity){ PersonaLog.d(TAG,"=== PersonaLauncer - TruMobiBaseActivity finish ==="); finish(); } else if(requirePinScreenOnResume()) { PersonaLog.d(TAG,"=== - TruMobiBaseActivity launch main activity ==="); TruMobiTimerClass.launchMainActivity(context); } else { PersonaLog.d(TAG,"=== - TruMobiBaseActivity Register for broadcast ==="); mLocalBcMgr.registerReceiver(mMessageReceiver, new IntentFilter("KILL_ACT")); if(TruMobiTimerClass.scheduledExecutorService == null ||TruMobiTimerClass.scheduledExecutorService.isShutdown() || TruMobiTimerClass.scheduledExecutorService.isTerminated()) { TruMobiTimerClass.startTimerTrigger(context); } } vulnarability(); // mLocalBcMgr.registerReceiver(mMessageReceiver, new IntentFilter("KILL_ACT")); // if(TruMobiTimerClass.scheduledExecutorService == null ||TruMobiTimerClass.scheduledExecutorService.isShutdown() || TruMobiTimerClass.scheduledExecutorService.isTerminated()) // { // TruMobiTimerClass.startTimerTrigger(context); // } // vulnarability(); // if(bkillActivity) // finish(); // else { // if(requirePinScreenOnResume()) { // TruMobiTimerClass.launchMainActivity(); // } // } } private boolean requirePinScreenOnResume() { boolean requirePinScreen = new SharedPreferences(this).getBoolean( "showPinOnResume", false); return requirePinScreen; } private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { PersonaLog.d(TAG, "in onReceive "+ TAG); bkillActivity = true; TruMobiBaseActivity.bkillActivity = true; // PIM_REQ_CHG finish(); } }; @Override public boolean dispatchTouchEvent(final MotionEvent ev) { final int action = ev.getAction(); if (action == MotionEvent.ACTION_DOWN) {} TruMobiTimerClass.userInteractedTrigger(); return super.dispatchTouchEvent(ev); } @Override public boolean dispatchKeyEvent(final KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {} if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {} TruMobiTimerClass.userInteractedTrigger(); return super.dispatchKeyEvent(event); } @Override public boolean dispatchTrackballEvent(final MotionEvent ev) { TruMobiTimerClass.userInteractedTrigger(); return super.dispatchTrackballEvent(ev); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); mLocalBcMgr.unregisterReceiver(mMessageReceiver); //TruMobiTimerClass.userInteractedTrigger(); } public void vulnarability(){ boolean bvul = false; //check condition based on value from truboxsdk if(bvul) { finish(); } } // IME_KEYPAD_TIMER_FIX : Added this method to handle Timer value during Keypad show. @Override public void onUserInteraction() { // TODO Auto-generated method stub super.onUserInteraction(); TruMobiTimerClass.userInteractedTrigger(); } }
30455dd2cd3debbdf9d45cf223e95925eacc9d85
5501066bfb3a9088648cc40db39f252ea923cf4f
/shopping/src/main/java/com/shopping/entity/Drugs.java
6897392d4e9d7a6d5e6ed61ed82b4366db542126
[]
no_license
KIM-JS-95/FreeNote
50cfcce15472373df9e715f2ca2ced475baba9b7
6beb1337c8c81e1c6e0eb6ecba1d36146de80251
refs/heads/master
2023-06-28T06:53:42.429271
2021-07-27T13:16:51
2021-07-27T13:16:51
340,592,604
0
0
null
null
null
null
UTF-8
Java
false
false
351
java
package com.shopping.entity; import lombok.*; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity @AllArgsConstructor @NoArgsConstructor @Getter @Setter @Builder public class Drugs { @Id @GeneratedValue private Long id; private String name; private String image; }
62da1ce7173849ff954f41d5b38cd9da544a167a
0786708b5b8aaf5b9348a994a1383f19d65e5d3e
/fr.ut2j.m1ice.fsm.edit/src-gen/fr/ut2j/m1ice/fsm/provider/FsmItemProviderAdapterFactory.java
2dfa403e53890b54be638ff5c5307a5d892615ad
[]
no_license
fxbeckert/DSL
ec68480d5d097ab6984a6707e2bb31f442436398
ffd29df16d95cb8feb52e4a1829415debf6520af
refs/heads/master
2021-01-02T17:39:37.671760
2020-02-11T13:47:42
2020-02-11T13:47:42
239,726,061
0
0
null
null
null
null
UTF-8
Java
false
false
8,221
java
/** */ package fr.ut2j.m1ice.fsm.provider; import fr.ut2j.m1ice.fsm.util.FsmAdapterFactory; import java.util.ArrayList; import java.util.Collection; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.edit.provider.ChangeNotifier; import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; import org.eclipse.emf.edit.provider.ComposedAdapterFactory; import org.eclipse.emf.edit.provider.IChangeNotifier; import org.eclipse.emf.edit.provider.IDisposable; import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; import org.eclipse.emf.edit.provider.IItemLabelProvider; import org.eclipse.emf.edit.provider.IItemPropertySource; import org.eclipse.emf.edit.provider.INotifyChangedListener; import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; import org.eclipse.emf.edit.provider.ITreeItemContentProvider; /** * This is the factory that is used to provide the interfaces needed to support Viewers. * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. * The adapters also support Eclipse property sheets. * Note that most of the adapters are shared among multiple instances. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public class FsmItemProviderAdapterFactory extends FsmAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { /** * This keeps track of the root adapter factory that delegates to this adapter factory. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ComposedAdapterFactory parentAdapterFactory; /** * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected IChangeNotifier changeNotifier = new ChangeNotifier(); /** * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<Object> supportedTypes = new ArrayList<Object>(); /** * This constructs an instance. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public FsmItemProviderAdapterFactory() { supportedTypes.add(IEditingDomainItemProvider.class); supportedTypes.add(IStructuredItemContentProvider.class); supportedTypes.add(ITreeItemContentProvider.class); supportedTypes.add(IItemLabelProvider.class); supportedTypes.add(IItemPropertySource.class); } /** * This keeps track of the one adapter used for all {@link fr.ut2j.m1ice.fsm.State} instances. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected StateItemProvider stateItemProvider; /** * This creates an adapter for a {@link fr.ut2j.m1ice.fsm.State}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Adapter createStateAdapter() { if (stateItemProvider == null) { stateItemProvider = new StateItemProvider(this); } return stateItemProvider; } /** * This keeps track of the one adapter used for all {@link fr.ut2j.m1ice.fsm.Transition} instances. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected TransitionItemProvider transitionItemProvider; /** * This creates an adapter for a {@link fr.ut2j.m1ice.fsm.Transition}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Adapter createTransitionAdapter() { if (transitionItemProvider == null) { transitionItemProvider = new TransitionItemProvider(this); } return transitionItemProvider; } /** * This keeps track of the one adapter used for all {@link fr.ut2j.m1ice.fsm.FSM} instances. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected FSMItemProvider fsmItemProvider; /** * This creates an adapter for a {@link fr.ut2j.m1ice.fsm.FSM}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Adapter createFSMAdapter() { if (fsmItemProvider == null) { fsmItemProvider = new FSMItemProvider(this); } return fsmItemProvider; } /** * This keeps track of the one adapter used for all {@link fr.ut2j.m1ice.fsm.Final} instances. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected FinalItemProvider finalItemProvider; /** * This creates an adapter for a {@link fr.ut2j.m1ice.fsm.Final}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Adapter createFinalAdapter() { if (finalItemProvider == null) { finalItemProvider = new FinalItemProvider(this); } return finalItemProvider; } /** * This keeps track of the one adapter used for all {@link fr.ut2j.m1ice.fsm.Initial} instances. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected InitialItemProvider initialItemProvider; /** * This creates an adapter for a {@link fr.ut2j.m1ice.fsm.Initial}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Adapter createInitialAdapter() { if (initialItemProvider == null) { initialItemProvider = new InitialItemProvider(this); } return initialItemProvider; } /** * This returns the root adapter factory that contains this factory. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public ComposeableAdapterFactory getRootAdapterFactory() { return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); } /** * This sets the composed adapter factory that contains this factory. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { this.parentAdapterFactory = parentAdapterFactory; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean isFactoryForType(Object type) { return supportedTypes.contains(type) || super.isFactoryForType(type); } /** * This implementation substitutes the factory itself as the key for the adapter. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Adapter adapt(Notifier notifier, Object type) { return super.adapt(notifier, this); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object adapt(Object object, Object type) { if (isFactoryForType(type)) { Object adapter = super.adapt(object, type); if (!(type instanceof Class<?>) || (((Class<?>) type).isInstance(adapter))) { return adapter; } } return null; } /** * This adds a listener. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void addListener(INotifyChangedListener notifyChangedListener) { changeNotifier.addListener(notifyChangedListener); } /** * This removes a listener. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void removeListener(INotifyChangedListener notifyChangedListener) { changeNotifier.removeListener(notifyChangedListener); } /** * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void fireNotifyChanged(Notification notification) { changeNotifier.fireNotifyChanged(notification); if (parentAdapterFactory != null) { parentAdapterFactory.fireNotifyChanged(notification); } } /** * This disposes all of the item providers created by this factory. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void dispose() { if (stateItemProvider != null) stateItemProvider.dispose(); if (transitionItemProvider != null) transitionItemProvider.dispose(); if (fsmItemProvider != null) fsmItemProvider.dispose(); if (finalItemProvider != null) finalItemProvider.dispose(); if (initialItemProvider != null) initialItemProvider.dispose(); } }
6991f274904d63b7b3e9ae5bd26b4a30b0e7793f
30e7af9411300fd4282dfc27c6a2ec901bbb6b1e
/src/main/java/com/gameword/user/security/dto/FunctionDto.java
714e45f11d069e4b37ecc33b2843166d2a82033a
[]
no_license
bjmajiancheng/gameword-user-service
9e95752f6bd6a5336c1f239625ba5f729898b844
c9c63eadfc09794d160ac3be12e0abe3759fcc69
refs/heads/master
2022-12-21T22:19:08.572283
2020-08-05T13:37:41
2020-08-05T13:37:41
246,044,278
1
0
null
2022-12-16T11:36:33
2020-03-09T13:34:08
Java
UTF-8
Java
false
false
1,806
java
package com.gameword.user.security.dto; import java.io.Serializable; import java.util.Date; /** * Created by majiancheng on 2019/9/16. */ public class FunctionDto implements Serializable { private static final long serialVersionUID = 5026705051341318200L; private Integer id; private Integer parentId; private String functionName; private Integer display; private Integer status; private String action; private String icon; private Integer sort; private Date ctime; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getParentId() { return parentId; } public void setParentId(Integer parentId) { this.parentId = parentId; } public String getFunctionName() { return functionName; } public void setFunctionName(String functionName) { this.functionName = functionName; } public Integer getDisplay() { return display; } public void setDisplay(Integer display) { this.display = display; } public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public Integer getSort() { return sort; } public void setSort(Integer sort) { this.sort = sort; } public Date getCtime() { return ctime; } public void setCtime(Date ctime) { this.ctime = ctime; } }
f7b43fc5e3cc1fa38d5fd3e2e6a9c6a9a59f3a6b
6ab4eaff0e1bc6043221b770f5e0b417c809ae77
/src/main/java/ourpoolstats/api/coin/GetListMarketPersonalPrepare.java
201ed5af6cbdedb8daf7cab3e7998b522ee3fc50
[]
no_license
albertopaletta90/ourpoolstats
97efad0567331dea046bdd5a79949a37b14f5435
01b02ac2fc5b61f64721dc9652c0b8c0847241f2
refs/heads/OPSMGR
2022-12-30T22:07:09.600406
2019-05-23T22:49:12
2019-05-23T22:49:12
161,920,671
0
0
null
2022-12-16T09:42:52
2018-12-15T15:58:46
Java
UTF-8
Java
false
false
1,064
java
package ourpoolstats.api.coin; import java.util.List; import org.springframework.http.ResponseEntity; import ourpoolstats.commonOperation.CommonOperationCoin; import ourpoolstats.model.Balance; import ourpoolstats.response.BalanceResponse; import ourpoolstats.response.status.BalanceResponseStatus; import ourpoolstats.type.LogOperation; public class GetListMarketPersonalPrepare { private CommonOperationCoin commonOperationCoin; public ResponseEntity<BalanceResponse> getListMarket(String username) { this.commonOperationCoin = new CommonOperationCoin(); BalanceResponse balanceResponse = new BalanceResponse(); try { List<Balance>listMarket = commonOperationCoin.getListCoinUser(username); return new BalanceResponseStatus().success(username, balanceResponse,LogOperation.GETLISTMARKETPERSONAL, listMarket); } catch (Exception e) { List<Balance>listMarket = commonOperationCoin.getListCoinUser(username); return new BalanceResponseStatus().notFound(balanceResponse, username, LogOperation.GETLISTMARKETPERSONAL,listMarket); } } }
bc5fb96f7538ad0492e1d790751ca7d5f4bf0a6c
4733f0a44af0a40ba85ed8ceb0fabbcab26795fe
/app/src/main/java/com/dxtdkwt/zzh/appframework/ui/activity/ViewActivity.java
41bcd9e09981cffbe646e82277d0fd37225d983a
[]
no_license
TonyFai/AppFrameWork
13742617e23ed44bab905b91a1b63f34117553e8
908446d3b75255cafa61cd6e126278a5c9af09c6
refs/heads/master
2021-07-20T11:00:20.982088
2020-07-07T08:00:12
2020-07-07T08:00:12
191,485,072
0
0
null
null
null
null
UTF-8
Java
false
false
671
java
package com.dxtdkwt.zzh.appframework.ui.activity; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.Scroller; import com.dxtdkwt.zzh.appframework.R; public class ViewActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_activity); // Scroller } @Override public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } }
33f0be38bef804c885f406a7a51628134791f57e
bf232ce57489b3b41a933970c56cf049305d5770
/src/main/java/com/wht/admin/demo/test/ABCThread.java
fdaa3d09ff34133a35873504b4b1eb5caedf30ab
[]
no_license
OceanWht/adminwht001
55cf85042a286bd410338a7a416bc9a206351c29
ca7affef4b44cdb409511b7b2e1ea91c40d438fb
refs/heads/master
2020-04-29T07:19:58.374318
2019-03-16T10:55:29
2019-03-16T10:55:29
175,949,092
0
0
null
null
null
null
UTF-8
Java
false
false
5,635
java
package com.wht.admin.demo.test; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class ABCThread { private static int cond = 1; private static Lock lock = new ReentrantLock();//jdk1.5 同步锁 锁来保证线程的访问的互斥 private static Condition condition = lock.newCondition(); public static void main(String[] args) { Runnable ra = new Runnable() { @Override public void run() { lock.lock(); try { while (true) { if (cond % 3 == 1) { System.out.print("A"); cond++; condition.signalAll(); break; } else { try { condition.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } finally { lock.unlock(); } } }; Runnable rb = new Runnable() { @Override public void run() { lock.lock(); try { while (true) { if (cond % 3 == 2) { System.out.print("B"); cond++; condition.signalAll(); break; } else { try { condition.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } finally { lock.unlock(); } } }; Runnable rc = new Runnable() { @Override public void run() { lock.lock(); try { while (true) { if (cond % 3 == 0) { System.out.print("C"); cond++; condition.signalAll(); break; } else { try { condition.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } finally { lock.unlock(); } } }; /* ThreadA ta = abcThread.new ThreadA(); ThreadB tb = abcThread.new ThreadB(); ThreadC tc = abcThread.new ThreadC();*/ ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 10; i++) { executorService.execute(ra); executorService.execute(rb); executorService.execute(rc); } executorService.shutdown();// 关闭线程池 } /*class ThreadA implements Runnable { @Override public void run() { lock.lock();//获得锁 try { while (true) { if (cond % 3 == 1) { System.out.print("A"); cond++; condition.signalAll(); break; } else { try { condition.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } finally { lock.unlock(); } } } class ThreadB implements Runnable { @Override public void run() { lock.lock();//获得锁 try { while (true) { if (cond % 3 == 2) { System.out.print("B"); cond++; condition.signalAll(); break; } else { try { condition.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } finally { lock.unlock(); } } } class ThreadC implements Runnable { @Override public void run() { lock.lock();//获得锁 try { while (true) { if (cond % 3 == 0) { System.out.print("C"); cond++; condition.signalAll(); break; } else { try { condition.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } finally { lock.unlock(); } } }*/ }
dc3de16ed6155ce44f1985e978184a4584bad92c
286e12844efb07d361bff2b5d905bbcf1e26f245
/liaozl-netty/src/main/java/com/liaozl/netty/bio/TimeServerHandler.java
bc13305d1ba7865fbd9f1dcadf04b205e62e878a
[]
no_license
liaozuliang/liaozl-app
aeeb638addcd34f9e39e46539927fc0989818d90
41dc0395e54da2ecc2c931e36094e4f8a5ee235d
refs/heads/master
2020-06-26T04:31:00.081849
2017-10-13T08:10:01
2017-10-13T08:10:01
74,546,768
0
0
null
null
null
null
UTF-8
Java
false
false
2,131
java
package com.liaozl.netty.bio; import com.liaozl.netty.executor.TimeServerHandlerExecutePool; import com.liaozl.netty.util.SocketUtil; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.Date; /** * @author liaozuliang * @date 2016-12-06 */ public class TimeServerHandler implements Runnable { private ServerSocket serverSocket; private Socket socket; private TimeServerHandlerExecutePool pool; public TimeServerHandler(ServerSocket serverSocket, Socket socket) { this.serverSocket = serverSocket; this.socket = socket; } public TimeServerHandler(ServerSocket serverSocket, Socket socket, TimeServerHandlerExecutePool pool) { this.serverSocket = serverSocket; this.socket = socket; this.pool = pool; } @Override public void run() { BufferedReader in = null; PrintWriter out = null; try { in = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); out = new PrintWriter(this.socket.getOutputStream(), true); String currentTime = null; String body = null; while (true) { body = in.readLine(); if (body == null) { System.out.println("close connection"); break; } if ("CLOSE SERVER".equals(body)) { if (pool != null) { TimeServerHandlerExecutePool.close(pool); } SocketUtil.closeServer(serverSocket); break; } System.out.println("The time server receive order: " + body); currentTime = "QUERY TIME ORDER".equals(body) ? (new Date().toLocaleString()) : "BAD ORDER"; out.println(currentTime); } } catch (Exception e) { e.printStackTrace(); } finally { SocketUtil.close(socket, in, out); } } }
fb77246ed0c27b133f1fb499967be301ae1ebd11
3f62bf02fd89c23fd57ad62d6ac77772ff4faa85
/src/main/java/fun/StackQueueGUI.java
475d58b72b02fd55a73dbfefd5540704648dc4b7
[]
no_license
jborden3/Cosc210
983e975b4d5232eff40887ba679ed22cdc8bbcf1
d286b1cdd1d145dace13b12e88b05e30734e6a91
refs/heads/master
2020-07-14T21:50:55.008487
2019-12-13T02:04:45
2019-12-13T02:04:45
205,410,732
0
0
null
null
null
null
UTF-8
Java
false
false
20,541
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package fun; import edu.samford.jonathanborden.stacksandqueues.ListQueue; import edu.samford.jonathanborden.stacksandqueues.ListStack; import edu.samford.jonathanborden.stacksandqueues.Queue; import edu.samford.jonathanborden.stacksandqueues.Stack; import javax.swing.DefaultListModel; import javax.swing.JList; /** * * @author borde */ public class StackQueueGUI extends javax.swing.JFrame { protected Stack<String> theStack = new ListStack<>(); protected Queue<String> theQueue = new ListQueue<>(); /** * Creates new form StackQueueGUI */ public StackQueueGUI() { initComponents(); jLabelData.setText(""); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jButton4 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jListStack = new javax.swing.JList<>(); jScrollPane2 = new javax.swing.JScrollPane(); jListQueue = new javax.swing.JList<>(); jTextNewItem = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButtonPush = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jButtonEnqueue = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); jLabel4 = new javax.swing.JLabel(); jLabelData = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jButtonPop = new javax.swing.JButton(); jButtonTop = new javax.swing.JButton(); jButtonDequeue = new javax.swing.JButton(); jButtonFront = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jButton4.setText("jButton4"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jScrollPane1.setViewportView(jListStack); jScrollPane2.setViewportView(jListQueue); jTextNewItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextNewItemActionPerformed(evt); } }); jLabel1.setText("New Data Item:"); jLabel2.setText("Stack:"); jButtonPush.setText("Push"); jButtonPush.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonPushActionPerformed(evt); } }); jLabel3.setText("Queue:"); jButtonEnqueue.setText("Enqueue"); jButtonEnqueue.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonEnqueueActionPerformed(evt); } }); jLabel4.setText("Retrieved Data:"); jLabelData.setFont(new java.awt.Font("Tahoma", 1, 22)); // NOI18N jLabelData.setText("RETRIEVED DATA"); jLabel6.setText("Stack:"); jLabel7.setText("Queue:"); jButtonPop.setText("Pop"); jButtonPop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonPopActionPerformed(evt); } }); jButtonTop.setText("Top"); jButtonTop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonTopActionPerformed(evt); } }); jButtonDequeue.setText("Dequeue"); jButtonDequeue.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonDequeueActionPerformed(evt); } }); jButtonFront.setText("Front"); jButtonFront.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonFrontActionPerformed(evt); } }); jLabel8.setText("TOP"); jLabel9.setText("REAR"); jLabel10.setText("FRONT"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(jLabel3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonEnqueue) .addComponent(jTextNewItem, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonPush))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(41, 41, 41) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel6) .addComponent(jLabel4) .addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabelData) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonDequeue) .addComponent(jButtonPop)) .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonTop) .addComponent(jButtonFront))))) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(80, 80, 80) .addComponent(jLabel8) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel9) .addGap(112, 112, 112)))))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(jLabel10) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 623, javax.swing.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel9)) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextNewItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(4, 4, 4) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jButtonPush)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonEnqueue) .addComponent(jLabel3)) .addGap(33, 33, 33) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(jLabelData)) .addGap(7, 7, 7) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(jButtonPop) .addComponent(jButtonTop)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(jLabel7)) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButtonDequeue) .addComponent(jButtonFront)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jTextNewItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextNewItemActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextNewItemActionPerformed private void jButtonPushActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPushActionPerformed // TODO add your handling code here: theStack.push(jTextNewItem.getText()); jButtonPop.setEnabled(true); jButtonTop.setEnabled(true); displayStack(); jTextNewItem.requestFocus(); jTextNewItem.selectAll(); }//GEN-LAST:event_jButtonPushActionPerformed private void jButtonEnqueueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEnqueueActionPerformed // TODO add your handling code here: theQueue.enqueue(jTextNewItem.getText()); jButtonDequeue.setEnabled(true); jButtonFront.setEnabled(true); displayQueue(); }//GEN-LAST:event_jButtonEnqueueActionPerformed private void jButtonDequeueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDequeueActionPerformed // TODO add your handling code here: if (!theQueue.isEmpty()) { String item = theQueue.dequeue(); jLabelData.setText(item); } else { jLabelData.setText("The queue is empty!"); } if (theQueue.isEmpty()) { jButtonDequeue.setEnabled(false); jButtonFront.setEnabled(false); } displayQueue(); }//GEN-LAST:event_jButtonDequeueActionPerformed private void jButtonPopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPopActionPerformed // TODO add your handling code here: if (!theStack.isEmpty()) { String item = theStack.pop(); jLabelData.setText(item); } else { jLabelData.setText("The stack is empty!"); } if (theStack.isEmpty()) { jButtonPop.setEnabled(false); jButtonTop.setEnabled(false); } displayStack(); }//GEN-LAST:event_jButtonPopActionPerformed private void jButtonTopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTopActionPerformed // TODO add your handling code here: if (!theStack.isEmpty()) { String item = theStack.top(); jLabelData.setText(item); } else { jLabelData.setText("The stack is empty!"); } }//GEN-LAST:event_jButtonTopActionPerformed private void jButtonFrontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFrontActionPerformed // TODO add your handling code here: if (!theQueue.isEmpty()) { String item = theQueue.dequeue(); jLabelData.setText(item); } else { jLabelData.setText("The queue is empty!"); } if (theQueue.isEmpty()) { jButtonDequeue.setEnabled(false); jButtonFront.setEnabled(false); } displayQueue(); }//GEN-LAST:event_jButtonFrontActionPerformed private void displayQueue() { // string representation of the current queue contents String theQueueStr = theQueue.toString(); // chop pff the square brackets theQueueStr = theQueueStr.substring(1, theQueueStr.length() - 1); System.out.println(theQueueStr); DefaultListModel demoList = new DefaultListModel(); demoList.addElement(theQueueStr); jListQueue.setModel(demoList); } private void displayStack() { // string representation of the current stack contents String theStackStr = theStack.toString(); // chop pff the square brackets theStackStr = theStackStr.substring(1, theStackStr.length() - 1); // split the string up into individual items using commas String stackitems[] = theStackStr.split(","); DefaultListModel demoList = new DefaultListModel(); for (int i = stackitems.length-1; i >=0; i--) { String stackitem = stackitems[i]; demoList.addElement(stackitem); } jListStack.setModel(demoList); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(StackQueueGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(StackQueueGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(StackQueueGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(StackQueueGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new StackQueueGUI().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton4; private javax.swing.JButton jButtonDequeue; private javax.swing.JButton jButtonEnqueue; private javax.swing.JButton jButtonFront; private javax.swing.JButton jButtonPop; private javax.swing.JButton jButtonPush; private javax.swing.JButton jButtonTop; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JLabel jLabelData; private javax.swing.JList<String> jListQueue; private javax.swing.JList<String> jListStack; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JSeparator jSeparator1; private javax.swing.JTextField jTextNewItem; // End of variables declaration//GEN-END:variables }
1848597e5f337f9453a444b23d6a60b58dfdeef0
485f271606482431aa22f43ba923956c60ff6d86
/app/src/main/java/com/example/androidpractice/easycloud/DropletsAdapter.java
d7ac008f869ae409c7592a925085eca3233cfc02
[]
no_license
anujsp/Easy-Cloud
fdc74f0ee4663df84bd27c5ec57980c256607380
203a632a44b5b70936c1b1cc0b711347bc813852
refs/heads/master
2021-01-20T22:20:25.857788
2016-07-06T21:06:18
2016-07-06T21:06:18
62,753,155
0
0
null
null
null
null
UTF-8
Java
false
false
3,248
java
package com.example.androidpractice.easycloud; import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import java.util.List; /** * Created by anuj on 6/4/2016. */ public class DropletsAdapter extends RecyclerView.Adapter<DropletsAdapter.MyViewHolder> { private List<DropletModel> dropletList; private Context context; public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title, region; public ImageView image; public MyViewHolder(View view) { super(view); title = (TextView) view.findViewById(R.id.title); region = (TextView) view.findViewById(R.id.region); image = (ImageView) view.findViewById(R.id.imageview); title.setOnClickListener(this); region.setOnClickListener(this); image.setOnClickListener(this); } @Override public void onClick(View v) { Context context = itemView.getContext(); Intent intent = new Intent(context, DetailActivity.class); intent.putExtra("title", String.valueOf(dropletList.get(getAdapterPosition()).getTitle())); intent.putExtra("region", String.valueOf(dropletList.get(getAdapterPosition()).getRegion())); context.startActivity(intent); } } public DropletsAdapter(Context context,List<DropletModel> dropletList) { this.context = context; this.dropletList = dropletList; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.droplet_list_row, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(MyViewHolder holder, int position) { DropletModel dropletDescription = dropletList.get(position); String[] changeRegionValue = dropletDescription.getRegion().split("/"); String res = ""; for (int i =1;i< changeRegionValue.length-4;i++){ if(i != changeRegionValue.length-5){ res = res+ changeRegionValue[i]+"/"; } else{ res = res + changeRegionValue[i]; } } Log.v(" RESULT", res); holder.title.setText(dropletDescription.getTitle()); holder.region.setText(res); //holder.region.setText(dropletDescription.getRegion()); Picasso.with(context).load(dropletList.get(position).getImage()).resize(100,100).into(holder.image); } @Override public int getItemCount() { return dropletList.size(); } }
a5198cc77851063cfb1f04d46551c41453db7acf
e1273b1da9530e9a64124f335ae312092bf37be5
/src/main/java/com/yc/threadcoreknowledge/stopThread/RightWayStopThreadWithoutSleep.java
092a3709cf09a3eafac73ff2a8b27ca26b127e56
[]
no_license
Fenderon/JAVA_Concurrent
b8c6e4cfffc7e3c9496cb1656bb73f6040648fc3
c0ff9803881d8c8d88f214a56e4470caa02b002d
refs/heads/master
2020-12-13T18:44:48.633553
2020-02-27T09:53:26
2020-02-27T09:53:26
234,498,307
0
0
null
null
null
null
UTF-8
Java
false
false
863
java
package com.yc.threadcoreknowledge.stopThread; /** * run 方法内没有sleep或者wait方式时,停止线程 * * @version 1.0 create at 2020/1/18 * @auther yangchuan */ public class RightWayStopThreadWithoutSleep implements Runnable { public static void main(String[] args) throws InterruptedException { Thread thread = new Thread(new RightWayStopThreadWithoutSleep()); thread.start(); Thread.sleep(2000); thread.interrupt(); } @Override public void run() { int num = 0; //如果没有中断 while (!Thread.currentThread().isInterrupted() && num <= Integer.MAX_VALUE / 2) { if (num % 10000 == 0) { System.out.println(num + "是10000的倍数"); } num++; } System.out.println("运行结束了"); } }
81483c8a51ff4914205c747bdc735b0a3dc34cd0
11210ea4b2dc8083d9504ace8964f6d0e2ded524
/src/dreamschool/csourse/chapter05/MultipleFiveSumTest.java
4524b5145c4b2798fb1c72571da8dc4841e32065
[]
no_license
minesaves/dreamschool_java_camp
aac2c419e39b35105fb1b146b3563e61b67b8320
5f27dcfbc171d00a0f968648e661f004124b3fe0
refs/heads/master
2020-05-19T10:58:31.548838
2019-05-09T11:59:34
2019-05-09T11:59:34
184,980,856
0
0
null
null
null
null
UTF-8
Java
false
false
325
java
package dreamschool.csourse.chapter05; public class MultipleFiveSumTest { public static void main(String[] args) { int count = 1; int sum = 0; while(sum < 100) { int mulFive = count * 5; sum += mulFive; System.out.println(count +". ( + " + mulFive +" ) " + sum); count++; } } }
[ "학생44@user-pc" ]
학생44@user-pc
1080a5f0c8a04a068e5a94994aadfbbf59b2a86d
3308fd04d790adfc27cc713ea627b89d47fd2488
/app/src/main/java/com/numberx/kkmctimer/widget/ActionableToastBar.java
32752559460328c49fa6c9ce8bf180d286f0221e
[ "Apache-2.0" ]
permissive
KhonKaenMakerClub/KKMC-IoT
332b271b6ae2ad93d85bd30b47e64b7b4ed22aa8
2f03bb64d4311e3e5ba2996611bd3bc1430aaef8
refs/heads/master
2020-11-23T21:14:16.757462
2016-08-17T14:12:18
2016-08-17T14:12:18
65,912,668
0
1
null
null
null
null
UTF-8
Java
false
false
8,695
java
/* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.numberx.kkmctimer.widget; import android.animation.Animator; import android.animation.AnimatorInflater; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.numberx.kkmctimer.R; /** * A custom {@link View} that exposes an action to the user. * <p> * This is a copy of packages/apps/UnifiedEmail/src/com/android/mail/ui/ActionableToastBar.java * with minor modifications. */ public class ActionableToastBar extends LinearLayout { private boolean mHidden = false; private Animator mShowAnimation; private Animator mHideAnimation; private final int mBottomMarginSizeInConversation; /** Icon for the description. */ private ImageView mActionDescriptionIcon; /** The clickable view */ private View mActionButton; /** Icon for the action button. */ private View mActionIcon; /** The view that contains the description. */ private TextView mActionDescriptionView; /** The view that contains the text for the action button. */ private TextView mActionText; //private ToastBarOperation mOperation; public ActionableToastBar(Context context) { this(context, null); } public ActionableToastBar(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ActionableToastBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mBottomMarginSizeInConversation = context.getResources().getDimensionPixelSize( R.dimen.toast_bar_bottom_margin_in_conversation); LayoutInflater.from(context).inflate(R.layout.actionable_toast_row, this, true); } @Override protected void onFinishInflate() { super.onFinishInflate(); mActionDescriptionIcon = (ImageView) findViewById(R.id.description_icon); mActionDescriptionView = (TextView) findViewById(R.id.description_text); mActionButton = findViewById(R.id.action_button); mActionIcon = findViewById(R.id.action_icon); mActionText = (TextView) findViewById(R.id.action_text); } /** * Tells the view that it will be appearing in the conversation pane * and should adjust its layout parameters accordingly. * @param isInConversationMode true if the view will be shown in the conversation view */ public void setConversationMode(boolean isInConversationMode) { final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) getLayoutParams(); params.bottomMargin = isInConversationMode ? mBottomMarginSizeInConversation : 0; setLayoutParams(params); } /** * Displays the toast bar and makes it visible. Allows the setting of * parameters to customize the display. * @param listener performs some action when the action button is clicked * @param descriptionIconResourceId resource ID for the description icon or * 0 if no icon should be shown * @param descriptionText a description text to show in the toast bar * @param showActionIcon if true, the action button icon should be shown * @param actionTextResource resource ID for the text to show in the action button * @param replaceVisibleToast if true, this toast should replace any currently visible toast. * Otherwise, skip showing this toast. */ public void show(final ActionClickedListener listener, int descriptionIconResourceId, CharSequence descriptionText, boolean showActionIcon, int actionTextResource, boolean replaceVisibleToast) { if (!mHidden && !replaceVisibleToast) { return; } mActionButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View widget) { if (listener != null) { listener.onActionClicked(); } hide(true); } }); // Set description icon. if (descriptionIconResourceId == 0) { mActionDescriptionIcon.setVisibility(GONE); } else { mActionDescriptionIcon.setVisibility(VISIBLE); mActionDescriptionIcon.setImageResource(descriptionIconResourceId); } mActionDescriptionView.setText(descriptionText); mActionIcon.setVisibility(showActionIcon ? VISIBLE : GONE); mActionText.setText(actionTextResource); mHidden = false; getShowAnimation().start(); } /** * Hides the view and resets the state. */ public void hide(boolean animate) { // Prevent multiple call to hide. // Also prevent hiding if show animation is going on. if (!mHidden && !getShowAnimation().isRunning()) { mHidden = true; if (getVisibility() == View.VISIBLE) { mActionDescriptionView.setText(""); mActionButton.setOnClickListener(null); // Hide view once it's clicked. if (animate) { getHideAnimation().start(); } else { setAlpha(0); setVisibility(View.GONE); } } } } private Animator getShowAnimation() { if (mShowAnimation == null) { mShowAnimation = AnimatorInflater.loadAnimator(getContext(), R.animator.fade_in); mShowAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { // There is a tiny change that and hide animation could have finished right // before the show animation finished. In that case, the hide will mark the // view as GONE. We need to make sure the last one wins. setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); mShowAnimation.setTarget(this); } return mShowAnimation; } private Animator getHideAnimation() { if (mHideAnimation == null) { mHideAnimation = AnimatorInflater.loadAnimator(getContext(), R.animator.fade_out); mHideAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animation) { } }); mHideAnimation.setTarget(this); } return mHideAnimation; } public boolean isEventInToastBar(MotionEvent event) { if (!isShown()) { return false; } int[] xy = new int[2]; float x = event.getX(); float y = event.getY(); getLocationOnScreen(xy); return (x > xy[0] && x < (xy[0] + getWidth()) && y > xy[1] && y < xy[1] + getHeight()); } /** * Classes that wish to perform some action when the action button is clicked * should implement this interface. */ public interface ActionClickedListener { public void onActionClicked(); } }
59ec335983cc98f3ac39cd067aac8e452fa4085f
ee95a27329bd4103ebc51e05e218ac96fe61aa5b
/Malcolm test/ChatServer/src/ChatServer.java
b6240fc7ca2bad4168f35ea053caadcbf390e7aa
[]
no_license
ChadHolness/client_sever
264ed14a9f6d5612c9f5f22cb1b665bcbaee84dc
0ca3a88e0609ab7188deadedaf935293cdba2e87
refs/heads/master
2021-01-10T18:16:32.691681
2016-04-15T20:05:54
2016-04-15T20:05:54
53,999,799
0
0
null
null
null
null
UTF-8
Java
false
false
1,549
java
/*chat*/ import java.io.*; import java.net.*; import java.util.*; public class ChatServer { ArrayList clientOutputStreams; public class ClientHandler implements Runnable { BufferedReader reader; Socket sock; public ClientHandler(Socket clientSocket) { try { sock = clientSocket; InputStreamReader isReader = new InputStreamReader(sock.getInputStream()); reader = new BufferedReader(isReader); } catch(Exception x) { } } public void run() { String message; try { while((message = reader.readLine()) != null) { System.out.println("read" + message); tellEveryone(message); } } catch(Exception x) { } } } public void go() { clientOutputStreams = new ArrayList(); try { ServerSocket serverSock = new ServerSocket(5000); while(true) { Socket clientSocket = serverSock.accept(); PrintWriter writer = new PrintWriter(clientSocket.getOutputStream()); clientOutputStreams.add(writer); Thread t = new Thread(new ClientHandler(clientSocket)); t.start(); System.out.println("got a connection"); } } catch(Exception x) { } } public void tellEveryone(String message) { Iterator it = clientOutputStreams.iterator(); while(it.hasNext()) { try { PrintWriter writer = (PrintWriter) it.next(); writer.println(message); writer.flush(); } catch(Exception x) { } } } public static void main(String[] args) { new ChatServer().go(); } }
b6300ac82b5d6fdbfe207c5f09acc3b23e4576ff
cc20492a1ec20c4591f7e53fd7827fdcbc11bd5e
/src/org/review/connections/ArrayTest.java
82a330feb8c3c6085abbf3bac71ce04e52b0d272
[]
no_license
RickUniverse/JavaBaseReview
51d42861836a9555d16e02c824859607f3dab084
b5f7ebad25eee84b9f2d48e222688bb7e7bc8471
refs/heads/master
2023-02-08T14:37:58.000647
2020-12-29T14:01:16
2020-12-29T14:01:16
325,299,763
0
0
null
null
null
null
UTF-8
Java
false
false
1,343
java
package org.review.connections; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; /** * @author lijichen * @date 2020/8/1 - 15:53 */ public class ArrayTest { public static void main(String[] args) { List coll4 = new ArrayList(); coll4.add(123);//顺序相同 coll4.add(456);//顺序相同 coll4.add(true); coll4.add(new String("aaa")); coll4.add(new Parens("lisi",12)); coll4.add(123); System.out.println("********************"); System.out.println(coll4.indexOf(456)); System.out.println("********************"); coll4.addAll(1,Arrays.asList("asdf","fffff")); System.out.println(coll4); System.out.println("********************"); System.out.println(coll4.get(4)); System.out.println("********************"); System.out.println(coll4.lastIndexOf(123)); System.out.println("********************"); coll4.removeAll(Arrays.asList("asdf","fffff")); System.out.println(coll4); System.out.println("********************"); System.out.println(coll4.set(0, 333333333)); System.out.println("********************"); System.out.println(coll4.subList(1, 4)); coll4.remove(new Integer(456)); } }
a253df498c10c2930abc294c483c28b86118ed78
904946a43646ab654f092edd1be820fcb100aae5
/open/api/src/main/java/com/varela/api/view/MainController.java
14d0d99a21e615d9dd2cde599e76472135a8df0a
[]
no_license
guangping/open
8fc12f0eb5f36dccd75d8ae20ab08f3e746055a9
d0df3049d1409450e0ee048bbad84576f97b5727
refs/heads/master
2020-12-12T14:40:50.357051
2016-08-02T10:47:52
2016-08-02T10:47:52
43,875,842
2
0
null
null
null
null
UTF-8
Java
false
false
413
java
package com.varela.api.view; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * Created by lance on 12/10/2015. */ @Controller public class MainController { @RequestMapping(value = "/",method = RequestMethod.GET) public String execute(){ return "index"; } }
8b916550899e05ef88d5f4e99035eea842cfb8bb
e6bf8782b1067c159c8cb8097390f56c8771891c
/kritterui/api/reporting/src/main/java/com/kritter/kritterui/api/reporting/ReportingCrud.java
40f73aca6bb382578564fdcfb78a070623984770
[]
no_license
ieanwfg201/dsp-source
eecaacafbaeaa762128e9d2f6dc968f3b1ea6e94
19816478eadc31e397871508291f659d5e8723df
refs/heads/master
2021-07-14T16:16:11.239131
2017-03-22T05:58:36
2017-03-22T05:58:36
104,984,410
1
0
null
null
null
null
UTF-8
Java
false
false
21,216
java
package com.kritter.kritterui.api.reporting; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import org.apache.commons.lang.time.DateUtils; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.node.ArrayNode; import org.codehaus.jackson.node.ObjectNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.kritter.api.entity.reporting.ReportingEntity; import com.kritter.constants.ChartType; import com.kritter.constants.Naming; import com.kritter.kritterui.api.utils.TimeManipulation.TimeManipulator; import com.kritter.kumbaya.libraries.data_structs.common.KumbayaReportingConfiguration; import com.kritter.kumbaya.libraries.data_structs.query_planner.ColumnType; import com.kritter.kumbaya.libraries.data_structs.query_planner.Header; import com.kritter.kumbaya.libraries.data_structs.query_planner.KumbayaQueryPlanner; import com.kritter.kumbaya.libraries.query_planner.db.DBQueryPlanner; public class ReportingCrud { private static final Logger LOG = LoggerFactory.getLogger(ReportingCrud.class); public static ArrayNode createColumnNode(ObjectMapper mapper, List<Header> headerList){ ArrayNode columnNode = mapper.createArrayNode(); for(Header header: headerList){ ObjectNode columnObjNode = mapper.createObjectNode(); columnObjNode.put("title", header.ui_name); columnObjNode.put("field", header.name); columnObjNode.put("visible", header.isVisible()); if(header.isClickable()){ columnObjNode.put("clickable", true); } columnNode.add(columnObjNode); } return columnNode; } public static String createCsvHeader(List<Header> headerList, String csvDelimiter, ArrayList<SumEntity> csvTotalSum, boolean docsvTotalSsm){ StringBuffer sbuff = new StringBuffer(); for(Header header: headerList){ sbuff.append(csvDelimiter); sbuff.append(header.ui_name); if(docsvTotalSsm){ if(header.getColumnType() == ColumnType.METRIC){ switch(header.headerType){ case INT: csvTotalSum.add(new SumEntity(0)); break; case LONG: csvTotalSum.add(new SumEntity(1)); break; case DOUBLE: csvTotalSum.add(new SumEntity(2)); break; case STRING: csvTotalSum.add(null); default: break; } }else{ csvTotalSum.add(null); } } } return sbuff.toString(); } public static JsonNode get_data(Connection con,ReportingEntity reportingEntity, boolean returnWithId, boolean exportAsCSV, String absoluteFileName){ if(con == null || reportingEntity == null){ return null; } PreparedStatement pstmt = null; PreparedStatement foundRowPstmt = null; try{ DBQueryPlanner dbQueryPlanner = new DBQueryPlanner(); KumbayaQueryPlanner kQueryPlanner = new KumbayaQueryPlanner(); KumbayaReportingConfiguration kReportingConfiguration = new KumbayaReportingConfiguration(); dbQueryPlanner.convert(kQueryPlanner, kReportingConfiguration, reportingEntity, returnWithId); dbQueryPlanner.plan(kQueryPlanner, kReportingConfiguration, reportingEntity); //System.out.println(kQueryPlanner.getQueryString()); LOG.debug(kQueryPlanner.getQueryString()); String queryString = kQueryPlanner.getQueryString(); if(queryString == null){ return null; } pstmt = con.prepareStatement(queryString); ResultSet rset = pstmt.executeQuery(); ObjectMapper mapper = new ObjectMapper(); switch(reportingEntity.getChartType()){ case PIE: if(exportAsCSV){ return null; } ArrayNode arrayNode = mapper.createArrayNode(); int sum = 0; while(rset.next()){ ObjectNode dataObjNode = mapper.createObjectNode(); for(Header header: kQueryPlanner.getHeaderList()){ switch(header.headerType){ case INT: int percent = (int)(rset.getDouble(header.getName())*100); sum = sum + percent; dataObjNode.put("value",percent);break; case DOUBLE: percent = (int)(rset.getDouble(header.getName())*100); sum = sum + percent; dataObjNode.put("value",percent);break; case LONG: percent = (int)(rset.getDouble(header.getName())*100); sum = sum + percent; dataObjNode.put("value",percent);break; case STRING: dataObjNode.put("label",rset.getString(header.getName()));break; default: break; } } arrayNode.add(dataObjNode); } ObjectNode otherNode = mapper.createObjectNode(); otherNode.put("label",Naming.report_dashboard_others); otherNode.put("value",100-sum); arrayNode.add(otherNode); return arrayNode; /*case BAR: ObjectNode barRootNode = mapper.createObjectNode(); int size = kQueryPlanner.getHeaderList().size(); LinkedHashMap<String, ArrayNode> hashMap = new LinkedHashMap<String, ArrayNode>(); ArrayNode headerArrayNode = mapper.createArrayNode(); String xaxis = null; int i = 1; for(Header header: kQueryPlanner.getHeaderList()){ if(header.headerType==HeaderType.STRING){ xaxis = header.getName(); }else{ ObjectNode headerObjectNode = mapper.createObjectNode(); headerObjectNode.put("label", header.getUi_name()); headerObjectNode.put("data", "barChart.data"+i); headerArrayNode.add(headerObjectNode); hashMap.put(header.getName(), mapper.createArrayNode()); i++; } } barRootNode.put("barChart.data", headerArrayNode); String str = null; while(rset.next()){ str = rset.getString(xaxis); for(Header header: kQueryPlanner.getHeaderList()){ ArrayNode metricArrayNode = mapper.createArrayNode(); switch(header.headerType){ case INT: metricArrayNode.add(str); metricArrayNode.add(rset.getInt(header.getName())); hashMap.get(header.getName()).add(metricArrayNode);break; case DOUBLE: metricArrayNode.add(str); metricArrayNode.add(rset.getDouble(header.getName())); hashMap.get(header.getName()).add(metricArrayNode);break; case LONG: metricArrayNode.add(str); metricArrayNode.add(rset.getLong(header.getName())); hashMap.get(header.getName()).add(metricArrayNode);break; default: break; } } i =1; for(Header header: kQueryPlanner.getHeaderList()){ if(HeaderType.STRING != header.headerType){ barRootNode.put("barChart.data"+i, hashMap.get(header.getName())); i++; } } } return barRootNode;*/ default: String stringformat = null; if(reportingEntity.isRoundoffmetric()){ stringformat = "%."+reportingEntity.getRoundoffmetriclength()+"f"; } ObjectNode rootNode = mapper.createObjectNode(); ArrayNode dataNode = null; BufferedWriter bw = null; FileWriter fw = null; try{ ArrayList<SumEntity> csvTotalSum = null; if(exportAsCSV){ File f = new File(absoluteFileName); f.getParentFile().mkdirs(); fw = new FileWriter(f); bw = new BufferedWriter(fw); csvTotalSum = new ArrayList<SumEntity>(); bw.write(createCsvHeader(kQueryPlanner.getHeaderList(), reportingEntity.getCsvDelimiter(), csvTotalSum, reportingEntity.isRollup())); bw.write("\n"); }else{ dataNode = mapper.createArrayNode(); rootNode.put("column", createColumnNode(mapper, kQueryPlanner.getHeaderList())); } while(rset.next()){ ObjectNode dataObjNode = null; StringBuffer sbuff = null; if(exportAsCSV){ sbuff = new StringBuffer(); }else{ dataObjNode = mapper.createObjectNode(); } int count = 0; for(Header header: kQueryPlanner.getHeaderList()){ switch(header.headerType){ case INT: int i = rset.getInt(header.getName()); if(exportAsCSV){ sbuff.append(reportingEntity.getCsvDelimiter()); sbuff.append(i); if(reportingEntity.isRollup() && csvTotalSum.get(count) != null){ csvTotalSum.get(count).setSumInt(csvTotalSum.get(count).getSumInt()+i); } }else{ dataObjNode.put(header.name,i); } break; case DOUBLE: double d = rset.getDouble(header.getName()); if(exportAsCSV){ sbuff.append(reportingEntity.getCsvDelimiter()); if(stringformat != null){ sbuff.append(String.format(stringformat, d)); }else{ sbuff.append(d); } if(reportingEntity.isRollup() && csvTotalSum.get(count) != null){ csvTotalSum.get(count).setSumDouble(csvTotalSum.get(count).getSumDouble()+d); } }else{ if(stringformat != null){ dataObjNode.put(header.name,String.format(stringformat, d)); }else{ dataObjNode.put(header.name,d); } } break; case LONG: long l = rset.getLong(header.getName()); if(exportAsCSV){ sbuff.append(reportingEntity.getCsvDelimiter()); sbuff.append(l); if(reportingEntity.isRollup() && csvTotalSum.get(count) != null){ csvTotalSum.get(count).setSumLong(csvTotalSum.get(count).getSumLong()+l); } }else{ dataObjNode.put(header.name,l); } break; case STRING: String s = rset.getString(header.getName()); if(exportAsCSV){ sbuff.append(reportingEntity.getCsvDelimiter()); if("time".equals(header.getName())){ if(s != null){ sbuff.append(s.split("[.]")[0]); }else{ sbuff.append(s); } }else{ sbuff.append(s); } }else{ dataObjNode.put(header.name,s); } break; default: break; } count++; } if(exportAsCSV){ bw.write(sbuff.toString()); bw.write("\n"); }else{ dataNode.add(dataObjNode); } } if(exportAsCSV && reportingEntity.isRollup()){ bw.write("TOTAL"); for(SumEntity sumentity:csvTotalSum){ bw.write(reportingEntity.getCsvDelimiter()); if(sumentity != null){ if(sumentity.getType() == 0 ){ bw.write(sumentity.getSumInt()+""); }else if(sumentity.getType() == 1 ){ bw.write(sumentity.getSumLong()+""); }else if(sumentity.getType() == 2 ){ bw.write(sumentity.getSumDouble()+""); } } } bw.write("\n"); } if(!exportAsCSV){ rootNode.put("data", dataNode); } foundRowPstmt = con.prepareStatement("SELECT FOUND_ROWS() as count"); ResultSet foundRowRset = foundRowPstmt.executeQuery(); int count = 0; if(foundRowRset.next()){ count = foundRowRset.getInt("count"); } if(!exportAsCSV){ rootNode.put("count", count); } return rootNode; }catch(Exception e){ LOG.error(e.getMessage(),e); return null; }finally{ if(bw != null){ bw.close(); } if(fw != null){ fw.close(); } } } }catch(Exception e){ LOG.error(e.getMessage(),e); return null; }finally{ if(pstmt != null){ try { pstmt.close(); } catch (SQLException e) { LOG.error(e.getMessage(),e); } } if(foundRowPstmt != null){ try { foundRowPstmt.close(); } catch (SQLException e) { LOG.error(e.getMessage(),e); } } } } public static JsonNode get_top_n(Connection con, ReportingEntity reportingEntity){ if(con == null || reportingEntity == null){ return null; } Date enddate = new Date(); Date startdate = new Date(); if(reportingEntity.getTop_n_for_last_x_hours() > 0){ startdate = DateUtils.addHours(startdate, 0-reportingEntity.getTop_n_for_last_x_hours()); }else{ startdate = DateUtils.addHours(startdate, reportingEntity.getTop_n_for_last_x_hours()); } reportingEntity.setStart_time_str(TimeManipulator.convertDate(startdate, reportingEntity.getDate_format(), reportingEntity.getTimezone())); reportingEntity.setDate_as_dimension(false); reportingEntity.setEnd_time_str(TimeManipulator.convertDate(enddate, reportingEntity.getDate_format(), reportingEntity.getTimezone())); reportingEntity.setStartindex(0); reportingEntity.setPagesize(reportingEntity.getTop_n()); return get_data(con, reportingEntity, false, false, null); } public static JsonNode get_pie(Connection con, ReportingEntity reportingEntity){ if(con == null || reportingEntity == null){ return null; } Date enddate = new Date(); Date startdate = new Date(); if(reportingEntity.getTop_n_for_last_x_hours() > 0){ startdate = DateUtils.addHours(startdate, 0-reportingEntity.getTop_n_for_last_x_hours()); }else{ startdate = DateUtils.addHours(startdate, reportingEntity.getTop_n_for_last_x_hours()); } reportingEntity.setStart_time_str(TimeManipulator.convertDate(startdate, reportingEntity.getDate_format(), reportingEntity.getTimezone())); reportingEntity.setDate_as_dimension(false); reportingEntity.setEnd_time_str(TimeManipulator.convertDate(enddate, reportingEntity.getDate_format(), reportingEntity.getTimezone())); reportingEntity.setChartType(ChartType.PIE); reportingEntity.setStartindex(0); return get_data(con, reportingEntity, false, false, null); } public static JsonNode get_bar(Connection con, ReportingEntity reportingEntity){ if(con == null || reportingEntity == null){ return null; } Date enddate = new Date(); Date startdate = new Date(); if(reportingEntity.getTop_n_for_last_x_hours() > 0){ if(reportingEntity.getPagesize() >= reportingEntity.getTop_n_for_last_x_hours()){ startdate = DateUtils.addHours(startdate, 0-reportingEntity.getTop_n_for_last_x_hours()); }else{ startdate = DateUtils.addHours(startdate, 0-reportingEntity.getPagesize()); } }else{ if(reportingEntity.getPagesize() >= Math.abs(reportingEntity.getTop_n_for_last_x_hours())){ startdate = DateUtils.addHours(startdate, reportingEntity.getTop_n_for_last_x_hours()); }else{ startdate = DateUtils.addHours(startdate, 0-reportingEntity.getPagesize()); } } reportingEntity.setStart_time_str(TimeManipulator.convertDate(startdate, reportingEntity.getDate_format(), reportingEntity.getTimezone())); reportingEntity.setDate_as_dimension(true); reportingEntity.setEnd_time_str(TimeManipulator.convertDate(enddate, reportingEntity.getDate_format(), reportingEntity.getTimezone())); reportingEntity.setChartType(ChartType.BAR); reportingEntity.setStartindex(0); return get_data(con, reportingEntity, false, false, null); } /*public static void main(String args[]){ ReportingEntity re = new ReportingEntity(); re.setTotal_request(true); re.setTotal_impression(true); re.setTop_n_for_last_x_hours(-756); re.setFrequency(Frequency.HOURLY); re.setChartType(ChartType.BAR); Connection con = null ; try{ con = DBConnector.getConnection("MYSQL","localhost", "3306", "kritter", "root", "password"); System.out.println(ReportingCrud.get_bar(con, re).toString()); }catch(Exception e){ e.printStackTrace(); }finally{ if(con!= null){ try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }*/ }
01cc8710c5e6cb729811828e5d276dcae701ac10
838b74568920666bcfdeef2760394922da6af976
/src/main/java/com/cinematica/framework/contexto/Alterar.java
87e0afac18a826a72b45157af85dbfecb4d27109
[]
no_license
jadersonmb/cinematica-boot
387994dd85542ebf58c7d69792739f2ed49fc365
a35c1c4f5be99762273e4af567a9c5a150491e91
refs/heads/master
2020-12-13T11:05:06.728877
2020-09-29T19:12:26
2020-09-29T19:12:26
234,397,238
0
0
null
null
null
null
UTF-8
Java
false
false
87
java
package com.cinematica.framework.contexto; public interface Alterar extends Contexto{}
20ece2ea5a7728e0adf102d4c19aec2eddc24438
8f542b433af1dd0ba050a8cb1db04ae4dd2a3982
/src/Car.java
e7744204bea388444fe79999aaa0bac25f6518c5
[]
no_license
dominikapara/tdd_w57779_cars
1a034f55542137b0bd74be300f1bdc950bcedb5d
691c6f0eb5f95540cd56a5a936f297dea1e1f6c6
refs/heads/master
2023-03-26T00:11:02.766671
2021-03-22T23:13:01
2021-03-22T23:13:01
350,508,975
0
0
null
null
null
null
UTF-8
Java
false
false
1,141
java
public class Car { private final String color; private final String make; private final float fuelConsumption; private final int tankCapacity; private final float fuelLevel; private final int odometer; private final float dailyOdometer; public Car(String color, String make, float fuelConsumption, int tankCapacity, float fuelLevel, int odometer, float dailyOdometer) { this.color = color; this.make = make; this.fuelConsumption = fuelConsumption; this.tankCapacity = tankCapacity; this.fuelLevel = fuelLevel; this.odometer = odometer; this.dailyOdometer = dailyOdometer; } public String getColor() { return color; } public String getMake() { return make; } public float getFuelConsumption() { return fuelConsumption; } public int getTankCapacity() { return tankCapacity; } public float getFuelLevel() { return fuelLevel; } public int getOdometer() { return odometer; } public float getDailyOdometer() { return dailyOdometer; } }
26abfcd32f70417800b834939305c32f7424a309
a65785ab0a5d113b4157b2e2d0a486415fba426d
/src/main/java/chapter3/item13/Stack.java
a79cc170f66538886046a3192f6863dce67c0f4b
[]
no_license
StrongSoft/effectivejava
ab2824d643bf04c484331c877a7f2bd0db682e3c
7c065c59e4cce35ac9d989f81a94cf523259f98f
refs/heads/master
2023-05-26T03:36:21.187282
2021-06-08T13:34:34
2021-06-08T13:34:34
372,699,828
0
0
null
null
null
null
UTF-8
Java
false
false
1,536
java
package chapter3.item13; import java.util.Arrays; public class Stack { private Object[] elements; private int size = 0; private static final int DEFAULT_INITIAL_CAPACITY = 16; private Stack() { elements = new Object[DEFAULT_INITIAL_CAPACITY]; } private void push(Object e) { ensureCapacity(); elements[size++] = e; } //코드 7-2 제대로 구현한 pop 메서드 (37쪽) private Object pop() { if (size == 0) { throw new EmptyStackException(); } Object result = elements[--size]; elements[size] = null; return result; } private boolean isEmpty() { return size == 0; } /** * 원소를 위한 공간을 적어도 하나 이상 확보한다. 배열 크기를 늘려야 할 때마다 대략 두 배씩 늘린다. */ private void ensureCapacity() { if (elements.length == size) { elements = Arrays.copyOf(elements, 2 * size + 1); } } @Override public Stack clone() { try { Stack result = (Stack) super.clone(); result.elements = elements.clone(); return result; } catch (CloneNotSupportedException e) { throw new AssertionError(); } } public static void main(String[] args) { Stack stack = new Stack(); for (String arg : args) { stack.push(arg); } Stack copy = stack.clone(); while (!stack.isEmpty()) { System.out.println(stack.pop() + " "); } System.out.println(); while (!copy.isEmpty()) { System.err.println(stack.pop() + " "); } } }
a8a389a76c469e984a16f3258130cc6e85af800d
6b23d8ae464de075ad006c204bd7e946971b0570
/WEB-INF/plugin/reserve/src/jp/groupsession/v2/rsv/pdf/RsvGekPdfModel.java
2b9f8d6ec63785d9179e000edcfe130ddf186a50
[]
no_license
kosuke8/gsession
a259c71857ed36811bd8eeac19c456aa8f96c61e
edd22517a22d1fb2c9339fc7f2a52e4122fc1992
refs/heads/master
2021-08-20T05:43:09.431268
2017-11-28T07:10:08
2017-11-28T07:10:08
112,293,459
0
0
null
null
null
null
UTF-8
Java
false
false
3,755
java
package jp.groupsession.v2.rsv.pdf; import java.util.ArrayList; import jp.groupsession.v2.rsv.RsvWeekModel; /** * <br>[機 能] 施設予約[月間]PDF出力用モデルです。 * <br>[解 説] * <br>[備 考] * * @author JTS */ public class RsvGekPdfModel { /** ファイル名 */ private String rsvGekFileName__ = null; /** 保存先ファイル名 */ private String saveGekFileName__ = null; /**年月*/ private String rsvGekDspDate__ = null; /** ヘッダー表示用年月日(曜) */ private String rsvGekHeadDate__ = null; /** 表示グループ */ private String rsvGekDspGroup__ = null; /** 表示施設 */ private String rsvGekDspSisetsu__ = null; /** 施設毎の予約情報リスト */ private ArrayList<RsvWeekModel> rsvGekMonthList__ = null; /** * <p>rsvGekFileName を取得します。 * @return rsvGekFileName */ public String getRsvGekFileName() { return rsvGekFileName__; } /** * <p>rsvGekFileName をセットします。 * @param rsvGekFileName rsvGekFileName */ public void setRsvGekFileName(String rsvGekFileName) { rsvGekFileName__ = rsvGekFileName; } /** * <p>saveGekFileName を取得します。 * @return saveGekFileName */ public String getSaveGekFileName() { return saveGekFileName__; } /** * <p>saveGekFileName をセットします。 * @param saveGekFileName saveGekFileName */ public void setSaveGekFileName(String saveGekFileName) { saveGekFileName__ = saveGekFileName; } /** * <p>rsvGekDspDate を取得します。 * @return rsvGekDspDate */ public String getRsvGekDspDate() { return rsvGekDspDate__; } /** * <p>rsvGekDspDate をセットします。 * @param rsvGekDspDate rsvGekDspDate */ public void setRsvGekDspDate(String rsvGekDspDate) { rsvGekDspDate__ = rsvGekDspDate; } /** * <p>rsvGekHeadDate を取得します。 * @return rsvGekHeadDate */ public String getRsvGekHeadDate() { return rsvGekHeadDate__; } /** * <p>rsvGekHeadDate をセットします。 * @param rsvGekHeadDate rsvGekHeadDate */ public void setRsvGekHeadDate(String rsvGekHeadDate) { rsvGekHeadDate__ = rsvGekHeadDate; } /** * <p>rsvGekDspGroup を取得します。 * @return rsvGekDspGroup */ public String getRsvGekDspGroup() { return rsvGekDspGroup__; } /** * <p>rsvGekDspGroup をセットします。 * @param rsvGekDspGroup rsvGekDspGroup */ public void setRsvGekDspGroup(String rsvGekDspGroup) { rsvGekDspGroup__ = rsvGekDspGroup; } /** * <p>rsvGekDspSisetsu を取得します。 * @return rsvGekDspSisetsu */ public String getRsvGekDspSisetsu() { return rsvGekDspSisetsu__; } /** * <p>rsvGekDspSisetsu をセットします。 * @param rsvGekDspSisetsu rsvGekDspSisetsu */ public void setRsvGekDspSisetsu(String rsvGekDspSisetsu) { rsvGekDspSisetsu__ = rsvGekDspSisetsu; } /** * <p>rsvGekMonthList を取得します。 * @return rsvGekMonthList */ public ArrayList<RsvWeekModel> getRsvGekMonthList() { return rsvGekMonthList__; } /** * <p>rsvGekMonthList をセットします。 * @param rsvGekMonthList rsvGekMonthList */ public void setRsvGekMonthList(ArrayList<RsvWeekModel> rsvGekMonthList) { rsvGekMonthList__ = rsvGekMonthList; } }
[ "PK140601-29@PK140601-29" ]
PK140601-29@PK140601-29
7f7190474aabfbad3a798b7128a5ca9cee5c2157
1548aac7446d25ce8f807bcebe35440dc55cd8c8
/src/main/java/com/eazy/brush/controller/web/TestController.java
33b1a9356c30503e760ab8edb0249205a60234db
[]
no_license
cash2one/app_brush
a4bbfde3762e2c8a1e9124fe6286253817b646fb
144a6851c04d49b023cacf2bdf6546434e24151f
refs/heads/master
2020-05-23T22:59:10.955333
2016-10-20T08:22:21
2016-10-20T08:22:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,508
java
package com.eazy.brush.controller.web; import com.eazy.brush.controller.common.BaseController; import com.eazy.brush.core.enums.TaskState; import com.eazy.brush.dao.entity.Task; import com.eazy.brush.dao.entity.TaskHistory; import com.eazy.brush.service.TaskHistoryService; import com.eazy.brush.service.TaskService; import com.eazy.brush.service.TaskSubService; import com.google.common.base.Stopwatch; import lombok.extern.slf4j.Slf4j; import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import java.util.List; import java.util.concurrent.TimeUnit; /** * Created by yuekuapp on 16-9-20. */ @Controller @RequestMapping("/test") @Slf4j public class TestController extends BaseController { @Autowired TaskService taskService; @Autowired TaskSubService taskSubService; @Autowired TaskHistoryService taskHistoryService; /** * 每日凌晨进行旧任务的统计以及新任务的重新生成评估,需要做以下事情 * //旧任务的统计工作 * 1.统计昨日新增数据/失败数据/阻塞数据 * 2.统计昨日留存数据/失败数据/阻塞数据 * 3.重置计算剩余的新的留存率 * 4.将新增上面数据更新进任务历史记录 * 3.删除所有的留存任务数据(留存没有用,只有首日新增数据有用,后续留存是根据新增来的) * 4.删除所有的新增失败阻塞任务数据(失败的新增不能为后续做留存,故直接删除) * //新任务的开启生成工作 * 5.通过task重新生成新增Tasksub并写入数据库 * 6.通过扫描历史记录,找到需要做留存的任务,生成留存数据,并且更改历史记录中的留存率,方便下次任务扫描 * <p> * 注意: * 1.如果当日新增留存失败率过高,以后的留存也会同步减少 * 2.留存不受新增时间的时间段限制。新增我保证投递时间,别人安装上了,我如何保证他什么时候打开? */ @RequestMapping(value = "task", method = RequestMethod.GET) public void invokeAllSubTask() { Stopwatch stopwatch = Stopwatch.createStarted(); log.info("### start invokeMakeTaskSub ###"); int historyDay = Integer.parseInt(DateTime.now().minusDays(1).toString("yyyyMMdd")); //这里进行上一天的历史数据计算 List<TaskHistory> historys = taskSubService.getHistoryByCreateDay(historyDay); log.info("### end get historys ###" + historys); for (TaskHistory history : historys) { Task task = taskService.getById(history.getTaskId()); history.setAppName(task.getRemarkName()); history.setRemarkName(task.getRemarkName()); history.setUserId(task.getUserId()); history.setRetainStayday(task.getRetainDay());//这里不要写错! history.setRetainPercent(task.getRetainPercent()); history.setCreateDay(historyDay); } log.info("### begin insert historys ###" + historys); taskHistoryService.insert(historys); log.info("### end insert history,cost {} s ###", stopwatch.elapsed(TimeUnit.SECONDS)); taskSubService.deleteOldUnUseData(historyDay); log.info("### end delete unused subtask,cost {} s ###", stopwatch.elapsed(TimeUnit.SECONDS)); //获取所有运行中的任务,进行新的sub生成 List<Task> tasks = taskService.getByState(TaskState.running.getCode()); for (Task item : tasks) { taskSubService.makeIncrDayTaskSub(item); } log.info("### end make incrday subtask,cost {} s ###", stopwatch.elapsed(TimeUnit.SECONDS)); //这里是获取还有留存的历史TaskHistory,根据留存率进行判断 List<TaskHistory> activeTask = taskHistoryService.getActiveTask(); log.info("get task history number"+activeTask.size()); for (TaskHistory taskHistory : activeTask) { taskSubService.makeRetainDayTaskSub(taskHistory); taskHistoryService.changeRetainPercent(taskHistory); } log.info("### end make retain day subtask,cost {} s ###", stopwatch.elapsed(TimeUnit.SECONDS)); log.info("### end invokeMakeTaskSub,cost {} s ###", stopwatch.elapsed(TimeUnit.SECONDS)); stopwatch.stop(); } }
73db2321db9046ebb60a79a98b3f059d7c196a5c
a221fc0c940ed0348bda0ebe5dff4cfcf5dfdb30
/src/main/java/com/lmbx/ssm/vo/JqgridResponseContext.java
f428c069acdcb6f360603f21975e2f2dc6f06691
[]
no_license
123qweqwe123/ssm
7cfa827fab42d5342b0478faff3b4150b4d8a223
b10f8bb02c50020147cdf559b823ca0cc62daa2f
refs/heads/master
2021-04-05T23:37:38.512767
2018-03-09T08:26:03
2018-03-09T08:26:03
124,505,037
0
0
null
null
null
null
UTF-8
Java
false
false
639
java
package com.lmbx.ssm.vo; import java.util.List; public class JqgridResponseContext { protected static ThreadLocal<JqgridResponse> localResponse = new ThreadLocal(); public static <T> JqgridResponse<T> getJqgridResponse() { JqgridResponse<T> jqgridResponse = (JqgridResponse)localResponse.get(); if (jqgridResponse == null) { jqgridResponse = new JqgridResponse(); } localResponse.remove(); return jqgridResponse; } public static <T> JqgridResponse<T> getJqgridResponse(List<T> rows) { JqgridResponse<T> jqgridResponse = getJqgridResponse(); return jqgridResponse.setRows(rows); } }
e6770333998bdb7d9037ab5a5029dc650089a2ed
52ff9274ecb7d68dd98bf1a2010abc922e1d4171
/app/src/main/java/com/rishabh/companyproject/Common/LoginSignup/Login.java
a5a102fdf704508499aad8af8f7cb04966800d9b
[]
no_license
rishabhmishra705454/Agriculture-App
d1c23a90683283a1f31fe24d95694dad0e92a930
666023609717428ede16927d8ca70a985cb3e466
refs/heads/master
2023-05-03T16:39:27.586286
2021-05-18T03:56:13
2021-05-18T03:56:13
282,965,709
0
0
null
null
null
null
UTF-8
Java
false
false
649
java
package com.rishabh.companyproject.Common.LoginSignup; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import com.rishabh.companyproject.R; public class Login extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cabers_login); } //forget password public void callForgetPasswordScreen(View view){ Intent intent=new Intent(getApplicationContext(),ForgetPassword.class); startActivity(intent); } }
b1f27fa9277a7ecb4b8b085c2bf9e4795e6d23ff
cd15447d38629d1d4e6fc685f324acd0df8e2a3a
/dsajg6e/src/main/java/learn/dsajg6e/ch07list/exer/C0726CircularDynamicArrayList.java
7a37733a248eb473fd77494338ebb2c551026083
[]
no_license
dpopkov/learn
f17a8fd578b45d7057f643c131334b2e39846da1
2f811fb37415cbd5a051bfe569dcace83330511a
refs/heads/master
2022-12-07T11:17:50.492526
2021-02-23T16:58:31
2021-02-23T16:58:31
117,227,906
1
0
null
2022-11-16T12:22:17
2018-01-12T10:29:38
Java
UTF-8
Java
false
false
1,270
java
package learn.dsajg6e.ch07list.exer; /** * Dynamic circular array with unbounded capacity. */ public class C0726CircularDynamicArrayList<E> extends C0725CircularArrayList<E> { protected static final int DEFAULT_CAPACITY = 16; public C0726CircularDynamicArrayList() { this(DEFAULT_CAPACITY); } public C0726CircularDynamicArrayList(int capacity) { super(capacity); } @Override public void add(int i, E e) throws IndexOutOfBoundsException { checkIndex(i); checkCapacity(); super.add(i, e); } @Override public void add(E e) { checkCapacity(); super.add(e); } @SuppressWarnings("unchecked") private void checkCapacity() { if (size == data.length) { E[] newData = (E[]) new Object[data.length * 2]; int num1 = data.length - front; System.arraycopy(data, front, newData, 0, num1); if (front > 0) { System.arraycopy(data, 0, newData, num1, front); } data = newData; front = 0; } } private void checkIndex(int i) { if (i < 0 || i > size) { throw new IndexOutOfBoundsException("Invalid index: " + i); } } }
d884899a12ea97346e8c6e591927700b50f4ce54
7db560b4e4cbdd4a0415e2687ff342a0a5a864ad
/Transactions.java
995452f160efc7ae57351e528f4f1a68e3489e4e
[]
no_license
Protopaco/JavaATM
0a0fc2db0f28c18117d1c6dbf0f637319ae116dd
456b4f8716ffb626db8cb343a141ca658c181628
refs/heads/master
2022-09-20T05:39:45.301428
2020-05-31T21:53:51
2020-05-31T21:53:51
268,368,553
0
0
null
null
null
null
UTF-8
Java
false
false
5,176
java
package com.company; import java.util.Scanner; public class Transactions { //method to deposit money public static void deposit(String accountNumber) { Scanner scan = new Scanner(System.in); double currentBalance; double input; double newBalance; System.out.println("*************************************"); currentBalance = FileHandling.checkBalance(accountNumber); System.out.println("Current balance: " + currentBalance); System.out.printf("Enter deposit amount: "); input = scan.nextDouble(); newBalance = input + currentBalance; FileHandling.recordTransaction(accountNumber, "deposit +", input, newBalance); System.out.println("New balance: " + newBalance); } //method to withdraw money public static void withdraw(String accountNumber) { Scanner scan = new Scanner(System.in); double currentBalance; double input = 0; double newBalance; boolean enough = false; System.out.println("*************************************"); currentBalance = FileHandling.checkBalance(accountNumber); System.out.println("Current balance: " + currentBalance); while (enough == false) { System.out.printf("Enter withdrawal amount: "); input = scan.nextDouble(); if (currentBalance < input) { System.out.println("Not enough money in the account."); } else { enough = true; } } newBalance = currentBalance - input; FileHandling.recordTransaction(accountNumber, "withdraw -", input, newBalance); System.out.println("New balance: " + newBalance); } //method to transfer money between accounts public static void transfer(String accountNumber) { Scanner scan = new Scanner(System.in); double toTransfer = 0; String toAccountNumber = null; double fromBalance; boolean toAccountValid = false; boolean enoughToTransfer = false; double toNewBalance; //getting balance for from account fromBalance = FileHandling.checkBalance(accountNumber); System.out.println("Current balance: " + fromBalance); while (toAccountValid == false) { Scanner myReader = new Scanner(System.in); System.out.printf("Account number you wish to transfer money to: "); toAccountNumber = myReader.nextLine(); toAccountValid = FileHandling.accountNumberSearch(toAccountNumber); } toNewBalance = FileHandling.checkBalance(toAccountNumber); //Ask for amount of money to be transfered while (enoughToTransfer == false) { System.out.printf("Enter amount to transfer: "); toTransfer = scan.nextDouble(); if (fromBalance < toTransfer) { System.out.println("Insufficent Funds."); } else { enoughToTransfer = true; } } toNewBalance = toNewBalance + toTransfer; fromBalance = fromBalance - toTransfer; //FileHandling.recordTransaction toAccount FileHandling.recordTransaction(toAccountNumber, "Transfer +", toTransfer, toNewBalance); //FileHandling.recordTransaction fromAccount FileHandling.recordTransaction(accountNumber, "Transfer -", toTransfer, fromBalance); //update balance level System.out.println("Your balance is now: " + fromBalance); } //returns account balance public static void balance(String accountNumber) { double currentBalance; currentBalance = FileHandling.checkBalance(accountNumber); System.out.println("Current balance: " + currentBalance); } //method to change the customer's password public static void changePassword(String accountNumber) { Scanner myReader = new Scanner(System.in); String oldPassword = null; String newPassword1 = null; String newPassword2; boolean passwordMatch = false; boolean passwordValid = false; while (passwordValid == false) { System.out.printf("Enter your current password: "); oldPassword = myReader.nextLine(); passwordValid = FileHandling.checkPassword(accountNumber, oldPassword); } while(passwordMatch == false) { System.out.printf("Enter new password: "); newPassword1 = myReader.nextLine(); System.out.printf("Reenter new password: "); newPassword2 = myReader.nextLine(); if(newPassword1.equals(newPassword2)) { passwordMatch = true; } } FileHandling.replacePassword(accountNumber, oldPassword, newPassword1); } //prints out customer's transaction history public static void transactionHistory(String accountNumber) { System.out.println("Transaction history for account: " +accountNumber); System.out.println("*************************************"); FileHandling.history(accountNumber); } }
0a4f03d102775de7a9980eb814d241ab0f4ae417
3389348b101e48c482476ffb8c172712981286a8
/src/CL7/Anonymous/Person.java
698a39ad5a4617f547965123951f29792b971069
[]
no_license
7IsEnough/workspace4Java
2b78c0d11acc181f85642b5131959e0b9bd88843
154871364907aadb7f70ccd9d606e9c1b2b0b021
refs/heads/master
2023-03-09T20:17:28.867838
2021-02-20T11:44:48
2021-02-20T11:44:48
340,636,805
0
0
null
null
null
null
UTF-8
Java
false
false
205
java
package CL7.Anonymous; /** * @author Promise * @create 2019-07-22-14:26 */ public class Person { String name; public void showName(){ System.out.println("我叫:"+this.name); } }
f0c56ebd694f9bfa248530992aadc3c8cb801682
04fc705ca59453e59b8cc624ada90d06cae30539
/app/src/test/java/com/example/labinternet/ExampleUnitTest.java
37a58349e0f2ade3eed9ef89e849e7c03dbc80c5
[]
no_license
Azamat229/Lab11-Internet
240530e30ae55cd3b79ab53e0ee05194ca754c52
775c624cd7ced73ac234ed0aa4030db777d545d3
refs/heads/master
2023-05-01T09:43:34.620886
2021-05-20T10:06:37
2021-05-20T10:06:37
369,163,936
0
0
null
null
null
null
UTF-8
Java
false
false
384
java
package com.example.labinternet; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
a77c7b008ed7b387a87b9049fe21ab238e5202b7
062e9ca2163326e235f2d37da10245e36617cac3
/QMP6-pseudoCodigo.java
78796d0a6f18267271d1adddc34976783dbd8f6d
[]
no_license
sazcoaga/QueMePongo2
a6ef848905f8677a2a48aa13df3e581e758ea52b
eb9298d6b7b49d58c7d064083bcda3d37375dd94
refs/heads/main
2023-05-13T21:30:37.005207
2021-06-10T03:26:23
2021-06-10T03:26:23
362,606,976
0
0
null
null
null
null
UTF-8
Java
false
false
1,611
java
qmp6 pseudocodigo //Aclaraciones //No comprendí mucho el enunciado así que traté de diseñar algún pseudocódigo, pregunto las dudas en clase class Usuario{ String mail List<Notificaciones> notificaciones (tienen que tener un campo de si estan activas o no) } class Vestidor{ Atuendo sugerenciaDiaria = this.sugerenciaDiaria(); Atuendo sugerenciaDiaria(){ //algun timer para que se realice una vez por dia? ? calzado = seleccionarPrenda(calzados); superior = seleccionarPrenda(superior); inferior = seleccionarPrenda(inferior); crear atuendo(superior, inferior, calzado); return atuendo; } actualizarSugerencia(Alerta){ Alerta.notificar(); } } //dispararSugerencias: debería no ser ningún metodo sino la manera de activar ese método en todos los vestidores al mismo tiempo? class Clima{ Lista alertasActuales; void obtenerAlertas(){ apiAlertas = apiClima.getAlertas("Buenos Aires"); this.alertas = alertas.get("CurrentAlerts"); } } //considero que acutalizar alertas sería volver a llamar al metodo obtener alertas, que actualizaria el atributo alertasActuales interface Alerta{ notificar(); } class tormenta implements Alerta{ notificar(){ notificacionService.notify("llevar paraguas!"); } } class granizo implements Alerta{ notificar(){ notificacionService.notify("evitar salir en auto"); } } class Notificador{ apiMail mailSender String mensaje void enviarMail(Usuario){ mailSender.send(Usuario.mail, mensaje); } } class Empleado{ dispararCalculoSugerencias(){ paraTodos(vestidor -> vestidor.sugerenciaDiaria()); } }
50c27469dd39e123623000a94fd3cba7dea7d00a
ff8327b1453796fcd0b8dc885ad2805fd66cdc32
/loja/src/br/com/mrb/loja/imposto/CalculadoraDeImpostos.java
ebc3b5d6f5d3a4182b27b9e2bb72886d260325b1
[]
no_license
MauroBraga/designer-pattern-java
e8c6ac5862c24167d22ad745657136dc7cff987d
9ca8f67e8891bf45f184a2ab6f0daf4419fd52fc
refs/heads/main
2023-04-18T14:57:16.090341
2021-05-05T14:11:43
2021-05-05T14:11:43
354,931,856
0
0
null
null
null
null
UTF-8
Java
false
false
270
java
package br.com.mrb.loja.imposto; import java.math.BigDecimal; import br.com.mrb.loja.orcamento.Orcamento; public class CalculadoraDeImpostos { public BigDecimal calcular(Orcamento orcamento, Imposto imposto) { return imposto.calcular(orcamento); } }
[ "M@r202150016774" ]
M@r202150016774
e1e8c2f3556c669590a278511fa6feaedd69b29f
dff68c431f6fb685fc825d5af2c1da590c9b0c5d
/ugckit/src/main/java/com/tencent/qcloud/ugckit/module/record/VideoRecordSDK.java
06c5a7ee23cc4be0c8d906a629d8325f9a9dc462
[]
no_license
holoteqdeveloper/holo-live-stream
3124bb2ac29f98cdca40f27434a90e2d1c382222
e74ae50192dde74c22e6e0175d903df0d9a97927
refs/heads/master
2023-07-09T06:12:14.754367
2021-08-15T08:49:47
2021-08-15T08:49:47
396,284,822
0
0
null
null
null
null
UTF-8
Java
false
false
20,776
java
package com.tencent.qcloud.ugckit.module.record; import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.provider.MediaStore; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import com.tencent.qcloud.ugckit.R; import com.tencent.liteav.demo.beauty.BeautyParams; import com.tencent.qcloud.ugckit.UGCKit; import com.tencent.qcloud.ugckit.module.record.draft.RecordDraftInfo; import com.tencent.qcloud.ugckit.module.record.draft.RecordDraftManager; import com.tencent.qcloud.ugckit.utils.BackgroundTasks; import com.tencent.qcloud.ugckit.utils.LogReport; import com.tencent.qcloud.ugckit.utils.ToastUtil; import com.tencent.qcloud.ugckit.utils.VideoPathUtil; import com.tencent.rtmp.TXLog; import com.tencent.rtmp.ui.TXCloudVideoView; import com.tencent.ugc.TXRecordCommon; import com.tencent.ugc.TXUGCPartsManager; import com.tencent.ugc.TXUGCRecord; import com.tencent.ugc.TXVideoEditConstants; import com.tencent.ugc.TXVideoInfoReader; import java.util.List; public class VideoRecordSDK implements TXRecordCommon.ITXVideoRecordListener { private static final String TAG = "VideoRecordSDK"; public static int STATE_START = 1; public static int STATE_STOP = 2; public static int STATE_RESUME = 3; public static int STATE_PAUSE = 4; public static int START_RECORD_SUCC = 0; public static int START_RECORD_FAIL = -1; @NonNull private static VideoRecordSDK sInstance = new VideoRecordSDK(); @Nullable private TXUGCRecord mRecordSDK; private UGCKitRecordConfig mUGCKitRecordConfig; private RecordDraftManager mRecordDraftManager; private OnVideoRecordListener mOnVideoRecordListener; private OnRestoreDraftListener mOnRestoreDraftListener; private int mCurrentState = STATE_STOP; private boolean mPreviewFlag; private String mRecordVideoPath; private VideoRecordSDK() { } @NonNull public static VideoRecordSDK getInstance() { return sInstance; } /** * 初始化SDK:TXUGCRecord */ public void initSDK() { if (mRecordSDK == null) { mRecordSDK = TXUGCRecord.getInstance(UGCKit.getAppContext()); } mCurrentState = STATE_STOP; TXLog.d(TAG, "initSDK"); } @Nullable public TXUGCRecord getRecorder() { TXLog.d(TAG, "getRecorder mTXUGCRecord:" + mRecordSDK); return mRecordSDK; } public void initConfig(@NonNull UGCKitRecordConfig config) { mUGCKitRecordConfig = config; Log.d(TAG, "initConfig mBeautyParam:" + mUGCKitRecordConfig.mBeautyParams); } public UGCKitRecordConfig getConfig() { return mUGCKitRecordConfig; } public void startCameraPreview(TXCloudVideoView videoView) { Log.d(TAG, "startCameraPreview"); if (mPreviewFlag) { return; } mPreviewFlag = true; if (mUGCKitRecordConfig.mQuality >= 0) { // 推荐配置 TXRecordCommon.TXUGCSimpleConfig simpleConfig = new TXRecordCommon.TXUGCSimpleConfig(); simpleConfig.videoQuality = mUGCKitRecordConfig.mQuality; simpleConfig.minDuration = mUGCKitRecordConfig.mMinDuration; simpleConfig.maxDuration = mUGCKitRecordConfig.mMaxDuration; simpleConfig.isFront = mUGCKitRecordConfig.mFrontCamera; simpleConfig.touchFocus = mUGCKitRecordConfig.mTouchFocus; simpleConfig.needEdit = mUGCKitRecordConfig.mIsNeedEdit; if (mRecordSDK != null) { mRecordSDK.setVideoRenderMode(mUGCKitRecordConfig.mRecordMode); mRecordSDK.setMute(mUGCKitRecordConfig.mIsMute); } mRecordSDK.startCameraSimplePreview(simpleConfig, videoView); } else { // 自定义配置 TXRecordCommon.TXUGCCustomConfig customConfig = new TXRecordCommon.TXUGCCustomConfig(); customConfig.videoResolution = mUGCKitRecordConfig.mResolution; customConfig.minDuration = mUGCKitRecordConfig.mMinDuration; customConfig.maxDuration = mUGCKitRecordConfig.mMaxDuration; customConfig.videoBitrate = mUGCKitRecordConfig.mVideoBitrate; customConfig.videoGop = mUGCKitRecordConfig.mGOP; customConfig.videoFps = mUGCKitRecordConfig.mFPS; customConfig.isFront = mUGCKitRecordConfig.mFrontCamera; customConfig.touchFocus = mUGCKitRecordConfig.mTouchFocus; customConfig.needEdit = mUGCKitRecordConfig.mIsNeedEdit; mRecordSDK.startCameraCustomPreview(customConfig, videoView); } if (mRecordSDK != null) { mRecordSDK.setRecordSpeed(mUGCKitRecordConfig.mRecordSpeed); mRecordSDK.setHomeOrientation(mUGCKitRecordConfig.mHomeOrientation); mRecordSDK.setRenderRotation(mUGCKitRecordConfig.mRenderRotation); mRecordSDK.setAspectRatio(mUGCKitRecordConfig.mAspectRatio); mRecordSDK.setVideoRecordListener(this); } } public void stopCameraPreview() { Log.d(TAG, "stopCameraPreview"); if (mRecordSDK != null) { mRecordSDK.stopCameraPreview(); } mPreviewFlag = false; } public int getRecordState() { return mCurrentState; } public void updateBeautyParam(@NonNull BeautyParams beautyParams) { mUGCKitRecordConfig.mBeautyParams = beautyParams; if (mRecordSDK != null) { mRecordSDK.getBeautyManager().setBeautyStyle(beautyParams.mBeautyStyle); mRecordSDK.getBeautyManager().setBeautyLevel(beautyParams.mBeautyLevel); mRecordSDK.getBeautyManager().setWhitenessLevel(beautyParams.mWhiteLevel); mRecordSDK.getBeautyManager().setRuddyLevel(beautyParams.mRuddyLevel); mRecordSDK.getBeautyManager().setFaceSlimLevel(beautyParams.mFaceSlimLevel); mRecordSDK.getBeautyManager().setEyeScaleLevel(beautyParams.mBigEyeLevel); mRecordSDK.getBeautyManager().setFaceVLevel(beautyParams.mFaceVLevel); mRecordSDK.getBeautyManager().setFaceShortLevel(beautyParams.mFaceShortLevel); mRecordSDK.getBeautyManager().setChinLevel(beautyParams.mChinSlimLevel); mRecordSDK.getBeautyManager().setNoseSlimLevel(beautyParams.mNoseSlimLevel); mRecordSDK.getBeautyManager().setMotionTmpl(beautyParams.mMotionTmplPath); mRecordSDK.getBeautyManager().setEyeLightenLevel(beautyParams.mEyeLightenLevel); mRecordSDK.getBeautyManager().setToothWhitenLevel(beautyParams.mToothWhitenLevel); mRecordSDK.getBeautyManager().setWrinkleRemoveLevel(beautyParams.mWrinkleRemoveLevel); mRecordSDK.getBeautyManager().setPounchRemoveLevel(beautyParams.mPounchRemoveLevel); mRecordSDK.getBeautyManager().setSmileLinesRemoveLevel(beautyParams.mSmileLinesRemoveLevel); mRecordSDK.getBeautyManager().setForeheadLevel(beautyParams.mForeheadLevel); mRecordSDK.getBeautyManager().setEyeDistanceLevel(beautyParams.mEyeDistanceLevel); mRecordSDK.getBeautyManager().setEyeAngleLevel(beautyParams.mEyeAngleLevel); mRecordSDK.getBeautyManager().setMouthShapeLevel(beautyParams.mMouthShapeLevel); mRecordSDK.getBeautyManager().setNoseWingLevel(beautyParams.mNoseWingLevel); mRecordSDK.getBeautyManager().setNosePositionLevel(beautyParams.mNosePositionLevel); mRecordSDK.getBeautyManager().setLipsThicknessLevel(beautyParams.mLipsThicknessLevel); mRecordSDK.getBeautyManager().setFaceBeautyLevel(beautyParams.mFaceBeautyLevel); mRecordSDK.getBeautyManager().setGreenScreenFile(beautyParams.mGreenFile); mRecordSDK.getBeautyManager().setFilterStrength(beautyParams.mFilterStrength / 10.f); } } public void updateMotionParam(@NonNull BeautyParams beautyParams) { if (mRecordSDK != null) { mRecordSDK.getBeautyManager().setMotionTmpl(beautyParams.mMotionTmplPath); } } /** * 更新当前屏比 */ public void updateAspectRatio() { int aspectRatio = UGCKitRecordConfig.getInstance().mAspectRatio; switch (aspectRatio) { case TXRecordCommon.VIDEO_ASPECT_RATIO_9_16: if (mRecordSDK != null) { mRecordSDK.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_9_16); } break; case TXRecordCommon.VIDEO_ASPECT_RATIO_3_4: if (mRecordSDK != null) { mRecordSDK.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_3_4); } break; case TXRecordCommon.VIDEO_ASPECT_RATIO_1_1: if (mRecordSDK != null) { mRecordSDK.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_1_1); } break; case TXRecordCommon.VIDEO_ASPECT_RATIO_4_3: if (mRecordSDK != null) { mRecordSDK.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_4_3); } break; case TXRecordCommon.VIDEO_ASPECT_RATIO_16_9: if (mRecordSDK != null) { mRecordSDK.setAspectRatio(TXRecordCommon.VIDEO_ASPECT_RATIO_16_9); } break; } } /** * 拍照API {@link TXUGCRecord#snapshot(TXRecordCommon.ITXSnapshotListener)} */ public void takePhoto(@Nullable final RecordModeView.OnSnapListener listener) { if (mRecordSDK != null) { mRecordSDK.snapshot(new TXRecordCommon.ITXSnapshotListener() { @Override public void onSnapshot(final Bitmap bitmap) { String fileName = System.currentTimeMillis() + ".jpg"; MediaStore.Images.Media.insertImage(UGCKit.getAppContext().getContentResolver(), bitmap, fileName, null); BackgroundTasks.getInstance().runOnUiThread(new Runnable() { @Override public void run() { if (listener != null) { listener.onSnap(bitmap); } } }); } }); } } public TXUGCPartsManager getPartManager() { if (mRecordSDK != null) { return mRecordSDK.getPartsManager(); } return null; } /** * 初始化草稿箱功能 * * @param context */ public void initRecordDraft(Context context) { mRecordDraftManager = new RecordDraftManager(context); RecordDraftInfo lastDraftInfo = mRecordDraftManager.getLastDraftInfo(); if (lastDraftInfo == null) { return; } List<RecordDraftInfo.RecordPart> recordPartList = lastDraftInfo.getPartList(); if (recordPartList == null || recordPartList.size() == 0) { return; } long duration = 0; int recordPartSize = recordPartList.size(); Log.d(TAG, "initRecordDraft recordPartSize:" + recordPartSize); for (int i = 0; i < recordPartSize; i++) { RecordDraftInfo.RecordPart recordPart = recordPartList.get(i); if (mRecordSDK != null) { mRecordSDK.getPartsManager().insertPart(recordPart.getPath(), i); } TXVideoEditConstants.TXVideoInfo txVideoInfo = TXVideoInfoReader.getInstance(context).getVideoFileInfo(recordPart.getPath()); if (txVideoInfo != null) { duration = duration + txVideoInfo.duration; } if (mOnRestoreDraftListener != null) { mOnRestoreDraftListener.onDraftProgress((int) duration); } } if (recordPartList != null && recordPartList.size() > 0) { if (mOnRestoreDraftListener != null) { mOnRestoreDraftListener.onDraftTotal(mRecordSDK.getPartsManager().getDuration()); } } } public void setOnRestoreDraftListener(OnRestoreDraftListener listener) { mOnRestoreDraftListener = listener; } public void setConfig(UGCKitRecordConfig config) { mUGCKitRecordConfig = config; } public interface OnRestoreDraftListener { void onDraftProgress(long duration); void onDraftTotal(long duration); } public void deleteAllParts() { if (mRecordSDK != null) { mRecordSDK.getPartsManager().deleteAllParts(); } // 草稿箱也相应删除 if (mRecordDraftManager != null) { mRecordDraftManager.deleteLastRecordDraft(); } } /** * 保存上一段录制的视频到草稿箱 */ public void saveLastPart() { if (mRecordSDK != null && mRecordDraftManager != null) { List<String> pathList = mRecordSDK.getPartsManager().getPartsPathList(); String lastPath = pathList.get(pathList.size() - 1); mRecordDraftManager.saveLastPart(lastPath); } } /** * 从草稿箱删除上一段录制的视频 */ public void deleteLastPart() { mRecordSDK.getPartsManager().deleteLastPart(); // 删除草稿 if (mRecordDraftManager != null) { mRecordDraftManager.deleteLastPart(); } } /** * 开始录制 */ public int startRecord() { Log.d(TAG, "startRecord mCurrentState" + mCurrentState); if (mCurrentState == STATE_STOP) { String customVideoPath = VideoPathUtil.getCustomVideoOutputPath(); String customCoverPath = customVideoPath.replace(".mp4", ".jpg"); int retCode = 0; if (mRecordSDK != null) { retCode = mRecordSDK.startRecord(customVideoPath, customCoverPath); } Log.d(TAG, "startRecord retCode:" + retCode); if (retCode != TXRecordCommon.START_RECORD_OK) { if (retCode == TXRecordCommon.START_RECORD_ERR_NOT_INIT) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getString(R.string.ugckit_start_record_not_init)); } else if (retCode == TXRecordCommon.START_RECORD_ERR_IS_IN_RECORDING) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getString(R.string.ugckit_start_record_not_finish)); } else if (retCode == TXRecordCommon.START_RECORD_ERR_VIDEO_PATH_IS_EMPTY) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getString(R.string.ugckit_start_record_path_empty)); } else if (retCode == TXRecordCommon.START_RECORD_ERR_API_IS_LOWER_THAN_18) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getString(R.string.ugckit_start_record_version_below)); } // 增加了TXUgcSDK.licence校验的返回错误码 else if (retCode == TXRecordCommon.START_RECORD_ERR_LICENCE_VERIFICATION_FAILED) { ToastUtil.toastShortMessage("licence校验失败,请调用TXUGCBase.getLicenceInfo(Context context)获取licence信息"); } return START_RECORD_FAIL; } LogReport.getInstance().reportStartRecord(retCode); RecordMusicManager.getInstance().startMusic(); } else if (mCurrentState == STATE_PAUSE) { resumeRecord(); } mCurrentState = STATE_START; return START_RECORD_SUCC; } /** * 继续录制 */ public void resumeRecord() { Log.d(TAG, "resumeRecord"); if (mRecordSDK != null) { mRecordSDK.resumeRecord(); } RecordMusicManager.getInstance().resumeMusic(); AudioFocusManager.getInstance().requestAudioFocus(); mCurrentState = STATE_RESUME; } /** * 暂停录制 * FIXBUG:被打断时调用,暂停录制,修改状态,跳转到音乐界面也会被调用 */ public void pauseRecord() { Log.d(TAG, "pauseRecord"); if (mCurrentState == STATE_START || mCurrentState == STATE_RESUME) { RecordMusicManager.getInstance().pauseMusic(); if (mRecordSDK != null) { mRecordSDK.pauseRecord(); } mCurrentState = STATE_PAUSE; } mPreviewFlag = false; AudioFocusManager.getInstance().abandonAudioFocus(); } /** * 停止录制 */ public void stopRecord() { Log.d(TAG, "stopRecord"); int size = 0; if (mRecordSDK != null) { size = mRecordSDK.getPartsManager().getPartsPathList().size(); } if (mCurrentState == STATE_STOP && size == 0) { //如果录制未开始,且录制片段个数为0,则不需要停止录制 return; } if (mRecordSDK != null) { mRecordSDK.stopBGM(); mRecordSDK.stopRecord(); } AudioFocusManager.getInstance().abandonAudioFocus(); mCurrentState = STATE_STOP; } /** * 释放Record SDK资源 */ public void releaseRecord() { Log.d(TAG, "releaseRecord"); if (mRecordSDK != null) { mRecordSDK.stopBGM(); mRecordSDK.stopCameraPreview(); mRecordSDK.setVideoRecordListener(null); mRecordSDK.getPartsManager().deleteAllParts(); mRecordSDK.release(); mRecordSDK = null; mPreviewFlag = false; RecordMusicManager.getInstance().deleteMusic(); } // 删除草稿箱视频片段 if (mRecordDraftManager != null) { mRecordDraftManager.deleteLastRecordDraft(); } AudioFocusManager.getInstance().abandonAudioFocus(); } public void setFilter(Bitmap leftBmp, float leftSpecialRatio, Bitmap rightBmp, float rightSpecialRatio, float leftRatio) { if (mRecordSDK != null) { mRecordSDK.setFilter(leftBmp, leftSpecialRatio, rightBmp, rightSpecialRatio, leftRatio); } } public void setRecordSpeed(int speed) { if (mRecordSDK != null) { mRecordSDK.setRecordSpeed(speed); } } public void setVideoRecordListener(OnVideoRecordListener listener) { mOnVideoRecordListener = listener; } @Override public void onRecordEvent(int event, Bundle param) { if (event == TXRecordCommon.EVT_ID_PAUSE) { saveLastPart(); if (mOnVideoRecordListener != null) { mOnVideoRecordListener.onRecordEvent(); } } else if (event == TXRecordCommon.EVT_CAMERA_CANNOT_USE) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getResources().getString(R.string.ugckit_video_record_activity_on_record_event_evt_camera_cannot_use)); } else if (event == TXRecordCommon.EVT_MIC_CANNOT_USE) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getResources().getString(R.string.ugckit_video_record_activity_on_record_event_evt_mic_cannot_use)); } } @Override public void onRecordProgress(long milliSecond) { if (mOnVideoRecordListener != null) { mOnVideoRecordListener.onRecordProgress(milliSecond); } } @Override public void onRecordComplete(@NonNull TXRecordCommon.TXRecordResult result) { Log.d(TAG, "onRecordComplete"); mCurrentState = STATE_STOP; if (result.retCode < 0) { ToastUtil.toastShortMessage(UGCKit.getAppContext().getResources().getString(R.string.ugckit_video_record_activity_on_record_complete_fail_tip) + result.descMsg); } else { pauseRecord(); mRecordVideoPath = result.videoPath; if (mOnVideoRecordListener != null) { mOnVideoRecordListener.onRecordComplete(result); } } } public String getRecordVideoPath() { return mRecordVideoPath; } public void switchCamera(boolean isFront) { TXUGCRecord record = getRecorder(); if (record != null) { record.switchCamera(isFront); } if (mUGCKitRecordConfig != null) { mUGCKitRecordConfig.mFrontCamera = isFront; } } public interface OnVideoRecordListener { void onRecordProgress(long milliSecond); void onRecordEvent(); void onRecordComplete(TXRecordCommon.TXRecordResult result); } }
5450fb90496b6d0f69f17ea99e5cb6cdfc4dc121
d66f6804bb3b72e3aa1b161fc5194504a9b3cf8f
/app/src/main/java/com/rirsas/user/dinnerselect/ViewPagerAdapter.java
e1dc98e48d956eff2b23b531e1c973dde4aa16a4
[]
no_license
RIRSAS/reposDinnerSelect
5acf5b284843ce1e05605174683d8be1997b6e4e
b479d0a38bc56c0456f1676098cd7cd275411cad
refs/heads/master
2021-01-21T04:25:09.858346
2016-07-20T14:32:13
2016-07-20T14:32:13
58,814,002
0
0
null
null
null
null
UTF-8
Java
false
false
1,135
java
package com.rirsas.user.dinnerselect; import com.rirsas.user.dinnerselect.viewpagerMainPage; import com.rirsas.user.dinnerselect.viewpagerSubPage; import android.os.Parcel; import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.VelocityTrackerCompat; /** * Created by USER on 2016/06/19. */ public class ViewPagerAdapter extends FragmentStatePagerAdapter{ public ViewPagerAdapter(FragmentManager fm){ super(fm); } public Fragment getItem(int i){ switch(i){ case 0: return new viewpagerMainPage(); default: return new viewpagerSubPage(); } } @Override public int getCount(){ return 2; } @Override public CharSequence getPageTitle(int position){ switch(position){ case 0: return "メインページ"; default: return "サブページ"; } // return "Page" + position; } }
6568647beecf8523f465991b39483127350bcef9
3f462352ae70e48ee5a71914e2ae112cb247ee63
/Projects/chapter-07/LogicGate/src/logicgatepack/Connector.java
6e0664bc439ea8070628bf06eceedce11e8b7b9a
[]
no_license
Dan12/APCS-Projects
e2226296bf4b5691a153c622a2c10106cc0f7b67
f9fe545e158d006d69a0cd87cf9c32ad209db25c
refs/heads/master
2021-01-10T17:58:50.549856
2015-10-23T01:07:12
2015-10-23T01:07:12
44,781,361
0
0
null
null
null
null
UTF-8
Java
false
false
1,181
java
package logicgatepack; import java.awt.Color; import java.awt.Graphics; public class Connector { int conX1; int conY1; int conXO1; int conYO1; int conX2; int conY2; int conXO2; int conYO2; String cID1; String cID2; public Connector(int x, int y, String id, int xo, int yo){ conX1 = x; conX2 = x+xo; conY1 = y; conY2 = y+yo; conXO1 = xo; conYO1 = yo; conXO2 = 0; conYO2 = 0; cID1 = id; } public void drawConnector(Graphics g){ g.setColor(Color.BLACK); g.drawLine(conX1+conXO1, conY1+conYO1, conX2+conXO2, conY2+conYO2); } public void moveStart(int x, int y){ conX1 = x; conY1 = y; } public void moveEnd(int x, int y){ conX2 = x; conY2 = y; } public void placeEnd(int x, int y, String id, int xo, int yo){ conX2 = x; conY2 = y; conXO2 = xo; conYO2 = yo; cID2 = id; } public void changePosition(int x, int y){ conX1 += x; conY1 += y; conX2 += x; conY2 += y; } }
fcafb2c3897e9e1b7e013b22692c0b61d05de91e
ee32133c38272a9ad9d4d3212110c0a20b2db019
/app/src/main/java/com/tvt11/timemanagingapp/util/AppConstants.java
bf78d1cf3a614a67c1e9e1190b3db77c015b31b7
[ "MIT" ]
permissive
vitran96/time_managing_app
765d72aeab4ad15cea5dbbc2540fd5b30bf8e9b3
2ae75754ccfef5c0b02276476dc245743046287d
refs/heads/master
2022-01-05T22:09:21.333986
2019-05-10T12:07:07
2019-05-10T12:07:07
null
0
0
null
null
null
null
UTF-8
Java
false
false
183
java
package com.tvt11.timemanagingapp.util; public class AppConstants { public static final String ACTION_CANCEL ="cancel"; public static final String ACTION_FINISH ="finish"; }
71b6420e9e1b89369e6a16479b87f0ddb9457cc3
84675d3b507f5dfba93279bc6c4df8afcc5a6ae1
/cidade/src/tela/listagem/ListagemCidade.java
8c0a47364553d1596aca4525e7cb7438db1dbac9
[]
no_license
francescafborn/prova_cidade
21774658bc75b3857a1588094c6f5c35a8128f82
f222d3191582d3e0034599178c57e70424d05d10
refs/heads/master
2020-08-18T15:17:01.421880
2019-10-17T15:39:25
2019-10-17T15:39:25
215,805,755
0
0
null
null
null
null
UTF-8
Java
false
false
7,687
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package tela.listagem; import controlador.ControladorCidade; import tela.manutencao.ManutencaoCidade; /** * * @author Administrador */ public class ListagemCidade extends javax.swing.JDialog { /** * Creates new form ListagemCidade */ public ListagemCidade(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); ControladorCidade.atualizarTabela(tabela); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); tabela = new javax.swing.JTable(); jLabel1 = new javax.swing.JLabel(); btnNovo = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); tabela.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4", "Título 5", "Título 6", "Título 7" } )); tabela.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { tabelaMousePressed(evt); } }); jScrollPane1.setViewportView(tabela); jLabel1.setText("Tabela Cidade"); btnNovo.setText("Novo"); btnNovo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNovoActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(btnNovo) .addGap(179, 179, 179)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(180, 180, 180) .addComponent(jLabel1))) .addContainerGap(25, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39) .addComponent(btnNovo) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed ManutencaoCidade manutencao = new ManutencaoCidade(null, true, this); manutencao.setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_btnNovoActionPerformed private void tabelaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaMousePressed if (evt.getClickCount() == 2) { //obtem a linha selecionada int linhaSelecionada = tabela.getSelectedRow(); //obtém a chave primária int pk = Integer.parseInt(tabela.getValueAt(linhaSelecionada, 6).toString()); //pk está na coluna 0 //abre a manutenção ManutencaoCidade manutencao = new ManutencaoCidade(null, true, this, pk); manutencao.setVisible(true); } // TODO add your handling code here: }//GEN-LAST:event_tabelaMousePressed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ListagemCidade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ListagemCidade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ListagemCidade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ListagemCidade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { ListagemCidade dialog = new ListagemCidade(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables public javax.swing.JButton btnNovo; private javax.swing.JLabel jLabel1; private javax.swing.JScrollPane jScrollPane1; public javax.swing.JTable tabela; // End of variables declaration//GEN-END:variables }
443190342a9f876840d22f33c5cbf5f32fed819a
ca030864a3a1c24be6b9d1802c2353da4ca0d441
/classes10.dex_source_from_JADX/com/facebook/messaging/sync/delta/handler/DeltaNoOpHandler.java
834b13db704857cffe15d430ab960e6f8b8d74af
[]
no_license
pxson001/facebook-app
87aa51e29195eeaae69adeb30219547f83a5b7b1
640630f078980f9818049625ebc42569c67c69f7
refs/heads/master
2020-04-07T20:36:45.758523
2018-03-07T09:04:57
2018-03-07T09:04:57
124,208,458
4
0
null
null
null
null
UTF-8
Java
false
false
4,108
java
package com.facebook.messaging.sync.delta.handler; import android.os.Bundle; import com.facebook.auth.userscope.UserScoped; import com.facebook.messaging.model.threadkey.ThreadKey; import com.facebook.messaging.sync.delta.PrefetchedSyncData; import com.facebook.messaging.sync.delta.handlerbase.AbstractMessagesDeltaHandler; import com.facebook.messaging.sync.model.thrift.DeltaWrapper; import com.facebook.sync.delta.DeltaWithSequenceId; import com.google.common.collect.ImmutableSet; import com.google.common.collect.RegularImmutableSet; @UserScoped /* compiled from: privacy_can_guest_invite_friends_toggled */ public class DeltaNoOpHandler extends AbstractMessagesDeltaHandler { private static final Object f4543a = new Object(); private static DeltaNoOpHandler m4111a() { return new DeltaNoOpHandler(); } public final boolean mo127b(DeltaWrapper deltaWrapper) { return false; } public final Bundle mo124a(PrefetchedSyncData prefetchedSyncData, DeltaWithSequenceId deltaWithSequenceId) { return null; } public final ImmutableSet<ThreadKey> mo126a(DeltaWrapper deltaWrapper) { return RegularImmutableSet.a; } public final void m4115a(Bundle bundle, DeltaWithSequenceId deltaWithSequenceId) { } /* JADX WARNING: inconsistent code. */ /* Code decompiled incorrectly, please refer to instructions dump. */ public static com.facebook.messaging.sync.delta.handler.DeltaNoOpHandler m4112a(com.facebook.inject.InjectorLike r7) { /* r2 = com.facebook.inject.ScopeSet.a(); r0 = com.facebook.auth.userscope.UserScope.class; r0 = r7.getInstance(r0); r0 = (com.facebook.auth.userscope.UserScope) r0; r1 = r7.getScopeAwareInjector(); r1 = r1.b(); if (r1 != 0) goto L_0x001e; L_0x0016: r0 = new com.facebook.inject.ProvisioningException; r1 = "Called user scoped provider outside of context scope"; r0.<init>(r1); throw r0; L_0x001e: r3 = r0.a(r1); r4 = r3.b(); Catch:{ all -> 0x006b } r1 = f4543a; Catch:{ all -> 0x006b } r1 = r4.get(r1); Catch:{ all -> 0x006b } r5 = com.facebook.auth.userscope.UserScope.a; Catch:{ all -> 0x006b } if (r1 != r5) goto L_0x0035; L_0x0030: r3.c(); r0 = 0; L_0x0034: return r0; L_0x0035: if (r1 != 0) goto L_0x007b; L_0x0037: r1 = 4; r5 = r2.b(r1); Catch:{ } r6 = r0.a(r3); Catch:{ all -> 0x0066 } r6.e(); Catch:{ all -> 0x0061 } r1 = m4111a(); Catch:{ all -> 0x0061 } com.facebook.auth.userscope.UserScope.a(r6); Catch:{ } if (r1 != 0) goto L_0x0070; L_0x004c: r0 = f4543a; Catch:{ } r6 = com.facebook.auth.userscope.UserScope.a; Catch:{ } r0 = r4.putIfAbsent(r0, r6); Catch:{ } r0 = (com.facebook.messaging.sync.delta.handler.DeltaNoOpHandler) r0; Catch:{ } L_0x0056: if (r0 == 0) goto L_0x0079; L_0x0058: r2.c(r5); Catch:{ } L_0x005b: r0 = (com.facebook.messaging.sync.delta.handler.DeltaNoOpHandler) r0; Catch:{ } r3.c(); goto L_0x0034; L_0x0061: r0 = move-exception; com.facebook.auth.userscope.UserScope.a(r6); Catch:{ } throw r0; Catch:{ } L_0x0066: r0 = move-exception; r2.c(r5); Catch:{ } throw r0; Catch:{ } L_0x006b: r0 = move-exception; r3.c(); throw r0; L_0x0070: r0 = f4543a; Catch:{ } r0 = r4.putIfAbsent(r0, r1); Catch:{ } r0 = (com.facebook.messaging.sync.delta.handler.DeltaNoOpHandler) r0; Catch:{ } goto L_0x0056; L_0x0079: r0 = r1; goto L_0x0058; L_0x007b: r0 = r1; goto L_0x005b; */ throw new UnsupportedOperationException("Method not decompiled: com.facebook.messaging.sync.delta.handler.DeltaNoOpHandler.a(com.facebook.inject.InjectorLike):com.facebook.messaging.sync.delta.handler.DeltaNoOpHandler"); } }
d4978689cb754f3ae26f2aaab9151a06ca09ad57
d5dabc20b908c874e4d3ae0fe83d70b94b5d6e98
/app/src/test/java/com/example/asus/skripsi/ExampleUnitTest.java
6e2df24b9906ba18b0bd2938f01ef416323d2782
[]
no_license
muhammadrofiq/G-Trans
d585e3996b367da773cd6c8363a14d14b02a4558
b41f201c7ad6a9b6787100066274b430505d2b2f
refs/heads/master
2020-03-27T16:03:55.426073
2018-08-30T14:15:49
2018-08-30T14:15:49
144,647,067
0
0
null
null
null
null
UTF-8
Java
false
false
402
java
package com.example.asus.skripsi; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } }
ef2ffe442bd3e927ce554e9ee4d76f523eba1617
f7d18d4ca2de68c29e7f580e6b803b79c0847068
/src/A_HomeWork/camelLetterInEachWord.java
7fb76bdc6b810839cb77ad7f61786369cbb59ffd
[]
no_license
RdmBad/java-practice
d3f1a147b7db4a5668cc377d5c8d1c02e06b5cae
55e953a260c5e6a1aae9d1ff5038511554f27123
refs/heads/master
2022-05-14T15:48:19.428802
2019-05-29T22:22:28
2019-05-29T22:22:28
null
0
0
null
null
null
null
UTF-8
Java
false
false
488
java
package A_HomeWork; import java.util.Arrays; public class camelLetterInEachWord { public static void main(String[] args) { String str = "java is fun"; int idx = 0; String first = ""; String temp = ""; String word = ""; String[] arr = str.split(" "); for(int i = 0; i < arr.length; i++) { first = arr[i].substring(0,1); word = first.toUpperCase() + arr[i].substring(1); temp += word + " "; } temp = temp.substring(0, temp.length()-1); System.out.println(temp); } }
9c68e51e969c310fde63d58fe90686bc7d236107
9c26c293dcd6ce6d4011a873c2483828129a1ca0
/assignment 2/assignment2 final 2/src/calculator/Calculator.java
ae61bffdec30c875e81fc3029872d75d2960ca25
[]
no_license
isaurabh19/program-design-java
4b9b39116641e8fd7ad6810f0d280676cdb597a0
e61d73ef673dc6918d3435f54aa83fbe9c2ffa8e
refs/heads/master
2022-12-15T18:25:39.632403
2020-09-10T17:48:36
2020-09-10T17:48:36
294,481,885
0
0
null
null
null
null
UTF-8
Java
false
false
1,457
java
package calculator; /** * A calculator that works with whole numbers only and supports three arithmetic operations : * addition(+), subtraction(-) and multiplication(*). The interface simulates a real time calculator * like input i.e. it takes one character at a time as input and displays the current state of * output so far. */ public interface Calculator { /** * It allows to input operators operands and special inputs like 'C' and '=' one character at a * time. It checks for validity of the input sequence and proceeds ahead if valid, otherwise * throws exceptions. It clears the input on input 'C'. On '=' displays the arithmetic result up * to that point. * * @param input A single character literal representing the input for calculator. * @return A new Calculator instance with current result stored in it. * @throws IllegalArgumentException on illegal sequence of characters or illegal character * itself. * @throws RuntimeException if the operand overflows either on input or on calculation. */ Calculator input(char input) throws IllegalArgumentException, RuntimeException; /** * It displays the result of the calculator at the current state as a String. Formats the output * if it doesn't resemble a presentable format. * * @return a String containing the input of the calculator so far (at the time of calling). */ String getResult(); }
b8a2e50ba443ec1d2b19db7e85942277710b279d
364ae53a3d58cddda15f9a9a9acfad0103eee5eb
/app/src/main/java/mypocketvakil/example/com/score/activity/work_posted.java
cfbb7298ee17aa5eb3067ba68d7191860ad5f401
[]
no_license
sanyamjain65/Score
a44710695ec17e400a899a89390c9c42cc05ac07
e90172e7a6c1d94727f327ce3a85972d3789dbdc
refs/heads/master
2020-12-31T06:10:04.060697
2017-04-06T19:53:27
2017-04-06T19:53:27
80,620,051
0
0
null
null
null
null
UTF-8
Java
false
false
5,127
java
package mypocketvakil.example.com.score.activity; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; import android.widget.ProgressBar; import org.json.JSONArray; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import mypocketvakil.example.com.score.Adapters.WorkPostedAdapter; import mypocketvakil.example.com.score.NetworkCall.HttpHandler; import mypocketvakil.example.com.score.NetworkCall.NetworkKeys; import mypocketvakil.example.com.score.R; public class work_posted extends AppCompatActivity { String jsonStr; private static final String TAG = work_posted.class.getSimpleName(); ListView work_listview; String id; ArrayList<HashMap<String, String>> contactlist; ProgressBar progressBar; String[] id1=new String[20]; WorkPostedAdapter workPostedAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_work_posted); work_listview=(ListView)findViewById(R.id.work_listview); contactlist = new ArrayList<>(); progressBar=(ProgressBar)findViewById(R.id.work_progressBar); work_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { new Handler().postDelayed(new Runnable() { @Override public void run() { Intent intent=new Intent(work_posted.this,Bid_Posted.class); intent.putExtra("id",id1[i]); startActivity(intent); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } },100); } }); new postUser().execute(); } @Override public void onBackPressed() { new Handler().postDelayed(new Runnable() { @Override public void run() { Intent i=new Intent(work_posted.this,user.class); startActivity(i); overridePendingTransition(R.anim.slide_left, R.anim.slide_right); finish(); } }, 100); } private class postUser extends AsyncTask<Void, Void, Void> { String img; Bitmap decodebitmap; @Override protected Void doInBackground(Void... params) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(work_posted.this); id = String.valueOf(sharedPref.getInt("id", -1)); HttpHandler sh = new HttpHandler(); jsonStr = sh.makeServiceCall(NetworkKeys.NET_KEY.POST_USER+id+"/"); Log.e(TAG, "Response from url: " + jsonStr); if (jsonStr != null) { try { JSONArray contacts = new JSONArray(jsonStr); for (int i = 0; i < contacts.length(); i++) { JSONObject c = contacts.getJSONObject(i); String title=c.getString("work"); String image=c.getString("image"); id1[i]=c.getString("id"); if(image.equals("no image")){ img="no image"; } else{ img=image; // imageView.setImageBitmap(decodebitmap); } HashMap<String,String> contact=new HashMap<>(); contact.put("title", title); contact.put("image", img); contactlist.add(contact); } } catch (Exception e) { Log.e(TAG, "Json parsing error: " + e.getMessage()); } } return null; } @Override protected void onPreExecute() { super.onPreExecute(); progressBar.setVisibility(View.VISIBLE); } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); if (progressBar.isShown()) { progressBar.setVisibility(View.GONE); } // ListAdapter listAdapter = new SimpleAdapter(work_posted.this, contactlist, R.layout.work_list_items, new String[]{"title","image"}, new int[]{R.id.tv_list_title,R.id.iv_work_list}); // work_listview.setAdapter(listAdapter); workPostedAdapter=new WorkPostedAdapter(work_posted.this, contactlist); work_listview.setAdapter(workPostedAdapter); } } }
1ac7214c678244131e091a91746595f416434dc4
ff74949d46d0bc152caf19361a5b046944bb3005
/src/main/java/danceschool/javaversion/controller/InstructorController.java
e68acfeb498af85eb67ce3cdbe07ac2f2c7e506e
[]
no_license
Zoe-0925/danceschool-java
ffdaf48fea026f01f8554fb8e63791ae9e19590b
7bdce89373a46c8f5268f7459e114bdc6f8377cf
refs/heads/master
2023-04-16T01:56:08.741065
2021-04-30T04:46:24
2021-04-30T04:46:24
361,623,027
0
0
null
null
null
null
UTF-8
Java
false
false
2,013
java
package danceschool.javaversion.controller; import danceschool.javaversion.model.Instructor; import danceschool.javaversion.service.InstructorService; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/instructors") public class InstructorController { @Autowired InstructorService service; @GetMapping public ResponseEntity findAllInstructors() { List<Instructor> list = service.getAll(); if (list == null) { return ResponseEntity.notFound().build(); } else { return ResponseEntity.ok(list); } } @GetMapping("/{id}") public ResponseEntity<Instructor> findInstructorById( @PathVariable(value = "id") long id ) { return null; // Implement } //TODO @PostMapping public ResponseEntity saveInstructor(@RequestBody Instructor entity) { try { Long id = service.create(entity); return ResponseEntity.ok(id); } catch (Exception e) { //TODO return null; } } @PutMapping public ResponseEntity updateInstructor(@RequestBody Instructor entity) { try { service.update(entity); return ResponseEntity.ok().build(); } catch (Exception e) { //TODO return ResponseEntity.notFound().build(); } } @DeleteMapping("/{id}") public ResponseEntity deleteInstructor(@PathVariable("id") Long id) { service.delete(id); return ResponseEntity.noContent().build(); } }
5a059ee1050f30efc89965b59d407f6d44e8cadf
3fb819ff26fba5a1bb18260e34b4a8c8a166edbb
/app/src/main/java/fiordor/fiocca/quotations/custom/FavouriteAdapter.java
2fe73f0cf2a2de308cb6601e320dff1a7c454a9b
[]
no_license
Fiordor/Quotations
dc0017d82a711231b6805bf4e30e2119c4a1289c
2943393e8220710b2a1a7c045eeff14d5cf39c26
refs/heads/main
2023-03-21T07:00:47.921560
2021-03-04T21:23:55
2021-03-04T21:23:55
343,154,203
0
0
null
null
null
null
UTF-8
Java
false
false
3,336
java
package fiordor.fiocca.quotations.custom; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import java.util.List; import fiordor.fiocca.quotations.R; public class FavouriteAdapter extends RecyclerView.Adapter<FavouriteAdapter.ViewHolder> { private List<Quotation> quotations; private OnItemClickListener onItemClick; private OnItemLongClickListener onItemLongClick; public FavouriteAdapter(List<Quotation> quotations, OnItemClickListener onItemClick, OnItemLongClickListener onItemLongClick) { this.quotations = quotations; this.onItemClick = onItemClick; this.onItemLongClick = onItemLongClick; } public void clearAllList() { quotations.clear(); notifyDataSetChanged(); } public Quotation getQuoteUsingListPosition(int position) { return quotations.get(position); } public Quotation removeQuoteUsingListPosition(int position) { Quotation q = quotations.remove(position); notifyItemRemoved(position); return q; } @NonNull @Override public FavouriteAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.quotation_list_row, parent, false); FavouriteAdapter.ViewHolder holder = new ViewHolder(view, onItemClick, onItemLongClick); return holder; } @Override public void onBindViewHolder(@NonNull FavouriteAdapter.ViewHolder holder, int position) { Quotation q = quotations.get(position); holder.quoteText.setText(q.getQuoteText()); holder.quoteAuthor.setText(q.getQuoteAuthor()); } @Override public int getItemCount() { return quotations.size(); } public interface OnItemClickListener { void onItemClickListener(int position); } public interface OnItemLongClickListener { void onItemLongClickListener(int position); } static class ViewHolder extends RecyclerView.ViewHolder { public TextView quoteText; public TextView quoteAuthor; private OnItemClickListener onItemClick; private OnItemLongClickListener onItemLongClick; public ViewHolder(@NonNull View itemView, OnItemClickListener onItemClick, OnItemLongClickListener onItemLongClick) { super(itemView); quoteText = itemView.findViewById(R.id.tvQuoteText); quoteAuthor = itemView.findViewById(R.id.tvQuoteAuthor); this.onItemClick = onItemClick; this.onItemLongClick = onItemLongClick; itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onItemClick.onItemClickListener(getAdapterPosition()); } }); itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { onItemLongClick.onItemLongClickListener(getAdapterPosition()); return true; } }); } } }
a71d2a5d8a6a908d922a08b881a613cbb8124828
bacfc49ff6f141e0467b41a854342194560d1c23
/core/src/com/fadeland/editor/map/Tile.java
fed56027d20b0b38ed53c9e1846169e5480cd4a4
[]
no_license
BambooBandit/fadelandEditor
b053a5295cf56503957a11664678811ea46a3d0c
c61cbc0f3e9ff221c691405841070a1651ecc3f9
refs/heads/master
2021-06-20T10:33:43.346794
2019-10-18T18:20:05
2019-10-18T18:20:05
153,363,102
3
1
null
null
null
null
UTF-8
Java
false
false
3,299
java
package com.fadeland.editor.map; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import com.fadeland.editor.ui.tileMenu.TileTool; import static com.fadeland.editor.map.TileMap.tileSize; public class Tile { protected TileMap map; public Sprite sprite; protected float width, height; public Vector2 position; public TileTool tool; public boolean hasBeenPainted = false; public boolean hasBlockedObjectOnTop = false; public Layer layer; public Array<AttachedMapObject> drawableAttachedMapObjects; // For Tiles, and objects public Tile(TileMap map, Layer layer, float x, float y) { this.map = map; this.layer = layer; this.position = new Vector2(x, y); this.width = tileSize; this.height = tileSize; this.drawableAttachedMapObjects = new Array<>(); } // For MapSprites public Tile(TileMap map, TileTool tool, float x, float y) { this.map = map; this.sprite = new Sprite(tool.textureRegion); this.position = new Vector2(x, y); this.width = tileSize; this.height = tileSize; this.tool = tool; this.drawableAttachedMapObjects = new Array<>(); if(this.tool != null) { for (int i = 0; i < this.tool.mapObjects.size; i++) this.drawableAttachedMapObjects.add(new AttachedMapObject(this.tool.mapObjects.get(i), this)); } } public void setTool(TileTool tool) { this.drawableAttachedMapObjects.clear(); TileTool oldTool = this.tool; if(tool == null) this.sprite = null; else this.sprite = new Sprite(tool.textureRegion); this.tool = tool; if(this.tool != null) { for (int i = 0; i < this.tool.mapObjects.size; i++) this.drawableAttachedMapObjects.add(new AttachedMapObject(this.tool.mapObjects.get(i), this)); } if(oldTool != null) { for(int i = 0; i < oldTool.mapObjects.size; i ++) oldTool.mapObjects.get(i).updateLightsAndBodies(); } if(this.tool != null) { for(int i = 0; i < this.tool.mapObjects.size; i ++) this.tool.mapObjects.get(i).updateLightsAndBodies(); } } public void draw() { if(this.sprite != null) map.editor.batch.draw(sprite, position.x, position.y, width, height); } public void drawTopSprites() { if(this.sprite != null) { if(this.tool.topSprites != null) { for(int i = 0; i < this.tool.topSprites.size; i ++) map.editor.batch.draw(this.tool.topSprites.get(i), position.x, position.y); } } } public void setPosition(float x, float y) { this.position.set(x, y); if(this.sprite != null) this.sprite.setPosition(x, y); } public void addMapObject(AttachedMapObject mapObject) { // this.drawableAttachedMapObjects.add(new AttachedMapObject(mapObject, this)); this.tool.mapObjects.add(mapObject); map.addDrawableAttachedMapObjects(tool); } }
910266ef4a2e6cad9c4603c292dc1b67dcd29c3c
8eaf3a738dbe3cb1655538f9c5f68a90d7f6f8f9
/com.liferay.blade.api/src/com/liferay/blade/api/ProjectTemplate.java
272d6a9fde0858a762ee3fecb8a62f95c5131ddc
[ "Apache-2.0" ]
permissive
sez11a/liferay-blade-tools
59392a9938350aa5ef49b292e87ec1797b24e86d
6d8a8f9d37de7f3d5b13f56eea73b0102b795e65
refs/heads/master
2021-01-14T08:32:12.501283
2015-12-03T23:13:36
2015-12-03T23:13:36
46,747,900
0
0
null
2015-11-23T21:04:57
2015-11-23T21:04:57
null
UTF-8
Java
false
false
161
java
package com.liferay.blade.api; import org.osgi.annotation.versioning.ProviderType; @ProviderType public interface ProjectTemplate { public String name(); }
1354742f725f7b313c319db170bb261e645f09d4
d8c71cb0914467b52263929dd795f22f213ec8c8
/WEB-INF/classes/Inventory.java
4a50c46629574ba2d35c6729c741afd7b259545c
[]
no_license
Malhar-Patwari/Electronic-Shop-Web-Application
7a1d021e9d3455721db5c3ebc35efb9f2faeb785
ea17e224495c1a42968436d6c2c77d22ba291e1c
refs/heads/master
2020-05-17T21:26:04.575791
2019-04-28T23:47:37
2019-04-28T23:47:37
183,970,726
0
0
null
null
null
null
UTF-8
Java
false
false
2,582
java
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class Inventory extends HttpServlet { MySqlDataStoreUtilities ms = new MySqlDataStoreUtilities(); public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { PrintWriter out= response.getWriter(); String username = request.getParameter("username"); // Product product = new Product(); HttpSession session=request.getSession(); ArrayList<Product> products; String usertype = (String)session.getAttribute("usertype"); //String usert = user.usertype; Utilities utility = new Utilities(request,out); if(session.getAttribute("usertype").equals("StoreManager")) { //String n=(String)session.getAttribute("uname"); //users= (Users)session.getAttribute("user"); products=ms.checkInventory(); utility.printHtml("HeaderAdd.html"); out.println("<div id=\"body\">"); out.println("<section id=\"content\">"); out.println("<h2 align=\"center\" margin-top=\"60px\">Inventory List</h2>"); out.println("<table cellspacing=\"0\" class=\"shopping-cart\" style=\"Height:50px\"> "); out.println("<thead>"); out.println("<tr class=\"headings\">"); out.println("<th class=\"\">No.</td>"); out.println("<th class=\"\">Product Name</td>"); out.println("<th class=\"\">Price</td>"); out.println("<th class=\"\">Quantity</td>"); out.println("</tr>"); out.println("</thead>"); out.println("<tbody>"); int i= 1; for(Product product : products) { //Product product=(Product)entry.getValue(); out.println("<tr>"); out.println("<td class=\"productName\">"); out.println(i++); out.println("</td>"); out.println("<td class=\"productName\">"); out.println(product.getName()); out.println("</td>"); out.println("<td class=\"productName\">"); out.println(product.getPrice()); out.println("</td>"); out.println("<td class=\"productName\">"); out.println(product.getQuantity()); out.println("</td>"); out.println("</tr>"); } out.println("</tbody>"); out.println("</table>"); out.println("</section>"); //System.out.println("jsgdjs"+user.getusername()); utility.printHtml("Side_manager.html"); utility.printHtml("Footer.html"); } else { /*pw.println("Hello else");*/ utility.printHtml("Header.html"); utility.printHtml("product.html"); utility.printHtml("Sidebar.html"); utility.printHtml("Footer.html"); } } }
a3c96686ae4166b4ebf88d7fe3767e043047cb45
ff6a6f99770e6271e68bbedbfdcce8be7bd48e6e
/quiz-service/src/main/java/com/information/center/quizservice/model/SchoolDto.java
47a4c27937fe84b17627c41a228c20a42810662a
[ "MIT" ]
permissive
kolyaattila/information-center
a8ab6bbb235e073b1e7df26dbff81518c2ea5be3
cdb0ba313f0133c0aa6071683598f94f9d11cb5a
refs/heads/master
2022-12-20T20:59:17.831371
2021-04-30T20:30:48
2021-04-30T20:30:48
216,859,451
0
0
MIT
2022-12-10T05:47:26
2019-10-22T16:27:06
Java
UTF-8
Java
false
false
346
java
package com.information.center.quizservice.model; import lombok.Builder; import lombok.Getter; import lombok.Setter; import lombok.experimental.Tolerate; @Builder @Getter @Setter public class SchoolDto { @Tolerate public SchoolDto() { } private String externalId; private String name; private int numberOfQuestions; }
0c049992ef0c1f0b4d99bfc6b137f6486ef2d523
18b20ac21cc8effb72c1bf0f6b4757bad80ded02
/app/src/main/java/com/example/hospitalreviewsystem/AdapterForViewPager.java
f6c7f6bc592a448f19c0b4dc80f8f849d588ed3f
[]
no_license
NadsSani/HospitalReviewSystem
91b6ada22f43cd47e205fa72f33a317bfc2bc666
cb2aed646b02508cac4d48321d8e29b99ecdd46e
refs/heads/master
2020-05-30T16:45:15.280589
2019-05-27T17:35:35
2019-05-27T17:35:35
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,689
java
package com.example.hospitalreviewsystem; import android.content.Context; import android.support.annotation.NonNull; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.bumptech.glide.Glide; import java.util.ArrayList; public class AdapterForViewPager extends PagerAdapter { private Context context; ArrayList<String> list; private LayoutInflater layoutInflater; public AdapterForViewPager(Context context , ArrayList<String> arrayList) { this.context = context; this.list = arrayList; } @Override public int getCount() { return list.size(); } public Object instantiateItem(ViewGroup container, int position) { layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.image_for_sliding,null); ImageView imageView = (ImageView)view.findViewById(R.id.imageView); Glide.with(context).load(list.get(position)).into(imageView); //imageView.setImageResource(image[position]); ViewPager vp = (ViewPager)container; vp.addView(view,0); return view; } @Override public boolean isViewFromObject(@NonNull View view, @NonNull Object o) { return view == o; } @Override public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { ViewPager vp = (ViewPager)container; View view = (View)object; vp.removeView(view); } }
bc781d3ced4515080e576782be5008e56c96cf3b
48e835e6f176a8ac9ae3ca718e8922891f1e5a18
/benchmark/validation/org/axonframework/messaging/unitofwork/RollbackConfigurationTypeTest.java
e3206e16882b7720fab487ab2bf80a0686d9e0a2
[]
no_license
STAMP-project/dspot-experiments
f2c7a639d6616ae0adfc491b4cb4eefcb83d04e5
121487e65cdce6988081b67f21bbc6731354a47f
refs/heads/master
2023-02-07T14:40:12.919811
2019-11-06T07:17:09
2019-11-06T07:17:09
75,710,758
14
19
null
2023-01-26T23:57:41
2016-12-06T08:27:42
null
UTF-8
Java
false
false
2,011
java
/** * Copyright (c) 2010-2018. Axon Framework * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.axonframework.messaging.unitofwork; import org.junit.Assert; import org.junit.Test; import static RollbackConfigurationType.ANY_THROWABLE; import static RollbackConfigurationType.RUNTIME_EXCEPTIONS; import static RollbackConfigurationType.UNCHECKED_EXCEPTIONS; /** * * * @author Allard Buijze */ public class RollbackConfigurationTypeTest { @Test public void testAnyExceptionsRollback() { RollbackConfiguration testSubject = ANY_THROWABLE; Assert.assertTrue(testSubject.rollBackOn(new RuntimeException())); Assert.assertTrue(testSubject.rollBackOn(new Exception())); Assert.assertTrue(testSubject.rollBackOn(new AssertionError())); } @Test public void testUncheckedExceptionsRollback() { RollbackConfiguration testSubject = UNCHECKED_EXCEPTIONS; Assert.assertTrue(testSubject.rollBackOn(new RuntimeException())); Assert.assertFalse(testSubject.rollBackOn(new Exception())); Assert.assertTrue(testSubject.rollBackOn(new AssertionError())); } @Test public void testRuntimeExceptionsRollback() { RollbackConfiguration testSubject = RUNTIME_EXCEPTIONS; Assert.assertTrue(testSubject.rollBackOn(new RuntimeException())); Assert.assertFalse(testSubject.rollBackOn(new Exception())); Assert.assertFalse(testSubject.rollBackOn(new AssertionError())); } }
d09a76db5cebb2d524babdb3a67da1c9ad465e51
26b1c036a7369350ab7201d9e2ead8d417578b9b
/baseutil/src/main/java/vip/mae/baseutil/UserService.java
a6c7412a934269009f0e9a088239f1bee7fb9296
[]
no_license
ytzht/PicScore
db57b0da25b8ec49b816c13c7897d830a04f4b25
eccbf6ee53b82205da2ff5523fd024eb6fab6e59
refs/heads/master
2020-04-08T18:56:49.221345
2018-11-29T08:47:17
2018-11-29T08:47:17
159,631,590
0
0
null
null
null
null
UTF-8
Java
false
false
6,137
java
package vip.mae.baseutil; import android.content.Context; import android.content.SharedPreferences; /** * Created by zht on 2017/08/16 15:43 */ public class UserService { private static final String DeviceToken = "_deviceToken"; private static final String Token = "_token"; private static final String UserName = "_userName"; private static final String UserGroup = "_userGroup"; private static final String UserGroupName = "_userGroupName"; private static final String Phone = "_phone"; private static final String Password = "_password"; private static final String UserId = "_userId"; private static final String HeadURL = "_headURL"; private static final String SearchHistory = "_searchHistory"; private static final String SearchHistorys = "_searchHistorys"; private Context context; public static UserService service(Context context) { return new UserService(context); } public UserService(Context context) { this.context = context; } public String getDeviceToken() { SharedPreferences memberPrefs = context.getSharedPreferences( DeviceToken, Context.MODE_PRIVATE); return memberPrefs.getString(DeviceToken, ""); } public void setDeviceToken(String deviceToken) { SharedPreferences memberPrefs = context.getSharedPreferences( DeviceToken, Context.MODE_PRIVATE); memberPrefs.edit().putString(DeviceToken, deviceToken).apply(); } public String getToken() { SharedPreferences memberPrefs = context.getSharedPreferences( Token, Context.MODE_PRIVATE); return memberPrefs.getString(Token, "-1"); } public void setToken(String token) { SharedPreferences memberPrefs = context.getSharedPreferences( Token, Context.MODE_PRIVATE); memberPrefs.edit().putString(Token, token).apply(); } public String getUserName() { SharedPreferences memberPrefs = context.getSharedPreferences( UserName, Context.MODE_PRIVATE); return memberPrefs.getString(UserName, ""); } public void setUserName(String userName) { SharedPreferences memberPrefs = context.getSharedPreferences( UserName, Context.MODE_PRIVATE); memberPrefs.edit().putString(UserName, userName).apply(); } public String getUserGroup() { SharedPreferences memberPrefs = context.getSharedPreferences( UserGroup, Context.MODE_PRIVATE); return memberPrefs.getString(UserGroup, ""); } public void setUserGroup(String group) { SharedPreferences memberPrefs = context.getSharedPreferences( UserGroup, Context.MODE_PRIVATE); memberPrefs.edit().putString(UserGroup, group).apply(); } public String getUserGroupName() { SharedPreferences memberPrefs = context.getSharedPreferences( UserGroupName, Context.MODE_PRIVATE); return memberPrefs.getString(UserGroupName, ""); } public void setUserGroupName(String groupName) { SharedPreferences memberPrefs = context.getSharedPreferences( UserGroupName, Context.MODE_PRIVATE); memberPrefs.edit().putString(UserGroupName, groupName).apply(); } public int getUserId() { SharedPreferences memberPrefs = context.getSharedPreferences( UserId, Context.MODE_PRIVATE); return memberPrefs.getInt(UserId, -1); } public void setUserId(int userId) { SharedPreferences memberPrefs = context.getSharedPreferences( UserId, Context.MODE_PRIVATE); memberPrefs.edit().putInt(UserId, userId).apply(); } public String getHeadURL() { SharedPreferences memberPrefs = context.getSharedPreferences( HeadURL, Context.MODE_PRIVATE); return memberPrefs.getString(HeadURL, ""); } public void setHeadURL(String headURL) { SharedPreferences memberPrefs = context.getSharedPreferences( HeadURL, Context.MODE_PRIVATE); memberPrefs.edit().putString(HeadURL, headURL).apply(); } public String getPhone() { SharedPreferences memberPrefs = context.getSharedPreferences( Phone, Context.MODE_PRIVATE); return memberPrefs.getString(Phone, ""); } public void setPhone(String phone) { SharedPreferences memberPrefs = context.getSharedPreferences( Phone, Context.MODE_PRIVATE); memberPrefs.edit().putString(Phone, phone).apply(); } public String getPassword() { SharedPreferences memberPrefs = context.getSharedPreferences( Password, Context.MODE_PRIVATE); return memberPrefs.getString(Password, ""); } public void setPassword(String password) { SharedPreferences memberPrefs = context.getSharedPreferences( Password, Context.MODE_PRIVATE); memberPrefs.edit().putString(Password, password).apply(); } public String getSearchHistory() { SharedPreferences memberPrefs = context.getSharedPreferences( SearchHistory, Context.MODE_PRIVATE); return memberPrefs.getString(SearchHistory, ""); } public void saveSearchHistory(String searchHistory) { SharedPreferences memberPrefs = context.getSharedPreferences( SearchHistory, Context.MODE_PRIVATE); memberPrefs.edit().putString(SearchHistory, searchHistory).apply(); } public String getSearchHistorys() { SharedPreferences memberPrefs = context.getSharedPreferences( SearchHistorys, Context.MODE_PRIVATE); return memberPrefs.getString(SearchHistorys, ""); } public void saveSearchHistorys(String searchHistorys) { SharedPreferences memberPrefs = context.getSharedPreferences( SearchHistorys, Context.MODE_PRIVATE); memberPrefs.edit().putString(SearchHistorys, searchHistorys).apply(); } public boolean isLogin(){ return !getToken().equals("-1"); } }
052ea80d8b8e80e87e1aa3f736c08b002fa48e93
6df097c5c36bbfd49d2941800da4ba4c6f0220e5
/hazelcast/src/main/java/com/hazelcast/concurrent/idgen/IdGeneratorProxy.java
ccb91eee33cada2b9293e5d5a2ef8928aa1ec156
[]
no_license
JiangYongPlus/easycache
cd625afb27dc5dd20c1709727e89a6e5218b2d74
93e6bae20dcfa97ae9c57b9581c75e5a055cd831
refs/heads/master
2021-01-10T16:37:41.790505
2016-01-27T02:41:34
2016-01-27T02:41:34
50,475,643
1
0
null
null
null
null
UTF-8
Java
false
false
3,324
java
/* * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.hazelcast.concurrent.idgen; import com.hazelcast.core.IAtomicLong; import com.hazelcast.core.IdGenerator; import com.hazelcast.spi.AbstractDistributedObject; import com.hazelcast.spi.NodeEngine; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; public class IdGeneratorProxy extends AbstractDistributedObject<IdGeneratorService> implements IdGenerator { public static final int BLOCK_SIZE = 10000; private static final AtomicIntegerFieldUpdater<IdGeneratorProxy> RESIDUE_UPDATER = AtomicIntegerFieldUpdater .newUpdater(IdGeneratorProxy.class, "residue"); private static final AtomicLongFieldUpdater<IdGeneratorProxy> LOCAL_UPDATER = AtomicLongFieldUpdater .newUpdater(IdGeneratorProxy.class, "local"); private final String name; private final IAtomicLong blockGenerator; private volatile int residue = BLOCK_SIZE; private volatile long local = -1L; public IdGeneratorProxy(IAtomicLong blockGenerator, String name, NodeEngine nodeEngine, IdGeneratorService service) { super(nodeEngine, service); this.name = name; this.blockGenerator = blockGenerator; } @Override public boolean init(long id) { if (id < 0) { return false; } long step = (id / BLOCK_SIZE); synchronized (this) { boolean init = blockGenerator.compareAndSet(0, step + 1); if (init) { LOCAL_UPDATER.set(this, step); RESIDUE_UPDATER.set(this, (int) (id % BLOCK_SIZE) + 1); } return init; } } @Override public long newId() { int value = RESIDUE_UPDATER.getAndIncrement(this); if (value >= BLOCK_SIZE) { synchronized (this) { value = residue; if (value >= BLOCK_SIZE) { LOCAL_UPDATER.set(this, blockGenerator.getAndIncrement()); RESIDUE_UPDATER.set(this, 0); } //todo: we need to get rid of this. return newId(); } } return local * BLOCK_SIZE + value; } @Override public String getName() { return name; } @Override public String getServiceName() { return IdGeneratorService.SERVICE_NAME; } @Override protected void postDestroy() { blockGenerator.destroy(); //todo: this behavior is racy; imagine what happens when destroy is called by different threads LOCAL_UPDATER.set(this, -1); RESIDUE_UPDATER.set(this, BLOCK_SIZE); } }
9e58fa35bc264cf09bc1368b330cbe2f91b65778
0b745af036cd3f4748403ae40de31b087a55e5d9
/frequency-flashcards/stroke-img/src/test/java/com/google/code/donkirkby/GridLayoutTest.java
3358584c4263934b93046ea16958f063f6471eea
[ "MIT" ]
permissive
guiltedom/donkirkby
06810c2c38e98a67aff45b661501d6a450414b87
05dfa66fea7a63886b422aaf922d8b9d60300c96
refs/heads/master
2020-09-14T11:06:10.554499
2018-11-30T06:36:54
2018-11-30T06:36:54
null
0
0
null
null
null
null
UTF-8
Java
false
false
878
java
package com.google.code.donkirkby; import org.junit.Assert; import org.junit.Test; public class GridLayoutTest { @Test public void testLayouts() throws Exception { int items = 5; int expectedRows = 1; int expectedColumns = 5; testOneLayout(items, expectedRows, expectedColumns); testOneLayout(3, 1, 3); testOneLayout(6, 1, 6); testOneLayout(8, 1, 8); testOneLayout(24, 2, 12); testOneLayout(7, 1, 7); testOneLayout(9, 2, 5); } private void testOneLayout(int items, int expectedRows, int expectedColumns) { GridLayout layout = new GridLayout(); layout.setItems(items); Assert.assertEquals( "Rows should match for " + items + " items.", expectedRows, layout.getRows()); Assert.assertEquals( "Columns should match for " + items + " items.", expectedColumns, layout.getColumns()); } }
[ "donkirkby@5b1e2516-15c8-11df-a35d-4d785ab5a681" ]
donkirkby@5b1e2516-15c8-11df-a35d-4d785ab5a681
f09103d62f14a8f482fcab363b95cc28849de41c
7b82d70ba5fef677d83879dfeab859d17f4809aa
/tmp/sys/weixin/weixin-core/src/main/java/weixin/core/message/RespNewsMessage.java
2d9e9bfbc98351154e0a68563821747c50caa05d
[]
no_license
apollowesley/jun_test
fb962a28b6384c4097c7a8087a53878188db2ebc
c7a4600c3f0e1b045280eaf3464b64e908d2f0a2
refs/heads/main
2022-12-30T20:47:36.637165
2020-10-13T18:10:46
2020-10-13T18:10:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
560
java
package weixin.core.message; import java.util.List; public class RespNewsMessage extends BaseRespMessage { // 图文消息个数,限制为10条以内 private int ArticleCount; // 多条图文消息信息,默认第一个item为大图 private List<Article> Articles; public int getArticleCount() { return ArticleCount; } public void setArticleCount(int articleCount) { ArticleCount = articleCount; } public List<Article> getArticles() { return Articles; } public void setArticles(List<Article> articles) { Articles = articles; } }
5b63e0ff7710d32da79ffb1faa6ace3ced117202
be1ea339b68bd94d3a782e1c23ce41b5ea740b79
/dc/src/dc3_3/model/InformationFactory.java
da2eefcc9739f4414c685d0b15fcaa589dc171e7
[]
no_license
tomitake0846/Java-Training
25de4bc99f23f11dc175e1f8f95136c369d4f260
688b0a2de950d92d032b254799f53690c174ac5b
refs/heads/master
2021-06-16T08:54:20.978565
2021-05-05T11:42:38
2021-05-05T11:42:38
199,947,283
0
0
null
2021-05-05T11:42:39
2019-08-01T00:24:30
Java
UTF-8
Java
false
false
213
java
package dc3_3.model; public class InformationFactory { private final static Information timeInstance = new Time(); public static Information getTimeInstance() { return InformationFactory.timeInstance; } }
2af26a50db61c4110c72dbaff9eeef66ce54713b
4b0bf4787e89bcae7e4759bde6d7f3ab2c81f849
/aliyun-java-sdk-sas/src/main/java/com/aliyuncs/sas/model/v20181203/ModifyVulConfigRequest.java
bd88df29f938fb75b483b5c893286fa4651bb272
[ "Apache-2.0" ]
permissive
aliyun/aliyun-openapi-java-sdk
a263fa08e261f12d45586d1b3ad8a6609bba0e91
e19239808ad2298d32dda77db29a6d809e4f7add
refs/heads/master
2023-09-03T12:28:09.765286
2023-09-01T09:03:00
2023-09-01T09:03:00
39,555,898
1,542
1,317
NOASSERTION
2023-09-14T07:27:05
2015-07-23T08:41:13
Java
UTF-8
Java
false
false
1,769
java
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.aliyuncs.sas.model.v20181203; import com.aliyuncs.RpcAcsRequest; import com.aliyuncs.http.MethodType; import com.aliyuncs.sas.Endpoint; /** * @author auto create * @version */ public class ModifyVulConfigRequest extends RpcAcsRequest<ModifyVulConfigResponse> { private String type; private String config; public ModifyVulConfigRequest() { super("Sas", "2018-12-03", "ModifyVulConfig"); setMethod(MethodType.POST); try { com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointMap").set(this, Endpoint.endpointMap); com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointRegional").set(this, Endpoint.endpointRegionalType); } catch (Exception e) {} } public String getType() { return this.type; } public void setType(String type) { this.type = type; if(type != null){ putQueryParameter("Type", type); } } public String getConfig() { return this.config; } public void setConfig(String config) { this.config = config; if(config != null){ putQueryParameter("Config", config); } } @Override public Class<ModifyVulConfigResponse> getResponseClass() { return ModifyVulConfigResponse.class; } }
2e47e292c06b5d74b758c3044b95e33e642cd2ad
21f28b75a330012453ed48dd1fe8b3f3bcf1211a
/src/main/java/org/jboss/remoting3/spi/ConnectionProviderFactory.java
0160ff25bf50e2f434aec8d35ffc0edbeae5a53b
[ "Apache-2.0" ]
permissive
jboss-remoting/jboss-remoting
94419a153ef8d1286c9e5f19b9e8d560032350e4
76c75070c34632652bc2bb7cbd18663a2b4008d6
refs/heads/main
2023-08-15T03:33:45.158013
2022-10-07T08:34:38
2022-10-07T08:34:38
1,124,152
16
65
NOASSERTION
2023-02-14T11:38:08
2010-11-30T01:50:21
Java
UTF-8
Java
false
false
1,608
java
/* * JBoss, Home of Professional Open Source. * Copyright 2017 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting3.spi; import java.io.IOException; import org.xnio.OptionMap; /** * A connection provider factory. Implementations of this interface provide a connection facility for a URI scheme. An * endpoint will call the {@code createInstance()} method with its provider context when instances of this interface * are registered on that endpoint. */ public interface ConnectionProviderFactory { /** * Create a provider instance for an endpoint. * * @param context the provider context * @param optionMap the options to pass to the provider factory * @param protocolName the name of the protocol scheme * @return the provider * @throws IOException if the provider cannot be created */ ConnectionProvider createInstance(ConnectionProviderContext context, final OptionMap optionMap, final String protocolName) throws IOException; }
7399fc0291ab899eb65b9688fbe37f809b471070
00f76974faaf34da28b3a3f1c1cd2080cfac5c77
/src/SaveSystem/Serializer/SkinSerializer/SkinPropertyHelpSerializer/BorderPropertyHelpSerializer.java
aa339ab91db5e663656131cb3c1f5d5454580a73
[]
no_license
weakennN/Mind-Map
fb29d74f61c91ce8918c8dac7360ab146e8660f2
384306ac9fadb9624e0a5dda0f2cc226521b67a6
refs/heads/master
2023-06-16T17:25:06.765700
2021-07-08T18:49:28
2021-07-08T18:49:28
379,689,707
1
0
null
null
null
null
UTF-8
Java
false
false
1,914
java
package SaveSystem.Serializer.SkinSerializer.SkinPropertyHelpSerializer; import NodeSkin.SkinProperty.BorderProperty; import NodeSkin.SkinProperty.SkinProperty; import Nodes.Node; import SaveSystem.Serializer.PropertySerializer.BorderSerializer; import javafx.scene.layout.*; import javafx.scene.paint.Color; import java.util.Map; public class BorderPropertyHelpSerializer extends SkinPropertiesHelpSerializer { public BorderPropertyHelpSerializer() { super(); super.addPropertySerializer("borderProperty", new BorderSerializer()); } @Override public boolean isSuitable(SkinProperty skinProperty) { return skinProperty instanceof BorderProperty; } public boolean isSuitable(String property) { return property.equals("border"); } @Override public void save(SkinProperty skinProperty, Map<String, Map<String, Object>> fields) { super.getPropertySerializer("borderProperty").save(((BorderProperty) skinProperty).getBorder(), fields,"border"); } @Override public SkinProperty load(Map<String, Map<String, Object>> fields, Object object) { BorderProperty borderProperty = new BorderProperty(); Border border = (Border) super.getPropertySerializer("borderProperty").load(fields,"border"); BorderStroke borderStroke = border.getStrokes().get(0); borderProperty.setColor((Color) borderStroke.getBottomStroke()); borderProperty.setCornerRadii(borderStroke.getRadii()); borderProperty.setBorderWidths(borderStroke.getWidths()); borderProperty.setStrokeStyle(borderStroke.getBottomStyle()); borderProperty.setBorderStroke(borderStroke); borderProperty.setBorder(border); borderProperty.setNode((Node) object); borderProperty.setNodeBorder(); return borderProperty; } }
9f0c71b6e3b8321a6233f712aab948fc30a1b7b6
e53483b141a0daea13d36fa3a7a17c2be3b88008
/src/main/java/cis410/onlinebanking/service/OnlineAccountService.java
23b24f493a37f388a4ff21b4cd71b7f10516849d
[]
no_license
jkahn33/online-banking
9f83e8a6c1d31d30e5f5a5304767c275b049cbf7
db49b12b60404e9433704bd88dfd7f74595b73fe
refs/heads/master
2020-05-06T20:12:53.056336
2019-04-30T02:51:50
2019-04-30T02:51:50
180,227,479
0
0
null
2019-04-30T02:51:51
2019-04-08T20:27:12
null
UTF-8
Java
false
false
3,207
java
package cis410.onlinebanking.service; import cis410.onlinebanking.ResponseObject; import cis410.onlinebanking.dao.AddressDAO; import cis410.onlinebanking.dao.BankAccountDAO; import cis410.onlinebanking.dao.CustomerDAO; import cis410.onlinebanking.dao.OnlineAccountDAO; import cis410.onlinebanking.entities.*; import cis410.onlinebanking.sent.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import java.sql.Timestamp; import java.util.Date; import java.util.Optional; @Service public class OnlineAccountService { private final OnlineAccountDAO accountDAO; private final PasswordEncoder passwordEncoder; private final CustomerDAO customerDAO; private final AddressDAO addressDAO; private final BankAccountDAO bankAccountDAO; @Autowired public OnlineAccountService(OnlineAccountDAO accountDAO, PasswordEncoder passwordEncoder, CustomerDAO customerDAO, AddressDAO addressDAO, BankAccountDAO bankAccountDAO) { this.accountDAO = accountDAO; this.passwordEncoder = passwordEncoder; this.customerDAO = customerDAO; this.addressDAO = addressDAO; this.bankAccountDAO = bankAccountDAO; } public boolean verifyAccount(LoginAttempt attempt){ Optional<OnlineAccount> onlineAccountOptional = accountDAO.findById(attempt.getUser()); if(onlineAccountOptional.isPresent()){ OnlineAccount account = onlineAccountOptional.get(); return passwordEncoder.matches(attempt.getPass(), account.getPassword()); } return false; } public ResponseObject createOnlineAccount(NewOnlineAccount account){ Date date = new Date(); Timestamp currentTime = new Timestamp(date.getTime()); Optional<OnlineAccount> onlineAccountOptional = accountDAO.findById(account.getUserName()); if(onlineAccountOptional.isPresent()){ return new ResponseObject(false, "Username already in use."); } NewAddress newAddress = account.getNewCustomer().getAddress(); NewCustomer newCustomer = account.getNewCustomer(); Address address = new Address(newAddress.getAddr(), newAddress.getCity(), newAddress.getCountry(), newAddress.getZipcode()); addressDAO.save(address); Customer customer = new Customer(newCustomer.getName(), newCustomer.getDateOfBirth(), address, newCustomer.getPhone()); customerDAO.save(customer); BankAccount checking = new BankAccount(customer, AccountType.CHECKING, (float)0.0); BankAccount savings = new BankAccount(customer, AccountType.SAVINGS, (float)0.0); bankAccountDAO.save(checking); bankAccountDAO.save(savings); OnlineAccount onlineAccount = new OnlineAccount(account.getUserName(), passwordEncoder.encode(account.getPassword()), currentTime, customer); accountDAO.save(onlineAccount); return new ResponseObject(true, "Successfully created new account."); } }
89a832fb3d2c3b35834cabab753d382a54f82704
25729cf0666fb83f0c9b7553cd647b6c33968886
/src/main/freesql/cn/com/ebmp/freesql/builder/xml/dynamic/DynamicContext.java
5671a103ef8c9381b851553adb13f5fd00ac3aac
[]
no_license
545473750/zswxglxt
1b55f94d8c0c8c0de47a0180406cdcdacc2ff756
2a7b7aeba7981bd723f99db400c99d0decb6de43
refs/heads/master
2020-04-23T15:42:36.490753
2014-08-11T00:08:39
2014-08-11T00:08:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,672
java
package cn.com.ebmp.freesql.builder.xml.dynamic; import java.util.HashMap; import java.util.Map; import cn.com.ebmp.freesql.builder.factory.Configuration; import cn.com.ebmp.freesql.ognl.OgnlException; import cn.com.ebmp.freesql.ognl.OgnlRuntime; import cn.com.ebmp.freesql.ognl.PropertyAccessor; import cn.com.ebmp.freesql.reflection.MetaObject; public class DynamicContext { public static final String PARAMETER_OBJECT_KEY = "_parameter"; static { OgnlRuntime.setPropertyAccessor(ContextMap.class, new ContextAccessor()); } private final ContextMap bindings; private final StringBuilder sqlBuilder = new StringBuilder(); private int uniqueNumber = 0; public DynamicContext(Configuration configuration, Object parameterObject) { if (parameterObject != null && !(parameterObject instanceof Map)) { MetaObject metaObject = configuration.newMetaObject(parameterObject); bindings = new ContextMap(metaObject); } else { bindings = new ContextMap(null); } bindings.put(PARAMETER_OBJECT_KEY, parameterObject); } public Map<String, Object> getBindings() { return bindings; } public void bind(String name, Object value) { bindings.put(name, value); } public void appendSql(String sql) { sqlBuilder.append(sql); sqlBuilder.append(" "); } public String getSql() { return sqlBuilder.toString().trim(); } public int getUniqueNumber() { return uniqueNumber++; } static class ContextMap extends HashMap<String, Object> { private static final long serialVersionUID = 2977601501966151582L; private MetaObject parameterMetaObject; public ContextMap(MetaObject parameterMetaObject) { this.parameterMetaObject = parameterMetaObject; } @Override public Object get(Object key) { if (super.containsKey(key)) { return super.get(key); } if (parameterMetaObject != null) { Object object = parameterMetaObject.getValue(key.toString()); if (object != null) { super.put(key.toString(), object); } return object; } return null; } } static class ContextAccessor implements PropertyAccessor { public Object getProperty(Map context, Object target, Object name) throws OgnlException { Map map = (Map) target; Object result = map.get(name); if (result != null) { return result; } Object parameterObject = map.get(PARAMETER_OBJECT_KEY); if (parameterObject instanceof Map) { return ((Map) parameterObject).get(name); } return null; } public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { Map map = (Map) target; map.put(name, value); } } }
48eed73b2ac0dcee1d0bf8dee117ad558ea7fcc0
3b5e70dd5571ffe8e867b79a0fa07565fa771f51
/yoriessence/src/com/yoriessence/shopping/dao/ShoppingCartDao.java
1888e918bf558f349cdec09dddc3ecc1421b5af0
[]
no_license
HuiungJang/yorirecipe
cc16d1f07c1deb173de08b0e198b708457ca4a68
e252f2127e5d4a7e2a647a2d650f3f0a27f9aba0
refs/heads/main
2023-05-06T02:27:24.904412
2021-05-30T04:21:13
2021-05-30T04:21:13
362,690,836
0
1
null
null
null
null
UTF-8
Java
false
false
7,723
java
package com.yoriessence.shopping.dao; import static com.yoriessence.common.JDBCTemplate.close; import java.io.FileReader; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Properties; import com.yoriessence.shopping.vo.OrderDetails; import com.yoriessence.shopping.vo.Product; import com.yoriessence.shopping.vo.ShoppingCart; public class ShoppingCartDao { private Properties prop=new Properties(); public ShoppingCartDao() { try { String filePath=ShoppingCartDao.class.getResource("/sql/shopping.properties").getPath(); prop.load(new FileReader(filePath)); }catch(Exception e) { e.printStackTrace(); } } public List<ShoppingCart> ShoppingCartCheck(Connection conn,String memberId) { PreparedStatement pstmt=null; ResultSet rs=null; List<ShoppingCart> list=new ArrayList(); String sql=prop.getProperty("shoppingmember"); try { pstmt=conn.prepareStatement(sql); pstmt.setString(1, memberId); rs=pstmt.executeQuery(); while(rs.next()) { ShoppingCart sc=new ShoppingCart(); sc.setMemberid(rs.getString("MEMBER_ID")); sc.setProductname(rs.getString("PRODUCT_NAME")); sc.setProductprice(rs.getInt("PRODUCT_PRICE")); sc.setProductnumber(rs.getInt("PRODUCT_NUMBER")); sc.setProductshopify(rs.getInt("PRODUCT_SHOPIFY")); list.add(sc); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); }return list; } public List<Product> ProductAll(Connection conn, int cPage, int numPerpage) { PreparedStatement pstmt=null; ResultSet rs=null; List<Product> list=new ArrayList(); try { pstmt=conn.prepareStatement(prop.getProperty("ProductAll")); pstmt.setInt(1, (cPage-1)*numPerpage+1); pstmt.setInt(2, cPage*numPerpage); rs=pstmt.executeQuery(); while(rs.next()) { Product pd=new Product(); pd.setProductNo(rs.getInt("PRODUCTNO")); pd.setStock(rs.getInt("STOCK")); pd.setPrice(rs.getInt("PRICE")); pd.setExplanation(rs.getString("EXPLANATION")); pd.setProductName(rs.getString("PRODUCTNAME")); pd.setProductImage(rs.getString("PRODUCTIMAGE")); pd.setProductkategorie(rs.getString("PRODUCTKATEGORIE")); pd.setProductshopify(rs.getInt("PRODUCTSHOPIFY")); list.add(pd); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); }return list; } public int selectProductCount(Connection conn) { PreparedStatement pstmt=null; ResultSet rs=null; int result=0; try { pstmt=conn.prepareStatement(prop.getProperty("Productpage")); rs=pstmt.executeQuery(); if(rs.next()) { result=rs.getInt(1); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); }return result; } public Product Productsearch(Connection conn,String search) { PreparedStatement pstmt=null; ResultSet rs=null; Product pds=null; String sql=prop.getProperty("searchproduct"); try { pstmt=conn.prepareStatement(sql); pstmt.setString(1, search); rs=pstmt.executeQuery(); if(rs.next()) { pds=new Product(); pds.setProductNo(rs.getInt("PRODUCTNO")); pds.setStock(rs.getInt("STOCK")); pds.setPrice(rs.getInt("PRICE")); pds.setExplanation(rs.getString("EXPLANATION")); pds.setProductName(rs.getString("PRODUCTNAME")); pds.setProductImage(rs.getString("PRODUCTIMAGE")); pds.setProductkategorie(rs.getString("PRODUCTKATEGORIE")); pds.setProductshopify(rs.getInt("PRODUCTSHOPIFY")); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); } return pds; } public Product selectProduct(Connection conn, int productno) { PreparedStatement pstmt=null; ResultSet rs=null; Product pd=null; try { pstmt=conn.prepareStatement(prop.getProperty("selectProduct")); pstmt.setInt(1, productno); rs=pstmt.executeQuery(); if(rs.next()) { pd=new Product(); pd.setProductNo(rs.getInt("PRODUCTNO")); pd.setStock(rs.getInt("STOCK")); pd.setPrice(rs.getInt("PRICE")); pd.setExplanation(rs.getString("EXPLANATION")); pd.setProductName(rs.getString("PRODUCTNAME")); pd.setProductImage(rs.getString("PRODUCTIMAGE")); pd.setProductkategorie(rs.getString("PRODUCTKATEGORIE")); pd.setProductshopify(rs.getInt("PRODUCTSHOPIFY")); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); }return pd; } public int deleteShopping(Connection conn, String productname) { PreparedStatement pstmt=null; int result=0; try { pstmt=conn.prepareStatement(prop.getProperty("deleteShopping")); pstmt.setString(1, productname); result=pstmt.executeUpdate(); }catch(SQLException e) { e.printStackTrace(); }finally { close(pstmt); }return result; } public List<Product> Shoppingkategori(Connection conn, String katagori ){ PreparedStatement pstmt=null; ResultSet rs=null; List<Product> list=new ArrayList(); try { pstmt=conn.prepareStatement(prop.getProperty("Productkatagori")); pstmt.setString(1, katagori); rs=pstmt.executeQuery(); while(rs.next()) { Product pd=new Product(); pd.setProductNo(rs.getInt("PRODUCTNO")); pd.setStock(rs.getInt("STOCK")); pd.setPrice(rs.getInt("PRICE")); pd.setExplanation(rs.getString("EXPLANATION")); pd.setProductName(rs.getString("PRODUCTNAME")); pd.setProductImage(rs.getString("PRODUCTIMAGE")); pd.setProductkategorie(rs.getString("PRODUCTKATEGORIE")); pd.setProductshopify(rs.getInt("PRODUCTSHOPIFY")); list.add(pd); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); }return list; } public int insertShoppingCart(Connection conn, ShoppingCart sc) { PreparedStatement pstmt=null; int result=0; try { pstmt=conn.prepareStatement(prop.getProperty("insertShoppingCart")); pstmt.setString(1, sc.getMemberid()); pstmt.setString(2, sc.getProductname()); pstmt.setInt(3, sc.getProductprice()); pstmt.setInt(4, sc.getProductnumber()); pstmt.setInt(5, sc.getProductshopify()); result=pstmt.executeUpdate(); }catch(SQLException e) { e.printStackTrace(); }finally { close(pstmt); }return result; } public int ProductInsert(Connection conn, Product pd) { PreparedStatement pstmt=null; int result=0; try { pstmt=conn.prepareStatement(prop.getProperty("ProductInsert")); pstmt.setInt(1, pd.getStock()); pstmt.setInt(2, pd.getPrice()); pstmt.setString(3, pd.getExplanation()); pstmt.setString(4, pd.getProductName()); pstmt.setString(5, pd.getProductImage()); pstmt.setString(6, pd.getProductkategorie()); pstmt.setInt(7, pd.getProductshopify()); result=pstmt.executeUpdate(); }catch(SQLException e) { e.printStackTrace(); }finally { close(pstmt); }return result; } public List<OrderDetails> OrderDetails(Connection conn, String memberid){ PreparedStatement pstmt=null; ResultSet rs=null; List<OrderDetails> list=new ArrayList(); String sql=prop.getProperty("OrderDetails"); try { pstmt=conn.prepareStatement(sql); pstmt.setString(1, memberid); rs=pstmt.executeQuery(); while(rs.next()) { OrderDetails od=new OrderDetails(); od.setMEMBERID(rs.getString("MEMBERID")); od.setORDERAMOUTNT(rs.getInt("ORDERAMOUNT")); od.setORDERDATE(rs.getDate("ORDERDATE")); od.setPAYMENTDATE(rs.getDate("PAYMENTDATE")); list.add(od); } }catch(SQLException e) { e.printStackTrace(); }finally { close(rs); close(pstmt); }return list; } }
eb6c23b7d796999a4c4226ca9b25d972e6fb51ad
796771e3fbf4666b151c89a3938513552711f68a
/eclipse/rcp/csdnclient/src/org/dollyn/csdnclient/Activator.java
346a292cc7f610e7c26e26345f09a49074971593
[]
no_license
Dollyn/dollynprojects
8c6b96640e4b04586a5ba1d3ade698afe1b5e07e
7f6896893ca9da28fc7ec645c950517c29fde948
refs/heads/master
2016-09-06T16:54:26.865393
2012-02-08T12:31:45
2012-02-08T12:31:45
35,531,541
0
0
null
null
null
null
UTF-8
Java
false
false
2,246
java
package org.dollyn.csdnclient; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; /** * The activator class controls the plug-in life cycle */ public class Activator extends AbstractUIPlugin { // The plug-in ID public static final String PLUGIN_ID = "org.dollyn.csdnclient"; // The shared instance private static Activator plugin; private ImageRegistry imageRegistry; private boolean imageInited = false; /** * The constructor */ public Activator() { } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); plugin = this; //construct the model ModelManager.getInstance().start(); //initImages(); } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } /** * Returns the shared instance * @return the shared instance */ public static Activator getDefault() { return plugin; } public ImageRegistry getImageRegistry() { if(this.imageRegistry == null) { this.imageRegistry = new ImageRegistry(); } return this.imageRegistry; } public Image getImage(String name) { ImageRegistry registry = getImageRegistry(); String key = "/images/" + name; return registry.get(key); } public void initImages() { if(imageInited) return; ImageRegistry reg = getImageRegistry(); for(int i = 0; i < 105; i++) { String path = "/images/" + i + ".gif"; reg.put(path, getImageDescriptor(path)); } imageInited = true; } /** * Returns an image descriptor for the image file at the given * plug-in relative path * * @param path the path * @return the image descriptor */ public static ImageDescriptor getImageDescriptor(String path) { return imageDescriptorFromPlugin(PLUGIN_ID, path); } }
d667918bfbc913c346d7a817635aeae39d30db83
eb50ede88ae3c7664777e2f661688f58c86530f2
/src/main/java/com/techouts/fanniemae/mail/DefaultMailService.java
e8db316d256b2e4d169c367204c8c15d968873f9
[]
no_license
KallaSwathi/Swathi
ec3acd5e4cd1c19bcf106ea395fca9b4027eda20
5602915098e2fe8fca7df060e1443e5aa707ea09
refs/heads/master
2023-05-12T01:11:54.593694
2019-11-27T12:05:19
2019-11-27T12:05:19
224,421,544
0
0
null
2023-05-09T18:15:21
2019-11-27T12:04:11
Roff
UTF-8
Java
false
false
2,495
java
package com.techouts.fanniemae.mail; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Multipart; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import org.apache.log4j.Logger; import com.techouts.fanniemae.consts.FanniemaeConstants; import com.techouts.fanniemae.dto.mail.MailParam; import com.techouts.fanniemae.dto.mail.MailParam.MailConfig; import com.techouts.fanniemae.dto.testcase.SuiteResult; /** * * @author TO-WVLD-12 * */ public class DefaultMailService { private MailParam mailParam; private MailConfig config; private SuiteResult suiteResult; private DefaultMailServiceHelper helper; private static final Logger LOG =Logger.getLogger(DefaultMailService.class.getName()); public DefaultMailService(MailParam mailParam, SuiteResult suiteResult) { super(); this.mailParam = mailParam; config = mailParam.getMailConfig(); this.suiteResult = suiteResult; helper = new DefaultMailServiceHelper(); } public void transport() { if (helper.isMandateDataAvailable(mailParam, suiteResult)) { Session session = Session.getDefaultInstance(helper.getMailProperties(config)); MimeMessage message = new MimeMessage(session); try { message.setFrom(config.getFrom()); message.addRecipients(Message.RecipientType.TO, config.getTo()); message.setSubject(mailParam.getSubject()); Multipart multipart = new MimeMultipart(); helper.setBodyText(multipart, suiteResult); helper.attachBodyParts(multipart, mailParam.getAttachments()); message.setContent(multipart); Transport transport = session.getTransport(FanniemaeConstants.SMTP); transport.connect(config.getHost(), config.getFrom().toString(), config.getPasscode()); transport.sendMessage(message, message.getAllRecipients()); transport.close(); LOG.info("Mail Sent."); } catch (AddressException e) { LOG.error("Error occurred with an email addresses supplied are not valid or not active", e); } catch (MessagingException e) { LOG.error("Error occurred while sending an mail.", e); } catch (Exception e) { LOG.error("Unknown error occurred while sending email.",e); } }else { LOG.warn("Mail cannot be sent due to lack of mandatory data/permissions. Validation of "+mailParam+" and "+suiteResult+" failed and results in non transporatable mail."); } } }
4e661da8acd32358e352d593148ae5fe87fe2784
63335074405b5190f84638116861e5729519d9c4
/spring4/chapter15/src/main/java/com/rogercw/cache/simplecache/UserService.java
49e91a6a7968f009b8008ad25665bed243e8c81c
[]
no_license
nanbingf2/my-work
1f526948ae07cf43610ca5649634319a0fcdddb8
35d2042ee7d308e4343798d7672903c3a2ba8a44
refs/heads/master
2018-10-25T12:18:21.743703
2018-08-21T11:39:51
2018-08-21T11:39:51
120,987,271
0
0
null
null
null
null
UTF-8
Java
false
false
689
java
package com.rogercw.cache.simplecache; import com.rogercw.cache.domain.User; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; /** * Created by 1 on 2018/4/16. * 使用Spring Cache来实现缓存 */ @Service(value = "simpleCacheUserService") public class UserService { //使用名为users的缓存 @Cacheable(cacheNames = "users") public User getUserById(String id){ System.out.println("执行用户查询方法查找用户"); return getFromDB(id); } private User getFromDB(String id) { System.out.println("从数据库中查找用户"); return new User(id,"lisi",19); } }
f807c565bfc911d0ddb6ccc1447d712d35bcb01d
7932229018f7bb7e2aeaa4a714f4acc658a7f594
/choerodon-starter-mybatis/src/main/java/io/choerodon/mybatis/autoconfigure/PageConfiguration.java
97682f113597d82758511e6683385f54b0b64ef4
[ "Apache-2.0" ]
permissive
readme1988/choerodon-starters
f0e420b07409f636dff0cd62048796717bef615d
1422f2fdddd6b37007c5e3b7ec854a98de898866
refs/heads/master
2020-09-22T20:22:00.487158
2020-01-13T09:45:39
2020-01-13T09:45:39
225,314,103
0
0
Apache-2.0
2020-01-13T09:45:40
2019-12-02T07:40:45
null
UTF-8
Java
false
false
813
java
package io.choerodon.mybatis.autoconfigure; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.web.PageableArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.util.List; @Configuration public class PageConfiguration implements WebMvcConfigurer { @Override public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { PageableArgumentResolver pageableArgumentResolver = pageable(); resolvers.add(pageableArgumentResolver); } @Bean public PageableArgumentResolver pageable() { return new CustomPageableResolver(); } }
4dc4c538f00e8ec43b86d876250dd57ada0ee7bc
d21e82cc0703cbcc29890b9d47ff4348c565cb15
/LoaderInterface.java
d24ac4e1d6717c7f57f5843fdf91ef6a824a087f
[]
no_license
veswan/yoda_speech
7e9d0c6963c27b3170fa7f34bd2b6ede00fdf16b
bf55ff908b82c2d17497a41d6abec529db731476
refs/heads/master
2020-04-06T03:59:19.375208
2017-02-24T21:38:33
2017-02-24T21:38:33
83,084,587
0
0
null
null
null
null
UTF-8
Java
false
false
185
java
package com.shopkeep.yodaspeech.interfaces; public interface LoaderInterface { void showTextLoading(boolean show); void showText(String text); void showLoadingError(); }
e50967d003ebaefeebd2d6385dab532e35ee888a
4a842606cdb08c58e2f7ab1e72ac74afbbdd7660
/src/cn/java/filters/demo.java
28305fca27b429cda4c144b99055cba193efe3cb
[]
no_license
khalilwear/SSM_COMPLETE
7c04c42b17365e4cb3d179370eea9c564c7cde5a
00aca3dfbb81627b8056cdeab588dcbe62434a7c
refs/heads/master
2020-05-01T03:47:47.588322
2019-03-23T06:48:46
2019-03-23T06:48:46
177,254,845
0
0
null
null
null
null
UTF-8
Java
false
false
54
java
package cn.java.filters; public class demo { }
620c806e62948511ad3ffcadeda43399638a3b6f
f1734ef3cf6a69a97120933f930ad8a70cd566a3
/src/main/java/br/com/abbarros/moviechallenge/controller/response/MovieResponse.java
33e6508c8cacb75a7b71cf548b56baaf2fa9d974
[]
no_license
abbarros/movie-challenge
fa3af90929973ad64bb88bf58e5907390dd4321e
d62dfad87fdc563c6104cb3bd8ce674974d7d760
refs/heads/master
2022-11-07T21:57:26.466631
2020-06-22T13:56:37
2020-06-22T13:56:37
273,957,060
1
0
null
null
null
null
UTF-8
Java
false
false
565
java
package br.com.abbarros.moviechallenge.controller.response; import br.com.abbarros.moviechallenge.model.Censorship; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.time.LocalDate; import java.util.List; @Data @NoArgsConstructor @AllArgsConstructor public class MovieResponse implements Serializable { private String id; private String name; private LocalDate launchDate; private Censorship censorship; private String director; private List<String> cast; }
97922011518b2991a1dee86e191444503643dc10
ec69727516cce93ca7c2af1eaee8e40c17fea1da
/app/src/main/java/com/esgipa/smartplayer/server/authentication/SigninTask.java
e6b3842a212716791e7a869eab383ebb1b1e5bd4
[]
no_license
JChatelin/PA_ESGI_2020_PhoneApp_Grp1
3b6dd32fe851823d3c19ed521ea3adca59d7e140
d9e61f74b6674b94eb8bdf9b40f904febf7ba320
refs/heads/master
2022-12-25T11:32:01.145666
2020-10-05T15:26:10
2020-10-05T15:26:10
259,762,797
1
0
null
null
null
null
UTF-8
Java
false
false
5,757
java
package com.esgipa.smartplayer.server.authentication; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; import android.util.Log; import com.esgipa.smartplayer.utils.ConnectivityUtils; import com.esgipa.smartplayer.server.Callback; import com.esgipa.smartplayer.server.RequestResult; import com.esgipa.smartplayer.utils.StreamReader; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; public class SigninTask extends AsyncTask<String, Integer, RequestResult>{ /** * Implementation of AsyncTask designed to fetch data from the network. */ private Callback<JSONObject> callback; private String username, password; public SigninTask(Callback<JSONObject> callback, String username, String password) { setCallback(callback); this.username = username; this.password = password; } public void setCallback(Callback<JSONObject> callback) { this.callback = callback; } /** * Cancel background network operation if we do not have network connectivity. */ @Override protected void onPreExecute() { if (callback != null) { NetworkInfo networkInfo = callback.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isConnected() || (networkInfo.getType() != ConnectivityManager.TYPE_WIFI && networkInfo.getType() != ConnectivityManager.TYPE_MOBILE)) { // If no connectivity, cancel task and update Callback with null data. callback.updateUi(ConnectivityUtils.noConnection()); cancel(true); } } } /** * Defines work to perform on the background thread. */ @Override protected RequestResult doInBackground(String... urls) { RequestResult result = null; if (!isCancelled() && urls != null && urls.length > 0) { String urlString = urls[0]; try { URL url = new URL(urlString); JSONObject resultJson = signInRequest(url, username, password); if (resultJson != null) { result = new RequestResult(resultJson); } else { throw new IOException("No response received."); } } catch(Exception e) { result = new RequestResult(e); } } return result; } /** * Updates the Callback with the result. */ @Override protected void onPostExecute(RequestResult result) { if (result != null && callback != null) { if (result.exception != null) { JSONObject jsonError = new JSONObject(); try { jsonError.put("Error", result.exception.getMessage()); callback.updateUi(jsonError); } catch (JSONException e) { e.printStackTrace(); } } else if (result.resultValue != null) { callback.updateUi(result.resultValue); } } } /** * Override to add special behavior for cancelled AsyncTask. */ @Override protected void onCancelled(RequestResult result) { } private JSONObject signInRequest(URL serverUrl, String username, String password) throws IOException { InputStream stream = null; HttpURLConnection connection = null; JSONObject result = null; try { connection = (HttpURLConnection) serverUrl.openConnection(); connection.setReadTimeout(15000); connection.setConnectTimeout(15000); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json; UTF-8"); connection.setRequestProperty("Accept", "application/json"); // Already true by default but setting just in case; needs to be true since this request // is carrying an input (response) body. connection.setDoInput(true); connection.setDoOutput(true); // Add parameters to the post request JSONObject jsonBody = new JSONObject() .put("username", username) .put("password", password); Log.i("server interaction", "signInRequest query: "+jsonBody.toString()); OutputStream os = connection.getOutputStream(); byte[] input = jsonBody.toString().getBytes("utf-8"); os.write(input, 0, input.length); os.close(); // parameters end connection.connect(); int responseCode = connection.getResponseCode(); switch(responseCode) { case HttpURLConnection.HTTP_OK: stream = connection.getInputStream(); if (stream != null) { result = StreamReader.readStream(stream, 500); } break; case HttpURLConnection.HTTP_UNAUTHORIZED: throw new IOException("Invalid username and/or password."); default: throw new IOException("An error occurred."); } } catch (JSONException e) { e.printStackTrace(); } finally { if (stream != null) { stream.close(); } if (connection != null) { connection.disconnect(); } } return result; } }
027003432c6697f607dd2cf140f4c361836633f7
2df71d498c04df7aa7c0c3ca25544b02d9ef2b6e
/dashboard/src/main/java/nl/openweb/iot/dashboard/service/script/GroovySandboxFilter.java
6f454f273de3de032941d536b2ad7e379171019e
[]
no_license
openweb-dennis/wio-link-java-client
baa61eb3e52a2ea4e59d2da273ab5eda830814e7
39f637a777248b337169b741216d9d01fb31f84f
refs/heads/master
2021-01-19T06:22:40.604295
2017-04-06T15:22:39
2017-04-06T15:22:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
434
java
package nl.openweb.iot.dashboard.service.script; import org.kohsuke.groovy.sandbox.GroovyValueFilter; public class GroovySandboxFilter extends GroovyValueFilter { @Override public Object filter(Object o) { if (o != null && SandboxFilter.filter(o.getClass())) { throw new SecurityException("Oops, type " + o.getClass() + " is not permitted to be used in an script"); } return o; } }
c2927ef2f9bdac6d61d54e00402fa16b3f9d8ad5
621e4b2cb2e153790c5ebc8380c08bba563713ac
/src/main/java/com/demoapp/model/subscription/Marketplace.java
77d41b2797edbedd273a723cd0ce1a81b8ced3e0
[]
no_license
pjlacharite/demoApp
dbac96a746facd4427d78fcaee0da524132d516c
30e9f54792137f1052177b63e2415010c56e8f6b
refs/heads/master
2021-01-12T13:01:13.138400
2016-10-04T17:07:42
2016-10-04T17:07:42
69,402,717
0
0
null
null
null
null
UTF-8
Java
false
false
413
java
package com.demoapp.model.subscription; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import java.io.Serializable; @Entity public class Marketplace implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String baseUrl; private String partner; }
cf7ae98911a42fb549abe3592674e58e4737ec5f
2836c746634280c21a3b810f140e203582258797
/src/day02_printlnpractice/TellMeYourself.java
7afcce4df19a1e6a613e3eb286cb72e22ae1b624
[]
no_license
Bashiragha/java-programming
b4bd1e5f463722bb89e96d4c5cfbb0735e560fb7
57e5f486be93b3a756bf731f023660fb9e6643b6
refs/heads/master
2023-04-26T10:26:31.646440
2021-05-29T14:45:13
2021-05-29T14:45:13
371,998,533
0
0
null
null
null
null
UTF-8
Java
false
false
390
java
package day02_printlnpractice; public class TellMeYourself { public static void main(String[] args) { System.out.println("My Name is Khan."); System.out.println("I am a test automation Engineer."); System.out.print("My name is khan "); System.out.println(" and i am a future SDET in Sha Allah"); System.out.println("i am proud afghan"); } }
0f7a6c532ef24125684c78754229aca48308f375
3ca117375cf504474aa111aedfb1ad8f3c4c0830
/NovaSample/app/src/main/java/com/example/developeri/novasample/signUpScreen.java
92bff5cafb7f54380d0d21739de1c84538246e7f
[ "Apache-2.0" ]
permissive
123jyotigupta/androidApps
58096654d6649b0937029505fc9d5b16932fbac3
17760bd3c4f222b406e2babc5405e27ca0e4b36a
refs/heads/master
2021-01-10T20:03:47.147988
2015-08-21T21:31:03
2015-08-21T21:31:03
40,603,157
0
0
null
null
null
null
UTF-8
Java
false
false
12,691
java
package com.example.developeri.novasample; import android.content.Intent; import android.os.AsyncTask; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.ImageView; import android.provider.MediaStore; import android.net.Uri; import android.graphics.BitmapFactory; import android.graphics.Bitmap; import android.graphics.Matrix; import android.os.Environment; import java.io.IOException; import java.io.File; import java.io.OutputStream; import android.app.Activity; import java.io.FileNotFoundException; import android.database.Cursor; import org.apache.http.HttpResponse; import android.content.res.Resources; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.json.JSONObject; import org.json.JSONException; import android.provider.MediaStore.MediaColumns; import org.apache.http.entity.StringEntity; import java.io.FileOutputStream; import java.util.ArrayList; public class signUpScreen extends ActionBarActivity { final Context context = this; private static final int REQUEST_CAMERA = 100; private static final int SELECT_FILE = 1; private String selectedImagePath; ImageView profileimage; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final AlertDialog.Builder builder1 = new AlertDialog.Builder(context); setContentView(R.layout.activity_sign_up_screen); Button registerBtn = (Button) findViewById(R.id.signBtn); registerBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JSONObject jsonobj = new JSONObject(); try { EditText nameTxt = (EditText) findViewById(R.id.userNameView); EditText usernameTxt = (EditText) findViewById(R.id.nameView); EditText passTxt = (EditText) findViewById(R.id.passView); EditText emailTxt = (EditText) findViewById(R.id.emailView); EditText confirmPassTxt = (EditText) findViewById(R.id.confirmPassView); if (!usernameTxt.getText().toString().matches("") && !passTxt.getText().toString().matches("") && !emailTxt.getText().toString().matches("")&& !nameTxt.getText().toString().matches("")) { if (passTxt.getText().toString().trim().equals(confirmPassTxt.getText().toString().trim())) { jsonobj.put("email", emailTxt.getText().toString()); jsonobj.put("name", nameTxt.getText().toString()); jsonobj.put("username", usernameTxt.getText().toString()); jsonobj.put("password", passTxt.getText().toString()); } else { builder1.setTitle("Error Message"); builder1.setMessage("Password and confirm Password does not match"); builder1.setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed } }); AlertDialog alertdialog = builder1.create(); alertdialog.show(); return; } } else { builder1.setTitle("Error Message"); builder1.setMessage("Please fill all values"); builder1.setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed } }); AlertDialog alertdialog = builder1.create(); alertdialog.show(); return; } } catch (JSONException e) { Log.i("response", "error"); } new MysyncTask().execute(jsonobj.toString()); } ; }); profileimage = (ImageView)findViewById(R.id.profileView); profileimage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { takeImage(); } }); } public void takeImage(){ final CharSequence[] items = { "Take Photo", "Choose from Library", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Photo!"); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (items[item].equals("Take Photo")) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File f = new File(android.os.Environment .getExternalStorageDirectory(), "temp.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivityForResult(intent, REQUEST_CAMERA); } else if (items[item].equals("Choose from Library")) { Intent intent = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult( Intent.createChooser(intent, "Select File"), SELECT_FILE); } else if (items[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == REQUEST_CAMERA) { File f = new File(Environment.getExternalStorageDirectory() .toString()); for (File temp : f.listFiles()) { if (temp.getName().equals("temp.jpg")) { f = temp; break; } } try { Bitmap bm,bm1; BitmapFactory.Options btmapOptions = new BitmapFactory.Options(); bm = BitmapFactory.decodeFile(f.getAbsolutePath(), btmapOptions); bm = Bitmap.createScaledBitmap(bm, 300, 300, false); bm1 = Bitmap.createScaledBitmap(bm, 300, 300, false); Matrix mat = new Matrix(); mat.postRotate(90); Bitmap bMapRotate = Bitmap.createBitmap(bm1,0,0,bm1.getWidth(),bm1.getHeight(),mat,true); profileimage.setImageBitmap(bMapRotate); //profileimage.setImageBitmap(bm); String path = android.os.Environment .getExternalStorageDirectory() + File.separator + "Phoenix" + File.separator + "default"; f.delete(); OutputStream fOut = null; File file = new File(path, String.valueOf(System .currentTimeMillis()) + ".jpg"); try { fOut = new FileOutputStream(file); bm.compress(Bitmap.CompressFormat.JPEG, 85, fOut); fOut.flush(); fOut.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } } else if (requestCode == SELECT_FILE) { Uri selectedImageUri = data.getData(); String tempPath = getPath(selectedImageUri,this); Bitmap bm,bm1; BitmapFactory.Options btmapOptions = new BitmapFactory.Options(); bm = BitmapFactory.decodeFile(tempPath, btmapOptions); bm1= Bitmap.createScaledBitmap(bm, 300, 300, false); Matrix mat = new Matrix(); mat.postRotate(90); Bitmap bMapRotate = Bitmap.createBitmap(bm1,0,0,bm1.getWidth(),bm1.getHeight(),mat,true); profileimage.setImageBitmap(bMapRotate); } } }; public String getPath(Uri uri, Activity activity) { String[] projection = { MediaColumns.DATA }; Cursor cursor = activity.managedQuery(uri, projection, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.sign_up_screen, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } private class MysyncTask extends AsyncTask<String,Void,Void>{ @Override protected Void doInBackground(String... params) { // TODO Auto-generated method stub postData(params[0]); return null; } public void postData(String data) { //make api call here DefaultHttpClient httpclient = new DefaultHttpClient(); // String url = getString(R.string.url_name); HttpPost post = new HttpPost("http://nova.mybluemix.net/api/profiles"); String responseText = null; try { StringEntity se = new StringEntity(data); se.setContentType("application/json;charset=UTF-8"); post.setEntity(se); HttpResponse httpresponse = httpclient.execute(post); responseText = EntityUtils.toString(httpresponse.getEntity()); Log.i("response",responseText); JSONObject response = new JSONObject(responseText); //String test = response.getString("error"); if(response.has("summary")) { if (response.getString("summary").equals("1 attribute is invalid")) { Log.i("response", "1 attribute is invalid"); return; } }else{ Log.i("response","okkkk"); finish(); // Intent loginScreen = new Intent(signUpScreen.this,mainScreen.class); // startActivity(loginScreen); } } catch (IOException e) { Log.i("response", "http error"); } catch(JSONException e) { } } } }
c2ba13f959d972fffb46b64744abb250b8301817
9f7f223bcc0084d6c4d17d2334bf9f912e2e32f2
/aws-java-sdk-dms/src/main/java/com/amazonaws/services/databasemigrationservice/model/transform/DescribeCertificatesRequestMarshaller.java
927a86818253d09464e7f9e027f45e75eef62264
[ "Apache-2.0" ]
permissive
tahatopiwala/aws-sdk-java
faa78384df8f4f6811a36976f5eb2354b010021f
7880b1bff54960a4ff3ab27ed0fc47ecb4637551
refs/heads/master
2021-01-21T05:28:36.312514
2016-07-22T00:35:12
2016-07-22T00:35:12
64,186,054
0
0
null
2016-07-26T03:15:02
2016-07-26T03:15:02
null
UTF-8
Java
false
false
4,155
java
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights * Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.databasemigrationservice.model.transform; import java.io.ByteArrayInputStream; import java.util.Collections; import java.util.Map; import java.util.List; import java.util.regex.Pattern; import com.amazonaws.AmazonClientException; import com.amazonaws.Request; import com.amazonaws.DefaultRequest; import com.amazonaws.http.HttpMethodName; import com.amazonaws.services.databasemigrationservice.model.*; import com.amazonaws.transform.Marshaller; import com.amazonaws.util.BinaryUtils; import com.amazonaws.util.StringUtils; import com.amazonaws.util.IdempotentUtils; import com.amazonaws.util.StringInputStream; import com.amazonaws.protocol.json.*; /** * DescribeCertificatesRequest Marshaller */ public class DescribeCertificatesRequestMarshaller implements Marshaller<Request<DescribeCertificatesRequest>, DescribeCertificatesRequest> { private final SdkJsonProtocolFactory protocolFactory; public DescribeCertificatesRequestMarshaller( SdkJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } public Request<DescribeCertificatesRequest> marshall( DescribeCertificatesRequest describeCertificatesRequest) { if (describeCertificatesRequest == null) { throw new AmazonClientException( "Invalid argument passed to marshall(...)"); } Request<DescribeCertificatesRequest> request = new DefaultRequest<DescribeCertificatesRequest>( describeCertificatesRequest, "AWSDatabaseMigrationService"); request.addHeader("X-Amz-Target", "AmazonDMSv20160101.DescribeCertificates"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory .createGenerator(); jsonGenerator.writeStartObject(); java.util.List<Filter> filtersList = describeCertificatesRequest .getFilters(); if (filtersList != null) { jsonGenerator.writeFieldName("Filters"); jsonGenerator.writeStartArray(); for (Filter filtersListValue : filtersList) { if (filtersListValue != null) { FilterJsonMarshaller.getInstance().marshall( filtersListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } if (describeCertificatesRequest.getMaxRecords() != null) { jsonGenerator.writeFieldName("MaxRecords").writeValue( describeCertificatesRequest.getMaxRecords()); } if (describeCertificatesRequest.getMarker() != null) { jsonGenerator.writeFieldName("Marker").writeValue( describeCertificatesRequest.getMarker()); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", protocolFactory.getContentType()); } catch (Throwable t) { throw new AmazonClientException( "Unable to marshall request to JSON: " + t.getMessage(), t); } return request; } }
[ "" ]
93b05c206fa11a5e9c837774c9ea36cf3fd5742c
5e8e5007dc4e3f5ac753aa77e49decdd05d697a3
/java/web/console/src/org/blue/star/cgi/statuswml.java
01120dd7dde3ee9252cc4fb2ef9bdfd0756e9cbb
[]
no_license
dizhaung/bluecode
db14eb98cba26abe5526552ddbd2c8b1f879498b
b9100832814b0012a4d8b60b11fc97d11ab292ea
refs/heads/master
2020-04-27T21:59:08.175333
2011-01-30T15:22:12
2011-01-30T15:22:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
54,804
java
/***************************************************************************** * * Blue Star, a Java Port of . * Last Modified : 3/20/2006 * * License: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * *****************************************************************************/ package org.blue.star.cgi; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import org.blue.star.base.blue; import org.blue.star.base.utils; import org.blue.star.common.objects; import org.blue.star.common.statusdata; import org.blue.star.include.blue_h; import org.blue.star.include.cgiauth_h; import org.blue.star.include.cgiutils_h; import org.blue.star.include.common_h; import org.blue.star.include.config_h; import org.blue.star.include.objects_h; import org.blue.star.include.statusdata_h; public class statuswml extends blue_servlet { public static final int DISPLAY_HOST =0; public static final int DISPLAY_SERVICE =1; public static final int DISPLAY_HOSTGROUP =2; public static final int DISPLAY_INDEX =3; public static final int DISPLAY_PING =4; public static final int DISPLAY_TRACEROUTE =5; public static final int DISPLAY_QUICKSTATS =6; public static final int DISPLAY_PROCESS =7; public static final int DISPLAY_ALL_PROBLEMS =8; public static final int DISPLAY_UNHANDLED_PROBLEMS =9; public static final int DISPLAY_HOSTGROUP_SUMMARY =0; public static final int DISPLAY_HOSTGROUP_OVERVIEW =1; public static final int DISPLAY_HOST_SUMMARY =0; public static final int DISPLAY_HOST_SERVICES =1; public static int display_type=DISPLAY_INDEX; public static int hostgroup_style=DISPLAY_HOSTGROUP_SUMMARY; public static int host_style=DISPLAY_HOST_SUMMARY; public static String host_name=""; public static String hostgroup_name=""; public static String service_desc=""; public static String ping_address=""; public static String traceroute_address=""; public static int show_all_hostgroups=common_h.TRUE; public static cgiauth_h.authdata current_authdata; public void reset_context() { display_type=DISPLAY_INDEX; hostgroup_style=DISPLAY_HOSTGROUP_SUMMARY; host_style=DISPLAY_HOST_SUMMARY; host_name=""; hostgroup_name=""; service_desc=""; ping_address=""; traceroute_address=""; show_all_hostgroups=common_h.TRUE; current_authdata = new cgiauth_h.authdata (); } public void call_main() { main( null ); } public static void main(String[] args){ int result=common_h.OK; /* get the arguments passed in the URL */ process_cgivars(); document_header(); /* read the CGI configuration file */ result=cgiutils.read_cgi_config_file(cgiutils.get_cgi_config_location()); if(result==common_h.ERROR){ System.out.printf("<P>Error: Could not open CGI configuration file '%s' for reading!</P>\n",cgiutils.get_cgi_config_location()); document_footer(); cgiutils.exit( common_h.ERROR ); return; } /* read the main configuration file */ result=cgiutils.read_main_config_file(cgiutils.main_config_file); if(result==common_h.ERROR){ System.out.printf("<P>Error: Could not open main configuration file '%s' for reading!</P>\n",cgiutils.main_config_file); document_footer(); cgiutils.exit( common_h.ERROR ); return; } /* read all object configuration data */ result=cgiutils.read_all_object_configuration_data(cgiutils.main_config_file,common_h.READ_ALL_OBJECT_DATA); if(result==common_h.ERROR){ System.out.printf("<P>Error: Could not read some or all object configuration data!</P>\n"); document_footer(); cgiutils.exit( common_h.ERROR ); return; } /* read all status data */ result=cgiutils.read_all_status_data(cgiutils.get_cgi_config_location(),statusdata_h.READ_ALL_STATUS_DATA); if(result==common_h.ERROR){ System.out.printf("<P>Error: Could not read host and service status information!</P>\n"); document_footer(); cgiutils.exit( common_h.ERROR ); return; } /* get authentication information */ cgiauth.get_authentication_information(current_authdata); /* decide what to display to the user */ if(display_type==DISPLAY_HOST && host_style==DISPLAY_HOST_SERVICES) display_host_services(); else if(display_type==DISPLAY_HOST) display_host(); else if(display_type==DISPLAY_SERVICE) display_service(); else if(display_type==DISPLAY_HOSTGROUP && hostgroup_style==DISPLAY_HOSTGROUP_OVERVIEW) display_hostgroup_overview(); else if(display_type==DISPLAY_HOSTGROUP && hostgroup_style==DISPLAY_HOSTGROUP_SUMMARY) display_hostgroup_summary(); else if(display_type==DISPLAY_PING) display_ping(); else if(display_type==DISPLAY_TRACEROUTE) display_traceroute(); else if(display_type==DISPLAY_QUICKSTATS) display_quick_stats(); else if(display_type==DISPLAY_PROCESS) display_process(); else if(display_type==DISPLAY_ALL_PROBLEMS || display_type==DISPLAY_UNHANDLED_PROBLEMS) display_problems(); else display_index(); document_footer(); cgiutils.exit( common_h.OK ); } public static void document_header(){ String date_time ; // MAX_DATETIME_LENGTH if ( response != null ) { response.setHeader( "Cache-Control", "no-store" ); response.setHeader( "Pragma", "no-cache" ); response.setDateHeader( "Last-Modified", System.currentTimeMillis() ); response.setDateHeader( "Expires", System.currentTimeMillis() ); response.setContentType("text/vnd.wap.wml"); } else { System.out.printf("Cache-Control: no-store\r\n"); System.out.printf("Pragma: no-cache\r\n"); date_time = cgiutils.get_time_string( 0, common_h.HTTP_DATE_TIME); System.out.printf("Last-Modified: %s\r\n",date_time); date_time = cgiutils.get_time_string( 0, common_h.HTTP_DATE_TIME); System.out.printf("Expires: %s\r\n",date_time); System.out.printf("Content-type: text/vnd.wap.wml\r\n\r\n"); } System.out.printf("<?xml version=\"1.0\"?>\n"); System.out.printf("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n"); System.out.printf("<wml>\n"); System.out.printf("<head>\n"); System.out.printf("<meta forua=\"true\" http-equiv=\"Cache-Control\" content=\"max-age=0\"/>\n"); System.out.printf("</head>\n"); return; } public static void document_footer(){ System.out.printf("</wml>\n"); return; } public static int process_cgivars(){ String[] variables; int error=common_h.FALSE; int x; variables=getcgi.getcgivars(request_string); for(x=0; x < variables.length ;x++){ /* we found the hostgroup argument */ if(variables[x].equals("hostgroup")){ display_type=DISPLAY_HOSTGROUP; x++; if(variables[x]==null){ error=common_h.TRUE; break; } hostgroup_name = variables[x]; if( hostgroup_name.equals("all")) show_all_hostgroups=common_h.TRUE; else show_all_hostgroups=common_h.FALSE; } /* we found the host argument */ else if(variables[x].equals("host")){ display_type=DISPLAY_HOST; x++; if(variables[x]==null){ error=common_h.TRUE; break; } host_name = variables[x]; } /* we found the service argument */ else if(variables[x].equals("service")){ display_type=DISPLAY_SERVICE; x++; if(variables[x]==null){ error=common_h.TRUE; break; } service_desc = variables[x]; } /* we found the hostgroup style argument */ else if(variables[x].equals("style")){ x++; if(variables[x]==null){ error=common_h.TRUE; break; } if(variables[x].equals("overview")) hostgroup_style=DISPLAY_HOSTGROUP_OVERVIEW; else if(variables[x].equals("summary")) hostgroup_style=DISPLAY_HOSTGROUP_SUMMARY; else if(variables[x].equals("servicedetail")) host_style=DISPLAY_HOST_SERVICES; else if(variables[x].equals("processinfo")) display_type=DISPLAY_PROCESS; else if(variables[x].equals("aprobs")) display_type=DISPLAY_ALL_PROBLEMS; else if(variables[x].equals("uprobs")) display_type=DISPLAY_UNHANDLED_PROBLEMS; else display_type=DISPLAY_QUICKSTATS; } /* we found the ping argument */ else if(variables[x].equals("ping")){ display_type=DISPLAY_PING; x++; if(variables[x]==null){ error=common_h.TRUE; break; } ping_address = variables[x]; } /* we found the traceroute argument */ else if(variables[x].equals("traceroute")){ display_type=DISPLAY_TRACEROUTE; x++; if(variables[x]==null){ error=common_h.TRUE; break; } traceroute_address = variables[x]; } } /* free memory allocated to the CGI variables */ getcgi.free_cgivars(variables); return error; } /* main intro screen */ public static void display_index(){ /**** MAIN MENU SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Nagios WAP Interface'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Nagios</b><br/><b>WAP Interface</b><br/>\n"); System.out.printf("<b><anchor title='Quick Stats'>Quick Stats<go href='%s'><postfield name='style' value='quickstats'/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='Status Summary'>Status Summary<go href='%s'><postfield name='hostgroup' value='all'/><postfield name='style' value='summary'/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='Status Overview'>Status Overview<go href='%s'><postfield name='hostgroup' value='all'/><postfield name='style' value='overview'/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='All Problems'>All Problems<go href='%s'><postfield name='style' value='aprobs'/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='Unhandled Problems'>Unhandled Problems<go href='%s'><postfield name='style' value='uprobs'/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='Process Info'>Process Info<go href='%s'><postfield name='style' value='processinfo'/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='Network Tools'>Tools<go href='#card2'/></anchor></b><br/>\n"); System.out.printf("<b><anchor title='About'>About<go href='#card3'/></anchor></b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** TOOLS SCREEN (CARD 2) ****/ System.out.printf("<card id='card2' title='Network Tools'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Network Tools:</b><br/>\n"); System.out.printf("<b><anchor title='Ping Host'>Ping<go href='%s'><postfield name='ping' value=''/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='Traceroute'>Traceroute<go href='%s'><postfield name='traceroute' value=''/></go></anchor></b><br/>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("<b><anchor title='View Host'>View Host<go href='#card4'/></anchor></b><br/>\n"); System.out.printf("<b><anchor title='View Hostgroup'>View Hostgroup<go href='#card5'/></anchor></b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** ABOUT SCREEN (CARD 3) ****/ System.out.printf("<card id='card3' title='About'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>About</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Nagios %s</b><br/><b>WAP Interface</b><br/>\n",common_h.PROGRAM_VERSION); System.out.printf("Copyright (C) 2001 Ethan Galstad<br/>\n"); System.out.printf("[email protected]<br/><br/>\n"); System.out.printf("License: <b>GPL</b><br/><br/>\n"); System.out.printf("Based in part on features found in AskAround's Wireless Network Tools<br/>\n"); System.out.printf("<b>www.askaround.com</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** VIEW HOST SCREEN (CARD 4) ****/ System.out.printf("<card id='card4' title='View Host'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>View Host</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Host Name:</b><br/>\n"); System.out.printf("<input name='hname'/>\n"); System.out.printf("<do type='accept'>\n"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='$(hname)'/></go>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("</do>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** VIEW HOSTGROUP SCREEN (CARD 5) ****/ System.out.printf("<card id='card5' title='View Hostgroup'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>View Hostgroup</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Hostgroup Name:</b><br/>\n"); System.out.printf("<input name='gname'/>\n"); System.out.printf("<do type='accept'>\n"); System.out.printf("<go href='%s' method='post'><postfield name='hostgroup' value='$(gname)'/><postfield name='style' value='overview'/></go>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("</do>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays process info */ public static void display_process(){ /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Process Info'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Process Info</b><br/><br/>\n"); /* check authorization */ if(cgiauth.is_authorized_for_system_information(current_authdata)==common_h.FALSE){ System.out.printf("<b>Error: Not authorized for process info!</b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } if(cgiutils.blue_process_state==blue_h.STATE_OK) System.out.printf("Nagios process is running<br/>\n"); else System.out.printf("<b>Nagios process may not be running</b><br/>\n"); if(blue.enable_notifications==common_h.TRUE) System.out.printf("Notifications are enabled<br/>\n"); else System.out.printf("<b>Notifications are disabled</b><br/>\n"); if(blue.execute_service_checks==common_h.TRUE) System.out.printf("Check execution is enabled<br/>\n"); else System.out.printf("<b>Check execution is disabled</b><br/>\n"); System.out.printf("<br/>\n"); System.out.printf("<b><anchor title='Process Commands'>Process Commands<go href='#card2'/></anchor></b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** COMMANDS SCREEN (CARD 2) ****/ System.out.printf("<card id='card2' title='Process Commands'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Process Commands</b><br/>\n"); if(blue.enable_notifications==common_h.FALSE) System.out.printf("<b><anchor title='Enable Notifications'>Enable Notifications<go href='%s' method='post'><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,common_h.CMD_ENABLE_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); else System.out.printf("<b><anchor title='Disable Notifications'>Disable Notifications<go href='%s' method='post'><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,common_h.CMD_DISABLE_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); if(blue.execute_service_checks==common_h.FALSE) System.out.printf("<b><anchor title='Enable Check Execution'>Enable Check Execution<go href='%s' method='post'><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,common_h.CMD_START_EXECUTING_SVC_CHECKS,cgiutils_h.CMDMODE_COMMIT); else System.out.printf("<b><anchor title='Disable Check Execution'>Disable Check Execution<go href='%s' method='post'><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,common_h.CMD_STOP_EXECUTING_SVC_CHECKS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays quick stats */ public static void display_quick_stats(){ // objects_h.host temp_host; statusdata_h.hoststatus temp_hoststatus; // objects_h.service temp_service; statusdata_h.servicestatus temp_servicestatus; int hosts_unreachable=0; int hosts_down=0; int hosts_up=0; int hosts_pending=0; int services_critical=0; int services_unknown=0; int services_warning=0; int services_ok=0; int services_pending=0; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Quick Stats'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Quick Stats</b><br/>\n"); System.out.printf("</p>\n"); /* check all hosts */ for( objects_h.host temp_host : (ArrayList<objects_h.host>) objects.host_list ){ if(cgiauth.is_authorized_for_host(temp_host,current_authdata)==common_h.FALSE) continue; temp_hoststatus=statusdata.find_hoststatus(temp_host.name); if(temp_hoststatus==null) continue; if(temp_hoststatus.status==statusdata_h.HOST_UNREACHABLE) hosts_unreachable++; else if(temp_hoststatus.status==statusdata_h.HOST_DOWN) hosts_down++; else if(temp_hoststatus.status==statusdata_h.HOST_PENDING) hosts_pending++; else hosts_up++; } /* check all services */ for(objects_h.service temp_service : (ArrayList<objects_h.service>) objects.service_list ){ if( cgiauth.is_authorized_for_service(temp_service,current_authdata)==common_h.FALSE) continue; temp_servicestatus= statusdata.find_servicestatus(temp_service.host_name,temp_service.description); if(temp_servicestatus==null) continue; if(temp_servicestatus.status==statusdata_h.SERVICE_CRITICAL) services_critical++; else if(temp_servicestatus.status==statusdata_h.SERVICE_UNKNOWN) services_unknown++; else if(temp_servicestatus.status==statusdata_h.SERVICE_WARNING) services_warning++; else if(temp_servicestatus.status==statusdata_h.SERVICE_PENDING) services_pending++; else services_ok++; } System.out.printf("<p align='left' mode='nowrap'>\n"); System.out.printf("<b>Host Totals</b>:<br/>\n"); System.out.printf("%d UP<br/>\n",hosts_up); System.out.printf("%d DOWN<br/>\n",hosts_down); System.out.printf("%d UNREACHABLE<br/>\n",hosts_unreachable); System.out.printf("%d PENDING<br/>\n",hosts_pending); System.out.printf("<br/>\n"); System.out.printf("<b>Service Totals:</b><br/>\n"); System.out.printf("%d OK<br/>\n",services_ok); System.out.printf("%d WARNING<br/>\n",services_warning); System.out.printf("%d UNKNOWN<br/>\n",services_unknown); System.out.printf("%d CRITICAL<br/>\n",services_critical); System.out.printf("%d PENDING<br/>\n",services_pending); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays hostgroup status overview */ public static void display_hostgroup_overview(){ // objects_h.hostgroup temp_hostgroup; // objects_h.hostgroupmember temp_member; objects_h.host temp_host; statusdata_h.hoststatus temp_hoststatus; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Status Overview'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b><anchor title='Status Overview'>Status Overview<go href='%s' method='post'><postfield name='hostgroup' value='%s'/><postfield name='style' value='summary'/></go></anchor></b><br/><br/>\n",cgiutils_h.STATUSWML_CGI,hostgroup_name); /* check all hostgroups */ for(objects_h.hostgroup temp_hostgroup : (ArrayList<objects_h.hostgroup>) objects.hostgroup_list ){ if(show_all_hostgroups==common_h.FALSE && !temp_hostgroup.group_name.equals(hostgroup_name)) continue; if( cgiauth.is_authorized_for_hostgroup(temp_hostgroup,current_authdata)==common_h.FALSE) continue; System.out.printf("<b>%s</b>\n",temp_hostgroup.alias); System.out.printf("<table columns='2' align='LL'>\n"); /* check all hosts in this hostgroup */ for( objects_h.hostgroupmember temp_member : (ArrayList<objects_h.hostgroupmember>) temp_hostgroup.members ){ temp_host=objects.find_host(temp_member.host_name); if(temp_host==null) continue; if( objects.is_host_member_of_hostgroup(temp_hostgroup,temp_host)==common_h.FALSE) continue; temp_hoststatus=statusdata.find_hoststatus(temp_host.name); if(temp_hoststatus==null) continue; System.out.printf("<tr><td><anchor title='%s'>",temp_host.name); if(temp_hoststatus.status==statusdata_h.HOST_UP) System.out.printf("UP"); else if(temp_hoststatus.status==statusdata_h.HOST_PENDING) System.out.printf("PND"); else if(temp_hoststatus.status==statusdata_h.HOST_DOWN) System.out.printf("DWN"); else if(temp_hoststatus.status==statusdata_h.HOST_UNREACHABLE) System.out.printf("UNR"); else System.out.printf("???"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='%s'/></go></anchor></td>",cgiutils_h.STATUSWML_CGI,temp_host.name); System.out.printf("<td>%s</td></tr>\n",temp_host.name); } System.out.printf("</table>\n"); System.out.printf("<br/>\n"); } if(show_all_hostgroups==common_h.FALSE) System.out.printf("<b><anchor title='View All Hostgroups'>View All Hostgroups<go href='%s' method='post'><postfield name='hostgroup' value='all'/><postfield name='style' value='overview'/></go></anchor></b>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays hostgroup status summary */ public static void display_hostgroup_summary(){ // objects_h.hostgroup temp_hostgroup; // objects_h.hostgroupmember temp_member; objects_h.host temp_host; statusdata_h.hoststatus temp_hoststatus; // objects_h.service temp_service; statusdata_h.servicestatus temp_servicestatus; int hosts_unreachable=0; int hosts_down=0; int hosts_up=0; int hosts_pending=0; int services_critical=0; int services_unknown=0; int services_warning=0; int services_ok=0; int services_pending=0; int found=0; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Status Summary'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b><anchor title='Status Summary'>Status Summary<go href='%s' method='post'><postfield name='hostgroup' value='%s'/><postfield name='style' value='overview'/></go></anchor></b><br/><br/>\n",cgiutils_h.STATUSWML_CGI,hostgroup_name); /* check all hostgroups */ for(objects_h.hostgroup temp_hostgroup : (ArrayList<objects_h.hostgroup>) objects.hostgroup_list ){ if(show_all_hostgroups==common_h.FALSE && !temp_hostgroup.group_name.equals(hostgroup_name)) continue; if(cgiauth.is_authorized_for_hostgroup(temp_hostgroup,current_authdata)==common_h.FALSE) continue; System.out.printf("<b><anchor title='%s'>%s<go href='%s' method='post'><postfield name='hostgroup' value='%s'/><postfield name='style' value='overview'/></go></anchor></b>\n",temp_hostgroup.group_name,temp_hostgroup.alias,cgiutils_h.STATUSWML_CGI,temp_hostgroup.group_name); System.out.printf("<table columns='2' align='LL'>\n"); hosts_up=0; hosts_pending=0; hosts_down=0; hosts_unreachable=0; services_ok=0; services_pending=0; services_warning=0; services_unknown=0; services_critical=0; /* check all hosts in this hostgroup */ for(objects_h.hostgroupmember temp_member : (ArrayList<objects_h.hostgroupmember>) temp_hostgroup.members ){ temp_host=objects.find_host(temp_member.host_name); if(temp_host==null) continue; if( objects.is_host_member_of_hostgroup(temp_hostgroup,temp_host)==common_h.FALSE) continue; temp_hoststatus=statusdata.find_hoststatus(temp_host.name); if(temp_hoststatus==null) continue; if(temp_hoststatus.status==statusdata_h.HOST_UNREACHABLE) hosts_unreachable++; else if(temp_hoststatus.status==statusdata_h.HOST_DOWN) hosts_down++; else if(temp_hoststatus.status==statusdata_h.HOST_PENDING) hosts_pending++; else hosts_up++; /* check all services on this host */ for(objects_h.service temp_service : (ArrayList<objects_h.service>) objects.service_list ){ if(!temp_service.host_name.equals(temp_host.name)) continue; if( cgiauth.is_authorized_for_service(temp_service,current_authdata)==common_h.FALSE) continue; temp_servicestatus= statusdata.find_servicestatus(temp_service.host_name,temp_service.description); if(temp_servicestatus==null) continue; if(temp_servicestatus.status==statusdata_h.SERVICE_CRITICAL) services_critical++; else if(temp_servicestatus.status==statusdata_h.SERVICE_UNKNOWN) services_unknown++; else if(temp_servicestatus.status==statusdata_h.SERVICE_WARNING) services_warning++; else if(temp_servicestatus.status==statusdata_h.SERVICE_PENDING) services_pending++; else services_ok++; } } System.out.printf("<tr><td>Hosts:</td><td>"); found=0; if(hosts_unreachable>0){ System.out.printf("%d UNR",hosts_unreachable); found=1; } if(hosts_down>0){ System.out.printf("%s%d DWN",(found==1)?", ":"",hosts_down); found=1; } if(hosts_pending>0){ System.out.printf("%s%d PND",(found==1)?", ":"",hosts_pending); found=1; } System.out.printf("%s%d UP",(found==1)?", ":"",hosts_up); System.out.printf("</td></tr>\n"); System.out.printf("<tr><td>Services:</td><td>"); found=0; if(services_critical>0){ System.out.printf("%d CRI",services_critical); found=1; } if(services_warning>0){ System.out.printf("%s%d WRN",(found==1)?", ":"",services_warning); found=1; } if(services_unknown>0){ System.out.printf("%s%d UNK",(found==1)?", ":"",services_unknown); found=1; } if(services_pending>0){ System.out.printf("%s%d PND",(found==1)?", ":"",services_pending); found=1; } System.out.printf("%s%d OK",(found==1)?", ":"",services_ok); System.out.printf("</td></tr>\n"); System.out.printf("</table>\n"); System.out.printf("<br/>\n"); } if(show_all_hostgroups==common_h.FALSE) System.out.printf("<b><anchor title='View All Hostgroups'>View All Hostgroups<go href='%s' method='post'><postfield name='hostgroup' value='all'/><postfield name='style' value='summary'/></go></anchor></b>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays host status */ public static void display_host(){ objects_h.host temp_host; statusdata_h.hoststatus temp_hoststatus; String last_check ; // MAX_DATETIME_LENGTH long current_time; long t; String state_duration ; // 48 int found; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Host Status'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Host '%s'</b><br/>\n",host_name); /* find the host */ temp_host=objects.find_host(host_name); temp_hoststatus=statusdata.find_hoststatus(host_name); if(temp_host==null || temp_hoststatus==null){ System.out.printf("<b>Error: Could not find host!</b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* check authorization */ if(cgiauth.is_authorized_for_host(temp_host,current_authdata)==common_h.FALSE){ System.out.printf("<b>Error: Not authorized for host!</b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } System.out.printf("<table columns='2' align='LL'>\n"); System.out.printf("<tr><td>Status:</td><td>"); if(temp_hoststatus.status==statusdata_h.HOST_UP) System.out.printf("UP"); else if(temp_hoststatus.status==statusdata_h.HOST_PENDING) System.out.printf("PENDING"); else if(temp_hoststatus.status==statusdata_h.HOST_DOWN) System.out.printf("DOWN"); else if(temp_hoststatus.status==statusdata_h.HOST_UNREACHABLE) System.out.printf("UNREACHABLE"); else System.out.printf("?"); System.out.printf("</td></tr>\n"); System.out.printf("<tr><td>Info:</td><td>%s</td></tr>\n",temp_hoststatus.plugin_output); last_check = cgiutils.get_time_string(temp_hoststatus.last_check, common_h.SHORT_DATE_TIME); System.out.printf("<tr><td>Last Check:</td><td>%s</td></tr>\n",last_check); current_time= utils.currentTimeInSeconds(); if(temp_hoststatus.last_state_change==0) t=current_time-blue.program_start; else t=current_time-temp_hoststatus.last_state_change; cgiutils.time_breakdown tb = cgiutils.get_time_breakdown( t ); state_duration = String.format( "%2dd %2dh %2dm %2ds%s",tb.days,tb.hours,tb.minutes,tb.seconds,(temp_hoststatus.last_state_change==0)?"+":""); System.out.printf("<tr><td>Duration:</td><td>%s</td></tr>\n",state_duration); System.out.printf("<tr><td>Properties:</td><td>"); found=0; if(temp_hoststatus.checks_enabled==common_h.FALSE){ System.out.printf("%sChecks disabled",(found==1)?", ":""); found=1; } if(temp_hoststatus.notifications_enabled==common_h.FALSE){ System.out.printf("%sNotifications disabled",(found==1)?", ":""); found=1; } if(temp_hoststatus.problem_has_been_acknowledged==common_h.TRUE){ System.out.printf("%sProblem acknowledged",(found==1)?", ":""); found=1; } if(temp_hoststatus.scheduled_downtime_depth>0){ System.out.printf("%sIn scheduled downtime",(found==1)?", ":""); found=1; } if(found==0) System.out.printf("N/A"); System.out.printf("</td></tr>\n"); System.out.printf("</table>\n"); System.out.printf("<br/>\n"); System.out.printf("<b><anchor title='View Services'>View Services<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='style' value='servicedetail'/></go></anchor></b>\n",cgiutils_h.STATUSWML_CGI,host_name); System.out.printf("<b><anchor title='Host Commands'>Host Commands<go href='#card2'/></anchor></b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** COMMANDS SCREEN (CARD 2) ****/ System.out.printf("<card id='card2' title='Host Commands'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Host Commands</b><br/>\n"); System.out.printf("<b><anchor title='Ping Host'>Ping Host<go href='%s' method='post'><postfield name='ping' value='%s'/></go></anchor></b>\n",cgiutils_h.STATUSWML_CGI,temp_host.address); System.out.printf("<b><anchor title='Traceroute'>Traceroute<go href='%s' method='post'><postfield name='traceroute' value='%s'/></go></anchor></b>\n",cgiutils_h.STATUSWML_CGI,temp_host.address); if(temp_hoststatus.status!=statusdata_h.HOST_UP && temp_hoststatus.status!=statusdata_h.HOST_PENDING) System.out.printf("<b><anchor title='Acknowledge Problem'>Acknowledge Problem<go href='#card3'/></anchor></b>\n"); if(temp_hoststatus.checks_enabled==common_h.FALSE) System.out.printf("<b><anchor title='Enable Host Checks'>Enable Host Checks<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_ENABLE_HOST_CHECK,cgiutils_h.CMDMODE_COMMIT); else System.out.printf("<b><anchor title='Disable Host Checks'>Disable Host Checks<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_DISABLE_HOST_CHECK,cgiutils_h.CMDMODE_COMMIT); if(temp_hoststatus.notifications_enabled==common_h.FALSE) System.out.printf("<b><anchor title='Enable Host Notifications'>Enable Host Notifications<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_ENABLE_HOST_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); else System.out.printf("<b><anchor title='Disable Host Notifications'>Disable Host Notifications<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_DISABLE_HOST_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("<b><anchor title='Enable All Service Checks'>Enable All Service Checks<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_ENABLE_HOST_SVC_CHECKS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("<b><anchor title='Disable All Service Checks'>Disable All Service Checks<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_DISABLE_HOST_SVC_CHECKS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("<b><anchor title='Enable All Service Notifications'>Enable All Service Notifications<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_ENABLE_HOST_SVC_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("<b><anchor title='Disable All Service Notifications'>Disable All Service Notifications<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_DISABLE_HOST_SVC_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** ACKNOWLEDGEMENT SCREEN (CARD 3) ****/ System.out.printf("<card id='card3' title='Acknowledge Problem'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Acknowledge Problem</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Your Name:</b><br/>\n"); System.out.printf("<input name='name'/><br/>\n"); System.out.printf("<b>Comment:</b><br/>\n"); System.out.printf("<input name='comment'/>\n"); System.out.printf("<do type='accept'>\n"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='com_author' value='$(name)'/><postfield name='com_data' value='$(comment)'/><postfield name='persistent' value=''/><postfield name='send_notification' value=''/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go>\n",cgiutils_h.COMMAND_CGI,host_name,common_h.CMD_ACKNOWLEDGE_HOST_PROBLEM,cgiutils_h.CMDMODE_COMMIT); System.out.printf("</do>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays services on a host */ public static void display_host_services(){ // objects_h.service temp_service; statusdata_h.servicestatus temp_servicestatus; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Host Services'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Host <anchor title='%s'>'%s'<go href='%s' method='post'><postfield name='host' value='%s'/></go></anchor> Services</b><br/>\n",host_name,host_name,cgiutils_h.STATUSWML_CGI,host_name); System.out.printf("<table columns='2' align='LL'>\n"); /* check all services */ for(objects_h.service temp_service : (ArrayList<objects_h.service>) objects.service_list ){ if(!temp_service.host_name.equals(host_name)) continue; if(cgiauth.is_authorized_for_service(temp_service,current_authdata)==common_h.FALSE) continue; temp_servicestatus=statusdata.find_servicestatus(temp_service.host_name,temp_service.description); if(temp_servicestatus==null) continue; System.out.printf("<tr><td><anchor title='%s'>",temp_service.description); if(temp_servicestatus.status==statusdata_h.SERVICE_OK) System.out.printf("OK"); else if(temp_servicestatus.status==statusdata_h.SERVICE_PENDING) System.out.printf("PND"); else if(temp_servicestatus.status==statusdata_h.SERVICE_WARNING) System.out.printf("WRN"); else if(temp_servicestatus.status==statusdata_h.SERVICE_UNKNOWN) System.out.printf("UNK"); else if(temp_servicestatus.status==statusdata_h.SERVICE_CRITICAL) System.out.printf("CRI"); else System.out.printf("???"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/></go></anchor></td>",cgiutils_h.STATUSWML_CGI,temp_service.host_name,temp_service.description); System.out.printf("<td>%s</td></tr>\n",temp_service.description); } System.out.printf("</table>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays service status */ public static void display_service(){ objects_h.service temp_service; statusdata_h.servicestatus temp_servicestatus; String last_check ; // MAX_DATETIME_LENGTH long current_time; long t; String state_duration ; // 48 int found; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Service Status'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Service '%s' on host '%s'</b><br/>\n",service_desc,host_name); /* find the service */ temp_service=objects.find_service(host_name,service_desc); temp_servicestatus=statusdata.find_servicestatus(host_name,service_desc); if(temp_service==null || temp_servicestatus==null){ System.out.printf("<b>Error: Could not find service!</b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* check authorization */ if(cgiauth.is_authorized_for_service(temp_service,current_authdata)==common_h.FALSE){ System.out.printf("<b>Error: Not authorized for service!</b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } System.out.printf("<table columns='2' align='LL'>\n"); System.out.printf("<tr><td>Status:</td><td>"); if(temp_servicestatus.status==statusdata_h.SERVICE_OK) System.out.printf("OK"); else if(temp_servicestatus.status==statusdata_h.SERVICE_PENDING) System.out.printf("PENDING"); else if(temp_servicestatus.status==statusdata_h.SERVICE_WARNING) System.out.printf("WARNING"); else if(temp_servicestatus.status==statusdata_h.SERVICE_UNKNOWN) System.out.printf("UNKNOWN"); else if(temp_servicestatus.status==statusdata_h.SERVICE_CRITICAL) System.out.printf("CRITICAL"); else System.out.printf("?"); System.out.printf("</td></tr>\n"); System.out.printf("<tr><td>Info:</td><td>%s</td></tr>\n",temp_servicestatus.plugin_output); last_check = cgiutils.get_time_string(temp_servicestatus.last_check, common_h.SHORT_DATE_TIME); System.out.printf("<tr><td>Last Check:</td><td>%s</td></tr>\n",last_check); current_time=utils.currentTimeInSeconds(); if(temp_servicestatus.last_state_change==0) t=current_time-blue.program_start; else t=current_time-temp_servicestatus.last_state_change; cgiutils.time_breakdown tb = cgiutils.get_time_breakdown( t ); state_duration = String.format( "%2dd %2dh %2dm %2ds%s",tb.days,tb.hours,tb.minutes,tb.seconds,(temp_servicestatus.last_state_change==0)?"+":""); System.out.printf("<tr><td>Duration:</td><td>%s</td></tr>\n",state_duration); System.out.printf("<tr><td>Properties:</td><td>"); found=0; if(temp_servicestatus.checks_enabled==common_h.FALSE){ System.out.printf("%sChecks disabled",(found==1)?", ":""); found=1; } if(temp_servicestatus.notifications_enabled==common_h.FALSE){ System.out.printf("%sNotifications disabled",(found==1)?", ":""); found=1; } if(temp_servicestatus.problem_has_been_acknowledged==common_h.TRUE){ System.out.printf("%sProblem acknowledged",(found==1)?", ":""); found=1; } if(temp_servicestatus.scheduled_downtime_depth>0){ System.out.printf("%sIn scheduled downtime",(found==1)?", ":""); found=1; } if(found==0) System.out.printf("N/A"); System.out.printf("</td></tr>\n"); System.out.printf("</table>\n"); System.out.printf("<br/>\n"); System.out.printf("<b><anchor title='View Host'>View Host<go href='%s' method='post'><postfield name='host' value='%s'/></go></anchor></b>\n",cgiutils_h.STATUSWML_CGI,host_name); System.out.printf("<b><anchor title='Service Commands'>Svc. Commands<go href='#card2'/></anchor></b>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** COMMANDS SCREEN (CARD 2) ****/ System.out.printf("<card id='card2' title='Service Commands'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Service Commands</b><br/>\n"); if(temp_servicestatus.status!=statusdata_h.SERVICE_OK && temp_servicestatus.status!=statusdata_h.SERVICE_PENDING) System.out.printf("<b><anchor title='Acknowledge Problem'>Acknowledge Problem<go href='#card3'/></anchor></b>\n"); if(temp_servicestatus.checks_enabled==common_h.FALSE) System.out.printf("<b><anchor title='Enable Checks'>Enable Checks<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,service_desc,common_h.CMD_ENABLE_SVC_CHECK,cgiutils_h.CMDMODE_COMMIT); else{ System.out.printf("<b><anchor title='Disable Checks'>Disable Checks<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,service_desc,common_h.CMD_DISABLE_SVC_CHECK,cgiutils_h.CMDMODE_COMMIT); System.out.printf("<b><anchor title='Schedule Immediate Check'>Schedule Immediate Check<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/><postfield name='start_time' value='%d'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,service_desc,current_time,common_h.CMD_SCHEDULE_SVC_CHECK,cgiutils_h.CMDMODE_COMMIT); } if(temp_servicestatus.notifications_enabled==common_h.FALSE) System.out.printf("<b><anchor title='Enable Notifications'>Enable Notifications<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,service_desc,common_h.CMD_ENABLE_SVC_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); else System.out.printf("<b><anchor title='Disable Notifications'>Disable Notifications<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go></anchor></b><br/>\n",cgiutils_h.COMMAND_CGI,host_name,service_desc,common_h.CMD_DISABLE_SVC_NOTIFICATIONS,cgiutils_h.CMDMODE_COMMIT); System.out.printf("</p>\n"); System.out.printf("</card>\n"); /**** ACKNOWLEDGEMENT SCREEN (CARD 3) ****/ System.out.printf("<card id='card3' title='Acknowledge Problem'>\n"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Acknowledge Problem</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Your Name:</b><br/>\n"); System.out.printf("<input name='name'/><br/>\n"); System.out.printf("<b>Comment:</b><br/>\n"); System.out.printf("<input name='comment'/>\n"); System.out.printf("<do type='accept'>\n"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/><postfield name='com_author' value='$(name)'/><postfield name='com_data' value='$(comment)'/><postfield name='persistent' value=''/><postfield name='send_notification' value=''/><postfield name='cmd_typ' value='%d'/><postfield name='cmd_mod' value='%d'/><postfield name='content' value='wml'/></go>\n",cgiutils_h.COMMAND_CGI,host_name,service_desc,common_h.CMD_ACKNOWLEDGE_SVC_PROBLEM,cgiutils_h.CMDMODE_COMMIT); System.out.printf("</do>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } /* displays ping results */ public static void display_ping(){ String input_buffer ; // MAX_INPUT_BUFFER String buffer ; // MAX_INPUT_BUFFER // String temp_ptr; // FILE *fp; int odd=0; int in_macro=common_h.FALSE; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Ping'>\n"); if( ping_address.equals("")){ System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Ping Host</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Host Name/Address:</b><br/>\n"); System.out.printf("<input name='address'/>\n"); System.out.printf("<do type='accept'>\n"); System.out.printf("<go href='%s'><postfield name='ping' value='$(address)'/></go>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("</do>\n"); System.out.printf("</p>\n"); } else{ System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Results For Ping Of %s:</b><br/>\n",ping_address); System.out.printf("</p>\n"); System.out.printf("<p mode='nowrap'>\n"); if(cgiutils.ping_syntax==null) System.out.printf("ping_syntax in CGI config file is null!\n"); else{ /* process macros in the ping syntax */ buffer = ""; input_buffer = cgiutils.ping_syntax ; String[] split = input_buffer.split( "[$]" ); for ( String temp_ptr : split ) { if(in_macro==common_h.FALSE){ buffer += temp_ptr ; in_macro=common_h.TRUE; } else{ if( temp_ptr.equals("HOSTADDRESS")) buffer = ping_address; in_macro=common_h.FALSE; } } try { Process process = Runtime.getRuntime().exec( buffer ); BufferedReader input = new BufferedReader( new InputStreamReader( process.getInputStream() ) ); for( buffer = input.readLine(); buffer != null; buffer = input.readLine() ) { if( odd != 0 ) { odd = 0; System.out.printf("%s<br/>\n",buffer); } else { odd = 1; System.out.printf("<b>%s</b><br/>\n",buffer); } } } catch( Throwable e ) { System.out.printf("Error executing traceroute!\n"); } } System.out.printf("</p>\n"); } System.out.printf("</card>\n"); return; } /* displays traceroute results */ public static void display_traceroute(){ String buffer ; // MAX_INPUT_BUFFER // FILE *fp; int odd=0; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='Traceroute'>\n"); if( traceroute_address.equals("")){ System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Traceroute</b><br/>\n"); System.out.printf("</p>\n"); System.out.printf("<p align='center' mode='wrap'>\n"); System.out.printf("<b>Host Name/Address:</b><br/>\n"); System.out.printf("<input name='address'/>\n"); System.out.printf("<do type='accept'>\n"); System.out.printf("<go href='%s'><postfield name='traceroute' value='$(address)'/></go>\n",cgiutils_h.STATUSWML_CGI); System.out.printf("</do>\n"); System.out.printf("</p>\n"); } else{ System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>Results For Traceroute To %s:</b><br/>\n",traceroute_address); System.out.printf("</p>\n"); System.out.printf("<p mode='nowrap'>\n"); buffer = String.format( "%s %s", config_h.TRACEROUTE_COMMAND,traceroute_address); try { Process process = Runtime.getRuntime().exec( buffer ); BufferedReader input = new BufferedReader( new InputStreamReader( process.getInputStream() ) ); for( buffer = input.readLine(); buffer != null; buffer = input.readLine() ) { if( odd != 0 ) { odd = 0; System.out.printf("%s<br/>\n",buffer); } else { odd = 1; System.out.printf("<b>%s</b><br/>\n",buffer); } } } catch( Throwable e ) { System.out.printf("Error executing traceroute!\n"); } System.out.printf("</p>\n"); } System.out.printf("</card>\n"); return; } /* displays problems */ public static void display_problems(){ objects_h.host temp_host; objects_h.service temp_service; // statusdata_h.hoststatus temp_hoststatus; int total_host_problems=0; // statusdata_h.servicestatus temp_servicestatus; int total_service_problems=0; /**** MAIN SCREEN (CARD 1) ****/ System.out.printf("<card id='card1' title='%s Problems'>\n",(display_type==DISPLAY_ALL_PROBLEMS)?"All":"Unhandled"); System.out.printf("<p align='center' mode='nowrap'>\n"); System.out.printf("<b>%s Problems</b><br/><br/>\n",(display_type==DISPLAY_ALL_PROBLEMS)?"All":"Unhandled"); System.out.printf("<b>Host Problems:</b>\n"); System.out.printf("<table columns='2' align='LL'>\n"); /* check all hosts */ for( statusdata_h.hoststatus temp_hoststatus : (ArrayList<statusdata_h.hoststatus>) statusdata.hoststatus_list ){ temp_host=objects.find_host(temp_hoststatus.host_name); if(temp_host==null) continue; if(cgiauth.is_authorized_for_host(temp_host,current_authdata)==common_h.FALSE) continue; if(temp_hoststatus.status==statusdata_h.HOST_UP || temp_hoststatus.status==statusdata_h.HOST_PENDING) continue; if(display_type==DISPLAY_UNHANDLED_PROBLEMS){ if(temp_hoststatus.problem_has_been_acknowledged==common_h.TRUE) continue; if(temp_hoststatus.checks_enabled==common_h.FALSE) continue; if(temp_hoststatus.notifications_enabled==common_h.FALSE) continue; if(temp_hoststatus.scheduled_downtime_depth>0) continue; } total_host_problems++; System.out.printf("<tr><td><anchor title='%s'>",temp_host.name); if(temp_hoststatus.status==statusdata_h.HOST_DOWN) System.out.printf("DWN"); else if(temp_hoststatus.status==statusdata_h.HOST_UNREACHABLE) System.out.printf("UNR"); else System.out.printf("???"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='%s'/></go></anchor></td>",cgiutils_h.STATUSWML_CGI,temp_host.name); System.out.printf("<td>%s</td></tr>\n",temp_host.name); } if(total_host_problems==0) System.out.printf("<tr><td>No problems</td></tr>\n"); System.out.printf("</table>\n"); System.out.printf("<br/>\n"); System.out.printf("<b>Svc Problems:</b>\n"); System.out.printf("<table columns='2' align='LL'>\n"); /* check all services */ for(statusdata_h.servicestatus temp_servicestatus : (ArrayList<statusdata_h.servicestatus>) statusdata.servicestatus_list ){ temp_service=objects.find_service(temp_servicestatus.host_name,temp_servicestatus.description); if(temp_service==null) continue; if(cgiauth.is_authorized_for_service(temp_service,current_authdata)==common_h.FALSE) continue; if(temp_servicestatus.status==statusdata_h.SERVICE_OK || temp_servicestatus.status==statusdata_h.SERVICE_PENDING) continue; if(display_type==DISPLAY_UNHANDLED_PROBLEMS){ if(temp_servicestatus.problem_has_been_acknowledged==common_h.TRUE) continue; if(temp_servicestatus.checks_enabled==common_h.FALSE) continue; if(temp_servicestatus.notifications_enabled==common_h.FALSE) continue; if(temp_servicestatus.scheduled_downtime_depth>0) continue; } total_service_problems++; System.out.printf("<tr><td><anchor title='%s'>",temp_servicestatus.description); if(temp_servicestatus.status==statusdata_h.SERVICE_CRITICAL) System.out.printf("CRI"); else if(temp_servicestatus.status==statusdata_h.SERVICE_WARNING) System.out.printf("WRN"); else if(temp_servicestatus.status==statusdata_h.SERVICE_UNKNOWN) System.out.printf("UNK"); else System.out.printf("???"); System.out.printf("<go href='%s' method='post'><postfield name='host' value='%s'/><postfield name='service' value='%s'/></go></anchor></td>",cgiutils_h.STATUSWML_CGI,temp_service.host_name,temp_service.description); System.out.printf("<td>%s/%s</td></tr>\n",temp_service.host_name,temp_service.description); } if(total_service_problems==0) System.out.printf("<tr><td>No problems</td></tr>\n"); System.out.printf("</table>\n"); System.out.printf("</p>\n"); System.out.printf("</card>\n"); return; } }
b8ccdbe78aeb0721d6ce07129f980fd352439530
a4422799ed092692fc78bbb0cc7d78e260dbe570
/src/main/java/com/wei/learncode/classloard/Simple.java
cd0fea1b3fde6110eefd8f27e2bf8bc238990e6c
[]
no_license
skyemin/learncode
fb1fac4236b3acd772179080a431442ab792b70b
5cea07df633c3ae0bc513418de74779256365222
refs/heads/master
2023-08-24T06:48:03.676448
2023-07-23T16:08:59
2023-07-23T16:08:59
181,654,837
0
0
null
null
null
null
UTF-8
Java
false
false
425
java
package com.wei.learncode.classloard; import java.util.Random; /** * @Author: weizz * @Date: 2019/4/29 9:10 * @Description: * @Version:1.0 */ public class Simple { static{ System.out.println("我被初始化了"); } public static final int a = 10; public static final int b = new Random().nextInt(10); public static void test(){ } public static void main(String[] args) { } }
e75217d28947f5da0dd4c3189f2ea0453bd64185
b6464c589c69cd08b33cb1985e9d72641cf57de0
/src/main/java/ru/fly/client/ui/field/datefield/MonthPickerField.java
01cac68dfdc6ee7aec0897c73eaef58c1e4b5397
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
filius/fly-gwt
e5f989da0c1ac540de542b386ca882bb1a0f4731
da965f28cbe8db9c8c545e6a5fc6f92e0f122cdd
refs/heads/master
2021-06-08T01:08:50.498792
2021-05-23T18:41:18
2021-05-23T18:41:18
29,881,628
1
0
Apache-2.0
2021-05-23T18:49:35
2015-01-26T21:07:09
Java
UTF-8
Java
false
false
4,609
java
package ru.fly.client.ui.field.datefield; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.RootPanel; import ru.fly.client.event.ValueChangeEvent; import ru.fly.client.ui.FElement; import ru.fly.client.ui.field.Field; import ru.fly.client.ui.field.TriggerController; import ru.fly.client.ui.field.datefield.decor.DateFieldDecor; import java.util.Date; /** * User: fil * Date: 18.10.15 */ public class MonthPickerField extends Field<Date> { private DateFieldDecor decor; private TriggerController triggerController; private MonthPicker monthPicker; private DateTimeFormat format; private FElement viewElement; private FElement triggerElement; public MonthPickerField() { this(DateTimeFormat.getFormat("MM.yyyy")); } public MonthPickerField(DateTimeFormat format) { this(GWT.<DateFieldDecor>create(DateFieldDecor.class), format); } public MonthPickerField(DateFieldDecor decor, DateTimeFormat format) { this.decor = decor; this.format = format; addStyleName(decor.css().dateField()); setWidth(100); viewElement = DOM.createDiv().cast(); viewElement.addClassName(decor.css().dateFieldView()); triggerElement = buildTriggerElement(); triggerController = new TriggerController(this, triggerElement) { @Override protected FElement getExpandedElement() { return getMonthPicker().getElement().cast(); } @Override public void onExpand() { MonthPickerField.this.onExpand(); } @Override public void onCollapse() { MonthPickerField.this.onCollapse(); } @Override public boolean isEnabled() { return MonthPickerField.this.isEnabled(); } }; } @Override public void onAfterFirstAttach() { super.onAfterFirstAttach(); getElement().appendChild(viewElement); getElement().appendChild(triggerElement); DOM.setEventListener(viewElement, new EventListener() { @Override public void onBrowserEvent(Event event) { triggerController.expandCollapse(); } }); DOM.sinkEvents(viewElement, Event.ONCLICK); } protected FElement buildTriggerElement() { FElement ret = DOM.createDiv().cast(); ret.addClassName(decor.css().dateFieldTrigger()); FElement trIcon = DOM.createDiv().cast(); ret.appendChild(trIcon); trIcon.setClassName(decor.css().dateFieldTriggerIcon()); return ret; } protected void onExpand() { int left = getAbsoluteLeft() + getWidth() - 130; int wndViewHeight = Window.getClientHeight() + Window.getScrollTop(); getMonthPicker().getElement().getStyle().setPosition(Style.Position.ABSOLUTE); getMonthPicker().getElement().getStyle().setZIndex(10000); RootPanel.get().add(getMonthPicker()); if (getElement().getAbsoluteTop() + getHeight() + 170 > wndViewHeight) { getMonthPicker().getElement().setPosition(left, getAbsoluteTop() - 170); } else { getMonthPicker().getElement().setPosition(left, getAbsoluteTop() + getHeight() + 2); } getMonthPicker().setValue(getValue(), false); } private MonthPicker getMonthPicker() { if (monthPicker == null) { monthPicker = new MonthPicker() { }; monthPicker.addValueChangeHandler(new ValueChangeEvent.ValueChangeHandler<Date>() { @Override public void onValueChange(Date object) { MonthPickerField.this.setValue(object); triggerController.collapse(); } }); } return monthPicker; } protected void onCollapse() { RootPanel.get().remove(getMonthPicker()); } @Override public boolean setValue(Date value, boolean fire) { if (viewElement != null) { if (value == null) viewElement.setInnerHTML(""); else viewElement.setInnerHTML(format.format(value)); } return super.setValue(value, fire); } }
53b3af7d12fd3f7df3e3de5f7288e0453bb59dc4
c7faf496e1a81d568329e0ca8bd43e2c6fc69682
/src/main/java/model/BonusTempo.java
adb395fe4588a2beb1200009b28be73b8ab8d6fe
[]
no_license
Hdelesposti/prova1
889c9ac813c0958cb10720a686967a1b01374aa3
0eb05e44d18eaeba8df52cbe74e386cd8d300ea8
refs/heads/main
2023-04-19T12:31:21.697332
2021-05-01T17:51:43
2021-05-01T17:51:43
363,024,191
0
0
null
null
null
null
UTF-8
Java
false
false
278
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package model; /** * * @author Heloiza */ public class BonusTempo { }
0041c052f359a825125505c877c2af5d65506cb0
9d54d949353cc9603c3b2b05d6a895ba4e316d75
/ccdb-business/src/main/java/org/openepics/discs/conf/util/PropertyValueUIElement.java
08e62c0d6532d3fa765e4a6a6fba1becbe30b59f
[]
no_license
openepics/discs-ccdb-ess
2228b42533f11a3954dc870b25c0f053940d0253
ceea63d44ff662ed92435a7e2cf82bdddca04605
refs/heads/master
2021-01-19T01:19:54.287141
2016-06-21T14:35:21
2016-06-21T14:35:21
61,640,811
0
1
null
null
null
null
UTF-8
Java
false
false
1,281
java
/* * Copyright (c) 2014 European Spallation Source * Copyright (c) 2014 Cosylab d.d. * * This file is part of Controls Configuration Database. * * Controls Configuration Database is free software: you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of the License, * or any newer version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see https://www.gnu.org/licenses/gpl-2.0.txt */ package org.openepics.discs.conf.util; /** * There are three possible UI elements for showing/editing a property value: * <ul> * <li>simple input field (single value)</li> * <li>text area input box (multiple values)</li> * <li>a drop down for selecting a single element (enumeration)</li> * </ul> * * @author <a href="mailto:[email protected]">Miha Vitorovič</a> * */ public enum PropertyValueUIElement { INPUT, TEXT_AREA, SELECT_ONE_MENU, NONE }
9f81cdcea1c660c5032fb484a411d9cf31220cc4
ff194f40e9ffee051627fdb28368b54a54658ceb
/rocketmq/src/main/java/com/demo/components/rocketmq/schedule/ScheduledMessageConsumer.java
7776c0540374f6fdbd008a798716ad7f10ac6b50
[]
no_license
haoshuimofu/common-components-parent
481a0cab1db60a59c3ff9b6ebbf6d063a06951ee
8cc2cc8e41117b28b5282d538334b396106b3387
refs/heads/master
2023-08-31T02:14:46.265734
2023-08-30T16:09:21
2023-08-30T16:09:21
281,634,859
0
5
null
2023-04-27T09:12:55
2020-07-22T09:32:52
Java
UTF-8
Java
false
false
2,037
java
package com.demo.components.rocketmq.schedule; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.common.message.MessageExt; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** * @author wude * @date 2020/7/31 15:05 */ public class ScheduledMessageConsumer { public static void main(String[] args) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); // Instantiate message consumer DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ScheduledMessageConsumerGroup"); consumer.setNamesrvAddr("localhost:9876"); // Subscribe topics consumer.subscribe("ScheduledMessageTopic", "*"); // Register message listener consumer.registerMessageListener(new MessageListenerConcurrently() { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> messages, ConsumeConcurrentlyContext context) { for (MessageExt message : messages) { // Print approximate delay time period System.out.println("Receive message[msgId=" + message.getMsgId() + "] " + (System.currentTimeMillis() - message.getStoreTimestamp()) + "ms later"); System.err.println("queueId = " + message.getQueueId() + ", queueOffset = " + message.getQueueOffset() + ", body = [" + new String(message.getBody()) + "], thread = " +Thread.currentThread().getName() + ", now = " + sdf.format(new Date())); } return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } }); // Launch consumer consumer.start(); } }
a029f214b9419eb76640c56d48d15c03589a1581
0c95221dbcc5bc871da027c4a1cb4cceafa866ed
/HBProj-7-Hibernate-hbm2ddlAutoProperty/src/com/nt/test/SaveObjectTest1.java
455fbc4ebac0332ce6f9825dfda3faa9d4194d31
[]
no_license
VaibhavBelkhude/Hibernate713
7114c90429bcd6be941494aba17d6ea70f3957e4
51c5102de31ffd1f9d7c8b8ffb9d8cf8b52e61b2
refs/heads/main
2023-04-16T04:55:41.998426
2021-04-15T09:17:25
2021-04-15T09:17:25
353,301,471
0
0
null
null
null
null
UTF-8
Java
false
false
1,902
java
package com.nt.test; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import com.nt.entity.Actor; public class SaveObjectTest1 { public static void main(String[] args) throws Exception{ //Bootstrap the Hibernate (Activate HB f/w) Configuration cfg=new Configuration(); //Specify the name and location of HB cfg file (indirectly mapping file ) cfg.configure("com/nt/cfgs/hibernate.cfg.xml"); // create HB SessionFactory object SessionFactory factory=cfg.buildSessionFactory(); Thread.sleep(20000); //create HB Session obj Session ses=factory.openSession(); //prepare Entity class object Actor actor=new Actor(); actor.setActorId(920); actor.setActorName("kartik"); actor.setActorAddrs("Rajura"); actor.setPhone(9952634555L); actor.setRemuneration(150556.0f); Transaction tx=null; boolean flag=false; try { //begin Tx tx=ses.beginTransaction(); // internally calls con.setAutoCommit(false) //execute logics int idVal=(int)ses.save(actor); System.out.println("Generated idvalue::"+idVal); flag=true; } catch(HibernateException he) { flag=false; he.printStackTrace(); } catch(Exception e) { flag=false; e.printStackTrace(); } finally { if(flag) { tx.commit(); //iternally calls con.commit() method System.out.println("Object is saved -- Object data is inserted to DB table as record"); Thread.sleep(20000); } else { tx.rollback(); System.out.println("Object is not saved -- Object data is not inserted to the DB table as record"); } //close Session obj (connection closing) ses.close(); //close SessionFactory object factory.close(); }//finally }//main }//class
49e278ded7bafc3e7710230fc14adf7859fde663
f9c621755f3b3e0786055c78738beff8885bc3b6
/java210208/src/book/ch5/EmpList.java
8300cceaa9ab71393bf46376a5aa131c635cb813
[]
no_license
dnguddl9436/java210208-1
b89a7d704450c33acbdef3aa01120166c24fca67
b4e7089b5254ed1decd8022c33211229d66933fe
refs/heads/main
2023-04-16T08:37:01.842605
2021-04-13T06:23:08
2021-04-13T06:23:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
650
java
package book.ch5; import com.vo.EmpVO; public class EmpList { /********************************************************************************************** * * @param empno - 사원번호 * @return String [] - 사원이름 , 부서명 *********************************************************************************************/ public String[] getEmpDetail(int empno) { String[] info = new String[2]; EmpVO eVO = new EmpVO(); eVO.setEmpno(7566); eVO.setD return info; } public static void main(String[] args) { /* EmpVO eVO = new EmpVO(); eVO = new EmpVO(); eVO = new EmpVO(); eVO = new EmpVO(); */ } }
36fae74128e61619c031cf1b73c690e1d104b094
8e2cac9db4a01eba41e554f2f494d29cf7fb5540
/autobahn/src/main/java/io/crossbar/autobahn/websocket/messages/Close.java
8c90f16e3753b8aaf3ed5f41a8d38fa8cf90492e
[ "MIT" ]
permissive
crossbario/autobahn-java
1786fef59121140659fb448533a4cb37b6cfcd2a
bdc093eea9398acfdfe3eab83d2487a0f72b518b
refs/heads/master
2023-08-14T08:06:24.436586
2022-06-21T08:35:54
2022-06-21T08:35:54
2,430,530
712
181
MIT
2022-11-02T03:25:31
2011-09-21T15:15:24
Java
UTF-8
Java
false
false
783
java
package io.crossbar.autobahn.websocket.messages; /// WebSockets close to send or received. public class Close extends Message { public int mCode; public String mReason; // Not to be delivered on the wire, only for local use. public boolean mIsReply; Close() { mCode = -1; mReason = null; } Close(int code) { mCode = code; mReason = null; } // For local use only. public Close(int code, boolean isReply) { mCode = code; mIsReply = isReply; } public Close(int code, String reason) { mCode = code; mReason = reason; } public Close(int code, String reason, boolean isReply) { mCode = code; mIsReply = isReply; mReason = reason; } }
db05430b1a45a396a874dde6e1c040f1b942bb38
b09646c70ae386afc63d5a72663dc83eab1e7281
/app/src/main/java/com/example/luisguzmn/healthcare40/crearCuentaHelo.java
9828ad03268260a2a0a336c5921196515a1f0954
[]
no_license
WilyPonce/SmartHealthcare
46c3d26303df3656075490331a9a48a90b42e142
2c11b9ad829c33cafcbf49208687381eb3186515
refs/heads/Healthcare
2020-03-13T15:35:19.638203
2018-05-16T19:04:59
2018-05-16T19:04:59
131,179,900
0
2
null
2018-05-07T13:58:37
2018-04-26T16:02:44
Java
UTF-8
Java
false
false
15,934
java
package com.example.luisguzmn.healthcare40; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.v7.widget.AppCompatSpinner; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.example.luisguzmn.healthcare40.Helo.CountrySpinnerItem; import com.example.luisguzmn.healthcare40.Helo.HeloConnection; import com.example.luisguzmn.healthcare40.Helo.PinActivity; import com.worldgn.connector.Connector; import com.worldgn.connector.ICallbackPin; import com.worldgn.connector.ILoginCallback; import com.worldgn.connector.Util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class crearCuentaHelo extends Activity { //VARIABLES EditText editTextEmail, editTextPhone, app_key, app_token; // AppCompatSpinner countrySpinner; TextView text_1; private List<CountrySpinnerItem> countrySpinnerItems; private String prefix = "",countryName; private final static String TAG = crearCuentaHelo.class.getSimpleName(); ProgressDialog progressDialog; SharedPreferences spLogin; // @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.crear_cuenta_helo); spLogin = PreferenceManager.getDefaultSharedPreferences(this); if (Connector.getInstance().isLoggedIn()) { startActivity(new Intent(this, MainActivity.class)); finish(); return; } //CAST progressDialog = new ProgressDialog(this); progressDialog.setMessage("Loading please wait..."); editTextEmail = (EditText) findViewById(R.id.email); editTextPhone = (EditText) findViewById(R.id.phonenumber); app_key = (EditText) findViewById(R.id.app_key); app_token = (EditText) findViewById(R.id.app_token); countrySpinner= (AppCompatSpinner) findViewById(R.id.countrySpinner); text_1=(TextView) findViewById(R.id.text_1); countrySpinnerItems=getCountries(this); ArrayAdapter<CountrySpinnerItem> adapterCountry = new ArrayAdapter<CountrySpinnerItem>( this, R.layout.spinner_item, countrySpinnerItems); adapterCountry.setDropDownViewResource(R.layout.spinner_item_dropdown); countrySpinner.setAdapter(adapterCountry); countrySpinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); // editTextEmail.setText("[email protected]"); editTextPhone.setText(spLogin.getString("phone","no phone")); app_key.setText("152384277176254522"); app_token.setText("B9B2E74B829AC1FCE45FFF44BE772CE8C5DD2200"); ///////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////LOGIN AUTOMATICO///////////////////////////////////////////////////// if(!TextUtils.isEmpty(app_key.getText().toString()) && !TextUtils.isEmpty(app_token.getText().toString())) { Connector.getInstance().initialize(this,app_key.getText().toString(), app_token.getText().toString()); if (Util.isvalidEmail(editTextEmail.getText().toString()) ) { editTextPhone.getText().clear();//to clear phone number to avoid final String email = editTextEmail.getText().toString(); //prefHelper.setString(Constants.PREF_DEV_ENVIRONMENT,"0"); progressDialog.show(); Connector.getInstance().login(email, new ILoginCallback() { @Override public void onSuccess(long heloUserId) { SharedPreferences.Editor spLoginEditor = spLogin.edit(); spLoginEditor.putBoolean("success",true); spLoginEditor.apply(); progressDialog.cancel(); startActivity(new Intent(crearCuentaHelo.this, HeloConnection.class)); finish(); } @Override public void onPinverification() { progressDialog.cancel(); Intent intent = new Intent(crearCuentaHelo.this, PinActivity.class); intent.putExtra(PinActivity.ACTION_TYPE, PinActivity.ACTION_EMAIL); intent.putExtra(PinActivity.ACTION_EMAIL, email); startActivity(intent); } @Override public void onFailure(String description) { progressDialog.cancel(); Toast.makeText(getApplicationContext(), description, Toast.LENGTH_LONG).show(); } @Override public void accountVerification() { } }); } else if (Util.isvalidPhone(editTextPhone.getText().toString())) { editTextEmail.getText().clear(); final String phone = editTextPhone.getText().toString(); if (TextUtils.isEmpty(phone)) { Toast.makeText(getApplicationContext(), "Enter phone address", Toast.LENGTH_LONG).show(); return; } progressDialog.show(); Connector.getInstance().login(text_1.getText().toString(), phone, new ILoginCallback() { @Override public void onSuccess(long heloUserId) { SharedPreferences.Editor spLoginEditor = spLogin.edit(); spLoginEditor.putBoolean("success",true); spLoginEditor.apply(); progressDialog.cancel(); startActivity(new Intent(crearCuentaHelo.this, HeloConnection.class)); } @Override public void onPinverification() { progressDialog.cancel(); Intent intent = new Intent(crearCuentaHelo.this, PinActivity.class); intent.putExtra(PinActivity.ACTION_TYPE, PinActivity.ACTION_PHONE); intent.putExtra(PinActivity.ACTION_PHONE, phone); startActivity(intent); } @Override public void onFailure(String description) { progressDialog.cancel(); Toast.makeText(getApplicationContext(), description, Toast.LENGTH_LONG).show(); } @Override public void accountVerification() { } }); } } else { Toast.makeText(this, "Please fill APP KEY and APP TOKEN", Toast.LENGTH_LONG).show(); } ///////////////////////////////////////////////////////////////////////////////////////////// } public void onClick(View view) { /*if (view.getId() == R.id.login) { if(!TextUtils.isEmpty(app_key.getText().toString()) && !TextUtils.isEmpty(app_token.getText().toString())) { Connector.getInstance().initialize(this,app_key.getText().toString(), app_token.getText().toString()); if (Util.isvalidEmail(editTextEmail.getText().toString()) ) { editTextPhone.getText().clear();//to clear phone number to avoid final String email = editTextEmail.getText().toString(); //prefHelper.setString(Constants.PREF_DEV_ENVIRONMENT,"0"); progressDialog.show(); Connector.getInstance().login(email, new ILoginCallback() { @Override public void onSuccess(long heloUserId) { progressDialog.cancel(); startActivity(new Intent(crearCuentaHelo.this, MainActivity.class)); finish(); } @Override public void onPinverification() { progressDialog.cancel(); Intent intent = new Intent(crearCuentaHelo.this, PinActivity.class); intent.putExtra(PinActivity.ACTION_TYPE, PinActivity.ACTION_EMAIL); intent.putExtra(PinActivity.ACTION_EMAIL, email); startActivity(intent); } @Override public void onFailure(String description) { progressDialog.cancel(); Toast.makeText(getApplicationContext(), description, Toast.LENGTH_LONG).show(); } @Override public void accountVerification() { } }); } else if (Util.isvalidPhone(editTextPhone.getText().toString())) { editTextEmail.getText().clear(); final String phone = editTextPhone.getText().toString(); if (TextUtils.isEmpty(phone)) { Toast.makeText(getApplicationContext(), "Enter phone address", Toast.LENGTH_LONG).show(); return; } progressDialog.show(); Connector.getInstance().login(text_1.getText().toString(), phone, new ILoginCallback() { @Override public void onSuccess(long heloUserId) { progressDialog.cancel(); startActivity(new Intent(crearCuentaHelo.this, MainActivity.class)); } @Override public void onPinverification() { progressDialog.cancel(); Intent intent = new Intent(crearCuentaHelo.this, PinActivity.class); intent.putExtra(PinActivity.ACTION_TYPE, PinActivity.ACTION_PHONE); intent.putExtra(PinActivity.ACTION_PHONE, phone); startActivity(intent); } @Override public void onFailure(String description) { progressDialog.cancel(); Toast.makeText(getApplicationContext(), description, Toast.LENGTH_LONG).show(); } @Override public void accountVerification() { } }); } } else { Toast.makeText(this, "Please fill APP KEY and APP TOKEN", Toast.LENGTH_LONG).show(); } }else if(view.getId() == R.id.CallBack_Phone_Pin){ if(Util.isvalidPhone(editTextPhone.getText().toString())){ final String phone = editTextPhone.getText().toString(); final String prefix=text_1.getText().toString(); progressDialog.show(); Connector.getInstance().CallBack_Phone(false,prefix, phone, new ICallbackPin() { @Override public void onPinverification() { progressDialog.cancel(); Intent intent = new Intent(crearCuentaHelo.this, PinActivity.class); intent.putExtra(PinActivity.ACTION_TYPE, PinActivity.ACTION_PHONE); intent.putExtra(PinActivity.ACTION_PHONE, phone); startActivity(intent); Toast.makeText(crearCuentaHelo.this,"onPinverification",Toast.LENGTH_LONG).show(); } @Override public void onFailure(String description) { progressDialog.cancel(); Toast.makeText(crearCuentaHelo.this,"onFailure",Toast.LENGTH_LONG).show(); } }); }else{ Toast.makeText(this,"not valid number",Toast.LENGTH_LONG).show(); } }else if(view.getId() == R.id.CallBack_Email_Pin){ if(Util.isvalidEmail(editTextEmail.getText().toString())){ final String email = editTextEmail.getText().toString(); progressDialog.show(); Connector.getInstance().CallBack_Phone(true, "00", email, new ICallbackPin() { @Override public void onPinverification() { progressDialog.cancel(); Intent intent = new Intent(crearCuentaHelo.this, PinActivity.class); intent.putExtra(PinActivity.ACTION_TYPE, PinActivity.ACTION_EMAIL); intent.putExtra(PinActivity.ACTION_EMAIL, email); startActivity(intent); } @Override public void onFailure(String description) { progressDialog.cancel(); Toast.makeText(crearCuentaHelo.this,"onFailure",Toast.LENGTH_LONG).show(); } }); }else{ Toast.makeText(this,"not valid Email",Toast.LENGTH_LONG).show(); } }*/ } private List<CountrySpinnerItem> getCountries(Context context) { List<CountrySpinnerItem> countrySpinnerItems = new ArrayList<CountrySpinnerItem>(); try { InputStream in = context.getAssets().open("PrefissIntern.txt"); BufferedReader re = new BufferedReader(new InputStreamReader(in)); String temp; while ((temp = re.readLine()) != null) { String[] tempArr = temp.split(";"); if (tempArr.length == 2) { countrySpinnerItems.add(new CountrySpinnerItem(tempArr[0] .trim(), tempArr[1].trim())); } } } catch (IOException e) { e.printStackTrace(); } return countrySpinnerItems; } private class MyOnItemSelectedListener implements AdapterView.OnItemSelectedListener { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Log.i(TAG, "arg2 = " + pos + " position = " ); Object item = parent.getItemAtPosition(pos); if (item != null) { //Toast.makeText(crearCuentaHelo.this, item.toString(), //Toast.LENGTH_SHORT).show(); } prefix = ((CountrySpinnerItem) countrySpinner.getSelectedItem()).getCode(); countryName = ((CountrySpinnerItem) countrySpinner.getSelectedItem()).getName(); if (!prefix.equals("-1")) { Log.i(TAG, "prefix = " + prefix); text_1.setText(prefix); } Log.d(TAG, "onItemSelected and the prefix is " + prefix); } @Override public void onNothingSelected(AdapterView<?> adapterView) { Log.i(TAG, "onNothingSelected : position = " + "onNothingSelected"); } } }