Posts

java - Can spring boot be told to start an application only if a resource is available? -

i part of team developing spring boot backend application, provides mobile applications data. along new feature need of loading resource @ backend, need provided mobile application arose. due fact resource important , making access resource effective loading once during startup, wondered if can tell spring boot not start without resource existing in file system. know annotation @postconstruct, loading resource there seems late. thanks in advance suggtestions @postconstruct can used make sure application has stuff need when starts db pooling etc. example, can throw illegalstateexception() if file not there , can stop application loading. ran quick test , works. can use them below. @postconstruct public void setup() { // check stuff need. if (condition) { throw new illegalstateexception(); } }

xml - Java-Handling empty nodes in DOM -

i using java dom parse xml file, format elements , output csv further processing later. want skip on nodes empty or id attribute null , i'm not sure how go this. below exerpt source code, if want full listing let me know! ... setup ... list<employee> emplist = new arraylist<>(); nodelist = document.getdocumentelement().getchildnodes(); (int = 0; < nodelist.getlength(); i++) { node = nodelist.item(i); if (node instanceof element) { employee emp = new employee(); emp.id = node.getattributes().getnameditem("id").getnodevalue(); nodelist childnodes = node.getchildnodes(); (int j = 0; j < childnodes.getlength(); j++) { ... identify child tags , add list. thanks, shaw

html - Css selector .a.b how do i exclude it from selecting a.b.c? -

i have inherited markup similar html below. <div class="a b">how_can_i_select_ab_only</div> <div class="a b disabled">how_can_i_select_ab_and_disabled_only</div> i want select both elements individually. css selector .a.b selects both divs <div class="a b">how_can_i_select_ab_only</div> <div class="a b disabled">how_can_i_select_ab_and_disabled_only</div> what selector select class a.b.disabled , class a.b ? three ways how it: the first one, set styles .a.b , them remove them (override) .a.b.disabled . .a.b {color: red;} .a.b.disabled {color: grey} https://jsfiddle.net/p84s61gp/ the second way, use attr selector. [class='a b'] {color: red} https://jsfiddle.net/p84s61gp/1/ next, can use :not selector, support since ie9. .a.b:not(.disabled) {color: red} https://jsfiddle.net/p84s61gp/2/

adobe analytics - Google Tag manager code added with the help of DTM is not working -

i had request add google tag manager our website , added using dynamic tag manage (dtm). created page load rule , added script. client saying not working dtm adds code page iframe. there way can fix issue? alternative directly add in page. don't want go in route have update our page templates these tags. avoid adding tag manager code in other tag containers. built standalone tag management solution , google won't provide support if it's embedded in 3rd party solution. your best option select 1 tag management solution , stick that. having multiple tag managers kind of defeats purpose, no?

local videos on android not playing when device resolution is lower -

i'm working on android app needs display videos. client gave me mp4 videos (that have 1 of accepted android formats) , play on nexus 5. but when tried devices have lower resolutions, don't have image anymore (they're black) , sound playing. pop says "cannot play video". videos work if lower resolution (it seems cannot above device resolution) what best strategy make sure videos play @ least devices have resolution ~480x800 ? make different versions of them , place them in dpi folders ? or convince client stream them online ? i'm using videoview display them , place them in raw folder of resources. code looks this: setcontentview(r.layout.videoactivity); videoview videoview = (videoview) findviewbyid(r.id.videoview); mediacontroller mc = new mediacontroller(this); videoview.setmediacontroller(mc); videoview.setvideopath("android.resource://" + getpackagename() + "/" + r.raw.asset1); videoview.requestfocus(); videoview.start(); ...

java - Keep the order of the map as in the arrayList before -

this question has answer here: java class implements map , keeps insertion order? 6 answers i trying merge line toghether create data programm. curently merging part of string s in arraylist 's buffer works when output content of map getting of string in arraylist 's buffer . is there way keep order of string s in arraylist buffer ? output: nathan marcus adler [04:43, 05:43, 12:11, 12:41, 19:11, 19:41] dukes of bedford [04:56, 05:56, 12:24, 12:54, 19:24, 19:54] prince albert [04:48, 05:48, 12:16, 12:46, 19:16, 19:46] joseph addison [04:41, 05:41, 12:08, 12:38, 19:08, 19:38] william baker [04:52, 05:52, 12:20, 12:50, 19:20, 19:50] the ouput should looks this: joseph addison [04:41, 05:41, 12:08, 12:38, 19:08, 19:38] nathan marcus adler [04:43, 05:43, 12:11, 12:41, 19:11, 19:41] prince albert [04:48, 05:48, 12:16, 12:46, 19:16, 19:46] will...

pause audio clip in java -

i have code 2 classes mplayer , audio. mplayer has gui (jbuttons, jpanel , jframe etc), , audio has code play audio. problem when call pause method in class mplayer, not pause audio. can me it? mplayer.java: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class mplayer extends jframe implements actionlistener { imageicon icon1, icon2, icon3, icon4; jpanel pan1; jframe frame; jmenubar bar; jmenu menu; jmenuitem menuitem; jbutton btn1, btn2; public void initgui() { bar = new jmenubar(); menu = new jmenu("open"); bar.add(menu); menuitem = new jmenuitem("open"); menu.add(menuitem); borderlayout bl = new borderlayout(); flowlayout fl = new flowlayout(); pan1 = new jpanel(); frame = new jframe("music player"); frame.setlayout(bl); pan1.setlayout(fl); frame.setjmenubar(bar); icon1 = new i...